setting view categories

This commit is contained in:
Ryan Fleury
2024-06-26 15:47:28 -07:00
parent 7584890edd
commit 5e2c6b5107
3 changed files with 181 additions and 112 deletions
+75 -9
View File
@@ -8490,6 +8490,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
DF_ThemeColor color_ctx_menu_color; DF_ThemeColor color_ctx_menu_color;
Vec4F32 color_ctx_menu_color_hsva; Vec4F32 color_ctx_menu_color_hsva;
DF_ThemePreset preset_apply_confirm; DF_ThemePreset preset_apply_confirm;
B32 category_collapsed[DF_SettingsItemKind_COUNT];
}; };
DF_SettingsViewState *sv = df_view_user_state(view, DF_SettingsViewState); DF_SettingsViewState *sv = df_view_user_state(view, DF_SettingsViewState);
if(!sv->initialized) if(!sv->initialized)
@@ -8505,7 +8506,21 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
{ {
DF_SettingsItemList items_list = {0}; DF_SettingsItemList items_list = {0};
//- rjf: settings header
if(query.size == 0)
{
DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1);
SLLQueuePush(items_list.first, items_list.last, n);
items_list.count += 1;
n->v.kind = DF_SettingsItemKind_CategoryHeader;
n->v.string = str8_lit("Interface Settings");
n->v.icon_kind = sv->category_collapsed[DF_SettingsItemKind_Setting] ? DF_IconKind_RightCaret : DF_IconKind_DownCaret;
n->v.category = DF_SettingsItemKind_Setting;
}
//- rjf: gather all settings //- rjf: gather all settings
if(!sv->category_collapsed[DF_SettingsItemKind_Setting] || query.size != 0)
{
for(EachEnumVal(DF_SettingCode, code)) for(EachEnumVal(DF_SettingCode, code))
{ {
String8 kind_string = str8_lit("Interface"); String8 kind_string = str8_lit("Interface");
@@ -8527,8 +8542,23 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
n->v.code = code; n->v.code = code;
} }
} }
}
//- rjf: theme presets header
if(query.size == 0)
{
DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1);
SLLQueuePush(items_list.first, items_list.last, n);
items_list.count += 1;
n->v.kind = DF_SettingsItemKind_CategoryHeader;
n->v.string = str8_lit("Theme Presets");
n->v.icon_kind = sv->category_collapsed[DF_SettingsItemKind_ThemePreset] ? DF_IconKind_RightCaret : DF_IconKind_DownCaret;
n->v.category = DF_SettingsItemKind_ThemePreset;
}
//- rjf: gather theme presets //- rjf: gather theme presets
if(!sv->category_collapsed[DF_SettingsItemKind_ThemePreset] || query.size != 0)
{
for(EachEnumVal(DF_ThemePreset, preset)) for(EachEnumVal(DF_ThemePreset, preset))
{ {
String8 kind_string = str8_lit("Theme Preset"); String8 kind_string = str8_lit("Theme Preset");
@@ -8550,8 +8580,23 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
n->v.preset = preset; n->v.preset = preset;
} }
} }
}
//- rjf: theme colors header
if(query.size == 0)
{
DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1);
SLLQueuePush(items_list.first, items_list.last, n);
items_list.count += 1;
n->v.kind = DF_SettingsItemKind_CategoryHeader;
n->v.string = str8_lit("Theme Colors");
n->v.icon_kind = sv->category_collapsed[DF_SettingsItemKind_ThemeColor] ? DF_IconKind_RightCaret : DF_IconKind_DownCaret;
n->v.category = DF_SettingsItemKind_ThemeColor;
}
//- rjf: gather all theme colors //- rjf: gather all theme colors
if(!sv->category_collapsed[DF_SettingsItemKind_ThemeColor] || query.size != 0)
{
for(EachNonZeroEnumVal(DF_ThemeColor, color)) for(EachNonZeroEnumVal(DF_ThemeColor, color))
{ {
String8 kind_string = str8_lit("Theme Color"); String8 kind_string = str8_lit("Theme Color");
@@ -8573,6 +8618,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
n->v.color = color; n->v.color = color;
} }
} }
}
//- rjf: convert to array //- rjf: convert to array
items.count = items_list.count; items.count = items_list.count;
@@ -8817,8 +8863,15 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
B32 is_slider = 0; B32 is_slider = 0;
S32 slider_s32_val = 0; S32 slider_s32_val = 0;
F32 slider_pct = 0.f; F32 slider_pct = 0.f;
UI_BoxFlags flags = UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawHotEffects|UI_BoxFlag_DrawActiveEffects;
switch(item->kind) switch(item->kind)
{ {
case DF_SettingsItemKind_COUNT:{}break;
case DF_SettingsItemKind_CategoryHeader:
{
cursor = OS_Cursor_HandPoint;
flags = UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawHotEffects;
}break;
case DF_SettingsItemKind_ThemePreset: case DF_SettingsItemKind_ThemePreset:
{ {
Vec4F32 *colors = df_g_theme_preset_colors_table[item->preset]; Vec4F32 *colors = df_g_theme_preset_colors_table[item->preset];
@@ -8856,24 +8909,28 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
//- rjf: build item widget //- rjf: build item widget
UI_Box *item_box = &ui_g_nil_box; UI_Box *item_box = &ui_g_nil_box;
UI_Row
{
if(query.size == 0 && item->kind != DF_SettingsItemKind_CategoryHeader)
{
ui_set_next_flags(UI_BoxFlag_DrawSideLeft);
ui_spacer(ui_em(2.f, 1.f));
}
UI_Focus(row_num+1 == sv->cursor.y ? UI_FocusKind_On : UI_FocusKind_Off) UI_Palette(palette) UI_Focus(row_num+1 == sv->cursor.y ? UI_FocusKind_On : UI_FocusKind_Off) UI_Palette(palette)
{ {
ui_set_next_hover_cursor(cursor); ui_set_next_hover_cursor(cursor);
item_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable| item_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|flags, "###option_%S_%S", item->kind_string, item->string);
UI_BoxFlag_DrawBackground|
UI_BoxFlag_DrawBorder|
UI_BoxFlag_DrawHotEffects|
UI_BoxFlag_DrawActiveEffects,
"###option_%S", item->string);
UI_Parent(item_box) UI_Parent(item_box)
{ {
ui_spacer(ui_em(1.f, 1.f)); if(item->icon_kind != DF_IconKind_Null)
UI_PrefWidth(ui_em(2.5f, 1.f)) {
UI_PrefWidth(ui_em(2.f, 1.f))
UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_Font(df_font_from_slot(DF_FontSlot_Icons))
UI_RunFlags(F_RunFlag_Smooth) UI_RunFlags(F_RunFlag_Smooth)
UI_Palette(ui_build_palette(ui_top_palette(), .text = rgba)) UI_Palette(ui_build_palette(ui_top_palette(), .text = rgba))
ui_label(df_g_icon_kind_text_table[item->icon_kind]); ui_label(df_g_icon_kind_text_table[item->icon_kind]);
UI_PrefWidth(ui_text_dim(10, 1)) }
if(item->kind_string.size != 0) UI_PrefWidth(ui_text_dim(10, 1))
{ {
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak, "%S", item->kind_string); UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak, "%S", item->kind_string);
ui_box_equip_fuzzy_match_ranges(box, &item->kind_string_matches); ui_box_equip_fuzzy_match_ranges(box, &item->kind_string_matches);
@@ -8913,6 +8970,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
} }
} }
} }
}
//- rjf: interact //- rjf: interact
UI_Signal sig = ui_signal_from_box(item_box); UI_Signal sig = ui_signal_from_box(item_box);
@@ -8962,6 +9020,14 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
{ {
sv->preset_apply_confirm = DF_ThemePreset_COUNT; sv->preset_apply_confirm = DF_ThemePreset_COUNT;
} }
if(item->kind != DF_SettingsItemKind_ThemePreset && ui_pressed(sig))
{
sv->preset_apply_confirm = DF_ThemePreset_COUNT;
}
if(item->kind == DF_SettingsItemKind_CategoryHeader && ui_pressed(sig))
{
sv->category_collapsed[item->category] ^= 1;
}
} }
} }
+3
View File
@@ -439,9 +439,11 @@ struct DF_MemoryViewState
typedef enum DF_SettingsItemKind typedef enum DF_SettingsItemKind
{ {
DF_SettingsItemKind_CategoryHeader,
DF_SettingsItemKind_Setting, DF_SettingsItemKind_Setting,
DF_SettingsItemKind_ThemeColor, DF_SettingsItemKind_ThemeColor,
DF_SettingsItemKind_ThemePreset, DF_SettingsItemKind_ThemePreset,
DF_SettingsItemKind_COUNT
} }
DF_SettingsItemKind; DF_SettingsItemKind;
@@ -457,6 +459,7 @@ struct DF_SettingsItem
DF_SettingCode code; DF_SettingCode code;
DF_ThemeColor color; DF_ThemeColor color;
DF_ThemePreset preset; DF_ThemePreset preset;
DF_SettingsItemKind category;
}; };
typedef struct DF_SettingsItemNode DF_SettingsItemNode; typedef struct DF_SettingsItemNode DF_SettingsItemNode;
+9 -9
View File
@@ -4,15 +4,15 @@
//////////////////////////////// ////////////////////////////////
//~ rjf: 0.9.11 TODO //~ rjf: 0.9.11 TODO
// //
// [ ] user settings (ui & functionality - generally need a story for it) // [x] user settings (ui & functionality - generally need a story for it)
// [ ] hover animations // [x] hover animations
// [ ] press animations // [x] press animations
// [ ] focus animations // [x] focus animations
// [ ] tooltip animations // [x] tooltip animations
// [ ] context menu animations // [x] context menu animations
// [ ] scrolling animations // [x] scrolling animations
// [ ] background blur // [x] background blur
// [ ] tab width // [x] tab width
// [ ] auto-scroll output window // [ ] auto-scroll output window
// //
// [ ] move breakpoints to being a global thing, not nested to particular files // [ ] move breakpoints to being a global thing, not nested to particular files