This commit is contained in:
jacob 2026-01-01 20:26:21 -06:00
parent 5b88c67af2
commit 818de65813
3 changed files with 51 additions and 34 deletions

View File

@ -83,7 +83,7 @@ V_WidgetTheme V_GetWidgetTheme(void)
theme.icon_font = UI_BuiltinIconFont(); theme.icon_font = UI_BuiltinIconFont();
// theme.font_size = 14; // theme.font_size = 14;
theme.font_size = TweakFloat("Font size", 14, 6, 50, .precision = 0); theme.font_size = TweakFloat("Font size", 16, 6, 50, .precision = 0);
theme.h1 = 2.00; theme.h1 = 2.00;
theme.h2 = 1.50; theme.h2 = 1.50;
theme.h3 = 1.25; theme.h3 = 1.25;
@ -116,7 +116,8 @@ V_WidgetTheme V_GetWidgetTheme(void)
theme.col.negative = VEC4(0.5, 0.25, 0.25, 1); theme.col.negative = VEC4(0.5, 0.25, 0.25, 1);
theme.col.text = Rgb32(0xffdddee0); theme.col.text = Rgb32(0xffdddee0);
theme.col.hint = Rgb32(0xff71767f); // theme.col.hint = Rgb32(0xff71767f);
theme.col.hint = Rgb32(0xff6b7078);
return theme; return theme;
} }
@ -355,7 +356,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Push(ChildLayoutAxis, Axis_Y); UI_Push(ChildLayoutAxis, Axis_Y);
UI_Push(Width, UI_GROW(1, 0)); UI_Push(Width, UI_GROW(1, 0));
UI_Push(Height, UI_GROW(1, 0)); UI_Push(Height, UI_GROW(1, 0));
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_Push(Parent, UI_BuildColumnEx(vis_box)); UI_Push(Parent, UI_BuildColumnEx(vis_box));
} }
@ -891,7 +892,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Width, UI_GROW(1, 0)); UI_SetNext(Width, UI_GROW(1, 0));
UI_SetNext(Height, UI_SHRINK(0, 1)); UI_SetNext(Height, UI_SHRINK(0, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_PushCP(UI_BuildRowEx(tab_row_key)); UI_PushCP(UI_BuildRowEx(tab_row_key));
////////////////////////////// //////////////////////////////
@ -1041,7 +1042,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Height, UI_SHRINK(0, 0)); UI_SetNext(Height, UI_SHRINK(0, 0));
UI_SetNext(ChildAlignment, UI_Region_Left); UI_SetNext(ChildAlignment, UI_Region_Left);
UI_SetNext(Misc, window == active_window); UI_SetNext(Misc, window == active_window);
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_SetNext(Text, tab_name); UI_SetNext(Text, tab_name);
UI_PushCP(UI_BuildRowEx(tab->key)); UI_PushCP(UI_BuildRowEx(tab->key));
{ {
@ -1069,7 +1070,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BorderColor, close_border_color); UI_SetNext(BorderColor, close_border_color);
UI_SetNext(BorderSize, 2); UI_SetNext(BorderSize, 2);
UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(ChildAlignment, UI_Region_Center);
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse);
UI_SetNext(Text, Lit("x")); UI_SetNext(Text, Lit("x"));
UI_SetNext(Width, UI_SHRINK(6, 0)); UI_SetNext(Width, UI_SHRINK(6, 0));
UI_SetNext(Height, UI_SHRINK(2, 0)); UI_SetNext(Height, UI_SHRINK(2, 0));
@ -1138,7 +1139,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Height, UI_SHRINK(2, 0)); UI_SetNext(Height, UI_SHRINK(2, 0));
UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(ChildAlignment, UI_Region_Center);
// UI_SetNext(FontSize, theme.font_size * 1.5); // UI_SetNext(FontSize, theme.font_size * 1.5);
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse);
UI_SetNext(Text, Lit("+")); UI_SetNext(Text, Lit("+"));
UI_PushCP(UI_BuildRowEx(key)); UI_PushCP(UI_BuildRowEx(key));
{ {
@ -1165,7 +1166,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BorderSize, 1); UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_GROW(1, 0)); UI_SetNext(Width, UI_GROW(1, 0));
UI_SetNext(Height, UI_GROW(1, 0)); UI_SetNext(Height, UI_GROW(1, 0));
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_PushCP(UI_BuildColumn()); UI_PushCP(UI_BuildColumn());
{ {
UI_Push(Tag, window->key.hash); UI_Push(Tag, window->key.hash);
@ -1198,7 +1199,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Width, UI_GROW(1, 0)); UI_SetNext(Width, UI_GROW(1, 0));
UI_SetNext(Height, UI_SHRINK(0, 0)); UI_SetNext(Height, UI_SHRINK(0, 0));
UI_SetNext(Misc, is_selected); UI_SetNext(Misc, is_selected);
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_PushCP(UI_BuildRowEx(key)); UI_PushCP(UI_BuildRowEx(key));
{ {
UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(ChildAlignment, UI_Region_Center);
@ -1245,7 +1246,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BackgroundColor, bg_color); UI_SetNext(BackgroundColor, bg_color);
UI_SetNext(BorderColor, border_color); UI_SetNext(BorderColor, border_color);
UI_SetNext(BorderSize, MaxF32((divider_size / 2.0) - (visible_size / 2.0), 0)); UI_SetNext(BorderSize, MaxF32((divider_size / 2.0) - (visible_size / 2.0), 0));
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_SetNext(AxisSize, UI_GROW(1, 1), .axis = panel->axis); UI_SetNext(AxisSize, UI_GROW(1, 1), .axis = panel->axis);
UI_SetNext(AxisSize, UI_PIX(divider_size, 1), .axis = !panel->axis); UI_SetNext(AxisSize, UI_PIX(divider_size, 1), .axis = !panel->axis);
UI_BuildBoxEx(panel->divider_key); UI_BuildBoxEx(panel->divider_key);
@ -1329,13 +1330,14 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Push(BackgroundColor, window_background_color); UI_Push(BackgroundColor, window_background_color);
UI_Push(BorderColor, window_border_color); UI_Push(BorderColor, window_border_color);
UI_Push(BorderSize, theme.window_bd_sz); UI_Push(BorderSize, theme.window_bd_sz);
UI_Push(Rounding, UI_RPIX(15 * theme.rounding)); // UI_Push(Rounding, UI_RPIX(15 * theme.rounding));
UI_Push(Rounding, UI_RGROW(0.1 * theme.rounding));
UI_Push(Width, UI_FNT(50, 0)); UI_Push(Width, UI_FNT(50, 0));
UI_Push(Height, UI_SHRINK(0, 0)); UI_Push(Height, UI_SHRINK(0, 0));
UI_Push(ChildLayoutAxis, Axis_Y); UI_Push(ChildLayoutAxis, Axis_Y);
UI_Push(FloatingPos, palette->pos); UI_Push(FloatingPos, palette->pos);
UI_SetNext(Anchor, UI_Region_Center); UI_SetNext(Anchor, UI_Region_Center);
UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_CaptureMouse);
UI_PushCP(UI_BuildBoxEx(palette->key)); UI_PushCP(UI_BuildBoxEx(palette->key));
{ {
// Title bar // Title bar
@ -1347,7 +1349,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Push(ChildLayoutAxis, Axis_X); UI_Push(ChildLayoutAxis, Axis_X);
UI_Push(Width, UI_GROW(1, 0)); UI_Push(Width, UI_GROW(1, 0));
UI_Push(Height, UI_FNT(2, 1)); UI_Push(Height, UI_FNT(2, 1));
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse);
UI_PushCP(UI_BuildBoxEx(titlebar_key)); UI_PushCP(UI_BuildBoxEx(titlebar_key));
{ {
UI_Push(Width, UI_GROW(1, 0)); UI_Push(Width, UI_GROW(1, 0));
@ -1500,7 +1502,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Width, UI_GROW(1, 0)); UI_SetNext(Width, UI_GROW(1, 0));
UI_SetNext(Height, UI_PIX(item_size_px, 1)); UI_SetNext(Height, UI_PIX(item_size_px, 1));
UI_SetNext(ChildAlignment, UI_Region_Left); UI_SetNext(ChildAlignment, UI_Region_Left);
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse);
UI_PushCP(UI_BuildRowEx(item->key)); UI_PushCP(UI_BuildRowEx(item->key));
{ {
UI_Push(Tag, item->key.hash); UI_Push(Tag, item->key.hash);
@ -1521,13 +1523,23 @@ void V_TickForever(WaveLaneCtx *lane)
TweakVar tweak_var = item->tweak_var; TweakVar tweak_var = item->tweak_var;
String old_tweak_str = tweak_var.value; String old_tweak_str = tweak_var.value;
String new_tweak_str = tweak_var.value; String new_tweak_str = tweak_var.value;
b32 is_default = MatchString(new_tweak_str, tweak_var.initial);
// Tweak label // Tweak label
UI_BuildSpacer(UI_PIX(spacing, 1), Axis_X); UI_BuildSpacer(UI_PIX(spacing, 1), Axis_X);
if (is_default)
{
UI_SetNext(TextColor, theme.col.hint);
UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5);
}
else
{
UI_SetNext(TextColor, Color_White);
}
UI_BuildLabel(new_tweak_str); UI_BuildLabel(new_tweak_str);
// Reset button // Reset button
if (!MatchString(new_tweak_str, tweak_var.initial)) if (!is_default)
{ {
UI_BuildSpacer(UI_PIX(spacing * 0.5, 1), Axis_X); UI_BuildSpacer(UI_PIX(spacing * 0.5, 1), Axis_X);
UI_Key reset_key = UI_KeyF("reset"); UI_Key reset_key = UI_KeyF("reset");
@ -1547,22 +1559,23 @@ void V_TickForever(WaveLaneCtx *lane)
// reset_bg = LerpSrgb(reset_bg, theme.col.button_active, reset_rep.active); // reset_bg = LerpSrgb(reset_bg, theme.col.button_active, reset_rep.active);
Vec4 reset_bd = Zi; Vec4 reset_bd = Zi;
reset_bd = LerpSrgb(reset_bd, theme.col.button_active, reset_rep.hot); // reset_bd = LerpSrgb(reset_bd, theme.col.button_active, reset_rep.hot);
// reset_bd = LerpSrgb(reset_bd, theme.col.text, reset_rep.hot);
Vec4 reset_text_col = theme.col.hint; Vec4 reset_text_col = theme.col.hint;
reset_text_col = LerpSrgb(reset_text_col, theme.col.text, reset_rep.hot); reset_text_col = LerpSrgb(reset_text_col, theme.col.text, reset_rep.hot);
UI_SetNext(Rounding, UI_RGROW(0.5 * theme.rounding)); UI_SetNext(Rounding, UI_RGROW(0.75 * theme.rounding));
UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(ChildAlignment, UI_Region_Bottom);
UI_SetNext(BackgroundColor, reset_bg); UI_SetNext(BackgroundColor, reset_bg);
UI_SetNext(BorderColor, reset_bd); UI_SetNext(BorderColor, reset_bd);
UI_SetNext(BorderSize, 1); UI_SetNext(BorderSize, 0);
UI_SetNext(TextColor, reset_text_col); UI_SetNext(TextColor, reset_text_col);
UI_SetNext(Width, UI_SHRINK(3, 1)); UI_SetNext(Width, UI_SHRINK(0, 1));
UI_SetNext(Height, UI_SHRINK(3, 1)); UI_SetNext(Height, UI_SHRINK(0, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6); UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6);
UI_BuildIconEx(reset_key, UI_Icon_Undo, theme.icon_font); UI_BuildIconEx(reset_key, UI_Icon_Loop2, theme.icon_font);
} }
UI_BuildSpacer(UI_PIX(spacing, 1), Axis_X); UI_BuildSpacer(UI_PIX(spacing, 1), Axis_X);
@ -1594,7 +1607,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BorderSize, 1); UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_FNT(1.25, 1)); UI_SetNext(Width, UI_FNT(1.25, 1));
UI_SetNext(Height, UI_FNT(1.25, 1)); UI_SetNext(Height, UI_FNT(1.25, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_PushCP(UI_BuildRowEx(cb_key)); UI_PushCP(UI_BuildRowEx(cb_key));
{ {
} }
@ -1610,6 +1623,10 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BoxReports slider_reps = UI_ReportsFromKey(slider_key); UI_BoxReports slider_reps = UI_ReportsFromKey(slider_key);
UI_BoxReports marker_reps = UI_ReportsFromKey(marker_key); UI_BoxReports marker_reps = UI_ReportsFromKey(marker_key);
b32 is_hot = slider_reps.draw.is_hot || marker_reps.draw.is_hot;
b32 is_active = slider_reps.draw.m1.held || marker_reps.draw.m1.held;
f32 hot = MaxF32(slider_reps.draw.hot, marker_reps.draw.hot);
Vec2 slider_pos = slider_reps.draw.screen_rect.p0; Vec2 slider_pos = slider_reps.draw.screen_rect.p0;
Vec2 slider_dims = DimsFromRng2(slider_reps.draw.screen_rect); Vec2 slider_dims = DimsFromRng2(slider_reps.draw.screen_rect);
Vec2 marker_dims = DimsFromRng2(marker_reps.draw.screen_rect); Vec2 marker_dims = DimsFromRng2(marker_reps.draw.screen_rect);
@ -1624,7 +1641,7 @@ void V_TickForever(WaveLaneCtx *lane)
f64 tweak_float = FloatFromString(new_tweak_str); f64 tweak_float = FloatFromString(new_tweak_str);
{ {
if (slider_reps.draw.m1.held && (frame->ui_cursor.x != last_frame->ui_cursor.x)) if (is_active && (frame->ui_cursor.x != last_frame->ui_cursor.x))
{ {
f64 initial_slider_pos = slider_reps.drag.screen_rect.p0.x; f64 initial_slider_pos = slider_reps.drag.screen_rect.p0.x;
f64 initial_marker_width = DimsFromRng2(marker_reps.drag.screen_rect).x; f64 initial_marker_width = DimsFromRng2(marker_reps.drag.screen_rect).x;
@ -1640,7 +1657,7 @@ void V_TickForever(WaveLaneCtx *lane)
tweak_float = ClampF64(tweak_float, range_min, range_max); tweak_float = ClampF64(tweak_float, range_min, range_max);
new_tweak_str = StringFromFloat(frame->arena, tweak_float, tweak_var.precision); new_tweak_str = StringFromFloat(frame->arena, tweak_float, tweak_var.precision);
} }
if (slider_reps.draw.is_hot) if (is_hot)
{ {
WND_SetCursor(window_frame, WND_CursorKind_HorizontalResize); WND_SetCursor(window_frame, WND_CursorKind_HorizontalResize);
} }
@ -1653,8 +1670,8 @@ void V_TickForever(WaveLaneCtx *lane)
Vec4 slider_border_color = theme.col.window_bd; Vec4 slider_border_color = theme.col.window_bd;
Vec4 slider_progress_color = theme.col.positive; Vec4 slider_progress_color = theme.col.positive;
Vec4 marker_bg_color = slider_progress_color; Vec4 marker_bg_color = slider_progress_color;
slider_border_color = LerpSrgb(slider_border_color, theme.col.button_active, slider_reps.draw.hot); slider_border_color = LerpSrgb(slider_border_color, theme.col.button_active, hot);
marker_bg_color = LerpSrgb(marker_bg_color, theme.col.text, slider_reps.draw.hot); marker_bg_color = LerpSrgb(marker_bg_color, theme.col.text, hot);
UI_SetNext(BackgroundColor, slider_bg_color); UI_SetNext(BackgroundColor, slider_bg_color);
UI_SetNext(BorderColor, slider_border_color); UI_SetNext(BorderColor, slider_border_color);
@ -1662,7 +1679,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BorderSize, 1); UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_FNT(10, 1)); UI_SetNext(Width, UI_FNT(10, 1));
UI_SetNext(Height, UI_PIX(tweak_size_px * 0.75, 1)); UI_SetNext(Height, UI_PIX(tweak_size_px * 0.75, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_SetNext(Misc, ratio); UI_SetNext(Misc, ratio);
UI_PushCP(UI_BuildRowEx(slider_key)); UI_PushCP(UI_BuildRowEx(slider_key));
{ {
@ -1691,7 +1708,7 @@ void V_TickForever(WaveLaneCtx *lane)
// UI_SetNext(Anchor, UI_Region_Center); // UI_SetNext(Anchor, UI_Region_Center);
// UI_SetNext(FloatingPos, VEC2(marker_pos, (marker_size_px * 0.5))); // UI_SetNext(FloatingPos, VEC2(marker_pos, (marker_size_px * 0.5)));
UI_SetNext(FloatingPos, VEC2(marker_pos, -marker_dims.y * 0.125)); UI_SetNext(FloatingPos, VEC2(marker_pos, -marker_dims.y * 0.125));
UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_NoFloatingClamp); UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_NoFloatingClamp | UI_BoxFlag_CaptureMouse);
UI_BuildBoxEx(marker_key); UI_BuildBoxEx(marker_key);
} }
} }
@ -1745,7 +1762,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Rounding, UI_RPIX(5)); UI_SetNext(Rounding, UI_RPIX(5));
UI_SetNext(BorderSize, 1); UI_SetNext(BorderSize, 1);
UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(ChildAlignment, UI_Region_Center);
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse);
UI_PushCP(UI_BuildRowEx(hotkey_key)); UI_PushCP(UI_BuildRowEx(hotkey_key));
{ {
} }
@ -1893,7 +1910,7 @@ void V_TickForever(WaveLaneCtx *lane)
if (minimized) if (minimized)
{ {
UI_SetNext(BackgroundColor, 0); UI_SetNext(BackgroundColor, 0);
UI_SetNext(Width, UI_PIX(500, 0)); UI_SetNext(Width, UI_FNT(50, 0));
UI_SetNext(Height, UI_SHRINK(0, 1)); UI_SetNext(Height, UI_SHRINK(0, 1));
} }
else else

View File

@ -677,7 +677,7 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color)
is_cursor_in_box = non_corner_edge_dist >= 0 && corner_edge_dist >= 0; is_cursor_in_box = non_corner_edge_dist >= 0 && corner_edge_dist >= 0;
} }
report->is_hovered = is_cursor_in_box; report->is_hovered = is_cursor_in_box;
if (top_hovered_box == 0 && box->desc.flags & UI_BoxFlag_Interactable && is_cursor_in_box) if (top_hovered_box == 0 && box->desc.flags & UI_BoxFlag_CaptureMouse && is_cursor_in_box)
{ {
top_hovered_box = box; top_hovered_box = box;
} }

View File

@ -87,7 +87,7 @@ Enum(UI_BoxFlag)
{ {
UI_BoxFlag_None = 0, UI_BoxFlag_None = 0,
UI_BoxFlag_DrawText = (1 << 0), UI_BoxFlag_DrawText = (1 << 0),
UI_BoxFlag_Interactable = (1 << 1), UI_BoxFlag_CaptureMouse = (1 << 1),
UI_BoxFlag_NoTextTruncation = (1 << 2), UI_BoxFlag_NoTextTruncation = (1 << 2),
UI_BoxFlag_Floating = (1 << 3), UI_BoxFlag_Floating = (1 << 3),
UI_BoxFlag_NoFloatingClamp = (1 << 4), UI_BoxFlag_NoFloatingClamp = (1 << 4),