Add standard radius
This commit is contained in:
@@ -47,6 +47,7 @@ void ui_set_theme(S32 theme_id) {
|
||||
g_theme.tab_inactive = Clay_Color{ 45, 45, 48, 255};
|
||||
g_theme.tab_inactive_hover= Clay_Color{ 55, 55, 60, 255};
|
||||
g_theme.tab_text = Clay_Color{240, 240, 240, 255};
|
||||
g_theme.corner_radius = 4.0f;
|
||||
break;
|
||||
|
||||
case 1: // Light
|
||||
@@ -70,6 +71,7 @@ void ui_set_theme(S32 theme_id) {
|
||||
g_theme.tab_inactive = Clay_Color{218, 218, 222, 255};
|
||||
g_theme.tab_inactive_hover= Clay_Color{205, 205, 210, 255};
|
||||
g_theme.tab_text = Clay_Color{255, 255, 255, 255};
|
||||
g_theme.corner_radius = 4.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,9 @@ struct UI_Theme {
|
||||
Clay_Color tab_inactive;
|
||||
Clay_Color tab_inactive_hover;
|
||||
Clay_Color tab_text; // Always light — readable on colored tab gradient
|
||||
|
||||
// Corner radius (unscaled pixels, applied via uis())
|
||||
F32 corner_radius;
|
||||
};
|
||||
|
||||
extern UI_Theme g_theme;
|
||||
@@ -105,7 +108,7 @@ static inline uint16_t uifs(float x) { return (uint16_t)(x * g_ui_scale + 0.5f);
|
||||
#define TAB_INACTIVE_BG g_theme.tab_inactive
|
||||
#define TAB_INACTIVE_HOVER g_theme.tab_inactive_hover
|
||||
#define TAB_HEIGHT uis(26)
|
||||
#define TAB_CORNER_RADIUS uis(5)
|
||||
#define TAB_CORNER_RADIUS CORNER_RADIUS
|
||||
#define TAB_PADDING_H uip(10)
|
||||
|
||||
////////////////////////////////
|
||||
@@ -147,20 +150,15 @@ struct CustomIconData {
|
||||
#define WIDGET_DROPDOWN_ITEM_H uis(28)
|
||||
|
||||
////////////////////////////////
|
||||
// Corner radii
|
||||
// Corner radius (from theme)
|
||||
|
||||
#define CORNER_RADIUS_SM uis(3)
|
||||
#define CORNER_RADIUS_MD uis(6)
|
||||
#define CORNER_RADIUS_ROUND uis(8)
|
||||
#define CORNER_RADIUS uis(g_theme.corner_radius)
|
||||
|
||||
////////////////////////////////
|
||||
// Modal / window styling
|
||||
|
||||
#define MODAL_OVERLAY_COLOR Clay_Color{ 0, 0, 0, 120}
|
||||
#define MODAL_WIDTH uis(400)
|
||||
#define MODAL_CORNER_RADIUS CORNER_RADIUS_MD
|
||||
|
||||
#define WINDOW_CORNER_RADIUS CORNER_RADIUS_MD
|
||||
#define WINDOW_TITLE_HEIGHT uis(32)
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -153,7 +153,7 @@ B32 ui_button(const char *id, const char *text) {
|
||||
.childAlignment = { .y = CLAY_ALIGN_Y_CENTER },
|
||||
},
|
||||
.backgroundColor = hovered ? g_theme.accent_hover : g_theme.accent,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_SM)
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS)
|
||||
) {
|
||||
CLAY_TEXT(clay_str(text), &g_widget_text_config_btn);
|
||||
}
|
||||
@@ -190,11 +190,11 @@ B32 ui_checkbox(const char *id, const char *label, B32 *value) {
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
|
||||
},
|
||||
.backgroundColor = box_bg,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_SM),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.border = { .color = g_theme.border, .width = { 1, 1, 1, 1 } }
|
||||
) {
|
||||
if (*value) {
|
||||
ui_icon(UI_ICON_CHECK, WIDGET_CHECKBOX_SIZE * 0.75f, g_theme.text);
|
||||
ui_icon(UI_ICON_CHECK, WIDGET_CHECKBOX_SIZE * 0.75f, g_theme.button_text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ B32 ui_radio_group(const char *id, const char **options, S32 count, S32 *selecte
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(WIDGET_RADIO_INNER), .height = CLAY_SIZING_FIXED(WIDGET_RADIO_INNER) },
|
||||
},
|
||||
.backgroundColor = g_theme.text,
|
||||
.backgroundColor = g_theme.button_text,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(uis(4))
|
||||
) {}
|
||||
}
|
||||
@@ -606,7 +606,7 @@ B32 ui_text_input(const char *id, char *buf, S32 buf_size) {
|
||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||
},
|
||||
.backgroundColor = bg,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_SM),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.border = { .color = border_color, .width = { 1, 1, 1, 1 } }
|
||||
) {
|
||||
if (len == 0 && !is_focused) {
|
||||
@@ -720,7 +720,7 @@ B32 ui_dropdown(const char *id, const char **options, S32 count, S32 *selected)
|
||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||
},
|
||||
.backgroundColor = bg,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_SM),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.border = { .color = is_open ? g_theme.accent : g_theme.border, .width = { 1, 1, 1, 1 } }
|
||||
) {
|
||||
CLAY(text_eid,
|
||||
@@ -762,6 +762,7 @@ B32 ui_dropdown(const char *id, const char **options, S32 count, S32 *selected)
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||
},
|
||||
.backgroundColor = g_theme.bg_dark,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.border = { .color = g_theme.border, .width = { 1, 1, 1, 1 } },
|
||||
.floating = {
|
||||
.parentId = eid.id,
|
||||
@@ -784,13 +785,18 @@ B32 ui_dropdown(const char *id, const char **options, S32 count, S32 *selected)
|
||||
Clay_TextElementConfig *item_text = (is_item_selected && !item_hovered)
|
||||
? &g_widget_text_config_btn : &g_widget_text_config;
|
||||
|
||||
Clay_CornerRadius item_radius = {};
|
||||
if (i == 0) { item_radius.topLeft = CORNER_RADIUS; item_radius.topRight = CORNER_RADIUS; }
|
||||
if (i == count - 1) { item_radius.bottomLeft = CORNER_RADIUS; item_radius.bottomRight = CORNER_RADIUS; }
|
||||
|
||||
CLAY(item_id,
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(WIDGET_DROPDOWN_ITEM_H) },
|
||||
.padding = { uip(8), uip(8), 0, 0 },
|
||||
.childAlignment = { .y = CLAY_ALIGN_Y_CENTER },
|
||||
},
|
||||
.backgroundColor = item_bg
|
||||
.backgroundColor = item_bg,
|
||||
.cornerRadius = item_radius
|
||||
) {
|
||||
CLAY_TEXT(clay_str(options[i]), item_text);
|
||||
}
|
||||
@@ -876,7 +882,7 @@ S32 ui_modal(const char *id, const char *title, const char *message,
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||
},
|
||||
.backgroundColor = g_theme.bg_medium,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_MD),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.floating = {
|
||||
.zIndex = 1001,
|
||||
.attachPoints = {
|
||||
@@ -896,7 +902,7 @@ S32 ui_modal(const char *id, const char *title, const char *message,
|
||||
.childAlignment = { .y = CLAY_ALIGN_Y_CENTER },
|
||||
},
|
||||
.backgroundColor = g_theme.title_bar,
|
||||
.cornerRadius = { MODAL_CORNER_RADIUS, MODAL_CORNER_RADIUS, 0, 0 },
|
||||
.cornerRadius = { CORNER_RADIUS, CORNER_RADIUS, 0, 0 },
|
||||
.border = { .color = g_theme.border, .width = { .bottom = 1 } }
|
||||
) {
|
||||
CLAY_TEXT(clay_str(title), &g_widget_text_config);
|
||||
@@ -937,7 +943,7 @@ S32 ui_modal(const char *id, const char *title, const char *message,
|
||||
.childAlignment = { .y = CLAY_ALIGN_Y_CENTER },
|
||||
},
|
||||
.backgroundColor = btn_hovered ? g_theme.accent_hover : g_theme.accent,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_SM)
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS)
|
||||
) {
|
||||
CLAY_TEXT(clay_str(buttons[i]), &g_widget_text_config_btn);
|
||||
}
|
||||
@@ -1060,7 +1066,7 @@ B32 ui_window(const char *id, const char *title, B32 *open,
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||
},
|
||||
.backgroundColor = g_theme.bg_medium,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_MD),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.floating = {
|
||||
.offset = { slot->position.x, slot->position.y },
|
||||
.zIndex = (int16_t)(100 + slot->z_order),
|
||||
@@ -1082,7 +1088,7 @@ B32 ui_window(const char *id, const char *title, B32 *open,
|
||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||
},
|
||||
.backgroundColor = g_theme.title_bar,
|
||||
.cornerRadius = { WINDOW_CORNER_RADIUS, WINDOW_CORNER_RADIUS, 0, 0 },
|
||||
.cornerRadius = { CORNER_RADIUS, CORNER_RADIUS, 0, 0 },
|
||||
.border = { .color = g_theme.border, .width = { .bottom = 1 } }
|
||||
) {
|
||||
// Title text (grows to push close button right)
|
||||
@@ -1095,14 +1101,16 @@ B32 ui_window(const char *id, const char *title, B32 *open,
|
||||
}
|
||||
|
||||
// Close button
|
||||
Clay_Color close_bg = close_hovered ? Clay_Color{200, 60, 60, 255} : Clay_Color{120, 50, 50, 255};
|
||||
Clay_Color close_bg = g_theme_id == 1
|
||||
? (close_hovered ? Clay_Color{220, 50, 50, 255} : Clay_Color{200, 70, 70, 255})
|
||||
: (close_hovered ? Clay_Color{200, 60, 60, 255} : Clay_Color{120, 50, 50, 255});
|
||||
CLAY(close_id,
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(uis(20)), .height = CLAY_SIZING_FIXED(uis(20)) },
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
|
||||
},
|
||||
.backgroundColor = close_bg,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS_SM)
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS)
|
||||
) {
|
||||
ui_icon(UI_ICON_CLOSE, uis(12), g_theme.button_text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user