theme header sizes

This commit is contained in:
jacob 2025-12-31 16:18:52 -06:00
parent 0c20353811
commit cfa109d9f7
5 changed files with 64 additions and 59 deletions

View File

@ -80,20 +80,18 @@ V_WidgetTheme V_GetWidgetTheme(void)
V_WidgetTheme theme = Zi;
// theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/fixedsys.ttf")));
// theme.font_size = 16;
// theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/seguisb.ttf")));
// theme.font_size = 16;
theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/seguisb.ttf")));
theme.font_size = 14;
theme.h1 = 2.00;
theme.h2 = 1.50;
theme.h3 = 1.17;
theme.h4 = 1.00;
theme.h5 = 0.83;
theme.h6 = 0.67;
// theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/seguisb.ttf")));
// theme.font_size = 12;
// theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/seguisb.ttf")));
// theme.font_size = 30;
theme.text_padding_x = 5;
theme.text_padding_y = 5;
// theme.font_size = TweakI32("Font size", 14, RNGI32(5, 100));
theme.window_background_color = Rgb32(0xff1a1d1e);
@ -111,10 +109,6 @@ V_WidgetTheme V_GetWidgetTheme(void)
theme.color_positive = VEC4(0.25, 0.5, 0.25, 1);
theme.color_negative = VEC4(0.5, 0.25, 0.25, 1);
theme.window_title_font_size = 16;
theme.text_padding_x = 5;
theme.text_padding_y = 5;
return theme;
}
@ -1355,7 +1349,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BuildRow();
// Title box
UI_SetNext(FontSize, theme.window_title_font_size);
UI_SetNext(FontSize, UI_Top(FontSize) * theme.h2);
UI_SetNext(ChildAlignment, UI_Region_Center);
UI_SetNext(Width, UI_SHRINK(0, 1));
UI_SetNext(Text, Lit("Command Palette"));
@ -1533,8 +1527,8 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BackgroundColor, tweak_bg_color);
UI_SetNext(BorderColor, tweak_border_color);
UI_SetNext(Rounding, UI_RGROW(0.8));
UI_SetNext(Border, 1);
UI_SetNext(Rounding, UI_RGROW(1));
UI_SetNext(Border, 2);
UI_SetNext(Width, UI_FNT(1.25, 1));
UI_SetNext(Height, UI_FNT(1.25, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable);
@ -1662,7 +1656,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y);
{
{
UI_Push(FontSize, 32);
UI_Push(FontSize, UI_Top(FontSize) * theme.h2);
UI_BuildLabelF("CPU:");
UI_Pop(FontSize);
}
@ -1673,7 +1667,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BuildSpacer(UI_PIX(padding, 1), Axis_Y);
{
{
UI_Push(FontSize, 32);
UI_Push(FontSize, UI_Top(FontSize) * theme.h2);
UI_BuildLabelF("GPU:");
UI_Pop(FontSize);
}

View File

@ -21,8 +21,14 @@
Struct(V_WidgetTheme)
{
GC_FontKey font;
f32 font_size;
f32 window_title_font_size;
f32 h1;
f32 h2;
f32 h3;
f32 h4;
f32 h5;
f32 h6;
Vec4 window_background_color;
Vec4 window_border_color;

View File

@ -30,7 +30,7 @@ b32 UI_IsKeyNil(UI_Key key)
UI_Key UI_KeyFromString(String str)
{
u64 top_tag = UI_UseTop(Tag);
u64 top_tag = UI_Top(Tag);
UI_Key key = Zi;
key.hash = HashFnv64(top_tag, str);
return key;
@ -503,25 +503,25 @@ UI_Key UI_BuildBoxEx(UI_Key semantic_key)
{
n->cmd.box.key = key;
n->cmd.box.is_transient = is_transient;
n->cmd.box.parent = UI_UseTop(Parent);
n->cmd.box.flags = (UI_UseTop(Flags) | UI_UseTop(OrFlags)) & ~UI_UseTop(OmitFlags);
n->cmd.box.pref_semantic_dims[Axis_X] = UI_UseTop(Width);
n->cmd.box.pref_semantic_dims[Axis_Y] = UI_UseTop(Height);
n->cmd.box.scale = UI_UseTop(Scale);
n->cmd.box.child_alignment = UI_UseTop(ChildAlignment);
n->cmd.box.child_layout_axis = UI_UseTop(ChildLayoutAxis);
n->cmd.box.background_color = UI_UseTop(BackgroundColor);
n->cmd.box.border_color = UI_UseTop(BorderColor);
n->cmd.box.debug_color = UI_UseTop(DebugColor);
n->cmd.box.invisible_debug_color = UI_UseTop(InvisibleDebugColor);
n->cmd.box.tint = UI_UseTop(Tint);
n->cmd.box.border = UI_UseTop(Border);
n->cmd.box.font = UI_UseTop(Font);
n->cmd.box.font_size = UI_UseTop(FontSize);
n->cmd.box.rounding = UI_UseTop(Rounding);
n->cmd.box.text = UI_UseTop(Text);
n->cmd.box.anchor = UI_UseTop(Anchor);
n->cmd.box.floating_pos = UI_UseTop(FloatingPos);
n->cmd.box.parent = UI_Top(Parent);
n->cmd.box.flags = (UI_Top(Flags) | UI_Top(OrFlags)) & ~UI_Top(OmitFlags);
n->cmd.box.pref_semantic_dims[Axis_X] = UI_Top(Width);
n->cmd.box.pref_semantic_dims[Axis_Y] = UI_Top(Height);
n->cmd.box.scale = UI_Top(Scale);
n->cmd.box.child_alignment = UI_Top(ChildAlignment);
n->cmd.box.child_layout_axis = UI_Top(ChildLayoutAxis);
n->cmd.box.background_color = UI_Top(BackgroundColor);
n->cmd.box.border_color = UI_Top(BorderColor);
n->cmd.box.debug_color = UI_Top(DebugColor);
n->cmd.box.invisible_debug_color = UI_Top(InvisibleDebugColor);
n->cmd.box.tint = UI_Top(Tint);
n->cmd.box.border = UI_Top(Border);
n->cmd.box.font = UI_Top(Font);
n->cmd.box.font_size = UI_Top(FontSize);
n->cmd.box.rounding = UI_Top(Rounding);
n->cmd.box.text = UI_Top(Text);
n->cmd.box.anchor = UI_Top(Anchor);
n->cmd.box.floating_pos = UI_Top(FloatingPos);
}
++frame->cmds_count;
SllQueuePush(frame->first_cmd_node, frame->last_cmd_node, n);
@ -1555,8 +1555,8 @@ void UI_EndFrame(UI_Frame *frame)
GC_Run raw_run = UI_ScaleRun(frame->arena, raw_run_unscaled, box->solved_scale);
if (AnyBit(box->desc.flags, UI_BoxFlag_DrawText) && raw_run.ready)
{
f32 max_baseline = CeilF32(DimsFromRng2(box->screen_rect).x);
b32 should_truncate = FloorF32(raw_run.baseline_length) > max_baseline && !AnyBit(box->desc.flags, UI_BoxFlag_NoTextTruncation);
f32 max_baseline_length = CeilF32(DimsFromRng2(box->screen_rect).x);
b32 should_truncate = FloorF32(raw_run.baseline_length) > max_baseline_length && !AnyBit(box->desc.flags, UI_BoxFlag_NoTextTruncation);
// Truncate run
u64 final_rects_count = 0;
@ -1567,7 +1567,7 @@ void UI_EndFrame(UI_Frame *frame)
// Get elipses run
GC_Run elipses_run_unscaled = GC_RunFromString(scratch.arena, Lit("..."), box->desc.font, box->desc.font_size);
GC_Run elipses_run = UI_ScaleRun(frame->arena, elipses_run_unscaled, box->solved_scale);
f32 truncation_offset = max_baseline - elipses_run.baseline_length;
f32 truncation_offset = max_baseline_length - elipses_run.baseline_length;
// Append non-overflowed rects
f32 elipses_offset = 0;
@ -1589,7 +1589,7 @@ void UI_EndFrame(UI_Frame *frame)
{
GC_RunRect rr = elipses_run.rects[rect_idx];
rr.baseline_pos += elipses_offset;
if (rr.baseline_pos + rr.advance <= max_baseline)
if (rr.baseline_pos + rr.advance <= max_baseline_length)
{
final_rects[final_rects_count] = rr;
final_rects_count += 1;
@ -1650,7 +1650,12 @@ void UI_EndFrame(UI_Frame *frame)
baseline.y += cap / 2;
} break;
}
baseline = CeilVec2(baseline);
// baseline = CeilVec2(baseline);
if (TweakB32("Round baseilne", 0))
{
baseline = RoundVec2(baseline);
}
// Push text rects
for (u64 rect_idx = 0; rect_idx < final_rects_count; ++rect_idx)

View File

@ -477,7 +477,7 @@ UI_Style UI_PopStyle(UI_StyleDesc desc);
#define UI_ForcePush(name, ...) UI_PushStyle(UI_STYLEDESC(name, .override = 1, .style.name = __VA_ARGS__))
#define UI_Pop(name, ...) UI_PopStyle(UI_STYLEDESC(name, .force_pop = 1, __VA_ARGS__)).name
#define UI_PeekTop(name, ...) UI_PopStyle(UI_STYLEDESC(name, __VA_ARGS__)).name
#define UI_UseTop(name, ...) UI_PopStyle(UI_STYLEDESC(name, .use = 1, __VA_ARGS__)).name
#define UI_Top(name, ...) UI_PopStyle(UI_STYLEDESC(name, .use = 1, __VA_ARGS__)).name
#define UI_PushCopy(name, src, ...) do { \
UI_StyleDesc _new = src; \

View File

@ -3,12 +3,12 @@
UI_Key UI_BuildLabel(String text)
{
UI_Key parent = UI_UseTop(Parent);
GC_FontKey font = UI_UseTop(Font);
f32 font_size = UI_UseTop(FontSize);
Vec2 scale = UI_UseTop(Scale);
Vec4 tint = UI_UseTop(Tint);
UI_Region alignment = UI_UseTop(ChildAlignment);
UI_Key parent = UI_Top(Parent);
GC_FontKey font = UI_Top(Font);
f32 font_size = UI_Top(FontSize);
Vec2 scale = UI_Top(Scale);
Vec4 tint = UI_Top(Tint);
UI_Region alignment = UI_Top(ChildAlignment);
UI_Key key = Zi;
UI_PushCP(UI_NilKey);
@ -50,9 +50,9 @@ UI_Key UI_BuildLabelF_(String fmt, ...)
UI_Key UI_BuildSpacer(UI_Size size, Axis axis)
{
UI_Key parent = UI_UseTop(Parent);
UI_Key parent = UI_Top(Parent);
UI_Key key = Zi;
Vec2 scale = UI_UseTop(Scale);
Vec2 scale = UI_Top(Scale);
UI_PushCP(UI_NilKey);
{
UI_PushDefaults();
@ -70,9 +70,9 @@ UI_Key UI_BuildSpacer(UI_Size size, Axis axis)
UI_Key UI_BuildDivider(UI_Size size, Vec4 color, Axis axis)
{
UI_Key key = Zi;
UI_Key parent = UI_UseTop(Parent);
Vec2 scale = UI_UseTop(Scale);
Vec4 tint = UI_UseTop(Tint);
UI_Key parent = UI_Top(Parent);
Vec2 scale = UI_Top(Scale);
Vec4 tint = UI_Top(Tint);
UI_PushCP(UI_NilKey);
{
UI_PushDefaults();