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
+169 -103
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,72 +8506,117 @@ DF_VIEW_UI_FUNCTION_DEF(Settings)
{ {
DF_SettingsItemList items_list = {0}; DF_SettingsItemList items_list = {0};
//- rjf: gather all settings //- rjf: settings header
for(EachEnumVal(DF_SettingCode, code)) if(query.size == 0)
{ {
String8 kind_string = str8_lit("Interface"); DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1);
String8 string = df_g_setting_code_display_string_table[code]; SLLQueuePush(items_list.first, items_list.last, n);
FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string); items_list.count += 1;
FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string); n->v.kind = DF_SettingsItemKind_CategoryHeader;
if(string_matches.count == string_matches.needle_part_count || n->v.string = str8_lit("Interface Settings");
kind_string_matches.count == kind_string_matches.needle_part_count) 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
if(!sv->category_collapsed[DF_SettingsItemKind_Setting] || query.size != 0)
{
for(EachEnumVal(DF_SettingCode, code))
{ {
DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1); String8 kind_string = str8_lit("Interface");
SLLQueuePush(items_list.first, items_list.last, n); String8 string = df_g_setting_code_display_string_table[code];
items_list.count += 1; FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string);
n->v.kind = DF_SettingsItemKind_Setting; FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string);
n->v.kind_string = kind_string; if(string_matches.count == string_matches.needle_part_count ||
n->v.string = string; kind_string_matches.count == kind_string_matches.needle_part_count)
n->v.kind_string_matches = kind_string_matches; {
n->v.string_matches = string_matches; DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1);
n->v.icon_kind = DF_IconKind_Window; SLLQueuePush(items_list.first, items_list.last, n);
n->v.code = code; items_list.count += 1;
n->v.kind = DF_SettingsItemKind_Setting;
n->v.kind_string = kind_string;
n->v.string = string;
n->v.kind_string_matches = kind_string_matches;
n->v.string_matches = string_matches;
n->v.icon_kind = DF_IconKind_Window;
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
for(EachEnumVal(DF_ThemePreset, preset)) if(!sv->category_collapsed[DF_SettingsItemKind_ThemePreset] || query.size != 0)
{ {
String8 kind_string = str8_lit("Theme Preset"); for(EachEnumVal(DF_ThemePreset, preset))
String8 string = df_g_theme_preset_display_string_table[preset];
FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string);
FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string);
if(string_matches.count == string_matches.needle_part_count ||
kind_string_matches.count == kind_string_matches.needle_part_count)
{ {
DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1); String8 kind_string = str8_lit("Theme Preset");
SLLQueuePush(items_list.first, items_list.last, n); String8 string = df_g_theme_preset_display_string_table[preset];
items_list.count += 1; FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string);
n->v.kind = DF_SettingsItemKind_ThemePreset; FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string);
n->v.kind_string = kind_string; if(string_matches.count == string_matches.needle_part_count ||
n->v.string = string; kind_string_matches.count == kind_string_matches.needle_part_count)
n->v.kind_string_matches = kind_string_matches; {
n->v.string_matches = string_matches; DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1);
n->v.icon_kind = DF_IconKind_Palette; SLLQueuePush(items_list.first, items_list.last, n);
n->v.preset = preset; items_list.count += 1;
n->v.kind = DF_SettingsItemKind_ThemePreset;
n->v.kind_string = kind_string;
n->v.string = string;
n->v.kind_string_matches = kind_string_matches;
n->v.string_matches = string_matches;
n->v.icon_kind = DF_IconKind_Palette;
n->v.preset = preset;
}
} }
} }
//- rjf: gather all theme colors //- rjf: theme colors header
for(EachNonZeroEnumVal(DF_ThemeColor, color)) if(query.size == 0)
{ {
String8 kind_string = str8_lit("Theme Color"); DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1);
String8 string = df_g_theme_color_display_string_table[color]; SLLQueuePush(items_list.first, items_list.last, n);
FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string); items_list.count += 1;
FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string); n->v.kind = DF_SettingsItemKind_CategoryHeader;
if(string_matches.count == string_matches.needle_part_count || n->v.string = str8_lit("Theme Colors");
kind_string_matches.count == kind_string_matches.needle_part_count) 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
if(!sv->category_collapsed[DF_SettingsItemKind_ThemeColor] || query.size != 0)
{
for(EachNonZeroEnumVal(DF_ThemeColor, color))
{ {
DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1); String8 kind_string = str8_lit("Theme Color");
SLLQueuePush(items_list.first, items_list.last, n); String8 string = df_g_theme_color_display_string_table[color];
items_list.count += 1; FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string);
n->v.kind = DF_SettingsItemKind_ThemeColor; FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string);
n->v.kind_string = kind_string; if(string_matches.count == string_matches.needle_part_count ||
n->v.string = string; kind_string_matches.count == kind_string_matches.needle_part_count)
n->v.kind_string_matches = kind_string_matches; {
n->v.string_matches = string_matches; DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1);
n->v.icon_kind = DF_IconKind_Palette; SLLQueuePush(items_list.first, items_list.last, n);
n->v.color = color; items_list.count += 1;
n->v.kind = DF_SettingsItemKind_ThemeColor;
n->v.kind_string = kind_string;
n->v.string = string;
n->v.kind_string_matches = kind_string_matches;
n->v.string_matches = string_matches;
n->v.icon_kind = DF_IconKind_Palette;
n->v.color = color;
}
} }
} }
@@ -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,60 +8909,65 @@ 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_Focus(row_num+1 == sv->cursor.y ? UI_FocusKind_On : UI_FocusKind_Off) UI_Palette(palette) UI_Row
{ {
ui_set_next_hover_cursor(cursor); if(query.size == 0 && item->kind != DF_SettingsItemKind_CategoryHeader)
item_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|
UI_BoxFlag_DrawBackground|
UI_BoxFlag_DrawBorder|
UI_BoxFlag_DrawHotEffects|
UI_BoxFlag_DrawActiveEffects,
"###option_%S", item->string);
UI_Parent(item_box)
{ {
ui_spacer(ui_em(1.f, 1.f)); ui_set_next_flags(UI_BoxFlag_DrawSideLeft);
UI_PrefWidth(ui_em(2.5f, 1.f)) ui_spacer(ui_em(2.f, 1.f));
UI_Font(df_font_from_slot(DF_FontSlot_Icons)) }
UI_RunFlags(F_RunFlag_Smooth) UI_Focus(row_num+1 == sv->cursor.y ? UI_FocusKind_On : UI_FocusKind_Off) UI_Palette(palette)
UI_Palette(ui_build_palette(ui_top_palette(), .text = rgba)) {
ui_label(df_g_icon_kind_text_table[item->icon_kind]); ui_set_next_hover_cursor(cursor);
UI_PrefWidth(ui_text_dim(10, 1)) item_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|flags, "###option_%S_%S", item->kind_string, item->string);
UI_Parent(item_box)
{ {
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak, "%S", item->kind_string); if(item->icon_kind != DF_IconKind_Null)
ui_box_equip_fuzzy_match_ranges(box, &item->kind_string_matches); {
} UI_PrefWidth(ui_em(2.f, 1.f))
UI_PrefWidth(ui_text_dim(10, 1)) UI_Font(df_font_from_slot(DF_FontSlot_Icons))
{ UI_RunFlags(F_RunFlag_Smooth)
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "%S", item->string); UI_Palette(ui_build_palette(ui_top_palette(), .text = rgba))
ui_box_equip_fuzzy_match_ranges(box, &item->string_matches); ui_label(df_g_icon_kind_text_table[item->icon_kind]);
} }
if(is_slider) UI_PrefWidth(ui_text_dim(10, 1)) if(item->kind_string.size != 0) UI_PrefWidth(ui_text_dim(10, 1))
{ {
UI_Font(df_font_from_slot(DF_FontSlot_Code)) UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak, "%S", item->kind_string);
UI_RunFlags(F_RunFlag_Smooth) ui_box_equip_fuzzy_match_ranges(box, &item->kind_string_matches);
UI_Flags(UI_BoxFlag_DrawTextWeak) }
ui_labelf("(%i)", slider_s32_val);
UI_PrefWidth(ui_pct(slider_pct, 1.f)) UI_HeightFill UI_FixedX(0) UI_FixedY(0)
UI_Palette(ui_build_palette(ui_top_palette(), .background = df_rgba_from_theme_color(DF_ThemeColor_HighlightOverlay)))
ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero());
}
if(is_toggler)
{
ui_spacer(ui_pct(1, 0));
UI_PrefWidth(ui_em(2.5f, 1.f))
UI_Font(df_font_from_slot(DF_FontSlot_Icons))
UI_RunFlags(F_RunFlag_Smooth)
UI_Flags(UI_BoxFlag_DrawTextWeak)
ui_label(df_g_icon_kind_text_table[is_toggled ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow]);
}
if(item->kind == DF_SettingsItemKind_ThemePreset && sv->preset_apply_confirm == item->preset)
{
ui_spacer(ui_pct(1, 0));
UI_PrefWidth(ui_text_dim(10, 1)) UI_PrefWidth(ui_text_dim(10, 1))
DF_Palette(DF_PaletteCode_NegativePopButton) {
UI_CornerRadius(ui_top_font_size()*0.5f) UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "%S", item->string);
UI_FontSize(ui_top_font_size()*0.9f) ui_box_equip_fuzzy_match_ranges(box, &item->string_matches);
ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawBackground, "Click Again To Apply"); }
if(is_slider) UI_PrefWidth(ui_text_dim(10, 1))
{
UI_Font(df_font_from_slot(DF_FontSlot_Code))
UI_RunFlags(F_RunFlag_Smooth)
UI_Flags(UI_BoxFlag_DrawTextWeak)
ui_labelf("(%i)", slider_s32_val);
UI_PrefWidth(ui_pct(slider_pct, 1.f)) UI_HeightFill UI_FixedX(0) UI_FixedY(0)
UI_Palette(ui_build_palette(ui_top_palette(), .background = df_rgba_from_theme_color(DF_ThemeColor_HighlightOverlay)))
ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero());
}
if(is_toggler)
{
ui_spacer(ui_pct(1, 0));
UI_PrefWidth(ui_em(2.5f, 1.f))
UI_Font(df_font_from_slot(DF_FontSlot_Icons))
UI_RunFlags(F_RunFlag_Smooth)
UI_Flags(UI_BoxFlag_DrawTextWeak)
ui_label(df_g_icon_kind_text_table[is_toggled ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow]);
}
if(item->kind == DF_SettingsItemKind_ThemePreset && sv->preset_apply_confirm == item->preset)
{
ui_spacer(ui_pct(1, 0));
UI_PrefWidth(ui_text_dim(10, 1))
DF_Palette(DF_PaletteCode_NegativePopButton)
UI_CornerRadius(ui_top_font_size()*0.5f)
UI_FontSize(ui_top_font_size()*0.9f)
ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawBackground, "Click Again To Apply");
}
} }
} }
} }
@@ -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