105 lines
2.4 KiB
C
105 lines
2.4 KiB
C
////////////////////////////////////////////////////////////
|
|
//~ Label helpers
|
|
|
|
UI_Key UI_BuildLabel(String text)
|
|
{
|
|
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);
|
|
{
|
|
UI_PushDefaults();
|
|
UI_Push(Parent, parent);
|
|
UI_Push(Scale, scale);
|
|
UI_Push(Tint, tint);
|
|
UI_Push(Font, font);
|
|
UI_Push(FontSize, font_size);
|
|
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);
|
|
key = UI_BuildBox();
|
|
}
|
|
UI_PopCP(UI_TopCP());
|
|
return key;
|
|
}
|
|
|
|
UI_Key UI_BuildLabelF_(String fmt, ...)
|
|
{
|
|
UI_Key key = Zi;
|
|
TempArena scratch = BeginScratchNoConflict();
|
|
{
|
|
va_list va;
|
|
va_start(va, fmt);
|
|
String str = FormatString(scratch.arena, fmt, FmtArgsFromVaList(scratch.arena, va));
|
|
key = UI_BuildLabel(str);
|
|
va_end(va);
|
|
}
|
|
EndScratch(scratch);
|
|
return key;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Spacing helpers
|
|
|
|
UI_Key UI_BuildSpacer(UI_Size size, Axis axis)
|
|
{
|
|
UI_Key parent = UI_Top(Parent);
|
|
UI_Key key = Zi;
|
|
Vec2 scale = UI_Top(Scale);
|
|
UI_PushCP(UI_NilKey);
|
|
{
|
|
UI_PushDefaults();
|
|
UI_Push(Parent, parent);
|
|
UI_Push(Scale, scale);
|
|
UI_Push(Tint, 0);
|
|
UI_Push(AxisSize, UI_GROW(1, 0), .axis = !axis);
|
|
UI_Push(AxisSize, size, .axis = axis);
|
|
key = UI_BuildBox();
|
|
}
|
|
UI_PopCP(UI_TopCP());
|
|
return key;
|
|
}
|
|
|
|
UI_Key UI_BuildDivider(UI_Size size, Vec4 color, Axis axis)
|
|
{
|
|
UI_Key key = Zi;
|
|
UI_Key parent = UI_Top(Parent);
|
|
Vec2 scale = UI_Top(Scale);
|
|
Vec4 tint = UI_Top(Tint);
|
|
UI_PushCP(UI_NilKey);
|
|
{
|
|
UI_PushDefaults();
|
|
UI_Push(Parent, parent);
|
|
UI_Push(Scale, scale);
|
|
UI_Push(Tint, tint);
|
|
UI_Push(BackgroundColor, color);
|
|
UI_Push(AxisSize, UI_GROW(1, 0), .axis = !axis);
|
|
UI_Push(AxisSize, size, .axis = axis);
|
|
key = UI_BuildBox();
|
|
}
|
|
UI_PopCP(UI_TopCP());
|
|
return key;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Layout helpers
|
|
|
|
UI_Key UI_BuildColumnEx(UI_Key key)
|
|
{
|
|
UI_SetNext(ChildLayoutAxis, Axis_Y);
|
|
return UI_BuildBoxEx(key);
|
|
}
|
|
|
|
UI_Key UI_BuildRowEx(UI_Key key)
|
|
{
|
|
UI_SetNext(ChildLayoutAxis, Axis_X);
|
|
return UI_BuildBoxEx(key);
|
|
}
|