Add standard radius

This commit is contained in:
2026-03-03 14:34:41 -05:00
parent c11c82186c
commit 6346dc8843
6 changed files with 114 additions and 56 deletions

View File

@@ -103,6 +103,9 @@ struct AppState {
S32 accent_sel;
S32 accent_prev;
// Corner radius selection
S32 radius_sel;
// Audio device selection
S32 audio_device_sel; // dropdown index: 0 = None, 1+ = device
S32 audio_device_prev; // previous selection for change detection
@@ -333,7 +336,7 @@ static void build_right_panel(AppState *app) {
.childAlignment = { .y = CLAY_ALIGN_Y_CENTER },
},
.backgroundColor = refresh_hovered ? g_theme.accent_hover : g_theme.bg_lighter,
.cornerRadius = CLAY_CORNER_RADIUS(uis(3))
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS)
) {
CLAY_TEXT(CLAY_STRING("Refresh"), &g_text_config_normal);
}
@@ -433,7 +436,7 @@ static void build_right_panel(AppState *app) {
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
},
.backgroundColor = box_color,
.cornerRadius = CLAY_CORNER_RADIUS(uis(3))
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS)
) {
CLAY_TEXT(note_str, box_txt);
}
@@ -507,6 +510,9 @@ static void build_log_panel(B32 show) {
}
////////////////////////////////
// Corner radius presets (indexed by AppState::radius_sel)
static const F32 radius_values[] = { 0.0f, 4.0f, 6.0f, 10.0f };
// Window content callbacks
static void settings_window_content(void *user_data) {
@@ -528,6 +534,17 @@ static void settings_window_content(void *user_data) {
ui_dropdown("SettingsAccent", accent_options, 7, &app->accent_sel);
}
ui_label("SettingsLblRadius", "Corner Radius");
static const char *radius_options[] = { "None", "Small", "Medium", "Large" };
// radius_values defined at file scope (used by theme change handler too)
CLAY(CLAY_ID("SettingsRadiusWrap"),
.layout = { .sizing = { .width = CLAY_SIZING_FIXED(uis(180)), .height = CLAY_SIZING_FIT() } }
) {
if (ui_dropdown("SettingsRadius", radius_options, 4, &app->radius_sel)) {
g_theme.corner_radius = radius_values[app->radius_sel];
}
}
ui_checkbox("SettingsVsync", "V-Sync", &app->settings_vsync);
ui_checkbox("SettingsAutosave", "Autosave", &app->settings_autosave);
@@ -590,7 +607,7 @@ static void settings_window_content(void *user_data) {
.childAlignment = { .y = CLAY_ALIGN_Y_CENTER },
},
.backgroundColor = g_theme.disabled_bg,
.cornerRadius = CLAY_CORNER_RADIUS(uis(3))
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS)
) {
static Clay_TextElementConfig disabled_text = {};
disabled_text.textColor = g_theme.disabled_text;
@@ -723,6 +740,7 @@ static void do_frame(AppState *app) {
if (app->settings_theme_sel != app->settings_theme_prev) {
ui_set_theme(app->settings_theme_sel);
ui_set_accent(app->accent_sel); // reapply accent on new base theme
g_theme.corner_radius = radius_values[app->radius_sel]; // preserve user radius
app->settings_theme_prev = app->settings_theme_sel;
// Refresh all text configs with new theme colors
@@ -834,6 +852,7 @@ int main(int argc, char **argv) {
app.show_log = 1;
app.show_midi_devices = 1;
app.demo_dropdown_sel = 1; // default to 48000 Hz
app.radius_sel = 1; // default to "Small" (4.0f)
snprintf(app.demo_text_a, sizeof(app.demo_text_a), "My Instrument");
#ifdef __APPLE__
snprintf(app.demo_text_b, sizeof(app.demo_text_b), "~/Samples/output");