From 07066620503c290b28342c80ecdd60e5353577b9 Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 31 Mar 2026 06:02:33 -0500 Subject: [PATCH] profiler tooltip --- src/base/base.cgh | 1 + src/base/base_async.c | 102 +++--- src/base/base_string.c | 28 ++ src/base/base_string.h | 42 +-- src/pp/pp_sim/pp_sim_core.c | 2 +- src/pp/pp_vis/pp_vis_core.c | 663 ++++++++++++++++-------------------- src/pp/pp_vis/pp_vis_core.h | 20 ++ src/ui/ui_core.c | 8 +- src/ui/ui_core.h | 12 +- src/ui/ui_extras.c | 8 +- 10 files changed, 441 insertions(+), 445 deletions(-) diff --git a/src/base/base.cgh b/src/base/base.cgh index 502b0d0d..dfb47414 100644 --- a/src/base/base.cgh +++ b/src/base/base.cgh @@ -260,6 +260,7 @@ //- Time #define NsFromSeconds(s) ((i64)((s) * 1000000000.0)) #define MsFromNs(ns) ((f64)((ns) / 1000000.0)) +#define UsFromNs(ns) ((f64)((ns) / 1000.0)) #define SecondsFromNs(ns) ((f64)(ns) / 1000000000.0) //- Busy-wait diff --git a/src/base/base_async.c b/src/base/base_async.c index 12db3ce8..abda96fd 100644 --- a/src/base/base_async.c +++ b/src/base/base_async.c @@ -43,65 +43,67 @@ void AsyncWorkerEntryPoint(WaveLaneCtx *lane) for (;;) { AsyncWorkerCtx *w = &Base.async.worker; - - ////////////////////////////// - //- Begin tick - - if (lane->idx == 0) { - // Wait for signal - { - i64 passive_timeout_ns = NsFromSeconds(0.25); - i64 now_ns = TimeNs(); - i64 passive_run_at_ns = now_ns + passive_timeout_ns; + ////////////////////////////// + //- Begin tick - i64 cur_signal = Atomic64Fetch(&Base.async.signal.v); - while (cur_signal <= w->last_seen_signal && (passive_run_at_ns - now_ns) > 1000000) - { - FutexYieldNeq(&Base.async.signal.v, &cur_signal, sizeof(cur_signal), passive_run_at_ns - now_ns); - cur_signal = Atomic64Fetch(&Base.async.signal.v); - now_ns = TimeNs(); - } - w->last_seen_signal = cur_signal; - } - // Collect callbacks + if (lane->idx == 0) { - Lock lock = LockE(&Base.async.mutex); + // Wait for signal { - w->callbacks_count = Base.async.callback_nodes_count; - w->callbacks = PushStructsNoZero(frame.arena, AsyncTickCallback, w->callbacks_count); - u64 callback_idx = 0; - for (AsyncTickCallbackNode *n = Base.async.first_callback_node; n; n = n->next) + i64 passive_timeout_ns = NsFromSeconds(0.25); + i64 now_ns = TimeNs(); + i64 passive_run_at_ns = now_ns + passive_timeout_ns; + + i64 cur_signal = Atomic64Fetch(&Base.async.signal.v); + while (cur_signal <= w->last_seen_signal && (passive_run_at_ns - now_ns) > 1000000) { - w->callbacks[callback_idx] = n->callback; - ++callback_idx; + FutexYieldNeq(&Base.async.signal.v, &cur_signal, sizeof(cur_signal), passive_run_at_ns - now_ns); + cur_signal = Atomic64Fetch(&Base.async.signal.v); + now_ns = TimeNs(); } + w->last_seen_signal = cur_signal; } - Unlock(&lock); + // Collect callbacks + { + Lock lock = LockE(&Base.async.mutex); + { + w->callbacks_count = Base.async.callback_nodes_count; + w->callbacks = PushStructsNoZero(frame.arena, AsyncTickCallback, w->callbacks_count); + u64 callback_idx = 0; + for (AsyncTickCallbackNode *n = Base.async.first_callback_node; n; n = n->next) + { + w->callbacks[callback_idx] = n->callback; + ++callback_idx; + } + } + Unlock(&lock); + } + } + + WaveSync(lane); + + ////////////////////////////// + //- Run async callbacks + + for (u64 callback_idx = 0; callback_idx < w->callbacks_count; ++callback_idx) + { + AsyncTickCallback *callback = &w->callbacks[callback_idx]; + callback->func(lane, &frame); + } + + ////////////////////////////// + //- End tick + + WaveSync(lane); + + ResetArena(frame.arena); + { + Arena *old_frame_arena = frame.arena; + ZeroStruct(&frame); + frame.arena = old_frame_arena; } } - WaveSync(lane); - - ////////////////////////////// - //- Run async callbacks - - for (u64 callback_idx = 0; callback_idx < w->callbacks_count; ++callback_idx) - { - AsyncTickCallback *callback = &w->callbacks[callback_idx]; - callback->func(lane, &frame); - } - - ////////////////////////////// - //- End tick - - WaveSync(lane); - - ResetArena(frame.arena); - { - Arena *old_frame_arena = frame.arena; - ZeroStruct(&frame); - frame.arena = old_frame_arena; - } } } diff --git a/src/base/base_string.c b/src/base/base_string.c index 7ad045f4..f6ab76ff 100644 --- a/src/base/base_string.c +++ b/src/base/base_string.c @@ -213,6 +213,28 @@ String StringFromUid(Arena *arena, Uid uid) return result; } +String StringFromTimeNs(Arena *arena, i64 time_ns, u32 precision) +{ + String result = Zi; + u64 abs_time_ns = AbsI64(time_ns); + if (abs_time_ns <= 999 * 1000) + { + // Microseconds + result = StringF(arena, "%F µs", FmtFloat(UsFromNs(time_ns), .p = precision)); + } + else if (abs_time_ns <= 999 * 1000000) + { + // Milliseconds + result = StringF(arena, "%F ms", FmtFloat(MsFromNs(time_ns), .p = precision)); + } + else + { + // Seconds + result = StringF(arena, "%F s", FmtFloat(SecondsFromNs(time_ns), .p = precision)); + } + return result; +} + //////////////////////////////////////////////////////////// //~ String helpers @@ -790,6 +812,11 @@ String FormatString(Arena *arena, String fmt, FmtArgArray args) parsed_arg = StringFromUid(arena, arg.value.uid); } break; + case FmtArgKind_TimeNs: + { + parsed_arg = StringFromTimeNs(arena, arg.value.time_ns, arg.p); + } break; + case FmtArgKind_End: { // Unexpected end. Not enough FMT args passed to function. @@ -881,6 +908,7 @@ FmtArgArray FmtArgsFromVaList(Arena *arena, va_list args) case FmtArgKind_Ptr: case FmtArgKind_Uid: case FmtArgKind_Handle: + case FmtArgKind_TimeNs: { // Continue } break; diff --git a/src/base/base_string.h b/src/base/base_string.h index 9d54dfd3..e01c56d6 100644 --- a/src/base/base_string.h +++ b/src/base/base_string.h @@ -31,6 +31,7 @@ Enum(FmtArgKind) FmtArgKind_Ptr = 0xc4519e4, FmtArgKind_Uid = 0xd1cd407, FmtArgKind_Handle = 0xead3bec, + FmtArgKind_TimeNs = 0x49456f44, FmtArgKind_End = 0xecbc5ae }; @@ -48,8 +49,9 @@ Struct(FmtArg) Vec4I64 sints; Vec4F64 floats; void *ptr; - Uid uid; u64 handle; + Uid uid; + i64 time_ns; } value; }; @@ -85,6 +87,7 @@ String StringFromFloats(Arena *arena, u64 floats_count, f64 *floats, u32 precisi String StringFromPtr(Arena *arena, void *ptr); String StringFromhandle(Arena *arena, u64 v); String StringFromUid(Arena *arena, Uid uid); +String StringFromTimeNs(Arena *arena, i64 time_ns, u32 precision); //////////////////////////////////////////////////////////// //~ String helpers @@ -131,28 +134,29 @@ String StringFromList(Arena *arena, StringList l, String separator); #define FMTARG(_kind, ...) ((FmtArg) { .kind = (_kind), .p = DefaultFmtPrecision, __VA_ARGS__ }) -#define FmtChar(v, ...) FMTARG(FmtArgKind_Char, .value.c = (v), __VA_ARGS__) -#define FmtString(v, ...) FMTARG(FmtArgKind_String, .value.string = (v), __VA_ARGS__) +#define FmtChar(v, ...) FMTARG(FmtArgKind_Char, .value.c = (v), __VA_ARGS__) +#define FmtString(v, ...) FMTARG(FmtArgKind_String, .value.string = (v), __VA_ARGS__) -#define FmtUint(v, ...) FMTARG(FmtArgKind_Uint, .value.uints = VEC4U64((v), 0, 0, 0), __VA_ARGS__) -#define FmtUint2(v, ...) FMTARG(FmtArgKind_Uint2, .value.uints = VEC4U64((v).x, (v).y, 0, 0), __VA_ARGS__) -#define FmtUint3(v, ...) FMTARG(FmtArgKind_Uint3, .value.uints = VEC4U64((v).x, (v).y, (v).z, 0), __VA_ARGS__) -#define FmtUint4(v, ...) FMTARG(FmtArgKind_Uint4, .value.uints = VEC4U64((v).x, (v).y, (v).z, (v).w), __VA_ARGS__) +#define FmtUint(v, ...) FMTARG(FmtArgKind_Uint, .value.uints = VEC4U64((v), 0, 0, 0), __VA_ARGS__) +#define FmtUint2(v, ...) FMTARG(FmtArgKind_Uint2, .value.uints = VEC4U64((v).x, (v).y, 0, 0), __VA_ARGS__) +#define FmtUint3(v, ...) FMTARG(FmtArgKind_Uint3, .value.uints = VEC4U64((v).x, (v).y, (v).z, 0), __VA_ARGS__) +#define FmtUint4(v, ...) FMTARG(FmtArgKind_Uint4, .value.uints = VEC4U64((v).x, (v).y, (v).z, (v).w), __VA_ARGS__) -#define FmtSint(v, ...) FMTARG(FmtArgKind_Sint, .value.sints = VEC4I64((v), 0, 0, 0), __VA_ARGS__) -#define FmtSint2(v, ...) FMTARG(FmtArgKind_Sint2, .value.sints = VEC4I64((v).x, (v).y, 0, 0), __VA_ARGS__) -#define FmtSint3(v, ...) FMTARG(FmtArgKind_Sint3, .value.sints = VEC4I64((v).x, (v).y, (v).z, 0), __VA_ARGS__) -#define FmtSint4(v, ...) FMTARG(FmtArgKind_Sint4, .value.sints = VEC4I64((v).x, (v).y, (v).z, (v).w), __VA_ARGS__) +#define FmtSint(v, ...) FMTARG(FmtArgKind_Sint, .value.sints = VEC4I64((v), 0, 0, 0), __VA_ARGS__) +#define FmtSint2(v, ...) FMTARG(FmtArgKind_Sint2, .value.sints = VEC4I64((v).x, (v).y, 0, 0), __VA_ARGS__) +#define FmtSint3(v, ...) FMTARG(FmtArgKind_Sint3, .value.sints = VEC4I64((v).x, (v).y, (v).z, 0), __VA_ARGS__) +#define FmtSint4(v, ...) FMTARG(FmtArgKind_Sint4, .value.sints = VEC4I64((v).x, (v).y, (v).z, (v).w), __VA_ARGS__) -#define FmtFloat(v, ...) FMTARG(FmtArgKind_Float, .value.floats = VEC4F64((v), 0, 0, 0), __VA_ARGS__) -#define FmtFloat2(v, ...) FMTARG(FmtArgKind_Float2, .value.floats = VEC4F64((v).x, (v).y, 0, 0), __VA_ARGS__) -#define FmtFloat3(v, ...) FMTARG(FmtArgKind_Float3, .value.floats = VEC4F64((v).x, (v).y, (v).z, 0), __VA_ARGS__) -#define FmtFloat4(v, ...) FMTARG(FmtArgKind_Float4, .value.floats = VEC4F64((v).x, (v).y, (v).z, (v).w), __VA_ARGS__) +#define FmtFloat(v, ...) FMTARG(FmtArgKind_Float, .value.floats = VEC4F64((v), 0, 0, 0), __VA_ARGS__) +#define FmtFloat2(v, ...) FMTARG(FmtArgKind_Float2, .value.floats = VEC4F64((v).x, (v).y, 0, 0), __VA_ARGS__) +#define FmtFloat3(v, ...) FMTARG(FmtArgKind_Float3, .value.floats = VEC4F64((v).x, (v).y, (v).z, 0), __VA_ARGS__) +#define FmtFloat4(v, ...) FMTARG(FmtArgKind_Float4, .value.floats = VEC4F64((v).x, (v).y, (v).z, (v).w), __VA_ARGS__) -#define FmtHex(v, ...) FMTARG(FmtArgKind_Hex, .value.uints.x = (v), __VA_ARGS__) -#define FmtPtr(v, ...) FMTARG(FmtArgKind_Ptr, .value.ptr = (v), __VA_ARGS__) -#define FmtHandle(v, ...) FMTARG(FmtArgKind_Handle, .value.handle = (v), __VA_ARGS__) -#define FmtUid(v, ...) FMTARG(FmtArgKind_Uid, .value.uid = (v), __VA_ARGS__) +#define FmtHex(v, ...) FMTARG(FmtArgKind_Hex, .value.uints.x = (v), __VA_ARGS__) +#define FmtPtr(v, ...) FMTARG(FmtArgKind_Ptr, .value.ptr = (v), __VA_ARGS__) +#define FmtHandle(v, ...) FMTARG(FmtArgKind_Handle, .value.handle = (v), __VA_ARGS__) +#define FmtUid(v, ...) FMTARG(FmtArgKind_Uid, .value.uid = (v), __VA_ARGS__) +#define FmtTimeNs(v, ...) FMTARG(FmtArgKind_TimeNs, .value.time_ns = (v), __VA_ARGS__) #define FmtEnd FMTARG(FmtArgKind_End) // Denotes end of VA list diff --git a/src/pp/pp_sim/pp_sim_core.c b/src/pp/pp_sim/pp_sim_core.c index 7b09a761..0c927f64 100644 --- a/src/pp/pp_sim/pp_sim_core.c +++ b/src/pp/pp_sim/pp_sim_core.c @@ -86,7 +86,7 @@ void S_TickForever(WaveLaneCtx *lane) b32 shutdown = 0; while (!shutdown) - ProfZoneDF("Sim Frame") + ProfZoneDF("Sim tick") { shutdown = Atomic32Fetch(&S.shutdown); P_tl.debug_draw_enabled = TweakBool("Simulation debug draw", 0); diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index ac323d8e..2fa1a067 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -601,6 +601,7 @@ V_WidgetTheme V_GetWidgetTheme(void) // theme.font_size = 14; theme.ui_font_size = TweakFloat("UI font size", 14, 8, 24, .precision = 0); theme.chat_font_size = TweakFloat("Chat font size", 16, 8, 24, .precision = 0); + theme.tooltip_offset_px = VEC2(12, 0); theme.h1 = 2.00; theme.h2 = 1.50; theme.h3 = 1.25; @@ -871,7 +872,7 @@ void V_TickForever(WaveLaneCtx *lane) b32 shutdown = 0; while (!shutdown) - ProfZoneDF("Vis frame") + ProfZoneDF("Vis tick") { shutdown = Atomic32Fetch(&V.shutdown); P_tl.debug_draw_enabled = TweakBool("Vis debug draw", 0); @@ -1056,8 +1057,8 @@ void V_TickForever(WaveLaneCtx *lane) V_PushWidgetThemeStyles(theme); UI_Push(ChildLayoutAxis, Axis_Y); - UI_Push(Width, UI_GROW(1, 0)); - UI_Push(Height, UI_GROW(1, 0)); + UI_Push(Width, UI_Grow(1, 0)); + UI_Push(Height, UI_Grow(1, 0)); UI_Key vis_game_box = UI_KeyF("vis game box"); UI_Key vis_ui_box = UI_KeyF("vis ui box"); { @@ -3744,8 +3745,8 @@ void V_TickForever(WaveLaneCtx *lane) } } - UI_SetNext(AxisSize, UI_GROW(panel->pref_ratio, 0), .axis = !panel->axis); - UI_SetNext(AxisSize, UI_GROW(1, 0), .axis = panel->axis); + UI_SetNext(AxisSize, UI_Grow(panel->pref_ratio, 0), .axis = !panel->axis); + UI_SetNext(AxisSize, UI_Grow(1, 0), .axis = panel->axis); if (panel->axis == Axis_X) { UI_BuildRowEx(panel->key); @@ -3769,14 +3770,14 @@ void V_TickForever(WaveLaneCtx *lane) ////////////////////////////// //- Build tab row - f32 tab_spacing = UI_FNT(0.25, 0).v; + f32 tab_spacing = UI_Fnt(0.25, 0).v; V_Window *active_window = 0; V_Window *close_window = 0; { UI_Key tab_row_key = UI_KeyF("tab row"); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_PushCp(UI_BuildRowEx(tab_row_key)); @@ -3859,7 +3860,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_Push(Tag, tab->key.v); if (tab == first_drawable_tab) { - UI_BuildSpacer(UI_PIX(tab_spacing, 0), Axis_X); + UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); } switch (tab->kind) @@ -3924,26 +3925,26 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, bg_color); UI_SetNext(BorderColor, border_color); UI_SetNext(BorderSize, 1); - UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Height, UI_SHRINK(0, 0)); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 0)); UI_SetNext(ChildAlignment, UI_Region_Left); UI_SetNext(Misc, window == active_window); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_PushCp(UI_BuildRowEx(tab->key)); { - UI_BuildSpacer(UI_PIX(tab_spacing, 0), Axis_X); + UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); // Build tab title { UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(Flags, UI_BoxFlag_DrawText); UI_SetNext(Text, tab_name); - UI_SetNext(Width, UI_SHRINK(0, 0)); - UI_SetNext(Height, UI_SHRINK(2, 0)); + UI_SetNext(Width, UI_Shrink(0, 0)); + UI_SetNext(Height, UI_Shrink(2, 0)); UI_BuildRow(); } - UI_BuildSpacer(UI_PIX(tab_spacing, 0), Axis_X); + UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); // Build tab close button { @@ -3959,18 +3960,18 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BorderSize, 2); UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - UI_SetNext(Width, UI_SHRINK(0, 0)); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Shrink(0, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_PushCp(UI_BuildRowEx(close_key)); { - UI_BuildSpacer(UI_PIX(tab_spacing * 2, 0), Axis_X); + UI_BuildSpacer(UI_Px(tab_spacing * 2, 0), Axis_X); - UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(FontSize, UI_Top(FontSize) * theme.micro); UI_BuildIcon(theme.icon_font, UI_Icon_Cross); - UI_BuildSpacer(UI_PIX(tab_spacing * 2, 0), Axis_X); + UI_BuildSpacer(UI_Px(tab_spacing * 2, 0), Axis_X); } UI_PopCp(UI_TopCp()); @@ -4003,9 +4004,9 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, bg_color); UI_SetNext(BorderColor, border_color); UI_SetNext(BorderSize, 2); - // UI_SetNext(Width, UI_PIX(30, 0)); - UI_SetNext(Width, UI_PIX(100, 0)); - UI_SetNext(Height, UI_GROW(1, 0)); + // UI_SetNext(Width, UI_Px(30, 0)); + UI_SetNext(Width, UI_Px(100, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_SetNext(ChildAlignment, UI_Region_Center); // UI_SetNext(FontSize, theme.font_size * 1.5); UI_PushCp(UI_BuildRowEx(tab->key)); @@ -4030,22 +4031,22 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, bg_color); UI_SetNext(BorderColor, border_color); UI_SetNext(BorderSize, 2); - UI_SetNext(Width, UI_SHRINK(10, 0)); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Shrink(10, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_SetNext(ChildAlignment, UI_Region_Center); // UI_SetNext(FontSize, theme.font_size * 1.5); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_PushCp(UI_BuildRowEx(key)); { - UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(FontSize, UI_Top(FontSize) * theme.micro); UI_BuildIcon(theme.icon_font, UI_Icon_Plus); } UI_PopCp(UI_TopCp()); } } - UI_BuildSpacer(UI_PIX(tab_spacing, 0), Axis_X); + UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); } UI_PopCp(UI_TopCp()); } @@ -4062,8 +4063,8 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, window_bg_color); UI_SetNext(BorderColor, window_border_color); UI_SetNext(BorderSize, 1); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_PushCp(UI_BuildColumn()); { @@ -4101,14 +4102,14 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, bg_color); UI_SetNext(BorderColor, border_color); UI_SetNext(BorderSize, 1); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_SHRINK(UI_FNT(0.25, 0).v, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0)); UI_SetNext(Misc, is_selected); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(ChildAlignment, UI_Region_Left); UI_PushCp(UI_BuildRowEx(key)); { - UI_BuildSpacer(UI_FNT(0.25, 0), Axis_X); + UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X); // Tile sprite { @@ -4117,21 +4118,21 @@ void V_TickForever(WaveLaneCtx *lane) SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); UI_SetNext(ChildAlignment, UI_Region_Center); - UI_SetNext(Width, UI_FNT(2.5, 0)); - UI_SetNext(Height, UI_FNT(2.5, 0)); + UI_SetNext(Width, UI_Fnt(2.5, 0)); + UI_SetNext(Height, UI_Fnt(2.5, 0)); UI_SetNext(SpriteSheet, sheet); UI_BuildRow(); } - UI_BuildSpacer(UI_FNT(0.5, 0), Axis_X); + UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X); // Tile name { UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(Text, tile_name); UI_SetNext(Flags, UI_BoxFlag_DrawText); - UI_SetNext(Width, UI_SHRINK(4, 0)); - UI_SetNext(Height, UI_SHRINK(2, 0)); + UI_SetNext(Width, UI_Shrink(4, 0)); + UI_SetNext(Height, UI_Shrink(2, 0)); UI_BuildRow(); } } @@ -4174,14 +4175,14 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, bg_color); UI_SetNext(BorderColor, border_color); UI_SetNext(BorderSize, 1); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_SHRINK(UI_FNT(0.25, 0).v, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0)); UI_SetNext(Misc, is_selected); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(ChildAlignment, UI_Region_Left); UI_PushCp(UI_BuildRowEx(key)); { - UI_BuildSpacer(UI_FNT(0.25, 0), Axis_X); + UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X); // Prefab sprite { @@ -4190,21 +4191,21 @@ void V_TickForever(WaveLaneCtx *lane) SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); UI_SetNext(ChildAlignment, UI_Region_Center); - UI_SetNext(Width, UI_FNT(2.5, 0)); - UI_SetNext(Height, UI_FNT(2.5, 0)); + UI_SetNext(Width, UI_Fnt(2.5, 0)); + UI_SetNext(Height, UI_Fnt(2.5, 0)); UI_SetNext(SpriteSheet, sheet); UI_BuildRow(); } - UI_BuildSpacer(UI_FNT(0.5, 0), Axis_X); + UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X); // Prefab name { UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(Text, prefab_name); UI_SetNext(Flags, UI_BoxFlag_DrawText); - UI_SetNext(Width, UI_SHRINK(4, 0)); - UI_SetNext(Height, UI_SHRINK(2, 0)); + UI_SetNext(Width, UI_Shrink(4, 0)); + UI_SetNext(Height, UI_Shrink(2, 0)); UI_BuildRow(); } } @@ -4246,8 +4247,8 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BorderColor, border_color); UI_SetNext(BorderSize, MaxF32((divider_size / 2.0) - (visible_size / 2.0), 0)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - 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_Grow(1, 1), .axis = panel->axis); + UI_SetNext(AxisSize, UI_Px(divider_size, 1), .axis = !panel->axis); UI_BuildBoxEx(panel->divider_key); if (UI_HotAbsolute(panel->divider_key) || UI_Held(panel->divider_key, Button_M1)) @@ -4331,15 +4332,15 @@ void V_TickForever(WaveLaneCtx *lane) palette->pos = VEC2(1000, 1000); } - UI_Size total_width = UI_FNT(40, 1); - UI_Size total_height = UI_FNT(30, 1); - UI_Size header_height = UI_FNT(1.3, 1); - UI_Size window_padding = UI_FNT(0.5, 1); - UI_Size icon_col_width = UI_FNT(1.75, 1); - UI_Size item_col_width = UI_FNT(30, 1); - // UI_Size col2_width = UI_FNT(10, 1); - UI_Size scrollbar_width = UI_FNT(1, 1); - f32 item_size_px = UI_FNT(1.5, 1).v; + UI_Size total_width = UI_Fnt(40, 1); + UI_Size total_height = UI_Fnt(30, 1); + UI_Size header_height = UI_Fnt(1.3, 1); + UI_Size window_padding = UI_Fnt(0.5, 1); + UI_Size icon_col_width = UI_Fnt(1.75, 1); + UI_Size item_col_width = UI_Fnt(30, 1); + // UI_Size col2_width = UI_Fnt(10, 1); + UI_Size scrollbar_width = UI_Fnt(1, 1); + f32 item_size_px = UI_Fnt(1.5, 1).v; UI_Key scissor_key = UI_KeyF("scissor"); UI_Key lister_key = UI_KeyF("lister"); @@ -4410,7 +4411,7 @@ void V_TickForever(WaveLaneCtx *lane) if (palette->is_showing || palette->show > 0.001) { - f32 tweak_size_px = UI_FNT(1.25, 1).v; + f32 tweak_size_px = UI_Fnt(1.25, 1).v; palette->key = UI_KeyF("command palette"); UI_Checkpoint palette_cp = UI_PushCp(UI_NilKey); @@ -4438,7 +4439,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BorderColor, window_border_color); // UI_SetNext(BorderSize, theme.window_bd_sz); UI_SetNext(BorderSize, 1); - UI_SetNext(Rounding, UI_RGROW(0.06 * theme.rounding)); + UI_SetNext(Rounding, UI_Rgrow(0.06 * theme.rounding)); UI_SetNext(Width, total_width); UI_SetNext(Height, total_height); UI_SetNext(FloatingPos, palette->pos); @@ -4454,14 +4455,14 @@ void V_TickForever(WaveLaneCtx *lane) { UI_Push(BackgroundColor, titlebar_color); UI_Push(BorderColor, titlebar_border_color); - UI_Push(Rounding, UI_RPIX(0)); + UI_Push(Rounding, UI_Rpx(0)); UI_Push(ChildLayoutAxis, Axis_X); - UI_Push(Width, UI_GROW(1, 0)); + UI_Push(Width, UI_Grow(1, 0)); UI_Push(Height, header_height); UI_SetNext(Flags, UI_BoxFlag_DrawText | (UI_BoxFlag_CaptureMouse * !!palette->is_showing)); UI_PushCp(UI_BuildBoxEx(titlebar_key)); { - UI_Push(Width, UI_GROW(1, 0)); + UI_Push(Width, UI_Grow(1, 0)); UI_Push(BorderColor, 0); // Left title box @@ -4472,7 +4473,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5); UI_SetNext(TextColor, theme.col.hint); UI_SetNext(ChildAlignment, UI_Region_Center); - UI_SetNext(Width, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Shrink(0, 1)); UI_SetNext(Text, Lit("Developer Palette")); UI_SetNext(Flags, UI_BoxFlag_DrawText); UI_BuildBox(); @@ -4487,16 +4488,16 @@ void V_TickForever(WaveLaneCtx *lane) //- Window box UI_SetNext(BackgroundColor, 0); UI_SetNext(Rounding, 0); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_PushCp(UI_BuildRow()); { UI_BuildSpacer(window_padding, Axis_X); UI_SetNext(BackgroundColor, 0); UI_SetNext(Rounding, 0); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_PushCp(UI_BuildColumn()); { ////////////////////////////// @@ -4505,11 +4506,11 @@ void V_TickForever(WaveLaneCtx *lane) b32 is_searching = 0; String search_pattern = Zi; { - UI_Size search_height = UI_PIX(item_size_px * 1.25, 1); + UI_Size search_height = UI_Px(item_size_px * 1.25, 1); UI_SetNext(BackgroundColor, 0); UI_SetNext(ChildAlignment, UI_Region_Left); - UI_SetNext(Width, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); UI_SetNext(Height, search_height); UI_PushCp(UI_BuildRow()); { @@ -4517,7 +4518,7 @@ void V_TickForever(WaveLaneCtx *lane) { f32 size_px = UI_Top(FontSize) * 1.25; - UI_SetNext(Rounding, UI_RGROW(0.75 * theme.rounding)); + UI_SetNext(Rounding, UI_Rgrow(0.75 * theme.rounding)); UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(BackgroundColor, 0); // UI_SetNext(BorderColor, reset_bd); @@ -4525,7 +4526,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Rounding, 0); UI_SetNext(TextColor, theme.col.hint); UI_SetNext(Width, icon_col_width); - UI_SetNext(Height, UI_PIX(size_px * 1.5, 1)); + UI_SetNext(Height, UI_Px(size_px * 1.5, 1)); // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(FontSize, size_px * theme.h6); UI_BuildIcon(theme.icon_font, UI_Icon_Search); @@ -4612,12 +4613,12 @@ void V_TickForever(WaveLaneCtx *lane) // Vec4 search_color = Color_Black; Vec4 search_color = Zi; - UI_SetNext(Width, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); UI_SetNext(Height, search_height); UI_SetNext(BackgroundColor, search_color); // UI_SetNext(BorderColor, item_border_color); UI_SetNext(BorderSize, 0); - // UI_SetNext(Rounding, UI_RPIX(5)); + // UI_SetNext(Rounding, UI_Rpx(5)); UI_SetNext(ChildAlignment, UI_Region_Left); UI_SetNext(TextColor, display_text_color); UI_SetNext(Text, display_text); @@ -4634,8 +4635,8 @@ void V_TickForever(WaveLaneCtx *lane) UI_Key selection_box = UI_KeyF("search selection"); - UI_Size caret_width = UI_PIX(1, 1); - UI_Size caret_height = UI_PIX(search_height.v, 1); + UI_Size caret_width = UI_Px(1, 1); + UI_Size caret_height = UI_Px(search_height.v, 1); Vec4 selection_color = VEC4(0, 0.25, 0.75, 0.5); @@ -4700,7 +4701,7 @@ void V_TickForever(WaveLaneCtx *lane) f32 min = MinF32(start_offset_px, end_offset_px); f32 max = MaxF32(start_offset_px, end_offset_px); - UI_SetNext(Width, UI_PIX(max - min, 1)); + UI_SetNext(Width, UI_Px(max - min, 1)); UI_SetNext(Height, caret_height); UI_SetNext(FloatingPos, VEC2(min, 0)); UI_SetNext(Anchor, UI_Region_Left); @@ -4731,7 +4732,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_PopCp(UI_TopCp()); } - UI_BuildDivider(UI_PIX(1, 1), divider_color, Axis_Y); + UI_BuildDivider(UI_Px(1, 1), divider_color, Axis_Y); ////////////////////////////// //- Build palette items list @@ -4739,8 +4740,8 @@ void V_TickForever(WaveLaneCtx *lane) // Scissor box UI_SetNext(BackgroundColor, 0); UI_SetNext(Rounding, 0); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_SetNext(Flags, UI_BoxFlag_Scissor); UI_PushCp(UI_BuildRowEx(scissor_key)); { @@ -4752,16 +4753,16 @@ void V_TickForever(WaveLaneCtx *lane) // Items box UI_SetNext(BackgroundColor, 0); UI_SetNext(Rounding, 0); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(FloatingPos, VEC2(0, -lister_offset)); UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_DontClampFloatingY | UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren); UI_PushCp(UI_BuildRowEx(lister_key)); { UI_SetNext(Tint, 0); UI_SetNext(Rounding, 0); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_PushCp(UI_BuildColumn()); { Enum(PaletteItemFlag) @@ -4858,7 +4859,7 @@ void V_TickForever(WaveLaneCtx *lane) // Divider if (item != first_item) { - UI_BuildDivider(UI_PIX(1, 1), divider_color, Axis_Y); + UI_BuildDivider(UI_Px(1, 1), divider_color, Axis_Y); } if (UI_Presses(item->key, Button_M1)) @@ -4886,19 +4887,19 @@ void V_TickForever(WaveLaneCtx *lane) } UI_SetNext(Tint, 0); - // UI_SetNext(Width, UI_PIX(total_width.v - window_padding.v * 2, 1)); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_FNT(1.5, 1)); + // UI_SetNext(Width, UI_Px(total_width.v - window_padding.v * 2, 1)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Fnt(1.5, 1)); UI_PushCp(UI_BuildRow()); { UI_SetNext(BackgroundColor, item_color); UI_SetNext(BorderColor, item_border_color); UI_SetNext(BorderSize, 1); - UI_SetNext(Rounding, UI_RPIX(5)); + UI_SetNext(Rounding, UI_Rpx(5)); // UI_SetNext(Width, item_col_width); - UI_SetNext(Width, UI_GROW(1, 0)); - // UI_SetNext(Height, UI_PIX(item_size_px, 1)); - // UI_SetNext(Height, UI_FNT(1, 0)); + UI_SetNext(Width, UI_Grow(1, 0)); + // UI_SetNext(Height, UI_Px(item_size_px, 1)); + // UI_SetNext(Height, UI_Fnt(1, 0)); UI_SetNext(ChildAlignment, UI_Region_Left); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse); UI_PushCp(UI_BuildRowEx(item->key)); @@ -4912,7 +4913,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildLabel(item->display_name); // Middle spacer - UI_BuildSpacer(UI_GROW(1, 0), Axis_X); + UI_BuildSpacer(UI_Grow(1, 0), Axis_X); // Tweak if (item->flags & PaletteItemFlag_IsTweakVar) @@ -4925,7 +4926,7 @@ void V_TickForever(WaveLaneCtx *lane) // Reset button if (!is_default) { - // UI_BuildSpacer(UI_PIX(spacing * 0.5, 1), Axis_X); + // UI_BuildSpacer(UI_Px(spacing * 0.5, 1), Axis_X); UI_Key reset_key = UI_KeyF("reset"); if (UI_Downs(reset_key, Button_M1)) @@ -4948,14 +4949,14 @@ void V_TickForever(WaveLaneCtx *lane) Vec4 reset_text_col = theme.col.hint; reset_text_col = LerpSrgb(reset_text_col, theme.col.text, UI_Hot(reset_key)); - UI_SetNext(Rounding, UI_RGROW(0.75 * theme.rounding)); + UI_SetNext(Rounding, UI_Rgrow(0.75 * theme.rounding)); UI_SetNext(ChildAlignment, UI_Region_Bottom); UI_SetNext(BackgroundColor, reset_bg); UI_SetNext(BorderColor, reset_bd); UI_SetNext(BorderSize, 0); UI_SetNext(TextColor, reset_text_col); - UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6); UI_BuildIconEx(reset_key, theme.icon_font, UI_Icon_Loop2); @@ -4974,8 +4975,8 @@ void V_TickForever(WaveLaneCtx *lane) } UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5); UI_SetNext(ChildAlignment, UI_Region_Left); - UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(Text, new_tweak_str); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_DontTruncateText); UI_SetNext(BackgroundColor, 0); @@ -5007,10 +5008,10 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, cb_bg_color); UI_SetNext(BorderColor, cb_border_color); - UI_SetNext(Rounding, UI_RGROW(theme.rounding)); + UI_SetNext(Rounding, UI_Rgrow(theme.rounding)); UI_SetNext(BorderSize, 1); - UI_SetNext(Width, UI_FNT(1.25, 1)); - UI_SetNext(Height, UI_FNT(1.25, 1)); + UI_SetNext(Width, UI_Fnt(1.25, 1)); + UI_SetNext(Height, UI_Fnt(1.25, 1)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_PushCp(UI_BuildRowEx(cb_key)); { @@ -5079,10 +5080,10 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, slider_bg_color); UI_SetNext(BorderColor, slider_border_color); - UI_SetNext(Rounding, UI_RGROW(theme.rounding)); + UI_SetNext(Rounding, UI_Rgrow(theme.rounding)); UI_SetNext(BorderSize, 1); - UI_SetNext(Width, UI_FNT(10, 1)); - UI_SetNext(Height, UI_PIX(tweak_size_px * 0.75, 1)); + UI_SetNext(Width, UI_Fnt(10, 1)); + UI_SetNext(Height, UI_Px(tweak_size_px * 0.75, 1)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(Misc, ratio); UI_PushCp(UI_BuildRowEx(slider_key)); @@ -5092,12 +5093,12 @@ void V_TickForever(WaveLaneCtx *lane) // Slider progress { UI_SetNext(BackgroundColor, slider_progress_color); - // UI_SetNext(Rounding, UI_RGROW(theme.rounding)); + // UI_SetNext(Rounding, UI_Rgrow(theme.rounding)); UI_SetNext(Rounding, 0); UI_SetNext(BorderColor, 0); UI_SetNext(BorderSize, 1); - UI_SetNext(Width, UI_PIX(marker_pos + half_marker_dims.x, 0)); - UI_SetNext(Height, UI_PIX(tweak_size_px * 0.75, 1)); + UI_SetNext(Width, UI_Px(marker_pos + half_marker_dims.x, 0)); + UI_SetNext(Height, UI_Px(tweak_size_px * 0.75, 1)); UI_BuildBox(); } @@ -5105,10 +5106,10 @@ void V_TickForever(WaveLaneCtx *lane) { UI_SetNext(BackgroundColor, marker_bg_color); UI_SetNext(BorderColor, slider_border_color); - UI_SetNext(Rounding, UI_RGROW(theme.rounding)); + UI_SetNext(Rounding, UI_Rgrow(theme.rounding)); UI_SetNext(BorderSize, 1); - UI_SetNext(Width, UI_PIX(tweak_size_px, 1)); - UI_SetNext(Height, UI_PIX(tweak_size_px, 1)); + UI_SetNext(Width, UI_Px(tweak_size_px, 1)); + UI_SetNext(Height, UI_Px(tweak_size_px, 1)); // UI_SetNext(Anchor, UI_Region_Center); // UI_SetNext(FloatingPos, VEC2(marker_pos, (marker_size_px * 0.5))); UI_SetNext(FloatingPos, VEC2(marker_pos, -marker_dims.y * 0.125)); @@ -5154,15 +5155,15 @@ void V_TickForever(WaveLaneCtx *lane) } else { - UI_BuildSpacer(UI_PIX(10, 1), Axis_X); + UI_BuildSpacer(UI_Px(10, 1), Axis_X); String hotkey_name = V_StringFromHotkey(UI_FrameArena(), hotkey); UI_SetNext(BackgroundColor, hotkey_color); UI_SetNext(BorderColor, hotkey_border_color); UI_SetNext(Text, hotkey_name); - UI_SetNext(Width, UI_SHRINK(theme.text_padding_x, 1)); - UI_SetNext(Height, UI_GROW(1, 0)); - UI_SetNext(Rounding, UI_RPIX(5)); + UI_SetNext(Width, UI_Shrink(theme.text_padding_x, 1)); + UI_SetNext(Height, UI_Grow(1, 0)); + UI_SetNext(Rounding, UI_Rpx(5)); UI_SetNext(BorderSize, 1); UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse); @@ -5212,10 +5213,10 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(BorderColor, bd_col); UI_SetNext(BorderSize, 1); - UI_SetNext(Rounding, UI_RGROW(theme.rounding * 0.5)); + UI_SetNext(Rounding, UI_Rgrow(theme.rounding * 0.5)); UI_SetNext(TextColor, col); - UI_SetNext(Width, UI_GROW(1, 1)); - UI_SetNext(Height, UI_FNT(1.5, 1)); + UI_SetNext(Width, UI_Grow(1, 1)); + UI_SetNext(Height, UI_Fnt(1.5, 1)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6); UI_BuildIconEx(scrollbar_up_key, theme.icon_font, UI_Icon_ArrowUp2); @@ -5223,7 +5224,7 @@ void V_TickForever(WaveLaneCtx *lane) //- Scrollbar thumb { - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_PushCp(UI_BuildBoxEx(track_key)); { Vec4 bg = theme.col.button_hot; @@ -5232,11 +5233,11 @@ void V_TickForever(WaveLaneCtx *lane) bd = LerpSrgb(bg, theme.col.button_active, UI_Hot(thumb_key)); UI_SetNext(BackgroundColor, bg); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_PIX(new_thumb_height, 1)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Px(new_thumb_height, 1)); UI_SetNext(BorderSize, 1); UI_SetNext(BorderColor, bd); - UI_SetNext(Rounding, UI_RGROW(1 * theme.rounding)); + UI_SetNext(Rounding, UI_Rgrow(1 * theme.rounding)); UI_SetNext(FloatingPos, VEC2(0, new_thumb_start)); UI_SetNext(Anchor, UI_Region_Center); UI_SetNext(Anchor, UI_Region_Top); @@ -5258,10 +5259,10 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(BorderColor, bd_col); UI_SetNext(BorderSize, 1); - UI_SetNext(Rounding, UI_RGROW(theme.rounding * 0.5)); + UI_SetNext(Rounding, UI_Rgrow(theme.rounding * 0.5)); UI_SetNext(TextColor, col); - UI_SetNext(Width, UI_GROW(1, 1)); - UI_SetNext(Height, UI_FNT(1.5, 1)); + UI_SetNext(Width, UI_Grow(1, 1)); + UI_SetNext(Height, UI_Fnt(1.5, 1)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6); UI_BuildIconEx(scrollbar_down_key, theme.icon_font, UI_Icon_ArrowDown2); @@ -5272,12 +5273,12 @@ void V_TickForever(WaveLaneCtx *lane) } UI_PopCp(UI_TopCp()); - UI_BuildDivider(UI_PIX(1, 1), divider_color, Axis_Y); + UI_BuildDivider(UI_Px(1, 1), divider_color, Axis_Y); } UI_PopCp(UI_TopCp()); UI_BuildSpacer(window_padding, Axis_X); - // UI_BuildSpacer(UI_FNT(100, 1), Axis_Y); + // UI_BuildSpacer(UI_Fnt(100, 1), Axis_Y); @@ -5328,15 +5329,15 @@ void V_TickForever(WaveLaneCtx *lane) // UI_SetNext(Width, scrollbar_width); // UI_PushCp(UI_BuildBoxEx(scrollbar_key)); // { - // UI_Size thumb_height = UI_FNT(10, 1); + // UI_Size thumb_height = UI_Fnt(10, 1); // Vec4 thumb_color = VEC4(0, 0.5, 1, 1); // thumb_color.a = thumb_reps.UI_Hot() * 0.5 + 0.5; // UI_SetNext(BackgroundColor, thumb_color); - // UI_SetNext(Width, UI_GROW(1, 0)); + // UI_SetNext(Width, UI_Grow(1, 0)); // UI_SetNext(Height, thumb_height); - // UI_SetNext(Rounding, UI_RGROW(1 * theme.rounding)); + // UI_SetNext(Rounding, UI_Rgrow(1 * theme.rounding)); // UI_SetNext(FloatingPos, VEC2(0, thumb_offset)); // // UI_SetNext(Anchor, UI_Region_Center); // UI_SetNext(Anchor, UI_Region_Top); @@ -5350,7 +5351,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_PopCp(UI_TopCp()); // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildDivider(UI_PIX(1, 1), divider_color, Axis_Y); + // UI_BuildDivider(UI_Px(1, 1), divider_color, Axis_Y); UI_BuildSpacer(header_height, Axis_Y); } @@ -5385,8 +5386,12 @@ void V_TickForever(WaveLaneCtx *lane) V_Profiler *profiler = &frame->profiler; - profiler->target_ns_per_px = MaxF64(profiler->target_ns_per_px, 1); - profiler->ns_per_px = MaxF64(profiler->ns_per_px, 1); + + f64 min_profiler_ns_per_px = 1; + f64 max_profiler_ns_per_px = NsFromSeconds(100); + profiler->target_ns_per_px = ClampF64(profiler->target_ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px); + profiler->ns_per_px = ClampF64(profiler->ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px); + UI_Key profiler_graph_box = UI_KeyF("graph"); UI_PushDF(OmitFlags, UI_BoxFlag_CaptureMouse * !!(frame->is_looking)) if (TweakBool("Show profiler", 1)) @@ -5472,15 +5477,15 @@ void V_TickForever(WaveLaneCtx *lane) { UI_Key main_box = UI_KeyF("main"); - UI_Size profiler_height = UI_FNT(40, 1); - UI_Size header_height = UI_FNT(2, 1); - UI_Size footer_height = UI_FNT(2, 1); - UI_Size window_padding = UI_FNT(0.60, 1); - // UI_Size graph_height = UI_GROW(0.25, 0); - UI_Size graph_height = UI_FNT(2, 1); - UI_Size main_height = UI_GROW(1, 0); - UI_Size zone_height = UI_FNT(1.25, 0); - UI_Size track_height = UI_FNT(25, 0); + UI_Size profiler_height = UI_Fnt(70, 1); + UI_Size header_height = UI_Fnt(2, 1); + UI_Size footer_height = UI_Fnt(2, 1); + UI_Size window_padding = UI_Fnt(0.60, 1); + // UI_Size graph_height = UI_Grow(0.25, 0); + UI_Size graph_height = UI_Fnt(2, 1); + UI_Size main_height = UI_Grow(1, 0); + UI_Size zone_height = UI_Fnt(1.25, 0); + UI_Size track_height = UI_Fnt(25, 0); f32 zone_text_padding_px = UI_Top(FontSize) * 0.2; // Vec2 old_main_dims = DimsFromRng2(UI_Rect(main_box)); @@ -5520,12 +5525,14 @@ void V_TickForever(WaveLaneCtx *lane) - i32 zooms = UI_Presses(main_box, Button_WheelDown) - UI_Presses(main_box, Button_WheelUp); - f32 zoom_factor = PowF32(prof_zoom_rate, zooms); + f64 zoom_factor = PowF64(prof_zoom_rate, UI_Presses(main_box, Button_WheelDown) - UI_Presses(main_box, Button_WheelUp)); profiler->target_ns_per_px *= zoom_factor; + profiler->target_ns_per_px = ClampF64(profiler->target_ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px); + // profiler->view_ns = profiler->cursor_ns - (profiler->cursor_ns - profiler->view_ns) * zoom_factor; + // TODO: Don't apply offset when zoom movement was clamped profiler->target_view_ns = profiler->cursor_ns - (profiler->cursor_ns - profiler->target_view_ns) * zoom_factor; profiler->ns_per_px = LerpF64(profiler->ns_per_px, profiler->target_ns_per_px, prof_lerp_rate); @@ -5605,6 +5612,9 @@ void V_TickForever(WaveLaneCtx *lane) Vec4 profiler_color = theme.col.window_bg; f32 profiler_opacity = TweakFloat("Profiler opacity", 1, 0, 1); + UI_Key hovered_zone_box = Zi; + V_ZoneDesc *hovered_zone = 0; + Vec4 main_color = profiler_color; main_color.r *= 0.75; main_color.g *= 0.75; @@ -5614,11 +5624,11 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BorderColor, theme.col.window_bd); UI_SetNext(BorderSize, 2); UI_SetNext(BackgroundColor, profiler_color); - UI_SetNext(Rounding, UI_RPIX(10 * theme.rounding)); + UI_SetNext(Rounding, UI_Rpx(10 * theme.rounding)); UI_SetNext(Height, profiler_height); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(Opacity, profiler_opacity); - UI_PushDF(Width, UI_GROW(1, 0)) + UI_PushDF(Width, UI_Grow(1, 0)) UI_PushDF(Parent, UI_BuildColumnEx(profiler_box)) UI_PushDF(Parent, UI_BuildRow()) { @@ -5636,7 +5646,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_PushDF(TextColor, theme.col.hint) UI_BuildLabelF("Profiler"); } - UI_BuildDivider(UI_PIX(1, 1), theme.col.divider, Axis_Y); + UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); //- Graph // UI_SetNext(BackgroundColor, Color_Cyan); @@ -5644,7 +5654,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_PushDF(Parent, UI_BuildBoxEx(profiler_graph_box)) { } - // UI_BuildDivider(UI_PIX(1, 1), theme.col.divider, Axis_Y); + // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); //- Main area if (do_break) @@ -5654,45 +5664,11 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Text, Lit("MAIN")); UI_SetNext(BackgroundColor, main_color); UI_SetNext(Height, main_height); - UI_SetNext(Rounding, UI_RPIX(4)); + UI_SetNext(Rounding, UI_Rpx(4)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren | UI_BoxFlag_Scissor); // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_PushDF(Parent, UI_BuildColumnEx(main_box)) { - - - - // FIXME: Remove this - - // Struct(V_ZoneDesc) - // { - // Vec4 color; - // i64 start_ns; - // i64 end_ns; - // }; - - // u64 zones_count = 64; - // V_ZoneDesc *zones = PushStructs(frame->arena, V_ZoneDesc, zones_count); - // for (u64 zone_idx = 0; zone_idx < zones_count; ++zone_idx) - // { - // V_ZoneDesc *zone = &zones[zone_idx]; - - // // zone->color = VEC4(0.5, 0.2, 0.2, 0.5); - // // zone->color.r += 0.5 * Norm24(MixU64(zone_idx)); - - // u64 seed0 = MixU64(zone_idx + 1); - // u64 seed1 = MixU64(seed0); - // u64 seed2 = MixU64(seed1); - // u64 seed3 = MixU64(seed2); - - // zone->color = VEC4(Norm24(seed0), Norm24(seed1), Norm24(seed2), 1); - // zone->color.r += (1.0 - zone->color.r) * 0.25; - - // zone->start_ns = NsFromSeconds(zone_idx * 2); - // zone->end_ns = NsFromSeconds(zone_idx * 2 + 1); - // }; - - RegisteredProfTracksArray tracks = FetchRegisteredProfTracks(frame->arena); for (u64 track_idx = 0; track_idx < tracks.count; ++track_idx) { @@ -5758,40 +5734,9 @@ void V_TickForever(WaveLaneCtx *lane) - samples_end_seq = MinU64(samples_end_seq, samples_start_seq + 512); - - - - - - - - - - - - - - Struct(V_ZoneDesc) - { - V_ZoneDesc *prev; - V_ZoneDesc *next; - - V_ZoneDesc *prev_in_row; - V_ZoneDesc *next_in_row; - - String name; - u64 start_sample_seq; - u64 end_sample_seq; - - u32 depth; - - Vec4 color; - i64 start_ns; - i64 end_ns; - }; - - + // samples_end_seq = MinU64(samples_end_seq, samples_start_seq + 512); + samples_end_seq = MinU64(samples_end_seq, samples_start_seq + 64); + // samples_end_seq = MinU64(samples_end_seq, samples_start_seq + Kibi(16)); @@ -5879,72 +5824,6 @@ void V_TickForever(WaveLaneCtx *lane) - - - - - - - // for (u64 zone_idx = 0; zone_idx < zones_count; ++zone_idx) - // { - // V_ZoneDesc *zone = &zones[zone_idx]; - // ProfSample *sample = &samples[(zone_idx + samples_start_seq) % ProfTrackSamplesCap]; - - // // zone->color = VEC4(0.5, 0.2, 0.2, 0.5); - // // zone->color.r += 0.5 * Norm24(MixU64(zone_idx)); - - // u64 seed0 = MixU64(zone_idx + 1); - // u64 seed1 = MixU64(seed0); - // u64 seed2 = MixU64(seed1); - // u64 seed3 = MixU64(seed2); - - // zone->color = VEC4(Norm24(seed0), Norm24(seed1), Norm24(seed2), 1); - // zone->color.r += (1.0 - zone->color.r) * 0.25; - - // // zone->start_ns = NsFromSeconds(zone_idx * 2); - // // zone->end_ns = NsFromSeconds(zone_idx * 2 + 1); - - // zone->start_ns = NsFromProfStamp(sample->stamp); - // zone->end_ns = zone->start_ns + NsFromSeconds(0.100); - // } - - - - - - - - // for (u64 zone_idx = 0; zone_idx < zones_count; ++zone_idx) - // { - // V_ZoneDesc *zone = &zones[zone_idx]; - - // ProfSample *sample = &samples[(zone_idx + samples_start_seq) % ProfTrackSamplesCap]; - - // // zone->color = VEC4(0.5, 0.2, 0.2, 0.5); - // // zone->color.r += 0.5 * Norm24(MixU64(zone_idx)); - - // u64 seed0 = MixU64(zone_idx + 1); - // u64 seed1 = MixU64(seed0); - // u64 seed2 = MixU64(seed1); - // u64 seed3 = MixU64(seed2); - - // zone->color = VEC4(Norm24(seed0), Norm24(seed1), Norm24(seed2), 1); - // zone->color.r += (1.0 - zone->color.r) * 0.25; - - // // zone->start_ns = NsFromSeconds(zone_idx * 2); - // // zone->end_ns = NsFromSeconds(zone_idx * 2 + 1); - - // zone->start_ns = NsFromProfStamp(sample->stamp); - // zone->end_ns = zone->start_ns + NsFromSeconds(0.100); - // } - - - - - - - - { for (u64 zone_row_idx = 0; zone_row_idx < zone_rows_count; ++zone_row_idx) { @@ -5962,6 +5841,11 @@ void V_TickForever(WaveLaneCtx *lane) if (zone->end_ns > zone->start_ns) { UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->start_sample_seq)); + if (UI_HotAbsolute(zone_box)) + { + hovered_zone_box = zone_box; + hovered_zone = zone; + } // TODO: Dim in HSV space Vec4 zone_color_dim = VEC4(0.15, 0.15, 0.15, 0); @@ -5986,7 +5870,7 @@ void V_TickForever(WaveLaneCtx *lane) f32 zone_offset_px = (zone->start_ns - profiler->view_ns) / profiler->ns_per_px; Vec2 zone_pos = VEC2(zone_offset_px, 0); - UI_Size zone_width = UI_PIX(zone_len_px, 1); + UI_Size zone_width = UI_Px(zone_len_px, 1); UI_SetNext(Text, StringF(frame->arena, "ZONE %F", FmtUint(zone_idx))); // if (do_break && UI_IsMouseHovered(zone_box)) @@ -5998,7 +5882,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Width, zone_width); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_SetNext(BackgroundColor, zone_color); UI_SetNext(BorderColor, zone_color_bd); UI_SetNext(BorderSize, 1); @@ -6008,9 +5892,9 @@ void V_TickForever(WaveLaneCtx *lane) // UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_DontClampFloatingX | UI_BoxFlag_DontClampFloatingY); UI_PushDF(Parent, UI_BuildRowEx(zone_box)) { - UI_BuildSpacer(UI_PIX(zone_text_padding_px, 0.25), Axis_X); + UI_BuildSpacer(UI_Px(zone_text_padding_px, 0.25), Axis_X); - UI_SetNext(Width, UI_SHRINK(1, 0)); + UI_SetNext(Width, UI_Shrink(1, 0)); UI_SetNext(ChildAlignment, UI_Region_Left); UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5); UI_SetNext(TextColor, zone_text_color); @@ -6019,7 +5903,7 @@ void V_TickForever(WaveLaneCtx *lane) // UI_SetNext(Flags, UI_BoxFlag_DrawText); UI_BuildRow(); - UI_BuildSpacer(UI_PIX(zone_text_padding_px, 1), Axis_X); + UI_BuildSpacer(UI_Px(zone_text_padding_px, 1), Axis_X); } zone_idx += 1; } @@ -6048,7 +5932,7 @@ void V_TickForever(WaveLaneCtx *lane) // f32 zone_offset_px = (zone->start_ns - profiler->view_ns) / profiler->ns_per_px; // Vec2 zone_pos = VEC2(zone_offset_px, 0); - // UI_Size zone_width = UI_PIX(zone_len_px, 1); + // UI_Size zone_width = UI_Px(zone_len_px, 1); // UI_SetNext(Text, StringF(frame->arena, "ZONE %F", FmtUint(zone_idx))); // // if (do_break && UI_IsMouseHovered(zone_box)) @@ -6087,13 +5971,70 @@ void V_TickForever(WaveLaneCtx *lane) Vec4 timeline_cursor_color = theme.col.window_bd; timeline_cursor_color.a = UI_Hot(main_box) * 0.5; - UI_SetNext(Width, UI_FNT(0.15, 1)); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Width, UI_Fnt(0.15, 1)); + UI_SetNext(Height, UI_Grow(1, 0)); UI_SetNext(BackgroundColor, timeline_cursor_color); UI_SetNext(FloatingPos, timeline_cursor_pos); UI_SetNext(Flags, UI_BoxFlag_Floating); UI_BuildBox(); } + + //- Timeline tooltop + { + UI_Key tooltip_box = UI_KeyF("tooltip"); + Vec2 tooltip_pos = SubVec2(frame->screen_cursor, UI_Anchor(main_box)); + tooltip_pos = AddVec2(tooltip_pos, theme.tooltip_offset_px); + f32 tooltip_opacity = 0.75; + + + // UI_Key tooltip_box = UI_KeyF("tooltip"); + // Vec2 main_cursor_pos = SubVec2(frame->screen_cursor, UI_Anchor(main_box)); + // tooltip_pos = AddVec2(tooltip_pos, theme.tooltip_offset_px); + // Vec2 tooltip_pos = VEC2(main_cursor_pos.x, main_cursor_pos.y); + // Vec2 tooltip_pos = VEC2(main_cursor_pos.x, UI_Rect(hovered_zone_box).p0.y - UI_Rect(main_box).p0.y); + // f32 tooltip_opacity = 0.75; + + + + UI_SetNext(BackgroundColor, theme.col.window_bg); + UI_SetNext(BorderColor, theme.col.window_bd); + UI_SetNext(Rounding, UI_Rpx(theme.rounding * 5)); + UI_SetNext(BorderSize, 1); + // UI_SetNext(Width, UI_Fnt(15, 0)); + // UI_SetNext(Height, UI_Fnt(15, 0)); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); + UI_SetNext(Anchor, UI_Region_TopLeft); + UI_SetNext(Opacity, tooltip_opacity); + UI_SetNext(FloatingPos, tooltip_pos); + UI_SetNext(Flags, UI_BoxFlag_Floating); + UI_PushDF(Parent, UI_BuildRowEx(tooltip_box)) + { + UI_BuildSpacer(window_padding, Axis_X); + + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); + UI_PushDF(Parent, UI_BuildColumn()) + { + if (hovered_zone) + { + UI_BuildSpacer(window_padding, Axis_Y); + + V_ZoneDesc *zone = hovered_zone; + // UI_BuildLabelF("Hi!!"); + i64 zone_elapsed_ns = zone->end_ns - zone->start_ns; + + + + // UI_BuildLabelF("%Fms", FmtFloat(MsFromNs(zone_elapsed_ns), .p = 3)); + UI_BuildLabelF("%F", FmtTimeNs(zone_elapsed_ns, .p = 3)); + + UI_BuildSpacer(window_padding, Axis_Y); + } + } + UI_BuildSpacer(window_padding, Axis_X); + } + } } // UI_BuildSpacer(window_padding, Axis_Y); @@ -6103,7 +6044,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_PushDF(ChildAlignment, UI_Region_Center) UI_PushDF(Parent, UI_BuildRow()) { - UI_BuildSpacer(UI_GROW(1, 0), Axis_X); + UI_BuildSpacer(UI_Grow(1, 0), Axis_X); if (do_break) { @@ -6162,11 +6103,11 @@ void V_TickForever(WaveLaneCtx *lane) // Vec4 bg = VEC4(0, 0, 0, 0.25); Vec4 bg = VEC4(0, 0, 0, 0); - UI_SetNext(Width, UI_PIX(width, 0)); - // UI_SetNext(Height, UI_PIX(height, 0)); - // UI_SetNext(Width, UI_GROW(0.9, 0)); - // UI_SetNext(Width, UI_SHRINK(0, 0)); - UI_SetNext(Height, UI_SHRINK(0, 0)); + UI_SetNext(Width, UI_Px(width, 0)); + // UI_SetNext(Height, UI_Px(height, 0)); + // UI_SetNext(Width, UI_Grow(0.9, 0)); + // UI_SetNext(Width, UI_Shrink(0, 0)); + UI_SetNext(Height, UI_Shrink(0, 0)); // UI_SetNext(FloatingPos, pos); UI_SetNext(BackgroundColor, bg); UI_SetNext(Rounding, 0); @@ -6188,13 +6129,13 @@ void V_TickForever(WaveLaneCtx *lane) } UI_SetNext(Tint, 0); - UI_SetNext(Width, UI_SHRINK(0, 0)); - UI_SetNext(Height, UI_SHRINK(0, 0)); + UI_SetNext(Width, UI_Shrink(0, 0)); + UI_SetNext(Height, UI_Shrink(0, 0)); UI_PushCp(UI_BuildRow()); { UI_Push(Tint, VEC4(1, 1, 1, opacity)); - UI_Push(Width, UI_SHRINK(0, 0)); - UI_Push(Height, UI_SHRINK(0, 0)); + UI_Push(Width, UI_Shrink(0, 0)); + UI_Push(Height, UI_Shrink(0, 0)); { String msg = StringF( frame->arena, @@ -6233,7 +6174,7 @@ void V_TickForever(WaveLaneCtx *lane) if (notif_idx != 0) { - UI_BuildSpacer(UI_PIX(5, 0), Axis_Y); + UI_BuildSpacer(UI_Px(5, 0), Axis_Y); } } } @@ -6271,47 +6212,47 @@ void V_TickForever(WaveLaneCtx *lane) Vec4 color = VEC4(0, 0, 0, 0.75); UI_SetNext(Flags, UI_BoxFlag_Floating); UI_SetNext(FloatingPos, VEC2(0, frame->screen_dims.y - dbg_dims.y)); - UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(BackgroundColor, color); - UI_SetNext(Rounding, UI_RPIX(rounding)); + UI_SetNext(Rounding, UI_Rpx(rounding)); UI_PushCp(UI_BuildColumn()); { - // UI_BuildSpacer(UI_PIX(10, 1), Axis_X); + // UI_BuildSpacer(UI_Px(10, 1), Axis_X); // UI_Push(ChildAlignment, UI_Region_Center); - // UI_SetNext(Width, UI_SHRINK(0, 1)); - // UI_SetNext(Height, UI_SHRINK(0, 1)); - UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + // UI_SetNext(Width, UI_Shrink(0, 1)); + // UI_SetNext(Height, UI_Shrink(0, 1)); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_PushCp(UI_BuildRow()); { - UI_BuildSpacer(UI_PIX(padding, 1), Axis_X); - UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_BuildSpacer(UI_Px(padding, 1), Axis_X); + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(Height, UI_Shrink(0, 1)); UI_PushCp(UI_BuildColumn()); { - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); { UI_BuildLabelF("Local server world tick: %F", FmtSint(sim_stats.tick)); UI_BuildLabelF("Local server world entities: %F", FmtSint(sim_stats.ents_count)); UI_BuildLabelF("Local server world constraints: %F", FmtSint(sim_stats.constraints_count)); - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); UI_BuildLabelF("Sim world seed: 0x%F", FmtHex(sim_world->seed)); UI_BuildLabelF("Sim world tick: %F", FmtSint(sim_world->last_frame->tick)); UI_BuildLabelF("Sim world entities: %F", FmtSint(sim_world->last_frame->ents_count)); UI_BuildLabelF("Sim world constraints: %F", FmtSint(sim_world->last_frame->constraints_count)); - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); UI_BuildLabelF("Predicted world seed: 0x%F", FmtHex(predict_world->seed)); UI_BuildLabelF("Predicted world tick: %F", FmtSint(predict_world->last_frame->tick)); UI_BuildLabelF("Predicted world entities: %F", FmtSint(predict_world->last_frame->ents_count)); UI_BuildLabelF("Predicted world constraints: %F", FmtSint(predict_world->last_frame->constraints_count)); - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); UI_BuildLabelF("Local world seed: 0x%F", FmtHex(frame->local_world->seed)); UI_BuildLabelF("Local world tick: %F", FmtSint(frame->local_world->last_frame->tick)); UI_BuildLabelF("Local world entities: %F", FmtSint(frame->local_world->last_frame->ents_count)); UI_BuildLabelF("Local world constraints: %F", FmtSint(frame->local_world->last_frame->constraints_count)); } - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); { Vec2 tile_pos = MulAffineVec2(frame->af.world_to_tile, frame->world_cursor); Vec2 cell_pos = MulAffineVec2(frame->af.world_to_cell, frame->world_cursor); @@ -6325,16 +6266,16 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildLabelF("Cursor cell pos: %F", FmtFloat2(cell_pos)); UI_BuildLabelF("Hovered ent: %F", P_FmtKey(hovered_ent->key)); } - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); { UI_BuildLabelF("Screen dims: %F", FmtFloat2(frame->screen_dims)); UI_BuildLabelF("Shade dims: %F", FmtFloat2(frame->shade_dims)); } - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); { UI_BuildLabelF("Particle seq: %F", FmtFloat(V.particle_seq)); } - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); { UI_BuildLabelF("RTT: %Fms", FmtFloat(smoothed_rtt * 1000, .p = 3)); UI_BuildLabelF("Client send: %F MiB", FmtFloat(CeilF64((f64)vis_pipe_stats.total_bytes_sent / 1024) / 1024, .p = 3)); @@ -6342,7 +6283,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildLabelF("Server send: %F MiB", FmtFloat(CeilF64((f64)sim_stats.pipe.total_bytes_sent / 1024) / 1024, .p = 3)); UI_BuildLabelF("Server recv: %F MiB", FmtFloat(CeilF64((f64)sim_stats.pipe.total_bytes_received / 1024) / 1024, .p = 3)); } - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); { { UI_Push(FontSize, UI_Top(FontSize) * theme.h2); @@ -6353,7 +6294,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildLabelF(" Arena memory committed: %F MiB", FmtFloat((f64)GetGstat(ArenaMemoryCommitted) / 1024 / 1024, .p = 3)); UI_BuildLabelF(" Arena memory reserved: %F TiB", FmtFloat((f64)GetGstat(ArenaMemoryReserved) / 1024 / 1024 / 1024 / 1024, .p = 3)); } - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); { { UI_Push(FontSize, UI_Top(FontSize) * theme.h2); @@ -6365,10 +6306,10 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildLabelF(" Host memory usage: %F MiB", FmtFloat((f64)gpu_stats.host_committed / 1024 / 1024, .p = 3)); UI_BuildLabelF(" Non-reuse tally: %F", FmtUint(gpu_stats.cumulative_nonreuse_count)); } - UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y); + UI_BuildSpacer(UI_Px(padding, 1), Axis_Y); } UI_PopCp(UI_TopCp()); - UI_BuildSpacer(UI_PIX(padding, 1), Axis_X); + UI_BuildSpacer(UI_Px(padding, 1), Axis_X); } UI_PopCp(UI_TopCp()); } @@ -6411,8 +6352,8 @@ void V_TickForever(WaveLaneCtx *lane) { UI_Key timeline_key = UI_KeyF("Timeline box"); - UI_Size timeline_width = UI_FNT(120, 1); - UI_Size timeline_height = UI_FNT(2, 1); + UI_Size timeline_width = UI_Fnt(120, 1); + UI_Size timeline_height = UI_Fnt(2, 1); Vec4 tmld_bg = Color_Black; Vec2 timeline_pos = VEC2(frame->screen_dims.x * 0.5, frame->screen_dims.y * 0.75); @@ -6421,10 +6362,10 @@ void V_TickForever(WaveLaneCtx *lane) f64 timeline_end_tick = timeline_start_tick + timeline_span_ticks; - UI_Size transient_marker_width = UI_FNT(0.1, 1); - UI_Size transient_marker_height = UI_FNT(2, 1); + UI_Size transient_marker_width = UI_Fnt(0.1, 1); + UI_Size transient_marker_height = UI_Fnt(2, 1); - UI_Size persistent_marker_width = UI_FNT(0.1, 1); + UI_Size persistent_marker_width = UI_Fnt(0.1, 1); UI_Size persistent_marker_height = timeline_height; UI_PushCp(UI_NilKey); @@ -6546,17 +6487,17 @@ void V_TickForever(WaveLaneCtx *lane) if (frame->held_buttons[Button_Tab]) { - // UI_Size name_sz = UI_GROW(0.75, 0); - // UI_Size kills_sz = UI_GROW(0.25, 0); - // UI_Size deaths_sz = UI_GROW(0.25, 0); - // UI_Size ping_sz = UI_GROW(0.25, 0); - // UI_Size spacing_sz = UI_FNT(1, 0); + // UI_Size name_sz = UI_Grow(0.75, 0); + // UI_Size kills_sz = UI_Grow(0.25, 0); + // UI_Size deaths_sz = UI_Grow(0.25, 0); + // UI_Size ping_sz = UI_Grow(0.25, 0); + // UI_Size spacing_sz = UI_Fnt(1, 0); - UI_Size name_sz = UI_FNT(10, 0); - UI_Size kills_sz = UI_FNT(10, 0); - UI_Size deaths_sz = UI_FNT(10, 0); - UI_Size ping_sz = UI_FNT(5, 0); - UI_Size spacing_sz = UI_FNT(1, 0); + UI_Size name_sz = UI_Fnt(10, 0); + UI_Size kills_sz = UI_Fnt(10, 0); + UI_Size deaths_sz = UI_Fnt(10, 0); + UI_Size ping_sz = UI_Fnt(5, 0); + UI_Size spacing_sz = UI_Fnt(1, 0); Enum(BoardRowFlag) { @@ -6605,8 +6546,8 @@ void V_TickForever(WaveLaneCtx *lane) Vec4 board_bg = VEC4(0, 0, 0, 1); f32 opacity = 0.75; - UI_Size board_width = UI_SHRINK(0, 0); - UI_Size board_height = UI_SHRINK(0, 0); + UI_Size board_width = UI_Shrink(0, 0); + UI_Size board_height = UI_Shrink(0, 0); Vec2 pos = VEC2(frame->screen_dims.x / 2, 50); UI_PushCp(UI_NilKey); { @@ -6624,14 +6565,14 @@ void V_TickForever(WaveLaneCtx *lane) { b32 is_header = AnyBit(board_row->flags, BoardRowFlag_Header); - UI_SetNext(Width, UI_SHRINK(0, 0)); + UI_SetNext(Width, UI_Shrink(0, 0)); if (is_header) { - UI_SetNext(Height, UI_FNT(3, 0)); + UI_SetNext(Height, UI_Fnt(3, 0)); } else { - UI_SetNext(Height, UI_FNT(2, 0)); + UI_SetNext(Height, UI_Fnt(2, 0)); } UI_SetNext(Tint, 0); UI_SetNext(ChildAlignment, UI_Region_Left); @@ -6662,7 +6603,7 @@ void V_TickForever(WaveLaneCtx *lane) } } UI_PopCp(UI_TopCp()); - UI_BuildDivider(UI_PIX(1, 1), theme.col.divider, Axis_X); + UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_X); UI_BuildSpacer(spacing_sz, Axis_X); UI_SetNext(Width, kills_sz); @@ -6678,7 +6619,7 @@ void V_TickForever(WaveLaneCtx *lane) } } UI_PopCp(UI_TopCp()); - UI_BuildDivider(UI_PIX(1, 1), theme.col.divider, Axis_X); + UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_X); UI_BuildSpacer(spacing_sz, Axis_X); UI_SetNext(Width, deaths_sz); @@ -6694,7 +6635,7 @@ void V_TickForever(WaveLaneCtx *lane) } } UI_PopCp(UI_TopCp()); - UI_BuildDivider(UI_PIX(1, 1), theme.col.divider, Axis_X); + UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_X); UI_BuildSpacer(spacing_sz, Axis_X); UI_SetNext(Width, ping_sz); @@ -6715,13 +6656,13 @@ void V_TickForever(WaveLaneCtx *lane) if (is_header) { - UI_BuildDivider(UI_PIX(3, 1), theme.col.divider, Axis_Y); + UI_BuildDivider(UI_Px(3, 1), theme.col.divider, Axis_Y); } else { if (board_row->next) { - UI_BuildDivider(UI_PIX(1, 1), theme.col.divider, Axis_Y); + UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); } } } @@ -6780,14 +6721,14 @@ void V_TickForever(WaveLaneCtx *lane) if (minimized) { UI_SetNext(BackgroundColor, 0); - UI_SetNext(Width, UI_FNT(50, 0)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Fnt(50, 0)); + UI_SetNext(Height, UI_Shrink(0, 1)); } else { UI_SetNext(BackgroundColor, Rgba(0, 0, 0, 1)); - UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_SHRINK(0, 1)); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Shrink(0, 1)); } UI_Key console_box = UI_BuildColumnEx(UI_KeyF("Console box")); UI_PushCp(console_box); @@ -6848,20 +6789,20 @@ void V_TickForever(WaveLaneCtx *lane) { Vec4 color = colors[log.level][log.level_id % 2]; UI_Push(BackgroundColor, color); - UI_Push(Width, UI_GROW(1, 0)); - UI_Push(Height, UI_FNT(1.5, 1)); - UI_Push(Rounding, UI_RPIX(0)); + UI_Push(Width, UI_Grow(1, 0)); + UI_Push(Height, UI_Fnt(1.5, 1)); + UI_Push(Rounding, UI_Rpx(0)); UI_Push(BorderSize, 0); UI_Push(ChildAlignment, UI_Region_Left); UI_PushCp(UI_BuildRow()); { - // UI_SetNext(Height, UI_PIX(100, 0)); - UI_BuildSpacer(UI_PIX(10, 0), Axis_X); + // UI_SetNext(Height, UI_Px(100, 0)); + UI_BuildSpacer(UI_Px(10, 0), Axis_X); UI_Push(BackgroundColor, 0); UI_Push(BorderSize, 0); UI_Push(Text, text); - UI_Push(Width, UI_GROW(1, 0)); - UI_Push(Height, UI_SHRINK(0, 1)); + UI_Push(Width, UI_Grow(1, 0)); + UI_Push(Height, UI_Shrink(0, 1)); UI_Push(Flags, UI_BoxFlag_DrawText); UI_BuildBox(); } diff --git a/src/pp/pp_vis/pp_vis_core.h b/src/pp/pp_vis/pp_vis_core.h index bf68e459..56d69ffe 100644 --- a/src/pp/pp_vis/pp_vis_core.h +++ b/src/pp/pp_vis/pp_vis_core.h @@ -37,6 +37,7 @@ Struct(V_WidgetTheme) f32 ui_font_size; f32 chat_font_size; + Vec2 tooltip_offset_px; f32 h1; f32 h2; @@ -238,6 +239,25 @@ Struct(V_Palette) //////////////////////////////////////////////////////////// //~ Profiler types +Struct(V_ZoneDesc) +{ + V_ZoneDesc *prev; + V_ZoneDesc *next; + + V_ZoneDesc *prev_in_row; + V_ZoneDesc *next_in_row; + + String name; + u64 start_sample_seq; + u64 end_sample_seq; + + u32 depth; + + Vec4 color; + i64 start_ns; + i64 end_ns; +}; + Struct(V_Profiler) { Vec2 graph_dims; diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index b2546f3f..f8685e64 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -326,8 +326,8 @@ void UI_PushDefaults(void) { default: break; case UI_StyleKind_Parent: { desc.style.Parent = UI_RootKey; } break; - case UI_StyleKind_Width: { desc.style.Width = UI_GROW(1, 0); } break; - case UI_StyleKind_Height: { desc.style.Height = UI_GROW(1, 0); } break; + case UI_StyleKind_Width: { desc.style.Width = UI_Grow(1, 0); } break; + case UI_StyleKind_Height: { desc.style.Height = UI_Grow(1, 0); } break; case UI_StyleKind_Scale: { desc.style.Scale = VEC2(1, 1); } break; case UI_StyleKind_Font: { desc.style.Font = UI_BuiltinTextFont(); } break; case UI_StyleKind_FontSize: { desc.style.FontSize = 16.0f; } break; @@ -876,8 +876,8 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags) //- Build root box { - UI_SetNext(Width, UI_PIX(frame->window_frame.draw_size.x, 1)); - UI_SetNext(Height, UI_PIX(frame->window_frame.draw_size.y, 1)); + UI_SetNext(Width, UI_Px(frame->window_frame.draw_size.x, 1)); + UI_SetNext(Height, UI_Px(frame->window_frame.draw_size.y, 1)); UI_SetNext(Parent, UI_NilKey); UI_BuildBoxEx(UI_RootKey); } diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index ce1797e4..3cfe48c7 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -532,18 +532,18 @@ UI_Checkpoint UI_TopCp(void); #define UI_SIZE(_kind, _v, _s) (UI_Size) { .kind = (_kind), .v = (_v), .strictness = (_s) } -#define UI_PIX(_v, _s) UI_SIZE(UI_SizeKind_Pixel, (_v), (_s)) -#define UI_SHRINK(_v, _s) UI_SIZE(UI_SizeKind_Shrink, (_v), (_s)) -#define UI_GROW(_v, _s) UI_SIZE(UI_SizeKind_Grow, (_v), (_s)) -#define UI_FNT(_v, _s) UI_SIZE(UI_SizeKind_Pixel, (f32)UI_PeekTop(FontSize) * (_v), (_s)) +#define UI_Px(_v, _s) UI_SIZE(UI_SizeKind_Pixel, (_v), (_s)) +#define UI_Shrink(_v, _s) UI_SIZE(UI_SizeKind_Shrink, (_v), (_s)) +#define UI_Grow(_v, _s) UI_SIZE(UI_SizeKind_Grow, (_v), (_s)) +#define UI_Fnt(_v, _s) UI_SIZE(UI_SizeKind_Pixel, (f32)UI_PeekTop(FontSize) * (_v), (_s)) //////////////////////////////////////////////////////////// //~ Rounding helpers #define UI_ROUND(_kind, _v) (UI_Round) { .kind = (_kind), .v = (_v)} -#define UI_RPIX(_v) UI_ROUND(UI_RoundKind_Pixel, (_v)) -#define UI_RGROW(_v) UI_ROUND(UI_RoundKind_Grow, (_v)) +#define UI_Rpx(_v) UI_ROUND(UI_RoundKind_Pixel, (_v)) +#define UI_Rgrow(_v) UI_ROUND(UI_RoundKind_Grow, (_v)) //////////////////////////////////////////////////////////// //~ Command helpers diff --git a/src/ui/ui_extras.c b/src/ui/ui_extras.c index 06749916..7a080f72 100644 --- a/src/ui/ui_extras.c +++ b/src/ui/ui_extras.c @@ -36,8 +36,8 @@ UI_Key UI_BuildLabel(String text) UI_Push(Font, font); UI_Push(FontSize, font_size); UI_Push(TextColor, text_color); - UI_Push(Width, UI_SHRINK(0, 1)); - UI_Push(Height, UI_SHRINK(0, 1)); + UI_Push(Width, UI_Shrink(0, 1)); + UI_Push(Height, UI_Shrink(0, 1)); UI_Push(Text, text); UI_Push(ChildAlignment, alignment); UI_Push(Flags, UI_BoxFlag_DrawText); @@ -88,7 +88,7 @@ UI_Key UI_BuildSpacer(UI_Size size, Axis axis) UI_Push(Parent, parent); UI_Push(Scale, scale); UI_Push(Tint, 0); - UI_Push(AxisSize, UI_GROW(1, 0), .axis = !axis); + UI_Push(AxisSize, UI_Grow(1, 0), .axis = !axis); UI_Push(AxisSize, size, .axis = axis); key = UI_BuildBox(); } @@ -111,7 +111,7 @@ UI_Key UI_BuildDivider(UI_Size size, Vec4 color, Axis axis) UI_Push(Tint, tint); UI_Push(Opacity, opacity); UI_Push(BackgroundColor, color); - UI_Push(AxisSize, UI_GROW(1, 0), .axis = !axis); + UI_Push(AxisSize, UI_Grow(1, 0), .axis = !axis); UI_Push(AxisSize, size, .axis = axis); key = UI_BuildBox(); }