diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index 07e10e6d..3be03858 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -5587,8 +5587,8 @@ void V_TickForever(WaveLaneCtx *lane) f32 cursor_px = frame->screen_cursor.x - UI_Rect(main_box).p0.x; - b32 is_hovered = UI_HotAbsolute(main_box); - if (is_hovered) + b32 is_main_hot = UI_HotAbsolute(main_box); + if (is_main_hot) { profiler->cursor_ns = (cursor_px * profiler->ns_per_px) + profiler->view_ns; } @@ -6022,11 +6022,13 @@ void V_TickForever(WaveLaneCtx *lane) UI_Key zone_row_box = zone_row_boxes[zone->depth - 1]; UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->id)); - if (UI_HotAbsolute(zone_box)) + b32 is_hovered = UI_HoveredAbsolute(zone_box) && UI_HotAbsolute(main_box); + if (is_hovered) { hovered_zone_box = zone_box; hovered_zone = zone; } + f32 zone_hovered = UI_Hovered(zone_box) * UI_Hot(main_box); f64 zone_offset_px = zone->start_px - view_start_px; f64 zone_len_px = zone->end_px - zone->start_px; @@ -6038,7 +6040,7 @@ void V_TickForever(WaveLaneCtx *lane) zone_color_bd = MulVec4(zone_color_bd, 0.65); zone_color_bd.a = 1; - zone_color_bd = LerpSrgb(zone_color_bd, Color_White, UI_Hot(zone_box)); + zone_color_bd = LerpSrgb(zone_color_bd, Color_White, zone_hovered); Vec4 zone_text_color = UI_Top(TextColor); zone_text_color.a *= 0.75; @@ -6051,8 +6053,8 @@ void V_TickForever(WaveLaneCtx *lane) // Vec4 collapsed_line_color = theme.col.hint; Vec4 collapsed_text_color = theme.col.positive; // Vec4 collapsed_line_color = collapsed_text_color; - collapsed_text_color = LerpSrgb(collapsed_text_color, Color_White, UI_Hot(zone_box)); - collapsed_line_color = LerpSrgb(collapsed_line_color, Color_White, UI_Hot(zone_box)); + collapsed_text_color = LerpSrgb(collapsed_text_color, Color_White, zone_hovered); + collapsed_line_color = LerpSrgb(collapsed_line_color, Color_White, zone_hovered); String zone_text = zone->name; if (is_collapsed) @@ -6084,7 +6086,7 @@ void V_TickForever(WaveLaneCtx *lane) { // Vertical line { - UI_SetDF(Opacity, 1.0 - UI_Hot(zone_box)) + UI_SetDF(Opacity, 1.0 - zone_hovered) UI_SetNext(BackgroundColor, collapsed_line_color); UI_SetNext(Width, collapsed_line_size); UI_SetNext(Height, UI_Grow(1, 0)); diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index 42cfc5cc..b53cff2a 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -711,6 +711,10 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags) } cev->captures += 1; } + else if (top_active_box) + { + cev->captures += 1; + } } } break; @@ -759,6 +763,7 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags) top_active_box = 0; } } + cev->captures += 1; } } else if (IsWheelButton(cev->button) && top_hovered_box) @@ -788,13 +793,11 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags) } if (top_active_box) { - top_active_box->mouse_hovered = 1; top_active_box->mouse_captured = 1; for (UI_Box *parent = top_active_box->parent; parent; parent = parent->parent) { if (parent->desc.flags & UI_BoxFlag_CaptureThroughChildren) { - parent->mouse_hovered = 1; parent->mouse_captured = 1; } } @@ -813,22 +816,26 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags) feedback->active_absolute = box->mouse_captured; feedback->hot_absolute = feedback->active_absolute || (top_active_box == 0 && box->mouse_hovered); + feedback->hovered_absolute = box->mouse_hovered; feedback->exists_absolute = (box->last_build_tick >= (frame->tick - 1)); f32 target_active = feedback->active_absolute ? Inf : lower_target; f32 target_hot = feedback->hot_absolute ? Inf : lower_target; + f32 target_hovered = feedback->hovered_absolute ? Inf : lower_target; f32 target_exists = feedback->exists_absolute ? upper_target : lower_target; f32 target_misc = box->desc.misc; // TODO: Configurable per-box blend rates f32 active_blend_rate = (15 * frame->dt); f32 hot_blend_rate = (15 * frame->dt); + f32 hovered_blend_rate = (15 * frame->dt); f32 exists_blend_rate = (30 * frame->dt); // f64 misc_blend_rate = (30 * frame->dt); f64 misc_blend_rate = 1; feedback->active_smooth = SaturateF32(LerpF32(feedback->active_smooth, target_active, active_blend_rate)); feedback->hot_smooth = SaturateF32(LerpF32(feedback->hot_smooth, target_hot, hot_blend_rate)); + feedback->hovered_smooth = SaturateF32(LerpF32(feedback->hovered_smooth, target_hovered, hovered_blend_rate)); feedback->exists_smooth = SaturateF32(LerpF32(feedback->exists_smooth, target_exists, exists_blend_rate)); feedback->misc_smooth = SaturateF32(LerpF32(feedback->misc_smooth, target_misc, misc_blend_rate)); @@ -983,6 +990,28 @@ b32 UI_HotAbsolute(UI_Key key) return result; } +f32 UI_Hovered(UI_Key key) +{ + f32 result = Zi; + UI_Box *box = UI_BoxFromKey(key); + if (box) + { + result = box->feedback.hovered_smooth; + } + return result; +} + +f32 UI_HoveredAbsolute(UI_Key key) +{ + f32 result = Zi; + UI_Box *box = UI_BoxFromKey(key); + if (box) + { + result = box->feedback.hovered_absolute; + } + return result; +} + f32 UI_Exists(UI_Key key) { f32 result = Zi; diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index 348f842c..7393f900 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -236,10 +236,12 @@ Struct(UI_Feedback) b32 active_absolute; b32 hot_absolute; + b32 hovered_absolute; b32 exists_absolute; f32 active_smooth; f32 hot_smooth; + f32 hovered_smooth; f32 exists_smooth; f64 misc_smooth; @@ -593,6 +595,9 @@ b32 UI_ActiveAbsolute(UI_Key key); f32 UI_Hot(UI_Key key); b32 UI_HotAbsolute(UI_Key key); +f32 UI_Hovered(UI_Key key); +f32 UI_HoveredAbsolute(UI_Key key); + f32 UI_Exists(UI_Key key); b32 UI_ExistsAbsolute(UI_Key);