diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index d8856016..f44d6c6f 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -4396,8 +4396,9 @@ void V_TickForever(WaveLaneCtx *lane) // UI_BuildLabelF("Profiler"); // } - UI_BuildSpacer(window_padding, Axis_Y); - UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); + // UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); //- Graph // UI_SetNext(BackgroundColor, Color_Cyan); @@ -4407,7 +4408,7 @@ void V_TickForever(WaveLaneCtx *lane) } // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); - UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); + // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); UI_BuildSpacer(window_padding, Axis_Y); @@ -4420,6 +4421,8 @@ void V_TickForever(WaveLaneCtx *lane) // UI_SetNext(BackgroundColor, main_color_unsampled); UI_SetNext(Height, main_height); UI_SetNext(Rounding, UI_Rpx(5 * theme.rounding)); + UI_SetNext(BorderSize, 1); + UI_SetNext(BorderColor, theme.col.divider); // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren | UI_BoxFlag_Scissor); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren); // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); @@ -4482,14 +4485,23 @@ void V_TickForever(WaveLaneCtx *lane) // TODO: Real wave/lane information String wave_name = Lit("Vis wave"); u32 lane_idx = 2; + UI_Key track_box = UI_KeyF("vis track %F", FmtUint(vis_track->id)); + + Vec2 track_dims_rate = VEC2(Inf, 15); UI_SetNext(Height, track_height); - UI_PushDF(Tag, HashF("vis track %F", FmtUint(vis_track->id))) - UI_PushDF(Parent, UI_BuildRow()) + UI_SetNext(DimsRate, track_dims_rate); + UI_PushDF(Tag, track_box.v) + UI_PushDF(Parent, UI_BuildRowEx(track_box)) { + // UI_BuildSpacer(window_padding, Axis_X); + + UI_SetNext(DimsRate, track_dims_rate); UI_SetNext(Height, track_height); - UI_PushDF(Parent, UI_BuildColumn()) + UI_PushDF(Parent, UI_BuildColumnEx(UI_KeyF("track area"))) { + UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildSpacer(window_padding, Axis_Y); // UI_BuildSpacer(track_padding, Axis_Y); // UI_BuildSpacer(track_padding, Axis_Y); @@ -4522,11 +4534,13 @@ void V_TickForever(WaveLaneCtx *lane) } UI_SetNext(Height, track_height); - UI_SetNext(Rounding, UI_Rpx(5)); + UI_SetNext(DimsRate, track_dims_rate); + UI_SetNext(Rounding, UI_Rpx(5 * theme.rounding)); UI_SetNext(BackgroundColor, profiler_color); UI_SetNext(BorderColor, theme.col.window_bd); UI_SetNext(BorderSize, 1); - UI_PushDF(Parent, UI_BuildRow()) + UI_SetNext(Flags, UI_BoxFlag_Scissor); + UI_PushDF(Parent, UI_BuildRowEx(UI_KeyF("zone rows"))) { // UI_BuildSpacer(window_padding, Axis_Y); @@ -4756,7 +4770,8 @@ void V_TickForever(WaveLaneCtx *lane) // UI_BuildSpacer(window_padding, Axis_Y); } - // UI_BuildSpacer(window_padding, Axis_Y); + + UI_BuildSpacer(window_padding, Axis_Y); } } } @@ -4940,7 +4955,7 @@ void V_TickForever(WaveLaneCtx *lane) // UI_BuildSpacer(window_padding, Axis_Y); - UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); + // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); //- Footer UI_PushDF(Height, footer_height) diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index 9e230ee5..ac96855a 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -322,6 +322,7 @@ void UI_PushDefaults(void) case UI_StyleKind_HoveredRate: { desc.style.HoveredRate = 15; } break; case UI_StyleKind_ExistsRate: { desc.style.ExistsRate = 30; } break; case UI_StyleKind_MiscRate: { desc.style.MiscRate = Inf; } break; + case UI_StyleKind_DimsRate: { desc.style.DimsRate = VEC2(Inf, Inf); } break; }; UI_PushStyle(desc); } @@ -504,6 +505,7 @@ UI_Key UI_BuildBoxEx(UI_Key semantic_key) n->cmd.box.hovered_rate = UI_Top(HoveredRate); n->cmd.box.exists_rate = UI_Top(ExistsRate); n->cmd.box.misc_rate = UI_Top(MiscRate); + n->cmd.box.dims_rate = UI_Top(DimsRate); } ++frame->cmds_count; SllQueuePush(frame->first_cmd_node, frame->last_cmd_node, n); @@ -1726,6 +1728,13 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync) box->solved_dims.v[axis] = scaled_size; } + //- Interpolate dimensions + { + Vec2 dims_rate = VEC2(SaturateF32(box->desc.dims_rate.x * frame->dt), SaturateF32(box->desc.dims_rate.y * frame->dt)); + box->smoothed_dims.x = LerpF32(box->smoothed_dims.x, box->solved_dims.x, dims_rate.x); + box->smoothed_dims.y = LerpF32(box->smoothed_dims.y, box->solved_dims.y, dims_rate.y); + } + //- Compute anchor offset Vec2 anchor_offset = Zi; { @@ -1738,11 +1747,11 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync) default: break; case UI_AxisRegion_Center: { - anchor_offset.v[axis] = box->solved_dims.v[axis] * 0.5; + anchor_offset.v[axis] = box->smoothed_dims.v[axis] * 0.5; } break; case UI_AxisRegion_End: { - anchor_offset.v[axis] = box->solved_dims.v[axis]; + anchor_offset.v[axis] = box->smoothed_dims.v[axis]; } break; } } @@ -1752,7 +1761,7 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync) { Axis axis = child_layout_axis; UI_AxisRegion alignment = child_alignment.v[axis]; - f32 box_size = box->solved_dims.v[axis]; + f32 box_size = box->smoothed_dims.v[axis]; f32 size_accum = box->final_children_size_accum.v[axis]; switch(alignment) { @@ -1794,14 +1803,14 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync) default: break; case UI_AxisRegion_Center: { - f32 parent_size = parent->solved_dims.v[axis]; - f32 box_size = box->solved_dims.v[axis]; + f32 parent_size = parent->smoothed_dims.v[axis]; + f32 box_size = box->smoothed_dims.v[axis]; offset.v[axis] = parent_size / 2 - box_size / 2; } break; case UI_AxisRegion_End: { - f32 parent_size = parent->solved_dims.v[axis]; - f32 box_size = box->solved_dims.v[axis]; + f32 parent_size = parent->smoothed_dims.v[axis]; + f32 box_size = box->smoothed_dims.v[axis]; offset.v[axis] = parent_size - box_size; } break; } @@ -1816,18 +1825,18 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync) Vec2 overshoot = Zi; if (!AnyBit(box->desc.flags, UI_BoxFlag_DontClampFloatingX)) { - overshoot.x = MaxF32(0, (screen_pos.x + box->solved_dims.x) - parent->screen_rect.p1.x); + overshoot.x = MaxF32(0, (screen_pos.x + box->smoothed_dims.x) - parent->screen_rect.p1.x); screen_pos.x = MaxF32(parent->screen_rect.p0.x, screen_pos.x - overshoot.x); } if (!AnyBit(box->desc.flags, UI_BoxFlag_DontClampFloatingY)) { - overshoot.y = MaxF32((screen_pos.y + box->solved_dims.y) - parent->screen_rect.p1.y, 0); + overshoot.y = MaxF32((screen_pos.y + box->smoothed_dims.y) - parent->screen_rect.p1.y, 0); screen_pos.y = MaxF32(parent->screen_rect.p0.y, screen_pos.y - overshoot.y); } } box->screen_rect.p0 = screen_pos; - box->screen_rect.p1 = AddVec2(box->screen_rect.p0, box->solved_dims); + box->screen_rect.p1 = AddVec2(box->screen_rect.p0, box->smoothed_dims); if (box->solved_scale.x == 1) { @@ -1845,7 +1854,7 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync) // Update parent cursor if (parent && !is_floating) { - parent->cursor += box->solved_dims.v[layout_axis_in_parent]; + parent->cursor += box->smoothed_dims.v[layout_axis_in_parent]; } } diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index 236a9052..328164e8 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -165,6 +165,7 @@ Enum(UI_DebugBreakFlag) X(HoveredRate, f32) \ X(ExistsRate, f32) \ X(MiscRate, f64) \ + X(DimsRate, Vec2) \ /* --------------------------------------------- */ \ /* --------------- Virtual styles -------------- */ \ /* --------------------------------------------- */ \ @@ -314,6 +315,7 @@ Struct(UI_BoxDesc) f32 hovered_rate; f32 exists_rate; f32 misc_rate; + Vec2 dims_rate; }; Struct(UI_Cmd) @@ -382,6 +384,7 @@ Struct(UI_Box) Rng2 solved_scissor; Vec2 final_children_size_accum; Vec2 solved_dims; + Vec2 smoothed_dims; f32 cursor; //- Layout results