add icon support to ui

This commit is contained in:
jacob 2026-01-01 19:38:16 -06:00
parent df480e3a44
commit 5b88c67af2
14 changed files with 712 additions and 158 deletions

View File

@ -28,42 +28,34 @@ u64 GC_HashFromGlyphDesc(GC_GlyphDesc desc)
//~ Run
// TODO: Thread-local cache
GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size)
GC_Run GC_RunFromString32(Arena *arena, String32 str32, GC_FontKey font, f32 font_size)
{
GC_Run result = Zi;
if (str.len > 0)
if (str32.len > 0)
{
TempArena scratch = BeginScratch(arena);
Arena *perm = PermArena();
u64 codepoints_count = 0;
u32 *codepoints = 0;
{
String32 str32 = String32FromString(scratch.arena, str);
codepoints_count = str32.len;
codepoints = str32.text;
}
//////////////////////////////
//- Grab glyphs from cache
u64 ready_glyphs_count = 0;
GC_Glyph **ready_glyphs = PushStructsNoZero(scratch.arena, GC_Glyph *, codepoints_count);
GC_Glyph **ready_glyphs = PushStructsNoZero(scratch.arena, GC_Glyph *, str32.len);
u32 *uncached_codepoints = PushStructsNoZero(scratch.arena, u32, codepoints_count);
u32 *uncached_codepoints = PushStructsNoZero(scratch.arena, u32, str32.len);
u64 uncached_codepoints_count = 0;
// TODO: Include advances for glyphs in run that have rasterized but not finished uploading to atlas
u64 pending_glyphs_count = 0;
{
if (codepoints_count > 0)
if (str32.len > 0)
{
Lock lock = LockS(&GC.glyphs_mutex);
{
i64 completion = G_CompletionValueFromQueue(G_QueueKind_AsyncCopy);
for (u64 codepoint_idx = 0; codepoint_idx < codepoints_count; ++codepoint_idx)
for (u64 codepoint_idx = 0; codepoint_idx < str32.len; ++codepoint_idx)
{
u32 codepoint = codepoints[codepoint_idx];
u32 codepoint = str32.text[codepoint_idx];
GC_GlyphDesc desc = Zi;
desc.font = font;

View File

@ -155,7 +155,7 @@ u64 GC_HashFromGlyphDesc(GC_GlyphDesc desc);
////////////////////////////////////////////////////////////
//~ Run
GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size);
GC_Run GC_RunFromString32(Arena *arena, String32 str32, GC_FontKey font, f32 font_size);
////////////////////////////////////////////////////////////
//~ Async

View File

@ -79,8 +79,8 @@ V_WidgetTheme V_GetWidgetTheme(void)
{
V_WidgetTheme theme = Zi;
// theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/fixedsys.ttf")));
theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/seguisb.ttf")));
theme.text_font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/seguisb.ttf")));
theme.icon_font = UI_BuiltinIconFont();
// theme.font_size = 14;
theme.font_size = TweakFloat("Font size", 14, 6, 50, .precision = 0);
@ -95,33 +95,37 @@ V_WidgetTheme V_GetWidgetTheme(void)
// theme.rounding = 1;
theme.rounding = TweakFloat("Rounding", 1, 0, 1);
theme.text_color = Rgb32(0xffdddee0);
theme.text_padding_x = 5;
theme.text_padding_y = 5;
theme.window_background_color = Rgb32(0xff1a1d1e);
theme.window_border_color = Rgb32(0xff343a3b);
theme.window_border = 1;
theme.window_padding = theme.window_border - 1;
theme.divider_color = theme.window_border_color;
theme.window_bd_sz = 1;
theme.window_padding = theme.window_bd_sz - 1;
theme.button_color = theme.window_background_color;
theme.button_active_color = Rgb32(0x0078a6);
theme.button_hot_color = Rgb32(0x103c4c);
theme.button_selected_color = Rgb32(0x00668D);
//- Colors
theme.col.window_bg = Rgb32(0xff1a1d1e);
theme.col.window_bd = Rgb32(0xff343a3b);
theme.col.divider = theme.col.window_bd;
theme.color_positive = VEC4(0.25, 0.5, 0.25, 1);
theme.color_negative = VEC4(0.5, 0.25, 0.25, 1);
theme.col.button = theme.col.window_bg;
theme.col.button_hot = Rgb32(0x103c4c);
theme.col.button_active = Rgb32(0x0078a6);
theme.col.button_selected = Rgb32(0x00668D);
theme.col.positive = VEC4(0.25, 0.5, 0.25, 1);
theme.col.negative = VEC4(0.5, 0.25, 0.25, 1);
theme.col.text = Rgb32(0xffdddee0);
theme.col.hint = Rgb32(0xff71767f);
return theme;
}
void V_PushWidgetThemeStyles(V_WidgetTheme theme)
{
UI_Push(Font, theme.font);
UI_Push(Font, theme.text_font);
UI_Push(FontSize, theme.font_size);
UI_Push(TextColor, theme.text_color);
UI_Push(TextColor, theme.col.text);
}
////////////////////////////////////////////////////////////
@ -323,13 +327,15 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Begin UI frame
V_WidgetTheme theme = V_GetWidgetTheme();
UI_FrameFlag ui_frame_flags = 0;
Vec4 swapchain_color = V_GetWidgetTheme().window_background_color;
Vec4 swapchain_color = theme.col.window_bg;
ui_frame_flags |= UI_FrameFlag_Debug * !!frame->ui_debug;
ui_frame_flags |= UI_FrameFlag_Vsync * !!VSYNC;
UI_Frame *ui_frame = UI_BeginFrame(ui_frame_flags, swapchain_color);
WND_Frame window_frame = ui_frame->window_frame;
WND_PushCmd(window_frame, .kind = WND_CmdKind_SetCursor, .cursor = WND_CursorKind_Default);
WND_SetCursor(window_frame, WND_CursorKind_Default);
// Restore window
{
@ -341,7 +347,6 @@ void V_TickForever(WaveLaneCtx *lane)
}
// Set widget theme
V_WidgetTheme theme = V_GetWidgetTheme();
V_PushWidgetThemeStyles(theme);
UI_Key vis_box = UI_KeyF("vis box");
@ -1007,17 +1012,17 @@ void V_TickForever(WaveLaneCtx *lane)
V.dragging_window = 0;
}
Vec4 bg_color = theme.window_background_color;
Vec4 border_color = theme.window_border_color;
Vec4 bg_color = theme.col.window_bg;
Vec4 border_color = theme.col.window_bd;
if (tab->window_idx == active_window_idx)
{
active_window = window;
border_color = theme.button_active_color;
border_color = theme.col.button_active;
}
bg_color = LerpSrgb(bg_color, theme.button_hot_color, tab_rep.hot);
bg_color = LerpSrgb(bg_color, theme.button_active_color, tab_rep.active * is_dragging);
border_color = LerpSrgb(border_color, theme.button_active_color, tab_rep.misc);
bg_color = LerpSrgb(bg_color, theme.col.button_hot, tab_rep.hot);
bg_color = LerpSrgb(bg_color, theme.col.button_active, tab_rep.active * is_dragging);
border_color = LerpSrgb(border_color, theme.col.button_active, tab_rep.misc);
String tab_name = Zi;
if (window->is_tile_window)
@ -1031,7 +1036,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BackgroundColor, bg_color);
UI_SetNext(BorderColor, border_color);
UI_SetNext(Border, 1);
UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_SHRINK(0, 0));
UI_SetNext(Height, UI_SHRINK(0, 0));
UI_SetNext(ChildAlignment, UI_Region_Left);
@ -1056,13 +1061,13 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BoxReport close_rep = UI_ReportsFromKey(close_key).draw;
Vec4 close_color = Zi;
close_color = LerpSrgb(close_color, theme.button_hot_color, close_rep.hot);
close_color = LerpSrgb(close_color, theme.button_active_color, close_rep.active);
Vec4 close_border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.button_active_color, close_rep.hot);
close_color = LerpSrgb(close_color, theme.col.button_hot, close_rep.hot);
close_color = LerpSrgb(close_color, theme.col.button_active, close_rep.active);
Vec4 close_border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, close_rep.hot);
UI_SetNext(BackgroundColor, close_color);
UI_SetNext(BorderColor, close_border_color);
UI_SetNext(Border, 2);
UI_SetNext(BorderSize, 2);
UI_SetNext(ChildAlignment, UI_Region_Center);
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable);
UI_SetNext(Text, Lit("x"));
@ -1090,9 +1095,9 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BoxReport rep = UI_ReportsFromKey(tab->key).draw;
Vec4 bg_color = Zi;
bg_color = LerpSrgb(bg_color, theme.button_hot_color, rep.exists);
bg_color = LerpSrgb(bg_color, theme.col.button_hot, rep.exists);
bg_color.w *= 0.5;
Vec4 border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.button_active_color, rep.exists);
Vec4 border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, rep.exists);
// UI_SetNext(Anchor, UI_Region_Center);
UI_SetNext(Anchor, UI_Region_TopRight);
@ -1100,7 +1105,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Scale, VEC2(rep.exists, 1));
UI_SetNext(BackgroundColor, bg_color);
UI_SetNext(BorderColor, border_color);
UI_SetNext(Border, 2);
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));
@ -1121,14 +1126,14 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BoxReport rep = UI_ReportsFromKey(key).draw;
Vec4 bg_color = Zi;
bg_color = LerpSrgb(bg_color, theme.button_hot_color, rep.hot);
bg_color = LerpSrgb(bg_color, theme.button_active_color, rep.active);
bg_color = LerpSrgb(bg_color, theme.col.button_hot, rep.hot);
bg_color = LerpSrgb(bg_color, theme.col.button_active, rep.active);
bg_color.w *= 0.5;
Vec4 border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.button_active_color, rep.hot);
Vec4 border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, rep.hot);
UI_SetNext(BackgroundColor, bg_color);
UI_SetNext(BorderColor, border_color);
UI_SetNext(Border, 2);
UI_SetNext(BorderSize, 2);
UI_SetNext(Width, UI_SHRINK(10, 0));
UI_SetNext(Height, UI_SHRINK(2, 0));
UI_SetNext(ChildAlignment, UI_Region_Center);
@ -1151,13 +1156,13 @@ void V_TickForever(WaveLaneCtx *lane)
if (active_window)
{
Vec4 window_bg_color = theme.window_background_color;
Vec4 window_border_color = theme.window_border_color;
Vec4 window_bg_color = theme.col.window_bg;
Vec4 window_border_color = theme.col.window_bd;
V_Window *window = active_window;
UI_SetNext(BackgroundColor, window_bg_color);
UI_SetNext(BorderColor, window_border_color);
UI_SetNext(Border, 1);
UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_GROW(1, 0));
UI_SetNext(Height, UI_GROW(1, 0));
UI_SetNext(Flags, UI_BoxFlag_Interactable);
@ -1178,18 +1183,18 @@ void V_TickForever(WaveLaneCtx *lane)
}
Vec4 bg_color = Zi;
bg_color = LerpSrgb(bg_color, theme.button_hot_color, rep.hot);
bg_color = LerpSrgb(bg_color, theme.button_active_color, rep.active);
bg_color = LerpSrgb(bg_color, theme.col.button_hot, rep.hot);
bg_color = LerpSrgb(bg_color, theme.col.button_active, rep.active);
b32 is_selected = tile_kind == frame->equipped_tile;
Vec4 border_color = Zi;
border_color = LerpSrgb(border_color, theme.button_selected_color, rep.misc);
border_color = LerpSrgb(border_color, theme.button_active_color, rep.hot);
border_color = LerpSrgb(border_color, theme.col.button_selected, rep.misc);
border_color = LerpSrgb(border_color, theme.col.button_active, rep.hot);
UI_SetNext(BackgroundColor, bg_color);
UI_SetNext(BorderColor, border_color);
UI_SetNext(Border, 1);
UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_GROW(1, 0));
UI_SetNext(Height, UI_SHRINK(0, 0));
UI_SetNext(Misc, is_selected);
@ -1227,8 +1232,8 @@ void V_TickForever(WaveLaneCtx *lane)
panel->divider_key = UI_KeyF("Divider");
UI_BoxReport rep = UI_ReportsFromKey(panel->divider_key).draw;
Vec4 active_color = theme.button_active_color;
Vec4 hot_color = LerpSrgb(theme.button_hot_color, theme.button_active_color, 0.25);
Vec4 active_color = theme.col.button_active;
Vec4 hot_color = LerpSrgb(theme.col.button_hot, theme.col.button_active, 0.25);
Vec4 bg_color = Zi;
bg_color = LerpSrgb(bg_color, hot_color, rep.hot);
@ -1239,7 +1244,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BackgroundColor, bg_color);
UI_SetNext(BorderColor, border_color);
UI_SetNext(Border, MaxF32((divider_size / 2.0) - (visible_size / 2.0), 0));
UI_SetNext(BorderSize, MaxF32((divider_size / 2.0) - (visible_size / 2.0), 0));
UI_SetNext(Flags, UI_BoxFlag_Interactable);
UI_SetNext(AxisSize, UI_GROW(1, 1), .axis = panel->axis);
UI_SetNext(AxisSize, UI_PIX(divider_size, 1), .axis = !panel->axis);
@ -1249,11 +1254,11 @@ void V_TickForever(WaveLaneCtx *lane)
{
if (panel->axis == Axis_X)
{
WND_PushCmd(window_frame, .kind = WND_CmdKind_SetCursor, WND_CursorKind_VerticalResize);
WND_SetCursor(window_frame, WND_CursorKind_VerticalResize);
}
else
{
WND_PushCmd(window_frame, .kind = WND_CmdKind_SetCursor, WND_CursorKind_HorizontalResize);
WND_SetCursor(window_frame, WND_CursorKind_HorizontalResize);
}
}
@ -1305,11 +1310,11 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BoxReports titlebar_reps = UI_ReportsFromKey(titlebar_key);
UI_BoxReports palette_reps = UI_ReportsFromKey(palette->key);
Vec4 window_background_color = theme.window_background_color;
Vec4 window_border_color = theme.window_border_color;
Vec4 window_background_color = theme.col.window_bg;
Vec4 window_border_color = theme.col.window_bd;
Vec4 titlebar_color = Zi;
Vec4 titlebar_border_color = Zi;
Vec4 divider_color = theme.divider_color;
Vec4 divider_color = theme.col.divider;
if (titlebar_reps.draw.m1.held)
{
Vec2 drag_offset = SubVec2(ui_frame->drag_cursor_pos, palette_reps.drag.screen_anchor);
@ -1323,7 +1328,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Push(BackgroundColor, window_background_color);
UI_Push(BorderColor, window_border_color);
UI_Push(Border, theme.window_border);
UI_Push(BorderSize, theme.window_bd_sz);
UI_Push(Rounding, UI_RPIX(15 * theme.rounding));
UI_Push(Width, UI_FNT(50, 0));
UI_Push(Height, UI_SHRINK(0, 0));
@ -1370,7 +1375,7 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Build palette items list
f32 window_padding = theme.window_border;
f32 window_padding = theme.window_bd_sz;
UI_SetNext(Tint, 0);
UI_SetNext(Rounding, 0);
UI_PushCP(UI_BuildRow());
@ -1469,17 +1474,17 @@ void V_TickForever(WaveLaneCtx *lane)
}
}
Vec4 item_color = theme.window_background_color;
Vec4 item_color = theme.col.window_bg;
Vec4 item_border_color = item_color;
if (item->flags & PaletteItemFlag_IsCmd)
{
item_color = LerpSrgb(item_color, theme.button_hot_color, item_rep.hot);
item_color = LerpSrgb(item_color, theme.button_active_color, item_rep.active);
item_border_color = LerpSrgb(item_border_color, theme.button_active_color, item_rep.hot);
item_color = LerpSrgb(item_color, theme.col.button_hot, item_rep.hot);
item_color = LerpSrgb(item_color, theme.col.button_active, item_rep.active);
item_border_color = LerpSrgb(item_border_color, theme.col.button_active, item_rep.hot);
}
else
{
item_border_color = LerpSrgb(item_border_color, theme.button_active_color, item_rep.hot);
item_border_color = LerpSrgb(item_border_color, theme.col.button_active, item_rep.hot);
}
f32 item_size_px = UI_FNT(1.5, 1).v;
@ -1528,30 +1533,40 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Key reset_key = UI_KeyF("reset");
UI_BoxReport reset_rep = UI_ReportsFromKey(reset_key).draw;
if (reset_rep.m1.presses > 0)
if (reset_rep.m1.downs > 0)
{
new_tweak_str = tweak_var.initial;
}
Vec4 reset_bg_color = Zi;
Vec4 reset_border_color = theme.window_border_color;
reset_bg_color = LerpSrgb(reset_bg_color, theme.button_hot_color, reset_rep.hot);
reset_bg_color = LerpSrgb(reset_bg_color, theme.button_active_color, reset_rep.active);
reset_border_color = LerpSrgb(reset_border_color, theme.button_active_color, reset_rep.hot);
// reset_border_color = LerpSrgb(reset_border_color, theme.button_active_color, reset_rep.active);
UI_SetNext(BackgroundColor, reset_bg_color);
UI_SetNext(BorderColor, reset_border_color);
UI_SetNext(Rounding, UI_RGROW(theme.rounding));
UI_SetNext(Border, 1);
UI_SetNext(Width, UI_FNT(1.25, 1));
UI_SetNext(Height, UI_FNT(1.25, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable);
UI_PushCP(UI_BuildRowEx(reset_key));
if (reset_rep.is_hot)
{
WND_SetCursor(window_frame, WND_CursorKind_Hand);
}
UI_PopCP(UI_TopCP());
Vec4 reset_bg = Zi;
// reset_bg = LerpSrgb(reset_bg, theme.col.button_hot, reset_rep.hot);
// reset_bg = LerpSrgb(reset_bg, theme.col.button_active, reset_rep.active);
Vec4 reset_bd = Zi;
reset_bd = LerpSrgb(reset_bd, theme.col.button_active, reset_rep.hot);
Vec4 reset_text_col = theme.col.hint;
reset_text_col = LerpSrgb(reset_text_col, theme.col.text, reset_rep.hot);
UI_SetNext(Rounding, UI_RGROW(0.5 * theme.rounding));
UI_SetNext(ChildAlignment, UI_Region_Center);
UI_SetNext(BackgroundColor, reset_bg);
UI_SetNext(BorderColor, reset_bd);
UI_SetNext(BorderSize, 1);
UI_SetNext(TextColor, reset_text_col);
UI_SetNext(Width, UI_SHRINK(3, 1));
UI_SetNext(Height, UI_SHRINK(3, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable);
UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6);
UI_BuildIconEx(reset_key, UI_Icon_Undo, theme.icon_font);
}
UI_BuildSpacer(UI_PIX(spacing, 1), Axis_X);
switch (tweak_var.kind)
{
// Boolean tweak
@ -1567,18 +1582,16 @@ void V_TickForever(WaveLaneCtx *lane)
new_tweak_str = StringFromBool(frame->arena, tweak_bool);
}
UI_BuildSpacer(UI_PIX(spacing, 1), Axis_X);
// Tweak checkbox
Vec4 cb_bg_color = Zi;
Vec4 cb_border_color = theme.window_border_color;
cb_bg_color = LerpSrgb(cb_bg_color, theme.color_positive, tweak_bool);
cb_border_color = LerpSrgb(cb_border_color, theme.button_active_color, cb_rep.hot);
Vec4 cb_border_color = theme.col.window_bd;
cb_bg_color = LerpSrgb(cb_bg_color, theme.col.positive, tweak_bool);
cb_border_color = LerpSrgb(cb_border_color, theme.col.button_active, cb_rep.hot);
UI_SetNext(BackgroundColor, cb_bg_color);
UI_SetNext(BorderColor, cb_border_color);
UI_SetNext(Rounding, UI_RGROW(theme.rounding));
UI_SetNext(Border, 1);
UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_FNT(1.25, 1));
UI_SetNext(Height, UI_FNT(1.25, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable);
@ -1629,26 +1642,24 @@ void V_TickForever(WaveLaneCtx *lane)
}
if (slider_reps.draw.is_hot)
{
WND_PushCmd(window_frame, .kind = WND_CmdKind_SetCursor, WND_CursorKind_HorizontalResize);
WND_SetCursor(window_frame, WND_CursorKind_HorizontalResize);
}
}
f32 ratio = 0;
ratio = (tweak_float - range_min) / (range_max - range_min);
ratio = ClampF32(ratio, 0, 1);
UI_BuildSpacer(UI_PIX(spacing, 1), Axis_X);
Vec4 slider_bg_color = theme.window_background_color;
Vec4 slider_border_color = theme.window_border_color;
Vec4 slider_progress_color = theme.color_positive;
Vec4 slider_bg_color = theme.col.window_bg;
Vec4 slider_border_color = theme.col.window_bd;
Vec4 slider_progress_color = theme.col.positive;
Vec4 marker_bg_color = slider_progress_color;
slider_border_color = LerpSrgb(slider_border_color, theme.button_active_color, slider_reps.draw.hot);
marker_bg_color = LerpSrgb(marker_bg_color, theme.text_color, slider_reps.draw.hot);
slider_border_color = LerpSrgb(slider_border_color, theme.col.button_active, slider_reps.draw.hot);
marker_bg_color = LerpSrgb(marker_bg_color, theme.col.text, slider_reps.draw.hot);
UI_SetNext(BackgroundColor, slider_bg_color);
UI_SetNext(BorderColor, slider_border_color);
UI_SetNext(Rounding, UI_RGROW(theme.rounding));
UI_SetNext(Border, 1);
UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_FNT(10, 1));
UI_SetNext(Height, UI_PIX(tweak_size_px * 0.75, 1));
UI_SetNext(Flags, UI_BoxFlag_Interactable);
@ -1663,7 +1674,7 @@ void V_TickForever(WaveLaneCtx *lane)
// UI_SetNext(Rounding, UI_RGROW(theme.rounding));
UI_SetNext(Rounding, 0);
UI_SetNext(BorderColor, slider_border_color);
UI_SetNext(Border, 1);
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_BuildBox();
@ -1674,7 +1685,7 @@ 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(Border, 1);
UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_PIX(tweak_size_px, 1));
UI_SetNext(Height, UI_PIX(tweak_size_px, 1));
// UI_SetNext(Anchor, UI_Region_Center);
@ -1732,7 +1743,7 @@ void V_TickForever(WaveLaneCtx *lane)
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(Border, 1);
UI_SetNext(BorderSize, 1);
UI_SetNext(ChildAlignment, UI_Region_Center);
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable);
UI_PushCP(UI_BuildRowEx(hotkey_key));
@ -1878,7 +1889,7 @@ void V_TickForever(WaveLaneCtx *lane)
{
UI_Push(FloatingPos, VEC2(0, 0));
UI_SetNext(Flags, UI_BoxFlag_Floating);
UI_SetNext(Border, 0);
UI_SetNext(BorderSize, 0);
if (minimized)
{
UI_SetNext(BackgroundColor, 0);
@ -1954,14 +1965,14 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Push(Height, UI_FNT(1.5, 1));
UI_Push(BorderColor, Rgb(0.25, 0.25, 0.25));
UI_Push(Rounding, UI_RPIX(0));
UI_Push(Border, 1);
UI_Push(BorderSize, 1);
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_Push(BackgroundColor, 0);
UI_Push(Border, 0);
UI_Push(BorderSize, 0);
UI_Push(Text, text);
UI_Push(Width, UI_GROW(1, 0));
UI_Push(Height, UI_SHRINK(0, 1));

View File

@ -20,7 +20,8 @@
Struct(V_WidgetTheme)
{
GC_FontKey font;
GC_FontKey text_font;
GC_FontKey icon_font;
f32 font_size;
f32 h1;
@ -32,23 +33,30 @@ Struct(V_WidgetTheme)
f32 rounding;
Vec4 window_background_color;
Vec4 window_border_color;
Vec4 divider_color;
f32 window_border;
f32 window_bd_sz;
f32 window_padding;
Vec4 button_color;
Vec4 button_hot_color;
Vec4 button_active_color;
Vec4 button_selected_color;
Vec4 color_positive;
Vec4 color_negative;
Vec4 text_color;
f32 text_padding_x;
f32 text_padding_y;
//- Colors
struct
{
Vec4 window_bg;
Vec4 window_bd;
Vec4 divider;
Vec4 button;
Vec4 button_hot;
Vec4 button_active;
Vec4 button_selected;
Vec4 positive;
Vec4 negative;
Vec4 text;
Vec4 hint;
} col;
};
////////////////////////////////////////////////////////////

View File

@ -20,6 +20,7 @@
//////////////////////////////
//- Api
@IncludeC ui_icon.h
@IncludeC ui_core.h
@IncludeC ui_extras.h
@IncludeC ui_shaders.cgh

View File

@ -7,14 +7,6 @@ void UI_Bootstrap(void)
{
}
////////////////////////////////////////////////////////////
//~ Font helpers
GC_FontKey UI_GetDefaultFont(void)
{
return GC_FontKeyFromResource(ResourceKeyFromStore(&UI_Resources, Lit("font/proggy.ttf")));
}
////////////////////////////////////////////////////////////
//~ Key helpers
@ -343,9 +335,9 @@ 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); }
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_GetDefaultFont(); } break;
case UI_StyleKind_Font: { desc.style.Font = UI_BuiltinTextFont(); } break;
case UI_StyleKind_FontSize: { desc.style.FontSize = 16.0f; } break;
case UI_StyleKind_Tint: { desc.style.Tint = Color_White; } break;
case UI_StyleKind_TextColor: { desc.style.TextColor = Color_White; } break;
@ -510,12 +502,13 @@ UI_Key UI_BuildBoxEx(UI_Key semantic_key)
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.border_size = UI_Top(BorderSize);
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_color = UI_Top(TextColor);
n->cmd.box.text = UI_Top(Text);
n->cmd.box.icon = UI_Top(Icon);
n->cmd.box.anchor = UI_Top(Anchor);
n->cmd.box.floating_pos = UI_Top(FloatingPos);
n->cmd.box.misc = UI_Top(Misc);
@ -1014,8 +1007,17 @@ void UI_EndFrame(UI_Frame *frame)
// Update box from cmd
{
box->desc = cmd.box;
box->glyph_run = GC_RunFromString(frame->arena, box->desc.text, box->desc.font, box->desc.font_size);
String32 codepoints = Zi;
if (box->desc.icon != UI_Icon_None)
{
codepoints.len = 1;
codepoints.text = (u32 *)&box->desc.icon;
}
else
{
codepoints = String32FromString(scratch.arena, box->desc.text);
}
box->glyph_run = GC_RunFromString32(frame->arena, codepoints, box->desc.font, box->desc.font_size);
}
box->last_build_tick = frame->tick;
} break;
@ -1549,7 +1551,7 @@ void UI_EndFrame(UI_Frame *frame)
rect->border_lin = LinearFromSrgb(box->desc.border_color);
rect->debug_lin = debug_lin;
rect->tint_lin = tint_lin;
rect->border = box->desc.border;
rect->border_size = box->desc.border_size;
rect->tl_rounding = box->rounding_tl;
rect->tr_rounding = box->rounding_tr;
rect->br_rounding = box->rounding_br;
@ -1573,7 +1575,8 @@ void UI_EndFrame(UI_Frame *frame)
if (should_truncate)
{
// Get elipses run
GC_Run elipses_run_unscaled = GC_RunFromString(scratch.arena, Lit("..."), box->desc.font, box->desc.font_size);
// GC_Run elipses_run_unscaled = GC_RunFromString(scratch.arena, Lit("..."), box->desc.font, box->desc.font_size);
GC_Run elipses_run_unscaled = Zi;
GC_Run elipses_run = UI_ScaleRun(frame->arena, elipses_run_unscaled, box->solved_scale);
f32 truncation_offset = max_baseline_length - elipses_run.baseline_length;

View File

@ -112,7 +112,7 @@ Enum(UI_BoxFlag)
X(DebugColor, Vec4) \
X(InvisibleDebugColor, Vec4) \
X(Tint, Vec4) \
X(Border, f32) \
X(BorderSize, f32) \
X(Anchor, UI_Region) \
X(FloatingPos, Vec2) \
X(Rounding, UI_Round) \
@ -120,6 +120,7 @@ Enum(UI_BoxFlag)
X(FontSize, f32) \
X(TextColor, Vec4) \
X(Text, String) \
X(Icon, UI_Icon) \
X(BackgroundTexture, G_Texture2DRef) \
X(BackgroundTextureSliceUv, Rng2) \
X(Misc, f64) \
@ -243,10 +244,11 @@ Struct(UI_BoxDesc)
Vec4 debug_color;
Vec4 invisible_debug_color;
Vec4 tint;
f32 border;
f32 border_size;
Vec2 scale;
Vec4 text_color;
String text;
UI_Icon icon;
GC_FontKey font;
f32 font_size;
Axis child_layout_axis;
@ -425,11 +427,6 @@ extern UI_Ctx UI;
void UI_Bootstrap(void);
////////////////////////////////////////////////////////////
//~ Font helpers
GC_FontKey UI_GetDefaultFont(void);
////////////////////////////////////////////////////////////
//~ Key helpers

View File

@ -1,5 +1,18 @@
////////////////////////////////////////////////////////////
//~ Label helpers
//~ Common resources
GC_FontKey UI_BuiltinTextFont(void)
{
return GC_FontKeyFromResource(ResourceKeyFromStore(&UI_Resources, Lit("font/proggy.ttf")));
}
GC_FontKey UI_BuiltinIconFont(void)
{
return GC_FontKeyFromResource(ResourceKeyFromStore(&UI_Resources, Lit("font/icomoon.ttf")));
}
////////////////////////////////////////////////////////////
//~ Text helpers
UI_Key UI_BuildLabel(String text)
{
@ -47,6 +60,18 @@ UI_Key UI_BuildLabelF_(String fmt, ...)
return key;
}
////////////////////////////////////////////////////////////
//~ Icon helpers
UI_Key UI_BuildIconEx(UI_Key key, UI_Icon icon, GC_FontKey font)
{
UI_SetNext(Font, font);
UI_SetNext(Icon, icon);
UI_SetNext(OrFlags, UI_BoxFlag_DrawText);
UI_BuildBoxEx(key);
return key;
}
////////////////////////////////////////////////////////////
//~ Spacing helpers

View File

@ -1,10 +1,22 @@
////////////////////////////////////////////////////////////
//~ Label helpers
//~ Common resources
GC_FontKey UI_BuiltinTextFont(void);
GC_FontKey UI_BuiltinIconFont(void);
////////////////////////////////////////////////////////////
//~ Text helpers
UI_Key UI_BuildLabel(String text);
#define UI_BuildLabelF(fmt_cstr, ...) UI_BuildLabelF_(Lit(fmt_cstr), __VA_ARGS__, FmtEnd)
UI_Key UI_BuildLabelF_(String fmt, ...);
////////////////////////////////////////////////////////////
//~ Icon helpers
UI_Key UI_BuildIconEx(UI_Key key, UI_Icon icon, GC_FontKey font);
#define UI_BuildIcon(icon, font) UI_BuildIconEx(UI_NilKey, (icon), (font))
////////////////////////////////////////////////////////////
//~ Spacing helpers

499
src/ui/ui_icon.h Normal file
View File

@ -0,0 +1,499 @@
////////////////////////////////////////////////////////////
//~ Icon codepoints
Enum(UI_Icon)
{
UI_Icon_None = 0,
UI_Icon_Home = 0xe900,
UI_Icon_Home2 = 0xe901,
UI_Icon_Home3 = 0xe902,
UI_Icon_Office = 0xe903,
UI_Icon_Newspaper = 0xe904,
UI_Icon_Pencil = 0xe905,
UI_Icon_Pencil2 = 0xe906,
UI_Icon_Quill = 0xe907,
UI_Icon_Pen = 0xe908,
UI_Icon_Blog = 0xe909,
UI_Icon_Eyedropper = 0xe90a,
UI_Icon_Droplet = 0xe90b,
UI_Icon_PaintFormat = 0xe90c,
UI_Icon_Image = 0xe90d,
UI_Icon_Images = 0xe90e,
UI_Icon_Camera = 0xe90f,
UI_Icon_Headphones = 0xe910,
UI_Icon_Music = 0xe911,
UI_Icon_Play = 0xe912,
UI_Icon_Film = 0xe913,
UI_Icon_VideoCamera = 0xe914,
UI_Icon_Dice = 0xe915,
UI_Icon_Pacman = 0xe916,
UI_Icon_Spades = 0xe917,
UI_Icon_Clubs = 0xe918,
UI_Icon_Diamonds = 0xe919,
UI_Icon_Bullhorn = 0xe91a,
UI_Icon_Connection = 0xe91b,
UI_Icon_Podcast = 0xe91c,
UI_Icon_Feed = 0xe91d,
UI_Icon_Mic = 0xe91e,
UI_Icon_Book = 0xe91f,
UI_Icon_Books = 0xe920,
UI_Icon_Library = 0xe921,
UI_Icon_FileText = 0xe922,
UI_Icon_Profile = 0xe923,
UI_Icon_FileEmpty = 0xe924,
UI_Icon_FilesEmpty = 0xe925,
UI_Icon_FileText2 = 0xe926,
UI_Icon_FilePicture = 0xe927,
UI_Icon_FileMusic = 0xe928,
UI_Icon_FilePlay = 0xe929,
UI_Icon_FileVideo = 0xe92a,
UI_Icon_FileZip = 0xe92b,
UI_Icon_Copy = 0xe92c,
UI_Icon_Paste = 0xe92d,
UI_Icon_Stack = 0xe92e,
UI_Icon_Folder = 0xe92f,
UI_Icon_FolderOpen = 0xe930,
UI_Icon_FolderPlus = 0xe931,
UI_Icon_FolderMinus = 0xe932,
UI_Icon_FolderDownload = 0xe933,
UI_Icon_FolderUpload = 0xe934,
UI_Icon_PriceTag = 0xe935,
UI_Icon_PriceTags = 0xe936,
UI_Icon_Barcode = 0xe937,
UI_Icon_Qrcode = 0xe938,
UI_Icon_Ticket = 0xe939,
UI_Icon_Cart = 0xe93a,
UI_Icon_CoinDollar = 0xe93b,
UI_Icon_CoinEuro = 0xe93c,
UI_Icon_CoinPound = 0xe93d,
UI_Icon_CoinYen = 0xe93e,
UI_Icon_CreditCard = 0xe93f,
UI_Icon_Calculator = 0xe940,
UI_Icon_Lifebuoy = 0xe941,
UI_Icon_Phone = 0xe942,
UI_Icon_PhoneHangUp = 0xe943,
UI_Icon_AddressBook = 0xe944,
UI_Icon_Envelop = 0xe945,
UI_Icon_Pushpin = 0xe946,
UI_Icon_Location = 0xe947,
UI_Icon_Location2 = 0xe948,
UI_Icon_Compass = 0xe949,
UI_Icon_Compass2 = 0xe94a,
UI_Icon_Map = 0xe94b,
UI_Icon_Map2 = 0xe94c,
UI_Icon_History = 0xe94d,
UI_Icon_Clock = 0xe94e,
UI_Icon_Clock2 = 0xe94f,
UI_Icon_Alarm = 0xe950,
UI_Icon_Bell = 0xe951,
UI_Icon_Stopwatch = 0xe952,
UI_Icon_Calendar = 0xe953,
UI_Icon_Printer = 0xe954,
UI_Icon_Keyboard = 0xe955,
UI_Icon_Display = 0xe956,
UI_Icon_Laptop = 0xe957,
UI_Icon_Mobile = 0xe958,
UI_Icon_Mobile2 = 0xe959,
UI_Icon_Tablet = 0xe95a,
UI_Icon_Tv = 0xe95b,
UI_Icon_Drawer = 0xe95c,
UI_Icon_Drawer2 = 0xe95d,
UI_Icon_BoxAdd = 0xe95e,
UI_Icon_BoxRemove = 0xe95f,
UI_Icon_Download = 0xe960,
UI_Icon_Upload = 0xe961,
UI_Icon_FloppyDisk = 0xe962,
UI_Icon_Drive = 0xe963,
UI_Icon_Database = 0xe964,
UI_Icon_Undo = 0xe965,
UI_Icon_Redo = 0xe966,
UI_Icon_Undo2 = 0xe967,
UI_Icon_Redo2 = 0xe968,
UI_Icon_Forward = 0xe969,
UI_Icon_Reply = 0xe96a,
UI_Icon_Bubble = 0xe96b,
UI_Icon_Bubbles = 0xe96c,
UI_Icon_Bubbles2 = 0xe96d,
UI_Icon_Bubble2 = 0xe96e,
UI_Icon_Bubbles3 = 0xe96f,
UI_Icon_Bubbles4 = 0xe970,
UI_Icon_User = 0xe971,
UI_Icon_Users = 0xe972,
UI_Icon_UserPlus = 0xe973,
UI_Icon_UserMinus = 0xe974,
UI_Icon_UserCheck = 0xe975,
UI_Icon_UserTie = 0xe976,
UI_Icon_QuotesLeft = 0xe977,
UI_Icon_QuotesRight = 0xe978,
UI_Icon_HourGlass = 0xe979,
UI_Icon_Spinner = 0xe97a,
UI_Icon_Spinner2 = 0xe97b,
UI_Icon_Spinner3 = 0xe97c,
UI_Icon_Spinner4 = 0xe97d,
UI_Icon_Spinner5 = 0xe97e,
UI_Icon_Spinner6 = 0xe97f,
UI_Icon_Spinner7 = 0xe980,
UI_Icon_Spinner8 = 0xe981,
UI_Icon_Spinner9 = 0xe982,
UI_Icon_Spinner10 = 0xe983,
UI_Icon_Spinner11 = 0xe984,
UI_Icon_Binoculars = 0xe985,
UI_Icon_Search = 0xe986,
UI_Icon_ZoomIn = 0xe987,
UI_Icon_ZoomOut = 0xe988,
UI_Icon_Enlarge = 0xe989,
UI_Icon_Shrink = 0xe98a,
UI_Icon_Enlarge2 = 0xe98b,
UI_Icon_Shrink2 = 0xe98c,
UI_Icon_Key = 0xe98d,
UI_Icon_Key2 = 0xe98e,
UI_Icon_Lock = 0xe98f,
UI_Icon_Unlocked = 0xe990,
UI_Icon_Wrench = 0xe991,
UI_Icon_Equalizer = 0xe992,
UI_Icon_Equalizer2 = 0xe993,
UI_Icon_Cog = 0xe994,
UI_Icon_Cogs = 0xe995,
UI_Icon_Hammer = 0xe996,
UI_Icon_MagicWand = 0xe997,
UI_Icon_AidKit = 0xe998,
UI_Icon_Bug = 0xe999,
UI_Icon_PieChart = 0xe99a,
UI_Icon_StatsDots = 0xe99b,
UI_Icon_StatsBars = 0xe99c,
UI_Icon_StatsBars2 = 0xe99d,
UI_Icon_Trophy = 0xe99e,
UI_Icon_Gift = 0xe99f,
UI_Icon_Glass = 0xe9a0,
UI_Icon_Glass2 = 0xe9a1,
UI_Icon_Mug = 0xe9a2,
UI_Icon_SpoonKnife = 0xe9a3,
UI_Icon_Leaf = 0xe9a4,
UI_Icon_Rocket = 0xe9a5,
UI_Icon_Meter = 0xe9a6,
UI_Icon_Meter2 = 0xe9a7,
UI_Icon_Hammer2 = 0xe9a8,
UI_Icon_Fire = 0xe9a9,
UI_Icon_Lab = 0xe9aa,
UI_Icon_Magnet = 0xe9ab,
UI_Icon_Bin = 0xe9ac,
UI_Icon_Bin2 = 0xe9ad,
UI_Icon_Briefcase = 0xe9ae,
UI_Icon_Airplane = 0xe9af,
UI_Icon_Truck = 0xe9b0,
UI_Icon_Road = 0xe9b1,
UI_Icon_Accessibility = 0xe9b2,
UI_Icon_Target = 0xe9b3,
UI_Icon_Shield = 0xe9b4,
UI_Icon_Power = 0xe9b5,
UI_Icon_Switch = 0xe9b6,
UI_Icon_PowerCord = 0xe9b7,
UI_Icon_Clipboard = 0xe9b8,
UI_Icon_ListNumbered = 0xe9b9,
UI_Icon_List = 0xe9ba,
UI_Icon_List2 = 0xe9bb,
UI_Icon_Tree = 0xe9bc,
UI_Icon_Menu = 0xe9bd,
UI_Icon_Menu2 = 0xe9be,
UI_Icon_Menu3 = 0xe9bf,
UI_Icon_Menu4 = 0xe9c0,
UI_Icon_Cloud = 0xe9c1,
UI_Icon_CloudDownload = 0xe9c2,
UI_Icon_CloudUpload = 0xe9c3,
UI_Icon_CloudCheck = 0xe9c4,
UI_Icon_Download2 = 0xe9c5,
UI_Icon_Upload2 = 0xe9c6,
UI_Icon_Download3 = 0xe9c7,
UI_Icon_Upload3 = 0xe9c8,
UI_Icon_Sphere = 0xe9c9,
UI_Icon_Earth = 0xe9ca,
UI_Icon_Link = 0xe9cb,
UI_Icon_Flag = 0xe9cc,
UI_Icon_Attachment = 0xe9cd,
UI_Icon_Eye = 0xe9ce,
UI_Icon_EyePlus = 0xe9cf,
UI_Icon_EyeMinus = 0xe9d0,
UI_Icon_EyeBlocked = 0xe9d1,
UI_Icon_Bookmark = 0xe9d2,
UI_Icon_Bookmarks = 0xe9d3,
UI_Icon_Sun = 0xe9d4,
UI_Icon_Contrast = 0xe9d5,
UI_Icon_BrightnessContrast = 0xe9d6,
UI_Icon_StarEmpty = 0xe9d7,
UI_Icon_StarHalf = 0xe9d8,
UI_Icon_StarFull = 0xe9d9,
UI_Icon_Heart = 0xe9da,
UI_Icon_HeartBroken = 0xe9db,
UI_Icon_Man = 0xe9dc,
UI_Icon_Woman = 0xe9dd,
UI_Icon_ManWoman = 0xe9de,
UI_Icon_Happy = 0xe9df,
UI_Icon_Happy2 = 0xe9e0,
UI_Icon_Smile = 0xe9e1,
UI_Icon_Smile2 = 0xe9e2,
UI_Icon_Tongue = 0xe9e3,
UI_Icon_Tongue2 = 0xe9e4,
UI_Icon_Sad = 0xe9e5,
UI_Icon_Sad2 = 0xe9e6,
UI_Icon_Wink = 0xe9e7,
UI_Icon_Wink2 = 0xe9e8,
UI_Icon_Grin = 0xe9e9,
UI_Icon_Grin2 = 0xe9ea,
UI_Icon_Cool = 0xe9eb,
UI_Icon_Cool2 = 0xe9ec,
UI_Icon_Angry = 0xe9ed,
UI_Icon_Angry2 = 0xe9ee,
UI_Icon_Evil = 0xe9ef,
UI_Icon_Evil2 = 0xe9f0,
UI_Icon_Shocked = 0xe9f1,
UI_Icon_Shocked2 = 0xe9f2,
UI_Icon_Baffled = 0xe9f3,
UI_Icon_Baffled2 = 0xe9f4,
UI_Icon_Confused = 0xe9f5,
UI_Icon_Confused2 = 0xe9f6,
UI_Icon_Neutral = 0xe9f7,
UI_Icon_Neutral2 = 0xe9f8,
UI_Icon_Hipster = 0xe9f9,
UI_Icon_Hipster2 = 0xe9fa,
UI_Icon_Wondering = 0xe9fb,
UI_Icon_Wondering2 = 0xe9fc,
UI_Icon_Sleepy = 0xe9fd,
UI_Icon_Sleepy2 = 0xe9fe,
UI_Icon_Frustrated = 0xe9ff,
UI_Icon_Frustrated2 = 0xea00,
UI_Icon_Crying = 0xea01,
UI_Icon_Crying2 = 0xea02,
UI_Icon_PointUp = 0xea03,
UI_Icon_PointRight = 0xea04,
UI_Icon_PointDown = 0xea05,
UI_Icon_PointLeft = 0xea06,
UI_Icon_Warning = 0xea07,
UI_Icon_Notification = 0xea08,
UI_Icon_Question = 0xea09,
UI_Icon_Plus = 0xea0a,
UI_Icon_Minus = 0xea0b,
UI_Icon_Info = 0xea0c,
UI_Icon_CancelCircle = 0xea0d,
UI_Icon_Blocked = 0xea0e,
UI_Icon_Cross = 0xea0f,
UI_Icon_Checkmark = 0xea10,
UI_Icon_Checkmark2 = 0xea11,
UI_Icon_SpellCheck = 0xea12,
UI_Icon_Enter = 0xea13,
UI_Icon_Exit = 0xea14,
UI_Icon_Play2 = 0xea15,
UI_Icon_Pause = 0xea16,
UI_Icon_Stop = 0xea17,
UI_Icon_Previous = 0xea18,
UI_Icon_Next = 0xea19,
UI_Icon_Backward = 0xea1a,
UI_Icon_Forward2 = 0xea1b,
UI_Icon_Play3 = 0xea1c,
UI_Icon_Pause2 = 0xea1d,
UI_Icon_Stop2 = 0xea1e,
UI_Icon_Backward2 = 0xea1f,
UI_Icon_Forward3 = 0xea20,
UI_Icon_First = 0xea21,
UI_Icon_Last = 0xea22,
UI_Icon_Previous2 = 0xea23,
UI_Icon_Next2 = 0xea24,
UI_Icon_Eject = 0xea25,
UI_Icon_VolumeHigh = 0xea26,
UI_Icon_VolumeMedium = 0xea27,
UI_Icon_VolumeLow = 0xea28,
UI_Icon_VolumeMute = 0xea29,
UI_Icon_VolumeMute2 = 0xea2a,
UI_Icon_VolumeIncrease = 0xea2b,
UI_Icon_VolumeDecrease = 0xea2c,
UI_Icon_Loop = 0xea2d,
UI_Icon_Loop2 = 0xea2e,
UI_Icon_Infinite = 0xea2f,
UI_Icon_Shuffle = 0xea30,
UI_Icon_ArrowUpLeft = 0xea31,
UI_Icon_ArrowUp = 0xea32,
UI_Icon_ArrowUpRight = 0xea33,
UI_Icon_ArrowRight = 0xea34,
UI_Icon_ArrowDownRight = 0xea35,
UI_Icon_ArrowDown = 0xea36,
UI_Icon_ArrowDownLeft = 0xea37,
UI_Icon_ArrowLeft = 0xea38,
UI_Icon_ArrowUpLeft2 = 0xea39,
UI_Icon_ArrowUp2 = 0xea3a,
UI_Icon_ArrowUpRight2 = 0xea3b,
UI_Icon_ArrowRight2 = 0xea3c,
UI_Icon_ArrowDownRight2 = 0xea3d,
UI_Icon_ArrowDown2 = 0xea3e,
UI_Icon_ArrowDownLeft2 = 0xea3f,
UI_Icon_ArrowLeft2 = 0xea40,
UI_Icon_CircleUp = 0xea41,
UI_Icon_CircleRight = 0xea42,
UI_Icon_CircleDown = 0xea43,
UI_Icon_CircleLeft = 0xea44,
UI_Icon_Tab = 0xea45,
UI_Icon_MoveUp = 0xea46,
UI_Icon_MoveDown = 0xea47,
UI_Icon_SortAlphaAsc = 0xea48,
UI_Icon_SortAlphaDesc = 0xea49,
UI_Icon_SortNumericAsc = 0xea4a,
UI_Icon_SortNumbericDesc = 0xea4b,
UI_Icon_SortAmountAsc = 0xea4c,
UI_Icon_SortAmountDesc = 0xea4d,
UI_Icon_Command = 0xea4e,
UI_Icon_Shift = 0xea4f,
UI_Icon_Ctrl = 0xea50,
UI_Icon_Opt = 0xea51,
UI_Icon_CheckboxChecked = 0xea52,
UI_Icon_CheckboxUnchecked = 0xea53,
UI_Icon_RadioChecked = 0xea54,
UI_Icon_RadioChecked2 = 0xea55,
UI_Icon_RadioUnchecked = 0xea56,
UI_Icon_Crop = 0xea57,
UI_Icon_MakeGroup = 0xea58,
UI_Icon_Ungroup = 0xea59,
UI_Icon_Scissors = 0xea5a,
UI_Icon_Filter = 0xea5b,
UI_Icon_Font = 0xea5c,
UI_Icon_Ligature = 0xea5d,
UI_Icon_Ligature2 = 0xea5e,
UI_Icon_TextHeight = 0xea5f,
UI_Icon_TextWidth = 0xea60,
UI_Icon_FontSize = 0xea61,
UI_Icon_Bold = 0xea62,
UI_Icon_Underline = 0xea63,
UI_Icon_Italic = 0xea64,
UI_Icon_Strikethrough = 0xea65,
UI_Icon_Omega = 0xea66,
UI_Icon_Sigma = 0xea67,
UI_Icon_PageBreak = 0xea68,
UI_Icon_Superscript = 0xea69,
UI_Icon_Subscript = 0xea6a,
UI_Icon_Superscript2 = 0xea6b,
UI_Icon_Subscript2 = 0xea6c,
UI_Icon_TextColor = 0xea6d,
UI_Icon_Pagebreak = 0xea6e,
UI_Icon_ClearFormatting = 0xea6f,
UI_Icon_Table = 0xea70,
UI_Icon_Table2 = 0xea71,
UI_Icon_InsertTemplate = 0xea72,
UI_Icon_Pilcrow = 0xea73,
UI_Icon_Ltr = 0xea74,
UI_Icon_Rtl = 0xea75,
UI_Icon_Section = 0xea76,
UI_Icon_ParagraphLeft = 0xea77,
UI_Icon_ParagraphCenter = 0xea78,
UI_Icon_ParagraphRight = 0xea79,
UI_Icon_ParagraphJustify = 0xea7a,
UI_Icon_IndentIncrease = 0xea7b,
UI_Icon_IndentDecrease = 0xea7c,
UI_Icon_Share = 0xea7d,
UI_Icon_NewTab = 0xea7e,
UI_Icon_Embed = 0xea7f,
UI_Icon_Embed2 = 0xea80,
UI_Icon_Terminal = 0xea81,
UI_Icon_Share2 = 0xea82,
UI_Icon_Mail = 0xea83,
UI_Icon_Mail2 = 0xea84,
UI_Icon_Mail3 = 0xea85,
UI_Icon_Mail4 = 0xea86,
UI_Icon_Amazon = 0xea87,
UI_Icon_Google = 0xea88,
UI_Icon_Google2 = 0xea89,
UI_Icon_Google3 = 0xea8a,
UI_Icon_GooglePlus = 0xea8b,
UI_Icon_GooglePlus2 = 0xea8c,
UI_Icon_GooglePlus3 = 0xea8d,
UI_Icon_Hangouts = 0xea8e,
UI_Icon_GoogleDrive = 0xea8f,
UI_Icon_Facebook = 0xea90,
UI_Icon_Facebook2 = 0xea91,
UI_Icon_Instagram = 0xea92,
UI_Icon_Whatsapp = 0xea93,
UI_Icon_Spotify = 0xea94,
UI_Icon_Telegram = 0xea95,
UI_Icon_Twitter = 0xea96,
UI_Icon_Vine = 0xea97,
UI_Icon_Vk = 0xea98,
UI_Icon_Renren = 0xea99,
UI_Icon_SinaWeibo = 0xea9a,
UI_Icon_Rss = 0xea9b,
UI_Icon_Rss2 = 0xea9c,
UI_Icon_Youtube = 0xea9d,
UI_Icon_Youtube2 = 0xea9e,
UI_Icon_Twitch = 0xea9f,
UI_Icon_Vimeo = 0xeaa0,
UI_Icon_Vimeo2 = 0xeaa1,
UI_Icon_Lanyrd = 0xeaa2,
UI_Icon_Flickr = 0xeaa3,
UI_Icon_Flickr2 = 0xeaa4,
UI_Icon_Flickr3 = 0xeaa5,
UI_Icon_Flickr4 = 0xeaa6,
UI_Icon_Dribbble = 0xeaa7,
UI_Icon_Behance = 0xeaa8,
UI_Icon_Behance2 = 0xeaa9,
UI_Icon_Deviantart = 0xeaaa,
UI_Icon_500px = 0xeaab,
UI_Icon_Steam = 0xeaac,
UI_Icon_Steam2 = 0xeaad,
UI_Icon_Dropbox = 0xeaae,
UI_Icon_Onedrive = 0xeaaf,
UI_Icon_Github = 0xeab0,
UI_Icon_Npm = 0xeab1,
UI_Icon_Basecamp = 0xeab2,
UI_Icon_Trello = 0xeab3,
UI_Icon_Wordpress = 0xeab4,
UI_Icon_Joomla = 0xeab5,
UI_Icon_Ello = 0xeab6,
UI_Icon_Blogger = 0xeab7,
UI_Icon_Blogger2 = 0xeab8,
UI_Icon_Tumblr = 0xeab9,
UI_Icon_Tumblr2 = 0xeaba,
UI_Icon_Yahoo = 0xeabb,
UI_Icon_Yahoo2 = 0xeabc,
UI_Icon_Tux = 0xeabd,
UI_Icon_Appleinc = 0xeabe,
UI_Icon_Finder = 0xeabf,
UI_Icon_Android = 0xeac0,
UI_Icon_Windows = 0xeac1,
UI_Icon_Windows8 = 0xeac2,
UI_Icon_Soundcloud = 0xeac3,
UI_Icon_Soundcloud2 = 0xeac4,
UI_Icon_Skype = 0xeac5,
UI_Icon_Reddit = 0xeac6,
UI_Icon_Hackernews = 0xeac7,
UI_Icon_Wikipedia = 0xeac8,
UI_Icon_Linkedin = 0xeac9,
UI_Icon_Linkedin2 = 0xeaca,
UI_Icon_Lastfm = 0xeacb,
UI_Icon_Lastfm2 = 0xeacc,
UI_Icon_Delicious = 0xeacd,
UI_Icon_Stumbleupon = 0xeace,
UI_Icon_Stumbleupon2 = 0xeacf,
UI_Icon_Stackoverflow = 0xead0,
UI_Icon_Pinterest = 0xead1,
UI_Icon_Pinterest2 = 0xead2,
UI_Icon_Xing = 0xead3,
UI_Icon_Xing2 = 0xead4,
UI_Icon_Flattr = 0xead5,
UI_Icon_Foursquare = 0xead6,
UI_Icon_Yelp = 0xead7,
UI_Icon_Paypal = 0xead8,
UI_Icon_Chrome = 0xead9,
UI_Icon_Firefox = 0xeada,
UI_Icon_IE = 0xeadb,
UI_Icon_Edge = 0xeadc,
UI_Icon_Safari = 0xeadd,
UI_Icon_Opera = 0xeade,
UI_Icon_FilePdf = 0xeadf,
UI_Icon_FileOpenoffice = 0xeae0,
UI_Icon_FileWord = 0xeae1,
UI_Icon_FileExcel = 0xeae2,
UI_Icon_Libreoffice = 0xeae3,
UI_Icon_HtmlFive = 0xeae4,
UI_Icon_HtmlFive2 = 0xeae5,
UI_Icon_Css3 = 0xeae6,
UI_Icon_Git = 0xeae7,
UI_Icon_Codepen = 0xeae8,
UI_Icon_Svg = 0xeae9,
UI_Icon_IcoMoon = 0xeaea,
};

BIN
src/ui/ui_res/font/icomoon.ttf (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -29,7 +29,7 @@ Struct(UI_DRect)
Vec4 background_lin;
Vec4 border_lin;
Vec4 debug_lin;
f32 border;
f32 border_size;
f32 tl_rounding;
f32 tr_rounding;

View File

@ -61,24 +61,24 @@ PixelShader(UI_DRectPS, UI_DRectPSOutput, UI_DRectPSInput input)
rect_dist = -rect_dist;
// Compute border sdf (negative means pixel is inside of border)
f32 border_width = 0;
f32 border_size = 0;
f32 border_dist = 0;
Vec4 border_color = 0;
{
if (rect.border > 0)
if (rect.border_size > 0)
{
border_width = rect.border;
border_size = rect.border_size;
border_color = input.border_lin;
}
else
{
border_width = 0;
border_size = 0;
border_color = input.background_lin;
}
border_dist = abs(rect_dist);
if (rect_dist <= 0)
{
border_dist -= border_width;
border_dist -= border_size;
}
}

View File

@ -84,6 +84,9 @@ void WND_Bootstrap(void);
#define WND_PushCmd(frame, ...) WND_PushCmd_((frame), (WND_Cmd) { __VA_ARGS__ })
void WND_PushCmd_(WND_Frame frame, WND_Cmd desc);
//- Command helpers
#define WND_SetCursor(_frame, _cursor) WND_PushCmd((_frame), .kind = WND_CmdKind_SetCursor, .cursor = (_cursor))
////////////////////////////////////////////////////////////
//~ @hookdecl Frame