WIP: lunasvg implementation, things stopped working
This commit is contained in:
@@ -10,6 +10,11 @@
|
||||
|
||||
UI_WidgetState g_wstate = {};
|
||||
|
||||
// Icon per-frame pool (forward declaration for begin_frame)
|
||||
#define UI_MAX_ICONS_PER_FRAME 32
|
||||
static CustomIconData g_icon_pool[UI_MAX_ICONS_PER_FRAME];
|
||||
static S32 g_icon_pool_count = 0;
|
||||
|
||||
void ui_widgets_init() {
|
||||
g_wstate = {};
|
||||
}
|
||||
@@ -17,6 +22,7 @@ void ui_widgets_init() {
|
||||
void ui_widgets_begin_frame(PlatformInput input) {
|
||||
g_wstate.input = input;
|
||||
g_wstate.mouse_clicked = (input.mouse_down && !input.was_mouse_down);
|
||||
g_icon_pool_count = 0;
|
||||
g_wstate.cursor_blink += 1.0f / 60.0f;
|
||||
g_wstate.text_input_count = 0;
|
||||
g_wstate.tab_pressed = 0;
|
||||
@@ -96,6 +102,26 @@ static Clay_String clay_str(const char *s) {
|
||||
#define WID(s) CLAY_SID(clay_str(s))
|
||||
#define WIDI(s, i) CLAY_SIDI(clay_str(s), i)
|
||||
|
||||
////////////////////////////////
|
||||
// Icon
|
||||
|
||||
void ui_icon(UI_IconID icon, F32 size, Clay_Color color) {
|
||||
if (g_icon_pool_count >= UI_MAX_ICONS_PER_FRAME) return;
|
||||
|
||||
S32 idx = g_icon_pool_count;
|
||||
CustomIconData *data = &g_icon_pool[g_icon_pool_count++];
|
||||
data->type = CUSTOM_RENDER_ICON;
|
||||
data->icon_id = (S32)icon;
|
||||
data->color = color;
|
||||
|
||||
CLAY(CLAY_IDI("UIIcon", idx),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(size), .height = CLAY_SIZING_FIXED(size) },
|
||||
},
|
||||
.custom = { .customData = data }
|
||||
) {}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// Label
|
||||
|
||||
@@ -168,7 +194,7 @@ B32 ui_checkbox(const char *id, const char *label, B32 *value) {
|
||||
.border = { .color = g_theme.border, .width = { 1, 1, 1, 1 } }
|
||||
) {
|
||||
if (*value) {
|
||||
CLAY_TEXT(CLAY_STRING("x"), &g_widget_text_config);
|
||||
ui_icon(UI_ICON_CHECK, WIDGET_CHECKBOX_SIZE * 0.75f, g_theme.text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,11 +733,11 @@ B32 ui_dropdown(const char *id, const char **options, S32 count, S32 *selected)
|
||||
|
||||
CLAY(WIDI(id, 501),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(uis(20)), .height = CLAY_SIZING_FIT() },
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER },
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(uis(20)), .height = CLAY_SIZING_FIXED(uis(20)) },
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
|
||||
}
|
||||
) {
|
||||
CLAY_TEXT(CLAY_STRING("v"), &g_widget_text_config_dim);
|
||||
ui_icon(UI_ICON_CHEVRON_DOWN, uis(12), g_theme.text_dim);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1078,7 +1104,7 @@ B32 ui_window(const char *id, const char *title, B32 *open,
|
||||
.backgroundColor = close_bg,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_SM)
|
||||
) {
|
||||
CLAY_TEXT(CLAY_STRING("x"), &g_widget_text_config_btn);
|
||||
ui_icon(UI_ICON_CLOSE, uis(12), g_theme.button_text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user