From 1b8e39c635868d1674e27fe076f37c72b760ed19 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Tue, 18 Feb 2025 18:08:18 -0800 Subject: [PATCH] work on tag-based styling --- src/base/base_strings.c | 47 +-- src/base/base_strings.h | 1 + src/raddbg/generated/raddbg.meta.c | 2 +- src/raddbg/raddbg.mdesk | 104 +++--- src/raddbg/raddbg_core.c | 514 ++++++++++++++--------------- src/raddbg/raddbg_core.h | 6 +- src/raddbg/raddbg_views.c | 46 ++- src/raddbg/raddbg_widgets.c | 51 +-- src/ui/generated/ui.meta.c | 11 +- src/ui/generated/ui.meta.h | 11 + src/ui/ui.mdesk | 17 +- src/ui/ui_core.c | 121 ++++--- src/ui/ui_core.h | 9 + 13 files changed, 501 insertions(+), 439 deletions(-) diff --git a/src/base/base_strings.c b/src/base/base_strings.c index 9e42e0cd..ed5d3147 100644 --- a/src/base/base_strings.c +++ b/src/base/base_strings.c @@ -242,7 +242,7 @@ str8_cstring_capped_reverse(void *raw_start, void *raw_cap) for(; ptr > start; ) { ptr -= 1; - + if (*ptr == '\0') { break; @@ -619,7 +619,7 @@ internal String8 str8_from_memory_size(Arena *arena, U64 size) { String8 result; - + if(size < KB(1)) { result = push_str8f(arena, "%llu Bytes", size); @@ -640,7 +640,7 @@ str8_from_memory_size(Arena *arena, U64 size) { result = push_str8f(arena, "%llu.%02llu TiB", size / TB(1), ((size * 100) / TB(1)) % 100); } - + return result; } @@ -648,7 +648,7 @@ internal String8 str8_from_count(Arena *arena, U64 count) { String8 result; - + if(count < 1 * 1000) { result = push_str8f(arena, "%llu", count); @@ -689,7 +689,7 @@ str8_from_count(Arena *arena, U64 count) result = push_str8f(arena, "%lluB", count / 1000000000, frac); } } - + return result; } @@ -1114,6 +1114,13 @@ str8_list_from_flags(Arena *arena, String8List *list, //////////////////////////////// //~ rjf; String Arrays +internal String8Array +str8_array_zero(void) +{ + String8Array result = {0}; + return result; +} + internal String8Array str8_array_from_list(Arena *arena, String8List *list) { @@ -1827,10 +1834,10 @@ try_guid_from_string(String8 string, Guid *guid_out) String8 data4_hi_str = list.first->next->next->next->string; String8 data4_lo_str = list.first->next->next->next->next->string; if(str8_is_integer(data1_str, 16) && - str8_is_integer(data2_str, 16) && - str8_is_integer(data3_str, 16) && - str8_is_integer(data4_hi_str, 16) && - str8_is_integer(data4_lo_str, 16)) + str8_is_integer(data2_str, 16) && + str8_is_integer(data3_str, 16) && + str8_is_integer(data4_hi_str, 16) && + str8_is_integer(data4_lo_str, 16)) { U64 data1 = u64_from_str8(data1_str, 16); U64 data2 = u64_from_str8(data2_str, 16); @@ -1838,10 +1845,10 @@ try_guid_from_string(String8 string, Guid *guid_out) U64 data4_hi = u64_from_str8(data4_hi_str, 16); U64 data4_lo = u64_from_str8(data4_lo_str, 16); if(data1 <= max_U32 && - data2 <= max_U16 && - data3 <= max_U16 && - data4_hi <= max_U16 && - data4_lo <= 0xffffffffffff) + data2 <= max_U16 && + data3 <= max_U16 && + data4_hi <= max_U16 && + data4_lo <= 0xffffffffffff) { guid_out->data1 = (U32)data1; guid_out->data2 = (U16)data2; @@ -2381,18 +2388,18 @@ str8_deserial_read_uleb128(String8 string, U64 off, U64 *value_out) { U8 byte = 0; U64 bytes_read = str8_deserial_read_struct(string, cursor, &byte); - + if(bytes_read != sizeof(byte)) { break; } - + U8 val = byte & 0x7fu; value |= ((U64)val) << shift; - + cursor += bytes_read; shift += 7u; - + if((byte & 0x80u) == 0) { break; @@ -2420,13 +2427,13 @@ str8_deserial_read_sleb128(String8 string, U64 off, S64 *value_out) { break; } - + U8 val = byte & 0x7fu; value |= ((U64)val) << shift; - + cursor += bytes_read; shift += 7u; - + if((byte & 0x80u) == 0) { if(shift < sizeof(value) * 8 && (byte & 0x40u) != 0) diff --git a/src/base/base_strings.h b/src/base/base_strings.h index fc946dd8..9c1eee7b 100644 --- a/src/base/base_strings.h +++ b/src/base/base_strings.h @@ -284,6 +284,7 @@ internal void str8_list_from_flags(Arena *arena, String8List *list, U32 //////////////////////////////// //~ rjf; String Arrays +internal String8Array str8_array_zero(void); internal String8Array str8_array_from_list(Arena *arena, String8List *list); internal String8Array str8_array_reserve(Arena *arena, U64 count); diff --git a/src/raddbg/generated/raddbg.meta.c b/src/raddbg/generated/raddbg.meta.c index b0b5f6a9..e427e354 100644 --- a/src/raddbg/generated/raddbg.meta.c +++ b/src/raddbg/generated/raddbg.meta.c @@ -809,7 +809,7 @@ str8_lit_comp("far_manager"), String8 rd_theme_preset_cfg_string_table[9] = { -str8_lit_comp("theme:\n{\n background: 0x1b1b1bff,\n alt: background: 0x222222ff,\n good: background: 0x222222ff,\n bad: background: 0x222222ff,\n pop: background: 0x222222ff,\n border: 0x404040ff,\n text: 0xe5e5e5ff,\n weak: text: 0xe5e5e5ff,\n hover: 0xffffffff,\n focus: 0xfda200ff,\n cursor: 0x8aff00ff,\n selection: 0x99ccffff,\n\n menu_bar:\n {\n background: 0x2b3740ff,\n border: 0x3e4c57ff,\n }\n\n good:\n {\n background: 0x2c5b36ff,\n border: 0x3f3f3fff,\n }\n\n bad:\n {\n background: 0x803425ff,\n border: 0xe88774ff,\n }\n\n pop:\n {\n background: 0x355b6eff,\n border: 0x355b6eff,\n }\n\n scroll_bar:\n {\n background: 0x2b2b2bff,\n border: 0x3f3f3fff,\n }\n\n tab:\n {\n background: 0x6f5135ff,\n border: 0x8a6e54ff,\n inactive:\n {\n background: 0x2b3740ff,\n border: 0x3e4c57ff,\n }\n }\n\n drop_site:\n {\n background: 0xffffffff,\n border: 0xffffffff,\n }\n\n code:\n {\n default: text: 0xcbcbcbff,\n symbol: text: 0x42a2cfff,\n type: text: 0xfec746ff,\n local: text: 0x98bc80ff,\n register: text: 0xb7afd5ff,\n keyword: text: 0xb38d4cff,\n delimiter_or_operator: text: 0x767676ff,\n numeric: text: 0x98abb1ff,\n numeric_alt_digit_group: text: 0x738287ff,\n string: text: 0x98abb1ff,\n meta: text: 0xd96759ff,\n comment: text: 0x717171ff,\n line_info_0: background: 0x99503dff,\n line_info_1: background: 0xfe8249ff,\n line_info_2: background: 0xffba17ff,\n line_info_3: background: 0xcefd69ff,\n line_info_4: background: 0x99503dff,\n line_info_5: background: 0xfe8249ff,\n line_info_6: background: 0xcefd69ff,\n line_info_7: background: 0x99503dff,\n }\n\n debug_state:\n {\n thread_0: 0xffcb7fff,\n thread_1: 0xb2ff65ff,\n thread_2: 0xff99e5ff,\n thread_3: 0x6598ffff,\n thread_4: 0x65ffcbff,\n thread_5: 0xff9819ff,\n thread_6: 0x9932ffff,\n thread_7: 0x65ff4cff,\n thread_unwound: 0xb2ccd8ff,\n thread_error: 0xb23219ff,\n breakpoint: 0xa72911ff,\n }\n}\n"), +str8_lit_comp("theme:\n{\n background: 0x1b1b1bff,\n alt: background: 0x222222ff,\n good_pop: background: 0x2c5b36ff,\n bad_pop: background: 0x803425ff,\n good: text: 0x32a852ff,\n bad: text: 0xcf5242ff,\n pop: background: 0x355b6eff,\n border: 0x404040ff,\n text: 0xe5e5e5ff,\n weak: text: 0xe5e5e5ff,\n hover: 0xffffffff,\n focus: 0xfda200ff,\n cursor: 0x8aff00ff,\n selection: 0x99ccffff,\n inactive: background: 0x0000002f,\n drop_shadow: 0x0000007f,\n\n code_default: 0xcbcbcbff,\n code_symbol: 0x42a2cfff,\n code_type: 0xfec746ff,\n code_local: 0x98bc80ff,\n code_register: 0xb7afd5ff,\n code_keyword: 0xb38d4cff,\n code_delimiter_or_operator: 0x767676ff,\n code_numeric: 0x98abb1ff,\n code_numeric_alt_digit_group: 0x738287ff,\n code_string: 0x98abb1ff,\n code_meta: 0xd96759ff,\n code_comment: 0x717171ff,\n line_info_0: 0x99503dff,\n line_info_1: 0xfe8249ff,\n line_info_2: 0xffba17ff,\n line_info_3: 0xcefd69ff,\n line_info_4: 0x99503dff,\n line_info_5: 0xfe8249ff,\n line_info_6: 0xcefd69ff,\n line_info_7: 0x99503dff,\n thread_0: 0xffcb7fff,\n thread_1: 0xb2ff65ff,\n thread_2: 0xff99e5ff,\n thread_3: 0x6598ffff,\n thread_4: 0x65ffcbff,\n thread_5: 0xff9819ff,\n thread_6: 0x9932ffff,\n thread_7: 0x65ff4cff,\n thread_unwound: 0xb2ccd8ff,\n thread_error: 0xb23219ff,\n breakpoint: 0xa72911ff,\n\n floating:\n {\n background: 0x2222225f,\n background: alt: 0x2222225f,\n border: 0xbfbfbf1f,\n }\n\n menu_bar:\n {\n background: 0x2b3740ff,\n border: 0x3e4c57ff,\n }\n\n good:\n {\n background: 0x2c5b36ff,\n border: 0x3f3f3fff,\n }\n\n bad:\n {\n background: 0x803425ff,\n border: 0xe88774ff,\n }\n\n pop:\n {\n background: 0x355b6eff,\n border: 0x355b6eff,\n }\n\n scroll_bar:\n {\n background: 0x2b2b2bff,\n border: 0x3f3f3fff,\n }\n\n implicit:\n {\n background: 0x00000000,\n border: 0x00000000,\n }\n\n hollow:\n {\n background: 0x00000000,\n border: 0xffffff1f,\n }\n\n tab:\n {\n background: 0x6f5135ff,\n border: 0x8a6e54ff,\n inactive:\n {\n background: 0x2b3740ff,\n border: 0x3e4c57ff,\n }\n }\n\n drop_site:\n {\n background: 0xffffff05,\n border: 0xffffff0f,\n }\n}\n"), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), diff --git a/src/raddbg/raddbg.mdesk b/src/raddbg/raddbg.mdesk index a196fe68..bb2db7ca 100644 --- a/src/raddbg/raddbg.mdesk +++ b/src/raddbg/raddbg.mdesk @@ -989,9 +989,11 @@ RD_ThemePresetTable: { background: 0x1b1b1bff, alt: background: 0x222222ff, - good: background: 0x222222ff, - bad: background: 0x222222ff, - pop: background: 0x222222ff, + good_pop: background: 0x2c5b36ff, + bad_pop: background: 0x803425ff, + good: text: 0x32a852ff, + bad: text: 0xcf5242ff, + pop: background: 0x355b6eff, border: 0x404040ff, text: 0xe5e5e5ff, weak: text: 0xe5e5e5ff, @@ -999,6 +1001,47 @@ RD_ThemePresetTable: focus: 0xfda200ff, cursor: 0x8aff00ff, selection: 0x99ccffff, + inactive: background: 0x0000002f, + drop_shadow: 0x0000007f, + + code_default: 0xcbcbcbff, + code_symbol: 0x42a2cfff, + code_type: 0xfec746ff, + code_local: 0x98bc80ff, + code_register: 0xb7afd5ff, + code_keyword: 0xb38d4cff, + code_delimiter_or_operator: 0x767676ff, + code_numeric: 0x98abb1ff, + code_numeric_alt_digit_group: 0x738287ff, + code_string: 0x98abb1ff, + code_meta: 0xd96759ff, + code_comment: 0x717171ff, + line_info_0: 0x99503dff, + line_info_1: 0xfe8249ff, + line_info_2: 0xffba17ff, + line_info_3: 0xcefd69ff, + line_info_4: 0x99503dff, + line_info_5: 0xfe8249ff, + line_info_6: 0xcefd69ff, + line_info_7: 0x99503dff, + thread_0: 0xffcb7fff, + thread_1: 0xb2ff65ff, + thread_2: 0xff99e5ff, + thread_3: 0x6598ffff, + thread_4: 0x65ffcbff, + thread_5: 0xff9819ff, + thread_6: 0x9932ffff, + thread_7: 0x65ff4cff, + thread_unwound: 0xb2ccd8ff, + thread_error: 0xb23219ff, + breakpoint: 0xa72911ff, + + floating: + { + background: 0x2222225f, + background: alt: 0x2222225f, + border: 0xbfbfbf1f, + } menu_bar: { @@ -1030,6 +1073,18 @@ RD_ThemePresetTable: border: 0x3f3f3fff, } + implicit: + { + background: 0x00000000, + border: 0x00000000, + } + + hollow: + { + background: 0x00000000, + border: 0xffffff1f, + } + tab: { background: 0x6f5135ff, @@ -1043,47 +1098,8 @@ RD_ThemePresetTable: drop_site: { - background: 0xffffffff, - border: 0xffffffff, - } - - code: - { - default: text: 0xcbcbcbff, - symbol: text: 0x42a2cfff, - type: text: 0xfec746ff, - local: text: 0x98bc80ff, - register: text: 0xb7afd5ff, - keyword: text: 0xb38d4cff, - delimiter_or_operator: text: 0x767676ff, - numeric: text: 0x98abb1ff, - numeric_alt_digit_group: text: 0x738287ff, - string: text: 0x98abb1ff, - meta: text: 0xd96759ff, - comment: text: 0x717171ff, - line_info_0: background: 0x99503dff, - line_info_1: background: 0xfe8249ff, - line_info_2: background: 0xffba17ff, - line_info_3: background: 0xcefd69ff, - line_info_4: background: 0x99503dff, - line_info_5: background: 0xfe8249ff, - line_info_6: background: 0xcefd69ff, - line_info_7: background: 0x99503dff, - } - - debug_state: - { - thread_0: 0xffcb7fff, - thread_1: 0xb2ff65ff, - thread_2: 0xff99e5ff, - thread_3: 0x6598ffff, - thread_4: 0x65ffcbff, - thread_5: 0xff9819ff, - thread_6: 0x9932ffff, - thread_7: 0x65ff4cff, - thread_unwound: 0xb2ccd8ff, - thread_error: 0xb23219ff, - breakpoint: 0xa72911ff, + background: 0xffffff05, + border: 0xffffff0f, } } ``` diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 5c572a61..53816c65 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -1997,10 +1997,10 @@ rd_hsva_from_cfg(RD_Cfg *cfg) } internal Vec4F32 -rd_rgba_from_cfg(RD_Cfg *cfg) +rd_color_from_cfg(RD_Cfg *cfg) { Vec4F32 hsva = rd_hsva_from_cfg(cfg); - Vec4F32 rgba = rgba_from_hsva(hsva); + Vec4F32 rgba = linear_from_srgba(rgba_from_hsva(hsva)); return rgba; } @@ -2105,7 +2105,7 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg) String8 expr_string = rd_expr_from_cfg(cfg); String8 collection_name = {0}; String8 file_path = {0}; - Vec4F32 rgba = linear_from_srgba(rd_rgba_from_cfg(cfg)); + Vec4F32 rgba = linear_from_srgba(rd_color_from_cfg(cfg)); if(rgba.w == 0) { rgba = ui_top_palette()->text; @@ -2686,12 +2686,12 @@ rd_tag_from_cfg(Arena *arena, RD_Cfg *cfg) //~ rjf: Control Entity Info Extraction internal Vec4F32 -rd_rgba_from_ctrl_entity(CTRL_Entity *entity) +rd_color_from_ctrl_entity(CTRL_Entity *entity) { Vec4F32 result = {0}; if(entity->rgba != 0) { - result = rgba_from_u32(entity->rgba); + result = linear_from_srgba(rgba_from_u32(entity->rgba)); } if(entity->rgba == 0) switch(entity->kind) { @@ -2702,11 +2702,11 @@ rd_rgba_from_ctrl_entity(CTRL_Entity *entity) CTRL_Entity *main_thread = ctrl_entity_child_from_kind(process, CTRL_EntityKind_Thread); if(main_thread != entity) { - result = srgba_from_linear(rd_rgba_from_theme_color(RD_ThemeColor_Thread1)); + result = rd_color_from_tags(str8_array_zero(), str8_lit("thread_1")); } else { - result = srgba_from_linear(rd_rgba_from_theme_color(RD_ThemeColor_Thread0)); + result = rd_color_from_tags(str8_array_zero(), str8_lit("thread_0")); } }break; } @@ -2735,7 +2735,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e //- rjf: unpack entity info F32 extras_size = ui_top_font_size()*0.95f; - Vec4F32 color = linear_from_srgba(rd_rgba_from_ctrl_entity(entity)); + Vec4F32 color = rd_color_from_ctrl_entity(entity); if(color.w == 0) { color = ui_top_palette()->text; @@ -2782,7 +2782,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e { CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity, CTRL_EntityKind_Process); String8 process_name = rd_name_from_ctrl_entity(arena, process); - Vec4F32 process_color = rd_rgba_from_ctrl_entity(process); + Vec4F32 process_color = rd_color_from_ctrl_entity(process); if(process_color.w == 0) { process_color = color; @@ -2813,6 +2813,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e //- rjf: threads get callstack extras if(entity->kind == CTRL_EntityKind_Thread && include_extras) { + Vec4F32 symbol_color = rd_color_from_tags(str8_array_zero(), str8_lit("code_symbol")); dr_fstrs_push_new(arena, &result, ¶ms, str8_lit(" ")); DI_Scope *di_scope = di_scope_open(); CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity, CTRL_EntityKind_Process); @@ -2834,7 +2835,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e name = push_str8_copy(arena, name); if(name.size != 0) { - dr_fstrs_push_new(arena, &result, ¶ms, name, .size = extras_size, .color = rd_rgba_from_theme_color(RD_ThemeColor_CodeSymbol)); + dr_fstrs_push_new(arena, &result, ¶ms, name, .size = extras_size, .color = symbol_color); if(idx+1 < unwind.frames.count) { dr_fstrs_push_new(arena, &result, ¶ms, str8_lit(" > "), .color = secondary_color, .size = extras_size); @@ -3756,7 +3757,7 @@ rd_view_ui(Rng2F32 rect) CTRL_EntityList processes = ctrl_entity_list_from_kind(d_state->ctrl_entity_store, CTRL_EntityKind_Process); //- rjf: icon & info - UI_Padding(ui_em(2.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_Padding(ui_em(2.f, 1.f)) UI_TagF("weak") { //- rjf: icon { @@ -3800,7 +3801,7 @@ rd_view_ui(Rng2F32 rect) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_em(22.f, 1.f)) UI_CornerRadius(ui_top_font_size()/2.f) - RD_Palette(RD_PaletteCode_Pop) + UI_TagF("pop") if(ui_clicked(rd_icon_buttonf(RD_IconKind_Add, 0, "Add Target"))) { rd_cmd(RD_CmdKind_RunCommand, .cmd_name = rd_cmd_kind_info_table[RD_CmdKind_AddTarget].string); @@ -3820,7 +3821,7 @@ rd_view_ui(Rng2F32 rect) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_em(22.f, 1.f)) UI_CornerRadius(ui_top_font_size()/2.f) - RD_Palette(RD_PaletteCode_Good) + UI_TagF("good_pop") { if(ui_clicked(rd_icon_buttonf(RD_IconKind_Play, 0, "Launch %S", target_name))) { @@ -3845,7 +3846,7 @@ rd_view_ui(Rng2F32 rect) //- rjf: or text if(helper_built) { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") UI_PrefHeight(ui_em(2.25f, 1.f)) UI_Row UI_Padding(ui_pct(1, 0)) @@ -3855,7 +3856,7 @@ rd_view_ui(Rng2F32 rect) } //- rjf: helper text for command lister activation - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") UI_PrefHeight(ui_em(2.25f, 1.f)) UI_Row UI_PrefWidth(ui_text_dim(10, 1)) UI_TextAlignment(UI_TextAlign_Center) @@ -4509,6 +4510,124 @@ rd_window_frame(void) ws->window_temporarily_focused_ipc = 0; ui_select_state(ws->ui); + ////////////////////////////// + //- rjf: compute window's theme + // + { + //- rjf: for this window, scan upwards, and then try the project, then the user, until we + // find explicit preset / colors trees in the config. we will prefer the tightest ones, so + // that windows can have their own colors, and have those override higher-up settings. + RD_Cfg *preset_cfg = &rd_nil_cfg; + RD_CfgList colors_cfgs = {0}; + RD_Cfg *scan_parents[] = {window, rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("project")), rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user"))}; + for EachElement(idx, scan_parents) + { + for(RD_Cfg *parent_cfg = scan_parents[idx]; parent_cfg != &rd_nil_cfg; parent_cfg = parent_cfg->parent) + { + if(preset_cfg != &rd_nil_cfg) + { + RD_Cfg *possible_preset_cfg = rd_cfg_child_from_string(parent_cfg, str8_lit("color_preset")); + if(possible_preset_cfg != &rd_nil_cfg) + { + preset_cfg = possible_preset_cfg; + } + } + RD_Cfg *colors_cfg = rd_cfg_child_from_string(parent_cfg, str8_lit("colors")); + if(colors_cfg != &rd_nil_cfg) + { + rd_cfg_list_push_front(scratch.arena, &colors_cfgs, colors_cfg); + } + if(preset_cfg != &rd_nil_cfg && colors_cfg != &rd_nil_cfg) + { + break; + } + } + } + + //- rjf: map the preset config to the associated preset tree + MD_Node *preset_tree = rd_state->theme_preset_trees[RD_ThemePreset_DefaultDark]; + if(preset_cfg != &rd_nil_cfg) + { + String8 preset_name = preset_cfg->first->string; + for EachEnumVal(RD_ThemePreset, p) + { + if(str8_match(preset_name, rd_theme_preset_code_string_table[p], 0)) + { + preset_tree = rd_state->theme_preset_trees[p]; + break; + } + } + } + + //- rjf: build tasks for color applications - each task comprises of a metadesk + // tree, describing the color patterns + typedef struct ThemeTask ThemeTask; + struct ThemeTask + { + ThemeTask *next; + MD_Node *tree; + }; + ThemeTask start_task = {0, preset_tree}; + ThemeTask *first_task = &start_task; + ThemeTask *last_task = first_task; + { + for(RD_CfgNode *n = colors_cfgs.first; n != 0; n = n->next) + { + ThemeTask *t = push_array(scratch.arena, ThemeTask, 1); + SLLQueuePush(first_task, last_task, t); + t->tree = md_tree_from_string(scratch.arena, rd_string_from_cfg_tree(scratch.arena, n->v)); + } + } + + //- rjf: apply theme tasks, build each color pattern for this window's + // structured theme + typedef struct ThemePatternNode ThemePatternNode; + struct ThemePatternNode + { + ThemePatternNode *next; + RD_ThemePattern pattern; + }; + ThemePatternNode *first_pattern = 0; + ThemePatternNode *last_pattern = 0; + U64 pattern_count = 0; + for(ThemeTask *t = first_task; t != 0; t = t->next) + { + MD_Node *tree_root = t->tree; + for(MD_Node *n = tree_root; !md_node_is_nil(n); n = md_node_rec_depth_first_pre(n, tree_root).next) + { + if(n->flags & MD_NodeFlag_Numeric && md_node_is_nil(n->first)) + { + U64 color_srgba_u64 = 0; + try_u64_from_str8_c_rules(n->string, &color_srgba_u64); + Vec4F32 color_srgba = rgba_from_u32((U32)color_srgba_u64); + Vec4F32 color_linear = linear_from_srgba(color_srgba); + String8List tags = {0}; + for(MD_Node *parent = n->parent; parent != tree_root && !md_node_is_nil(parent); parent = parent->parent) + { + str8_list_push(scratch.arena, &tags, push_str8_copy(rd_frame_arena(), parent->string)); + } + ThemePatternNode *node = push_array(scratch.arena, ThemePatternNode, 1); + node->pattern.tags = str8_array_from_list(rd_frame_arena(), &tags); + node->pattern.linear = color_linear; + SLLQueuePush(first_pattern, last_pattern, node); + pattern_count += 1; + } + } + } + + //- rjf: convert to final pattern array + ws->theme = push_array(rd_frame_arena(), RD_Theme, 1); + ws->theme->patterns_count = pattern_count; + ws->theme->patterns = push_array(rd_frame_arena(), RD_ThemePattern, ws->theme->patterns_count); + { + U64 idx = 0; + for(ThemePatternNode *n = first_pattern; n != 0; n = n->next, idx += 1) + { + ws->theme->patterns[idx] = n->pattern; + } + } + } + ////////////////////////////// //- rjf: pre-emptively rasterize common glyphs on the first frame // @@ -4787,18 +4906,18 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_FontSize(ui_top_font_size() - 1.f) UI_CornerRadius(ui_top_font_size()*0.5f) { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak|UI_BoxFlag_DrawBorder) ui_label(arch_str); + UI_TagF("weak") UI_FlagsAdd(UI_BoxFlag_DrawBorder) ui_label(arch_str); ui_spacer(ui_em(0.5f, 1.f)); if(ctrl_entity->kind == CTRL_EntityKind_Thread || ctrl_entity->kind == CTRL_EntityKind_Process) { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak|UI_BoxFlag_DrawBorder) ui_labelf("ID: %i", (U32)ctrl_entity->id); + UI_TagF("weak") UI_FlagsAdd(UI_BoxFlag_DrawBorder) ui_labelf("ID: %i", (U32)ctrl_entity->id); } } } // rjf: debug info status - if(ctrl_entity->kind == CTRL_EntityKind_Module) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + if(ctrl_entity->kind == CTRL_EntityKind_Module) UI_TagF("weak") { DI_Scope *di_scope = di_scope_open(); DI_Key dbgi_key = ctrl_dbgi_key_from_module(ctrl_entity); @@ -4821,6 +4940,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: unwind if(ctrl_entity->kind == CTRL_EntityKind_Thread) { + Vec4F32 symbol_color = rd_color_from_tags(str8_array_zero(), str8_lit("code_symbol")); CTRL_Entity *process = ctrl_entity_ancestor_from_kind(ctrl_entity, CTRL_EntityKind_Process); CTRL_Unwind base_unwind = d_query_cached_unwind_from_thread(ctrl_entity); CTRL_CallStack call_stack = ctrl_call_stack_from_unwind(scratch.arena, di_scope, process, &base_unwind); @@ -4849,21 +4969,21 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The name.str = rdi_name_from_procedure(rdi, procedure, &name.size); name.size = Min(512, name.size); } - UI_TextAlignment(UI_TextAlign_Left) RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(12.f, 1)) ui_labelf("0x%I64x", rip_vaddr); + UI_TextAlignment(UI_TextAlign_Left) RD_Font(RD_FontSlot_Code) UI_TagF("weak") UI_PrefWidth(ui_em(12.f, 1)) ui_labelf("0x%I64x", rip_vaddr); if(f->parent_num != 0) { - RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_label(str8_lit("[inlined]")); + RD_Font(RD_FontSlot_Code) UI_TagF("weak") UI_PrefWidth(ui_text_dim(10, 1)) ui_label(str8_lit("[inlined]")); } if(name.size != 0) { RD_Font(RD_FontSlot_Code) UI_PrefWidth(ui_text_dim(10, 1)) { - rd_code_label(1.f, 0, rd_rgba_from_theme_color(RD_ThemeColor_CodeSymbol), name); + rd_code_label(1.f, 0, symbol_color, name); } } else { - RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_labelf("[??? in %S]", module_name); + RD_Font(RD_FontSlot_Code) UI_TagF("weak") UI_PrefWidth(ui_text_dim(10, 1)) ui_labelf("[??? in %S]", module_name); } } } @@ -4892,8 +5012,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_Size main_width = ui_top_pref_width(); UI_Size main_height = ui_top_pref_height(); UI_TextAlign main_text_align = ui_top_text_alignment(); - RD_Palette(RD_PaletteCode_Tab) - UI_Tooltip + UI_Tooltip UI_PrefWidth(main_width) UI_PrefHeight(main_height) UI_TextAlignment(main_text_align) @@ -5287,9 +5406,9 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The { ui_set_next_pref_width(ui_children_sum(1)); ui_set_next_flags(UI_BoxFlag_DrawBorder); - UI_Row UI_Padding(ui_em(0.5f, 1.f)) + UI_Row UI_Padding(ui_em(0.5f, 1.f)) UI_TagF("weak") { - UI_Box *box = ui_build_box_from_key(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak, ui_key_zero()); + UI_Box *box = ui_build_box_from_key(UI_BoxFlag_DrawText, ui_key_zero()); ui_box_equip_display_string(box, item->kind_name); } } @@ -5299,7 +5418,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: description if(flags & RD_ListerFlag_Descriptions) { - if(item->description.size != 0) UI_WidthFill UI_Row UI_PrefWidth(ui_text_dim(1, 0)) UI_Flags(UI_BoxFlag_DrawTextWeak) + if(item->description.size != 0) UI_WidthFill UI_Row UI_PrefWidth(ui_text_dim(1, 0)) UI_TagF("weak") { UI_Box *box = ui_label(item->description).box; ui_box_equip_fuzzy_match_ranges(box, &item->description__matches); @@ -6117,9 +6236,9 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // if(ws->drop_completion_paths.node_count != 0) { - UI_CtxMenu(rd_state->drop_completion_key) UI_PrefWidth(ui_em(40.f, 1.f)) + UI_CtxMenu(rd_state->drop_completion_key) UI_PrefWidth(ui_em(40.f, 1.f)) UI_TagF("implicit") { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") for(String8Node *n = ws->drop_completion_paths.first; n != 0; n = n->next) { UI_Row UI_Padding(ui_em(1.f, 1.f)) @@ -6217,11 +6336,11 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_WidthFill UI_PrefHeight(ui_children_sum(1.f)) UI_Column UI_Padding(ui_pct(1, 0)) { UI_TextRasterFlags(rd_raster_flags_from_slot(RD_FontSlot_Main)) UI_FontSize(ui_top_font_size()*2.f) UI_PrefHeight(ui_em(3.f, 1.f)) ui_label(rd_state->popup_title); - UI_PrefHeight(ui_em(3.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(rd_state->popup_desc); + UI_PrefHeight(ui_em(3.f, 1.f)) UI_TagF("weak") ui_label(rd_state->popup_desc); ui_spacer(ui_em(1.5f, 1.f)); UI_Row UI_Padding(ui_pct(1.f, 0.f)) UI_PrefWidth(ui_em(16.f, 1.f)) UI_PrefHeight(ui_em(3.5f, 1.f)) UI_CornerRadius(ui_top_font_size()*0.5f) { - RD_Palette(RD_PaletteCode_Pop) + UI_TagF("pop") if(ui_clicked(ui_buttonf("OK")) || (ui_key_match(bg_box->default_nav_focus_hot_key, ui_key_zero()) && ui_slot_press(UI_EventActionSlot_Accept))) { rd_cmd(RD_CmdKind_PopupAccept); @@ -6248,8 +6367,8 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The os_window_push_custom_edges(ws->os, window_edge_px); os_window_push_custom_title_bar(ws->os, dim_2f32(top_bar_rect).y); ui_set_next_flags(UI_BoxFlag_DefaultFocusNav|UI_BoxFlag_DisableFocusOverlay); - RD_Palette(RD_PaletteCode_MenuBar) - UI_Focus((ws->menu_bar_focused && window_is_focused && !ui_any_ctx_menu_is_open() && !ws->hover_eval_focused) ? UI_FocusKind_On : UI_FocusKind_Null) + UI_Focus((ws->menu_bar_focused && window_is_focused && !ui_any_ctx_menu_is_open() && !ws->hover_eval_focused) ? UI_FocusKind_On : UI_FocusKind_Null) + UI_TagF("menu_bar") UI_Pane(top_bar_rect, str8_lit("###top_bar")) UI_WidthFill UI_Row UI_Focus(UI_FocusKind_Null) @@ -6281,7 +6400,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The { // rjf: file menu UI_Key file_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_file_menu_key_")); - UI_CtxMenu(file_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) + UI_CtxMenu(file_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) UI_TagF("implicit") { String8 cmds[] = { @@ -6305,7 +6424,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: window menu UI_Key window_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_window_menu_key_")); - UI_CtxMenu(window_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) + UI_CtxMenu(window_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) UI_TagF("implicit") { String8 cmds[] = { @@ -6325,7 +6444,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: panel menu UI_Key panel_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_panel_menu_key_")); - UI_CtxMenu(panel_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) + UI_CtxMenu(panel_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) UI_TagF("implicit") { String8 cmds[] = { @@ -6369,7 +6488,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: view menu UI_Key view_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_view_menu_key_")); - UI_CtxMenu(view_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) + UI_CtxMenu(view_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) UI_TagF("implicit") { String8 cmds[] = { @@ -6423,7 +6542,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: targets menu UI_Key targets_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_targets_menu_key_")); - UI_CtxMenu(targets_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) + UI_CtxMenu(targets_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) UI_TagF("implicit") { Temp scratch = scratch_begin(0, 0); String8 cmds[] = @@ -6441,7 +6560,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: ctrl menu UI_Key ctrl_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_ctrl_menu_key_")); - UI_CtxMenu(ctrl_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) + UI_CtxMenu(ctrl_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) UI_TagF("implicit") { String8 cmds[] = { @@ -6471,9 +6590,9 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: help menu UI_Key help_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_help_menu_key_")); - UI_CtxMenu(help_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) + UI_CtxMenu(help_menu_key) UI_PrefWidth(ui_em(50.f, 1.f)) UI_TagF("implicit") { - UI_Row UI_TextAlignment(UI_TextAlign_Center) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_Row UI_TextAlignment(UI_TextAlign_Center) UI_TagF("weak") ui_label(str8_lit(BUILD_TITLE_STRING_LITERAL)); ui_spacer(ui_em(1.f, 1.f)); UI_PrefHeight(ui_children_sum(1)) UI_Row UI_Padding(ui_pct(1, 0)) @@ -6496,7 +6615,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The rd_cmd_binding_buttons(rd_cmd_kind_info_table[RD_CmdKind_OpenLister].string); } ui_spacer(ui_em(1.f, 1.f)); - RD_Palette(RD_PaletteCode_Pop) + UI_TagF("pop") UI_Row UI_Padding(ui_pct(1, 0)) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_text_dim(10, 1)) UI_CornerRadius(ui_top_font_size()*0.5f) { @@ -6610,7 +6729,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The ui_spacer(ui_em(0.75f, 1)); // rjf: conversion task visualization - UI_PrefWidth(ui_text_dim(10, 1)) UI_HeightFill RD_Palette(RD_PaletteCode_Pop) + UI_PrefWidth(ui_text_dim(10, 1)) UI_HeightFill UI_TagF("pop") { Temp scratch = scratch_begin(0, 0); RD_CfgList tasks = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("conversion_task")); @@ -6658,7 +6777,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The if(can_play || !have_targets || processes.count == 0) UI_TextAlignment(UI_TextAlign_Center) UI_Flags((can_play ? 0 : UI_BoxFlag_Disabled)) - RD_Palette(can_play ? RD_PaletteCode_Good : RD_PaletteCode_MenuBar) + UI_TagF(can_play ? "good" : "") { UI_Signal sig = ui_button(rd_icon_kind_text_table[RD_IconKind_Play]); os_window_push_custom_title_bar_client_area(ws->os, sig.box->rect); @@ -6700,7 +6819,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The //- rjf: restart button else UI_TextAlignment(UI_TextAlign_Center) - RD_Palette(RD_PaletteCode_Good) + UI_TagF("good") { UI_Signal sig = ui_button(rd_icon_kind_text_table[RD_IconKind_Redo]); os_window_push_custom_title_bar_client_area(ws->os, sig.box->rect); @@ -6721,7 +6840,6 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The //- rjf: pause button UI_TextAlignment(UI_TextAlign_Center) UI_Flags(can_pause ? 0 : UI_BoxFlag_Disabled) - RD_Palette(can_pause ? RD_PaletteCode_Pop : RD_PaletteCode_MenuBar) { UI_Signal sig = ui_button(rd_icon_kind_text_table[RD_IconKind_Pause]); os_window_push_custom_title_bar_client_area(ws->os, sig.box->rect); @@ -6747,7 +6865,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The //- rjf: stop button UI_TextAlignment(UI_TextAlign_Center) UI_Flags(can_stop ? 0 : UI_BoxFlag_Disabled) - RD_Palette(can_stop ? RD_PaletteCode_Bad : RD_PaletteCode_MenuBar) + UI_TagF(can_stop ? "bad" : "") { UI_Signal sig = {0}; { @@ -6873,7 +6991,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The ui_spacer(ui_pct(1, 0)); // rjf: loaded user viz - if(do_user_prof) RD_Palette(RD_PaletteCode_Pop) + if(do_user_prof) UI_TagF("pop") { ui_set_next_pref_width(ui_children_sum(1)); ui_set_next_child_layout_axis(Axis2_X); @@ -6907,7 +7025,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The } // rjf: loaded project viz - if(do_user_prof) RD_Palette(RD_PaletteCode_Pop) + if(do_user_prof) UI_TagF("pop") { ui_set_next_pref_width(ui_children_sum(1)); ui_set_next_child_layout_axis(Axis2_X); @@ -6966,7 +7084,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The max_sig = rd_icon_buttonf(RD_IconKind_Window, 0, "##maximize"); } UI_PrefWidth(ui_px(button_dim, 1.f)) - RD_Palette(RD_PaletteCode_Bad) + UI_TagF("bad_pop") { cls_sig = rd_icon_buttonf(RD_IconKind_X, 0, "##close"); } @@ -7062,6 +7180,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The if(build_hover_eval && ws->hover_eval_string.size != 0 && hover_eval_is_open) RD_Font(RD_FontSlot_Code) UI_FontSize(rd_font_size_from_slot(RD_FontSlot_Main)) + UI_TagF("floating") { F32 hover_eval_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "hover_eval_open_t"), 1.f); RD_Cfg *root = rd_immediate_cfg_from_keyf("hover_eval_%p", ws); @@ -7241,7 +7360,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_Flags(UI_BoxFlag_DrawBackground) UI_TextAlignment(UI_TextAlign_Center) UI_CornerRadius(4) - RD_Palette(RD_PaletteCode_Pop) + UI_TagF("pop") ui_labelf("Currently rebinding \"%S\" hotkey", display_name); } @@ -7374,7 +7493,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The ui_anim(ui_key_from_stringf(ui_key_zero(), "drop_site_v2"), future_split_rect_target.x1, .initial = future_split_rect_target_center.x), ui_anim(ui_key_from_stringf(ui_key_zero(), "drop_site_v3"), future_split_rect_target.y1, .initial = future_split_rect_target_center.y), }; - UI_Rect(future_split_rect) RD_Palette(RD_PaletteCode_DropSite) UI_CornerRadius(ui_top_font_size()*2.f) + UI_Rect(future_split_rect) UI_TagF("drop_site") UI_CornerRadius(ui_top_font_size()*2.f) { ui_build_box_from_key(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder, ui_key_zero()); } @@ -7465,7 +7584,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The ui_anim(ui_key_from_stringf(ui_key_zero(), "drop_site_v2"), future_split_rect_target.x1, .initial = future_split_rect_target_center.x), ui_anim(ui_key_from_stringf(ui_key_zero(), "drop_site_v3"), future_split_rect_target.y1, .initial = future_split_rect_target_center.y), }; - UI_Rect(future_split_rect) RD_Palette(RD_PaletteCode_DropSite) UI_CornerRadius(ui_top_font_size()*2.f) + UI_Rect(future_split_rect) UI_TagF("drop_site") UI_CornerRadius(ui_top_font_size()*2.f) { ui_build_box_from_key(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder, ui_key_zero()); } @@ -7766,13 +7885,14 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_Parent(site_box_viz) UI_WidthFill UI_HeightFill UI_Padding(ui_px(padding, 1.f)) { ui_set_next_child_layout_axis(split_axis); - UI_Box *row_or_column = ui_build_box_from_key(0, ui_key_zero()); UI_Parent(row_or_column) UI_Padding(ui_px(padding, 1.f)) + UI_Box *row_or_column = ui_build_box_from_key(0, ui_key_zero()); + UI_Parent(row_or_column) UI_Padding(ui_px(padding, 1.f)) UI_TagF("drop_site") { if(split_side == Side_Min) { ui_set_next_flags(UI_BoxFlag_DrawBackground); } - RD_Palette(RD_PaletteCode_DropSite) ui_build_box_from_key(UI_BoxFlag_DrawBorder, ui_key_zero()); + ui_build_box_from_key(UI_BoxFlag_DrawBorder, ui_key_zero()); ui_spacer(ui_px(padding, 1.f)); if(split_side == Side_Max) { ui_set_next_flags(UI_BoxFlag_DrawBackground); } - RD_Palette(RD_PaletteCode_DropSite) ui_build_box_from_key(UI_BoxFlag_DrawBorder, ui_key_zero()); + ui_build_box_from_key(UI_BoxFlag_DrawBorder, ui_key_zero()); } } } @@ -7782,7 +7902,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The { ui_set_next_child_layout_axis(split_axis); UI_Box *row_or_column = ui_build_box_from_key(0, ui_key_zero()); - UI_Parent(row_or_column) UI_Padding(ui_px(padding, 1.f)) RD_Palette(RD_PaletteCode_DropSite) + UI_Parent(row_or_column) UI_Padding(ui_px(padding, 1.f)) UI_TagF("drop_site") { ui_build_box_from_key(UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground, ui_key_zero()); } @@ -7831,7 +7951,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The ui_anim(ui_key_from_stringf(ui_key_zero(), "drop_site_v2"), future_split_rect_target.x1, .initial = future_split_rect_target_center.x), ui_anim(ui_key_from_stringf(ui_key_zero(), "drop_site_v3"), future_split_rect_target.y1, .initial = future_split_rect_target_center.y), }; - UI_Rect(future_split_rect) RD_Palette(RD_PaletteCode_DropSite) UI_CornerRadius(ui_top_font_size()*2.f) + UI_Rect(future_split_rect) UI_TagF("drop_site") UI_CornerRadius(ui_top_font_size()*2.f) { ui_build_box_from_key(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder, ui_key_zero()); } @@ -7875,7 +7995,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_Parent(filter_box) UI_WidthFill UI_HeightFill { UI_PrefWidth(ui_em(3.f, 1.f)) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") RD_Font(RD_FontSlot_Icons) UI_TextAlignment(UI_TextAlign_Center) ui_label(rd_icon_kind_text_table[RD_IconKind_Find]); @@ -7915,13 +8035,8 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // if(build_panel) if(panel != panel_tree.focused) { - Vec4F32 darken_color = rd_rgba_from_theme_color(RD_ThemeColor_InactivePanelOverlay); - darken_color.w *= 0.2f; - UI_Palette(ui_build_palette(0, .background = darken_color)) - UI_Rect(content_rect) - { + UI_Rect(content_rect) UI_TagF("inactive") ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); - } } ////////////////////////// @@ -7978,7 +8093,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_Parent(view_container_box) if(selected_tab == &rd_nil_cfg) { ui_set_next_flags(UI_BoxFlag_DefaultFocusNav); - UI_Focus(UI_FocusKind_On) UI_WidthFill UI_HeightFill UI_NamedColumn(str8_lit("empty_view")) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_Focus(UI_FocusKind_On) UI_WidthFill UI_HeightFill UI_NamedColumn(str8_lit("empty_view")) UI_TagF("weak") UI_Padding(ui_pct(1, 0)) UI_Focus(UI_FocusKind_Null) { UI_PrefHeight(ui_em(3.f, 1.f)) @@ -7987,7 +8102,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_em(15.f, 1.f)) UI_CornerRadius(ui_top_font_size()/2.f) - RD_Palette(RD_PaletteCode_Bad) + UI_TagF("bad_pop") { if(ui_clicked(rd_icon_buttonf(RD_IconKind_X, 0, "Close Panel"))) { @@ -8180,7 +8295,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The ////////////////////////// //- rjf: build tab bar contents // - if(build_panel) UI_Focus(UI_FocusKind_Off) UI_Parent(tab_bar_box) UI_Padding(ui_em(0.5f, 1.f)) UI_PrefHeight(ui_pct(1, 0)) + if(build_panel) UI_Focus(UI_FocusKind_Off) UI_Parent(tab_bar_box) UI_Padding(ui_em(0.5f, 1.f)) UI_PrefHeight(ui_pct(1, 0)) UI_TagF("tab") { F32 corner_radius = ui_top_font_size()*0.6f; TabTask start_boundary_tab_task = {first_tab_task, &rd_nil_cfg}; @@ -8207,21 +8322,16 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: choose palette B32 omit_name = 0; - RD_PaletteCode palette_code = RD_PaletteCode_TabInactive; - if(tab_is_selected) - { - palette_code = RD_PaletteCode_Tab; - } if(rd_drag_is_active() && rd_state->drag_drop_regs->view == tab->id && rd_state->drag_drop_regs_slot == RD_RegSlot_View) { - palette_code = RD_PaletteCode_DropSite; omit_name = 1; } // rjf: build tab container box UI_Parent(tab_column_box) UI_PrefHeight(ui_px(tab_bar_vheight, 1)) - RD_Palette(palette_code) + UI_TagF(omit_name ? "hollow" : "") + UI_TagF(!tab_is_selected ? "inactive" : "") { if(panel->tab_side == Side_Max) { @@ -8254,14 +8364,21 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_PrefWidth(ui_px(tab_close_width_px, 1.f)) UI_TextAlignment(UI_TextAlign_Center) RD_Font(RD_FontSlot_Icons) UI_FontSize(rd_font_size_from_slot(RD_FontSlot_Icons)*0.75f) - UI_Flags(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") UI_CornerRadius00(0) UI_CornerRadius01(0) { UI_Palette *palette = ui_build_palette(ui_top_palette()); palette->background = v4f32(0, 0, 0, 0); ui_set_next_palette(palette); - UI_Signal sig = ui_buttonf("%S###close_view_%p", rd_icon_kind_text_table[RD_IconKind_X], tab); + ui_set_next_hover_cursor(OS_Cursor_HandPoint); + UI_Box *close_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable| + UI_BoxFlag_DrawBorder| + UI_BoxFlag_DrawText| + UI_BoxFlag_DrawHotEffects| + UI_BoxFlag_DrawActiveEffects, + "%S###close_view_%p", rd_icon_kind_text_table[RD_IconKind_X], tab); + UI_Signal sig = ui_signal_from_box(close_box); if(ui_clicked(sig) || ui_middle_clicked(sig)) { rd_cmd(RD_CmdKind_CloseTab); @@ -8317,7 +8434,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: build spot container box UI_Parent(tab_column_box) UI_PrefHeight(ui_px(tab_bar_vheight, 1)) - RD_Palette(RD_PaletteCode_DropSite) + UI_TagF("hollow") { if(panel->tab_side == Side_Max) { @@ -8363,12 +8480,13 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The UI_CornerRadius11(panel->tab_side == Side_Max ? corner_radius : 0) RD_Font(RD_FontSlot_Icons) UI_FontSize(ui_top_font_size()) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("implicit") + UI_TagF("weak") UI_HoverCursor(OS_Cursor_HandPoint) { - UI_Box *add_new_box = ui_build_box_from_stringf(UI_BoxFlag_DrawBackground| - UI_BoxFlag_DrawText| + UI_Box *add_new_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText| UI_BoxFlag_DrawBorder| + UI_BoxFlag_DrawBackground| UI_BoxFlag_DrawHotEffects| UI_BoxFlag_DrawActiveEffects| UI_BoxFlag_Clickable| @@ -8568,6 +8686,9 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The //- rjf: unpack settings B32 do_background_blur = rd_setting_b32_from_name(str8_lit("background_blur")); + Vec4F32 base_background_color = rd_color_from_tags(str8_array_zero(), str8_lit("background")); + Vec4F32 base_border_color = rd_color_from_tags(str8_array_zero(), str8_lit("border")); + Vec4F32 drop_shadow_color = rd_color_from_tags(str8_array_zero(), str8_lit("drop_shadow")); //- rjf: set up heatmap buckets F32 heatmap_bucket_size = 32.f; @@ -8586,14 +8707,12 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The //- rjf: draw background color { - Vec4F32 bg_color = rd_rgba_from_theme_color(RD_ThemeColor_BaseBackground); - dr_rect(os_client_rect_from_window(ws->os), bg_color, 0, 0, 0); + dr_rect(os_client_rect_from_window(ws->os), base_background_color, 0, 0, 0); } //- rjf: draw window border { - Vec4F32 color = rd_rgba_from_theme_color(RD_ThemeColor_BaseBorder); - dr_rect(os_client_rect_from_window(ws->os), color, 0, 1.f, 0.5f); + dr_rect(os_client_rect_from_window(ws->os), base_border_color, 0, 1.f, 0.5f); } //- rjf: recurse & draw @@ -8638,7 +8757,6 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The if(box->flags & UI_BoxFlag_DrawDropShadow) { Rng2F32 drop_shadow_rect = shift_2f32(pad_2f32(box->rect, 8), v2f32(4, 4)); - Vec4F32 drop_shadow_color = rd_rgba_from_theme_color(RD_ThemeColor_DropShadow); dr_rect(drop_shadow_rect, drop_shadow_color, 0.8f, 0, 8.f); } @@ -8649,53 +8767,47 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The MemoryCopyArray(params->corner_radii, box->corner_radii); } + // rjf: compute effective active t + F32 effective_active_t = box->active_t; + if(!(box->flags & UI_BoxFlag_DrawActiveEffects)) + { + effective_active_t = 0; + } + F32 t = box->hot_t*(1-effective_active_t); + + // rjf: compute background color + Vec4F32 box_background_color = {0}; + if(box->flags & UI_BoxFlag_DrawBackground) + { + box_background_color = rd_color_from_tags(box->tags, str8_lit("background")); + } + // rjf: draw background if(box->flags & UI_BoxFlag_DrawBackground) { - F32 effective_active_t = box->active_t; - if(!(box->flags & UI_BoxFlag_DrawActiveEffects)) - { - effective_active_t = 0; - } - F32 t = box->hot_t*(1-effective_active_t); - // rjf: hot effect extension (drop shadow) if(box->flags & UI_BoxFlag_DrawHotEffects) { Rng2F32 drop_shadow_rect = shift_2f32(pad_2f32(box->rect, 8), v2f32(4, 4)); - Vec4F32 drop_shadow_color = rd_rgba_from_theme_color(RD_ThemeColor_DropShadow); - drop_shadow_color.w *= t; - drop_shadow_color.w *= box->palette->colors[UI_ColorCode_Background].w; - dr_rect(drop_shadow_rect, drop_shadow_color, 0.8f, 0, 8.f); + Vec4F32 color = drop_shadow_color; + color.w *= t*box_background_color.w; + dr_rect(drop_shadow_rect, color, 0.8f, 0, 8.f); } - // rjf: main rectangle - { - Vec4F32 color = box->palette->colors[UI_ColorCode_Background]; - if(box->flags & UI_BoxFlag_DrawBad) - { - color = box->palette->colors[UI_ColorCode_BackgroundBad]; - } - else if(box->flags & UI_BoxFlag_DrawGood) - { - color = box->palette->colors[UI_ColorCode_BackgroundGood]; - } - else if(box->flags & UI_BoxFlag_DrawPop) - { - color = box->palette->colors[UI_ColorCode_BackgroundPop]; - } - R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, 1.f), color, 0, 0, 1.f); - MemoryCopyArray(inst->corner_radii, box->corner_radii); - } + // rjf: draw background + R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, 1.f), box_background_color, 0, 0, 1.f); + MemoryCopyArray(inst->corner_radii, box->corner_radii); // rjf: hot effect extension if(box->flags & UI_BoxFlag_DrawHotEffects) { + Vec4F32 hover_color = rd_color_from_tags(box->tags, str8_lit("hover")); + // rjf: brighten { + Vec4F32 color = hover_color; + color.w *= t*0.05f; R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, 1.f), v4f32(0, 0, 0, 0), 0, 0, 1.f); - Vec4F32 color = box->palette->hover; - color.w *= t*0.1f; inst->colors[Corner_00] = color; inst->colors[Corner_10] = color; MemoryCopyArray(inst->corner_radii, box->corner_radii); @@ -8704,33 +8816,18 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: soft circle around mouse if(box->hot_t > 0.01f) DR_ClipScope(box->rect) { + Vec4F32 color = hover_color; + color.w *= 0.015f*t; Vec2F32 center = ui_mouse(); F32 radius = box->font_size*12.f; - Vec4F32 color = box->palette->hover; - color.w *= 0.05f*t; dr_rect(pad_2f32(r2f32(center, center), radius), color, radius, 0, radius/3.f); } - - // rjf: slight emboss fadeoff - if(0) - { - Rng2F32 rect = r2f32p(box->rect.x0, - box->rect.y0, - box->rect.x1, - box->rect.y1); - R_Rect2DInst *inst = dr_rect(rect, v4f32(0, 0, 0, 0), 0, 0, 1.f); - inst->colors[Corner_00] = v4f32(0.f, 0.f, 0.f, 0.0f*t); - inst->colors[Corner_01] = v4f32(0.f, 0.f, 0.f, 0.3f*t); - inst->colors[Corner_10] = v4f32(0.f, 0.f, 0.f, 0.0f*t); - inst->colors[Corner_11] = v4f32(0.f, 0.f, 0.f, 0.3f*t); - MemoryCopyArray(inst->corner_radii, box->corner_radii); - } } // rjf: active effect extension if(box->flags & UI_BoxFlag_DrawActiveEffects) { - Vec4F32 shadow_color = rd_rgba_from_theme_color(RD_ThemeColor_DropShadow); + Vec4F32 shadow_color = drop_shadow_color; shadow_color.w *= 0.5f*box->active_t; Vec2F32 shadow_size = { @@ -8901,14 +8998,15 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: draw border if(b->flags & UI_BoxFlag_DrawBorder) { + Vec4F32 border_color = rd_color_from_tags(box->tags, str8_lit("border")); Rng2F32 b_border_rect = pad_2f32(b->rect, 1.f); - R_Rect2DInst *inst = dr_rect(b_border_rect, b->palette->colors[UI_ColorCode_Border], 0, 1.f, 1.f); + R_Rect2DInst *inst = dr_rect(b_border_rect, border_color, 0, 1.f, 1.f); MemoryCopyArray(inst->corner_radii, b->corner_radii); // rjf: hover effect if(b->flags & UI_BoxFlag_DrawHotEffects) { - Vec4F32 color = box->palette->hover; + Vec4F32 color = rd_color_from_tags(box->tags, str8_lit("hover")); color.w *= b->hot_t; R_Rect2DInst *inst = dr_rect(b_border_rect, color, 0, 1.f, 1.f); inst->colors[Corner_01].w *= 0.2f; @@ -8950,7 +9048,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: draw focus overlay if(b->flags & UI_BoxFlag_Clickable && !(b->flags & UI_BoxFlag_DisableFocusOverlay) && b->focus_hot_t > 0.01f) { - Vec4F32 color = box->palette->focus; + Vec4F32 color = rd_color_from_tags(box->tags, str8_lit("focus")); color.w *= 0.09f*b->focus_hot_t; R_Rect2DInst *inst = dr_rect(b->rect, color, 0, 0, 0.f); MemoryCopyArray(inst->corner_radii, b->corner_radii); @@ -8965,7 +9063,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The rect = pad_2f32(rect, 1.f); rect = intersect_2f32(window_rect, rect); } - Vec4F32 color = box->palette->focus; + Vec4F32 color = rd_color_from_tags(box->tags, str8_lit("focus")); color.w *= b->focus_active_t; R_Rect2DInst *inst = dr_rect(rect, color, 0, 1.f, 1.f); MemoryCopyArray(inst->corner_radii, b->corner_radii); @@ -8974,7 +9072,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The // rjf: disabled overlay if(b->disabled_t >= 0.005f) { - Vec4F32 disabled_overlay_color = v4f32(0, 0, 0, b->disabled_t*0.5f); + Vec4F32 disabled_overlay_color = v4f32(base_background_color.x, base_background_color.y, base_background_color.z, b->disabled_t*0.3f); R_Rect2DInst *inst = dr_rect(b->rect, disabled_overlay_color, 0, 0, 1); MemoryCopyArray(inst->corner_radii, b->corner_radii); } @@ -9020,7 +9118,9 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The //- rjf: draw border/overlay color to signify error if(ws->error_t > 0.01f) { - Vec4F32 color = rd_rgba_from_theme_color(RD_ThemeColor_BaseBackgroundBad); + String8 tags[] = {str8_lit("bad")}; + String8Array tags_array = {tags, ArrayCount(tags)}; + Vec4F32 color = rd_color_from_tags(tags_array, str8_lit("text")); color.w *= ws->error_t; Rng2F32 rect = os_client_rect_from_window(ws->os); dr_rect(pad_2f32(rect, 24.f), color, 0, 16.f, 12.f); @@ -10492,7 +10592,7 @@ rd_push_search_string(Arena *arena) //- rjf: colors internal Vec4F32 -rd_color_from_tags(String8Array tags) +rd_color_from_tags(String8Array tags, String8 name) { Vec4F32 result = {0}; { @@ -10505,23 +10605,26 @@ rd_color_from_tags(String8Array tags) { RD_ThemePattern *p = &theme->patterns[idx]; U64 match_count = 0; - for EachIndex(key_tags_idx, tags.count) + B32 name_matches = 0; + for EachIndex(key_tags_idx, tags.count+1) { + String8 key_string = key_tags_idx < tags.count ? tags.v[key_tags_idx] : name; for EachIndex(p_tags_idx, p->tags.count) { - if(str8_match(p->tags.v[p_tags_idx], tags.v[key_tags_idx], 0)) + if(str8_match(p->tags.v[p_tags_idx], key_string, 0)) { + name_matches = (key_tags_idx == tags.count); match_count += 1; break; } } } - if(match_count > best_match_count) + if(name_matches && match_count > best_match_count) { pattern = p; best_match_count = match_count; } - if(match_count == tags.count) + if(match_count == tags.count+1) { break; } @@ -11947,125 +12050,6 @@ rd_frame(void) } } - ////////////////////////////// - //- rjf: compute all window themes - // - ProfScope("compute window themes") - { - Temp scratch = scratch_begin(0, 0); - for(RD_WindowState *ws = rd_state->first_window_state; ws != &rd_nil_window_state; ws = ws->order_next) - { - //- rjf: for each window, scan upwards, and then try the project, then the user, until we - // find explicit preset / colors trees in the config. we will prefer the tightest ones, so - // that windows can have their own colors, and have those override higher-up settings. - RD_Cfg *preset_cfg = &rd_nil_cfg; - RD_CfgList colors_cfgs = {0}; - RD_Cfg *window_cfg = rd_cfg_from_id(ws->cfg_id); - RD_Cfg *scan_parents[] = {window_cfg, rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("project")), rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user"))}; - for EachElement(idx, scan_parents) - { - for(RD_Cfg *parent_cfg = scan_parents[idx]; parent_cfg != &rd_nil_cfg; parent_cfg = parent_cfg->parent) - { - if(preset_cfg == &rd_nil_cfg) - { - preset_cfg = rd_cfg_child_from_string(parent_cfg, str8_lit("color_preset")); - } - RD_Cfg *colors_cfg = rd_cfg_child_from_string(parent_cfg, str8_lit("colors")); - if(colors_cfg != &rd_nil_cfg) - { - rd_cfg_list_push_front(scratch.arena, &colors_cfgs, colors_cfg); - } - if(preset_cfg != &rd_nil_cfg && colors_cfg != &rd_nil_cfg) - { - break; - } - } - } - - //- rjf: map the preset config to the associated preset tree - MD_Node *preset_tree = rd_state->theme_preset_trees[RD_ThemePreset_DefaultDark]; - if(preset_cfg != &rd_nil_cfg) - { - String8 preset_name = preset_cfg->first->string; - for EachEnumVal(RD_ThemePreset, p) - { - if(str8_match(preset_name, rd_theme_preset_code_string_table[p], 0)) - { - preset_tree = rd_state->theme_preset_trees[p]; - break; - } - } - } - - //- rjf: build tasks for color applications - each task comprises of a metadesk - // tree, describing the color patterns - typedef struct ThemeTask ThemeTask; - struct ThemeTask - { - ThemeTask *next; - MD_Node *tree; - }; - ThemeTask start_task = {0, preset_tree}; - ThemeTask *first_task = &start_task; - ThemeTask *last_task = first_task; - { - for(RD_CfgNode *n = colors_cfgs.first; n != 0; n = n->next) - { - ThemeTask *t = push_array(scratch.arena, ThemeTask, 1); - SLLQueuePush(first_task, last_task, t); - t->tree = md_tree_from_string(scratch.arena, rd_string_from_cfg_tree(scratch.arena, n->v)); - } - } - - //- rjf: apply theme tasks, build each color pattern for this window's - // structured theme - typedef struct ThemePatternNode ThemePatternNode; - struct ThemePatternNode - { - ThemePatternNode *next; - RD_ThemePattern pattern; - }; - ThemePatternNode *first_pattern = 0; - ThemePatternNode *last_pattern = 0; - U64 pattern_count = 0; - for(ThemeTask *t = first_task; t != 0; t = t->next) - { - MD_Node *tree_root = t->tree; - for(MD_Node *n = tree_root; !md_node_is_nil(n); n = md_node_rec_depth_first_pre(n, tree_root).next) - { - if(n->flags & MD_NodeFlag_Numeric && md_node_is_nil(n)) - { - Vec4F32 color_srgba = rgba_from_hex_string_4f32(n->string); - Vec4F32 color_linear = linear_from_srgba(color_srgba); - String8List tags = {0}; - for(MD_Node *parent = n->parent; parent != tree_root && !md_node_is_nil(parent); parent = parent->parent) - { - str8_list_push(scratch.arena, &tags, push_str8_copy(ui_build_arena(), parent->string)); - } - ThemePatternNode *node = push_array(scratch.arena, ThemePatternNode, 1); - node->pattern.tags = str8_array_from_list(ui_build_arena(), &tags); - node->pattern.linear = color_linear; - SLLQueuePush(first_pattern, last_pattern, node); - pattern_count += 1; - } - } - } - - //- rjf: convert to final pattern array - ws->theme = push_array(ui_build_arena(), RD_Theme, 1); - ws->theme->patterns_count = pattern_count; - ws->theme->patterns = push_array(ui_build_arena(), RD_ThemePattern, ws->theme->patterns_count); - { - U64 idx = 0; - for(ThemePatternNode *n = first_pattern; n != 0; n = n->next, idx += 1) - { - ws->theme->patterns[idx] = n->pattern; - } - } - } - scratch_end(scratch); - } - ////////////////////////////// //- rjf: build theme from config // diff --git a/src/raddbg/raddbg_core.h b/src/raddbg/raddbg_core.h index bb09bd6f..4cf31c1f 100644 --- a/src/raddbg/raddbg_core.h +++ b/src/raddbg/raddbg_core.h @@ -999,7 +999,7 @@ internal RD_KeyMapNodePtrList rd_key_map_node_ptr_list_from_name(Arena *arena, S internal RD_KeyMapNodePtrList rd_key_map_node_ptr_list_from_binding(Arena *arena, RD_Binding binding); internal Vec4F32 rd_hsva_from_cfg(RD_Cfg *cfg); -internal Vec4F32 rd_rgba_from_cfg(RD_Cfg *cfg); +internal Vec4F32 rd_color_from_cfg(RD_Cfg *cfg); internal B32 rd_disabled_from_cfg(RD_Cfg *cfg); internal RD_Location rd_location_from_cfg(RD_Cfg *cfg); @@ -1026,7 +1026,7 @@ internal E_Expr *rd_tag_from_cfg(Arena *arena, RD_Cfg *cfg); //////////////////////////////// //~ rjf: Control Entity Info Extraction -internal Vec4F32 rd_rgba_from_ctrl_entity(CTRL_Entity *entity); +internal Vec4F32 rd_color_from_ctrl_entity(CTRL_Entity *entity); internal String8 rd_name_from_ctrl_entity(Arena *arena, CTRL_Entity *entity); internal DR_FStrList rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_extras); @@ -1164,7 +1164,7 @@ internal String8 rd_push_search_string(Arena *arena); //~ rjf: Colors, Fonts, Config //- rjf: colors -internal Vec4F32 rd_color_from_tags(String8Array tags); +internal Vec4F32 rd_color_from_tags(String8Array tags, String8 name); internal Vec4F32 rd_rgba_from_theme_color(RD_ThemeColor color); internal RD_ThemeColor rd_theme_color_from_txt_token_kind(TXT_TokenKind kind); internal RD_ThemeColor rd_theme_color_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8 string); diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 5f372f75..97cfdeca 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -2750,11 +2750,13 @@ RD_VIEW_UI_FUNCTION_DEF(watch) { if(row_is_fresh) { - row_flags |= UI_BoxFlag_DrawPop; + ui_set_next_tag(str8_lit("pop")); + row_flags |= UI_BoxFlag_DrawBackground; } - if(global_row_idx & 1) + else if(global_row_idx & 1) { - row_flags |= UI_BoxFlag_DrawAlt; + ui_set_next_tag(str8_lit("alt")); + row_flags |= UI_BoxFlag_DrawBackground; } if(!row_matches_last_row_topology) { @@ -2852,7 +2854,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch) rd_state->hover_regs_slot == RD_RegSlot_Cfg) { RD_Cfg *cfg = cell_info.cfg; - Vec4F32 rgba = linear_from_srgba(rd_rgba_from_cfg(cfg)); + Vec4F32 rgba = linear_from_srgba(rd_color_from_cfg(cfg)); if(rgba.w == 0) { rgba = ui_top_palette()->background_pop; @@ -2866,7 +2868,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch) rd_state->hover_regs_slot == RD_RegSlot_CtrlEntity) { CTRL_Entity *entity = cell_info.entity; - Vec4F32 rgba = linear_from_srgba(rd_rgba_from_ctrl_entity(entity)); + Vec4F32 rgba = rd_color_from_ctrl_entity(entity); if(rgba.w == 0) { rgba = ui_top_palette()->background_pop;; @@ -2894,7 +2896,6 @@ RD_VIEW_UI_FUNCTION_DEF(watch) UI_FocusHot(cell_selected ? UI_FocusKind_On : UI_FocusKind_Off) UI_FocusActive((cell_selected && ewv->text_editing) ? UI_FocusKind_On : UI_FocusKind_Off) RD_Font(RD_FontSlot_Code) - UI_FlagsAdd(row_depth > 0 ? UI_BoxFlag_DrawTextWeak : 0) { // rjf: cell has errors? -> build error box if(cell_info.flags & RD_WatchCellFlag_IsErrored) RD_Font(RD_FontSlot_Main) @@ -2960,7 +2961,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch) { RD_Font(RD_FontSlot_Icons) UI_Flags(UI_BoxFlag_DisableTextTrunc) - UI_Palette(ui_build_palette(ui_top_palette(), .text = rd_rgba_from_ctrl_entity(row_info->callstack_thread))) + UI_Palette(ui_build_palette(ui_top_palette(), .text = rd_color_from_ctrl_entity(row_info->callstack_thread))) ui_label(rd_icon_kind_text_table[RD_IconKind_RightArrow]); } } @@ -3181,16 +3182,16 @@ RD_VIEW_UI_FUNCTION_DEF(watch) E_IRTreeAndType irtree = e_irtree_and_type_from_expr(scratch.arena, parse.exprs.last); E_OpList oplist = e_oplist_from_irtree(scratch.arena, irtree.root); String8 bytecode = e_bytecode_from_oplist(scratch.arena, &oplist); - UI_Flags(UI_BoxFlag_DrawTextWeak) ui_labelf("Text:"); + ui_labelf("Text:"); ui_label(string); ui_spacer(ui_em(2.f, 1.f)); - UI_Flags(UI_BoxFlag_DrawTextWeak) ui_labelf("Tokens:"); + ui_labelf("Tokens:"); for(U64 idx = 0; idx < tokens.count; idx += 1) { ui_labelf("%S: '%S'", e_token_kind_strings[tokens.v[idx].kind], str8_substr(string, tokens.v[idx].range)); } ui_spacer(ui_em(2.f, 1.f)); - UI_Flags(UI_BoxFlag_DrawTextWeak) ui_labelf("Expression:"); + ui_labelf("Expression:"); { typedef struct Task Task; struct Task @@ -3243,7 +3244,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch) } } ui_spacer(ui_em(2.f, 1.f)); - UI_Flags(UI_BoxFlag_DrawTextWeak) ui_labelf("IR Tree:"); + ui_labelf("IR Tree:"); { typedef struct Task Task; struct Task @@ -3280,7 +3281,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch) } } ui_spacer(ui_em(2.f, 1.f)); - UI_Flags(UI_BoxFlag_DrawTextWeak) ui_labelf("Op List:"); + ui_labelf("Op List:"); { for(E_Op *op = oplist.first; op != 0; op = op->next) { @@ -3307,7 +3308,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch) } } ui_spacer(ui_em(2.f, 1.f)); - UI_Flags(UI_BoxFlag_DrawTextWeak) ui_labelf("Bytecode:"); + ui_labelf("Bytecode:"); { for(U64 idx = 0; idx < bytecode.size; idx += 1) { @@ -3526,7 +3527,7 @@ RD_VIEW_UI_FUNCTION_DEF(text) UI_Row UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_text_dim(10, 1)) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") { if(file_is_out_of_date) { @@ -3773,7 +3774,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm) UI_Row UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_text_dim(10, 1)) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") RD_Font(RD_FontSlot_Code) { U64 cursor_vaddr = (1 <= rd_regs()->cursor.line && rd_regs()->cursor.line <= dasm_info.lines.count) ? (range.min+dasm_info.lines.v[rd_regs()->cursor.line-1].code_off) : 0; @@ -4141,7 +4142,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory) Annotation *annotation = push_array(scratch.arena, Annotation, 1); annotation->name_string = thread->string.size ? thread->string : push_str8f(scratch.arena, "TID: %I64u", thread->id); annotation->kind_string = str8_lit("Stack"); - annotation->color = rd_rgba_from_ctrl_entity(thread); + annotation->color = rd_color_from_ctrl_entity(thread); annotation->vaddr_range = stack_vaddr_range; for(U64 vaddr = stack_vaddr_range_in_viz.min; vaddr < stack_vaddr_range_in_viz.max; vaddr += 1) { @@ -4220,7 +4221,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory) UI_Parent(header_box) RD_Font(RD_FontSlot_Code) UI_FontSize(font_size) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") { UI_PrefWidth(ui_px(big_glyph_advance*20.f, 1.f)) ui_labelf("Address"); UI_PrefWidth(ui_px(cell_width_px, 1.f)) @@ -4229,10 +4230,6 @@ RD_VIEW_UI_FUNCTION_DEF(memory) Rng1U64 col_selection_rng = r1u64(cursor%num_columns, mark%num_columns); for(U64 row_off = 0; row_off < num_columns*bytes_per_cell; row_off += bytes_per_cell) { - if(!(col_selection_rng.min <= row_off && row_off <= col_selection_rng.max)) - { - ui_set_next_flags(UI_BoxFlag_DrawTextWeak); - } ui_labelf("%I64X", row_off); } } @@ -4401,7 +4398,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory) { if(!(selection.max >= row_range_bytes.min && selection.min < row_range_bytes.max)) { - ui_set_next_flags(UI_BoxFlag_DrawTextWeak); + ui_set_next_tag(str8_lit("weak")); } ui_labelf("0x%016I64X", row_range_bytes.min); } @@ -4573,7 +4570,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory) footer_box = ui_build_box_from_stringf(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawDropShadow, "footer"); UI_Parent(footer_box) RD_Font(RD_FontSlot_Code) UI_FontSize(font_size) { - UI_PrefWidth(ui_em(7.5f, 1.f)) UI_HeightFill UI_Column UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_PrefWidth(ui_em(7.5f, 1.f)) UI_HeightFill UI_Column UI_TagF("weak") UI_PrefHeight(ui_px(row_height_px, 0.f)) { ui_labelf("Address:"); @@ -5049,7 +5046,8 @@ RD_VIEW_UI_FUNCTION_DEF(color_rgba) { UI_Signal h_sig = ui_hue_pickerf(&hsva.x, hsva.y, hsva.z, "hue_picker"); } - UI_PrefWidth(ui_children_sum(1)) UI_Column UI_PrefWidth(ui_text_dim(10, 1)) UI_PrefHeight(ui_em(2.f, 0.f)) RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_PrefWidth(ui_children_sum(1)) UI_Column UI_PrefWidth(ui_text_dim(10, 1)) UI_PrefHeight(ui_em(2.f, 0.f)) RD_Font(RD_FontSlot_Code) + UI_TagF("weak") { ui_labelf("Hex"); ui_labelf("R"); diff --git a/src/raddbg/raddbg_widgets.c b/src/raddbg/raddbg_widgets.c index ad48dec5..24e33ef8 100644 --- a/src/raddbg/raddbg_widgets.c +++ b/src/raddbg/raddbg_widgets.c @@ -292,7 +292,7 @@ rd_cmd_spec_button(String8 name) RD_Font(RD_FontSlot_Icons) UI_PrefWidth(ui_em(2.f, 1.f)) UI_TextAlignment(UI_TextAlign_Center) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") { ui_label(rd_icon_kind_text_table[canonical_icon]); } @@ -308,7 +308,7 @@ rd_cmd_spec_button(String8 name) UI_PrefWidth(ui_children_sum(1)) UI_FontSize(ui_top_font_size()*0.95f) UI_HeightFill UI_NamedRow(str8_lit("###bindings")) - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") UI_FastpathCodepoint(0) { rd_cmd_binding_buttons(name); @@ -365,7 +365,8 @@ rd_icon_button(RD_IconKind kind, FuzzyMatchRangeList *matches, String8 string) RD_Font(RD_FontSlot_Icons) UI_PrefWidth(ui_em(2.f, 1.f)) UI_PrefHeight(ui_pct(1, 0)) - UI_FlagsAdd(UI_BoxFlag_DisableTextTrunc|UI_BoxFlag_DrawTextWeak) + UI_FlagsAdd(UI_BoxFlag_DisableTextTrunc) + UI_TagF("weak") ui_label(rd_icon_kind_text_table[kind]); if(display_string.size != 0) { @@ -481,12 +482,14 @@ internal UI_BOX_CUSTOM_DRAW(rd_thread_box_draw_extensions) if(u->is_frozen) { F32 lock_icon_off = ui_top_font_size()*0.2f; - Vec4F32 lock_icon_color = ui_top_palette()->background_bad; + String8 tags[] = {str8_lit("bad")}; + String8Array tags_array = {tags, ArrayCount(tags)}; + Vec4F32 color = rd_color_from_tags(tags_array, str8_lit("text")); dr_text(rd_font_from_slot(RD_FontSlot_Icons), box->font_size, 0, 0, FNT_RasterFlag_Smooth, v2f32((box->rect.x0 + box->rect.x1)/2 + lock_icon_off/2, box->rect.y0 + lock_icon_off/2), - lock_icon_color, + color, rd_icon_kind_text_table[RD_IconKind_Locked]); } } @@ -590,10 +593,10 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe B32 ctrlified = (os_get_modifiers() & OS_Modifier_Ctrl); Vec4F32 code_line_bgs[] = { - rd_rgba_from_theme_color(RD_ThemeColor_LineInfoBackground0), - rd_rgba_from_theme_color(RD_ThemeColor_LineInfoBackground1), - rd_rgba_from_theme_color(RD_ThemeColor_LineInfoBackground2), - rd_rgba_from_theme_color(RD_ThemeColor_LineInfoBackground3), + rd_color_from_tags(str8_array_zero(), str8_lit("line_info_0")), + rd_color_from_tags(str8_array_zero(), str8_lit("line_info_1")), + rd_color_from_tags(str8_array_zero(), str8_lit("line_info_2")), + rd_color_from_tags(str8_array_zero(), str8_lit("line_info_3")), }; F32 line_num_padding_px = ui_top_font_size()*1.f; F32 entity_alive_t_rate = (1 - pow_f32(2, (-30.f * rd_state->frame_dt))); @@ -671,7 +674,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { CTRL_EntityList line_ips = params->line_ips[line_idx]; ui_set_next_hover_cursor(OS_Cursor_HandPoint); - UI_Box *line_margin_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable*!!(params->flags & RD_CodeSliceFlag_Clickable)|UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawActiveEffects, "line_margin_%I64x", line_num); + UI_Box *line_margin_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable*!!(params->flags & RD_CodeSliceFlag_Clickable)|UI_BoxFlag_DrawActiveEffects, "line_margin_%I64x", line_num); UI_Parent(line_margin_box) { //- rjf: build margin thread ip ui @@ -691,7 +694,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe U64 thread_rip_voff = ctrl_voff_from_vaddr(module, thread_rip_vaddr); // rjf: thread info => color - Vec4F32 color = linear_from_srgba(rd_rgba_from_ctrl_entity(thread)); + Vec4F32 color = rd_color_from_ctrl_entity(thread); { if(color.w == 0) { @@ -801,6 +804,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe // UI_Box *catchall_margin_container_box = &ui_nil_box; if(params->flags & RD_CodeSliceFlag_CatchallMargin) UI_Focus(UI_FocusKind_Off) UI_Parent(top_container_box) ProfScope("build catchall margins") + UI_TagF("implicit") { if(params->margin_float_off_px != 0) { @@ -844,7 +848,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe U64 thread_rip_voff = ctrl_voff_from_vaddr(module, thread_rip_vaddr); // rjf: thread info => color - Vec4F32 color = linear_from_srgba(rd_rgba_from_ctrl_entity(thread)); + Vec4F32 color = rd_color_from_ctrl_entity(thread); { if(color.w == 0) { @@ -952,7 +956,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe for(RD_CfgNode *n = line_bps.first; n != 0; n = n->next) { RD_Cfg *bp = n->v; - Vec4F32 bp_rgba = rd_rgba_from_cfg(bp); + Vec4F32 bp_rgba = rd_color_from_cfg(bp); if(bp_rgba.w == 0) { bp_rgba = rd_rgba_from_theme_color(RD_ThemeColor_Breakpoint); @@ -1045,7 +1049,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe for(RD_CfgNode *n = line_pins.first; n != 0; n = n->next) { RD_Cfg *pin = n->v; - Vec4F32 color = rd_rgba_from_cfg(pin); + Vec4F32 color = rd_color_from_cfg(pin); if(color.w == 0) { color = rd_rgba_from_theme_color(RD_ThemeColor_CodeDefault); @@ -1115,6 +1119,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe //- rjf: build line numbers // if(params->flags & RD_CodeSliceFlag_LineNums) UI_Parent(top_container_box) ProfScope("build line numbers") UI_Focus(UI_FocusKind_Off) + UI_TagF("implicit") { TxtRng select_rng = txt_rng(*cursor, *mark); Vec4F32 active_color = rd_rgba_from_theme_color(RD_ThemeColor_CodeLineNumbersSelected); @@ -1173,7 +1178,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe //- rjf: build background for line numbers & margins // { - UI_Parent(top_container_box) + UI_Parent(top_container_box) UI_TagF("floating") { ui_set_next_pref_width(ui_px(params->priority_margin_width_px + params->catchall_margin_width_px + params->line_num_width_px, 1)); ui_set_next_pref_height(ui_px(params->line_height_px*(dim_1s64(params->line_num_range)+1), 1.f)); @@ -1293,7 +1298,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe UI_BoxFlag_DrawBorder, pin_box_key); UI_Parent(pin_box) UI_PrefWidth(ui_text_dim(10, 1)) { - Vec4F32 pin_color = rd_rgba_from_cfg(pin); + Vec4F32 pin_color = rd_color_from_cfg(pin); if(pin_color.w == 0) { pin_color = rd_rgba_from_theme_color(RD_ThemeColor_CodeDefault); @@ -1485,7 +1490,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { line_drag_drop = 1; line_drag_cfg = cfg; - line_drag_drop_color = linear_from_srgba(rd_rgba_from_cfg(cfg)); + line_drag_drop_color = linear_from_srgba(rd_color_from_cfg(cfg)); if(line_drag_drop_color.w == 0) { line_drag_drop_color = ui_top_palette()->background_pop; @@ -1495,7 +1500,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { line_drag_drop = 1; line_drag_ctrl_entity = thread; - line_drag_drop_color = linear_from_srgba(rd_rgba_from_ctrl_entity(thread)); + line_drag_drop_color = rd_color_from_ctrl_entity(thread); if(line_drag_drop_color.w == 0) { line_drag_drop_color = ui_top_palette()->background_pop; @@ -2215,8 +2220,7 @@ rd_error_label(String8 string) ui_set_next_font(rd_font_from_slot(RD_FontSlot_Icons)); ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth); ui_set_next_text_alignment(UI_TextAlign_Center); - ui_set_next_flags(UI_BoxFlag_DrawTextWeak); - UI_PrefWidth(ui_em(2.25f, 1.f)) ui_label(rd_icon_kind_text_table[RD_IconKind_WarningBig]); + UI_TagF("weak") UI_PrefWidth(ui_em(2.25f, 1.f)) ui_label(rd_icon_kind_text_table[RD_IconKind_WarningBig]); UI_PrefWidth(ui_text_dim(10, 0)) rd_label(string); } return sig; @@ -2500,7 +2504,7 @@ rd_line_edit(RD_LineEditParams *params, String8 string) //- rjf: build expander placeholder else if(params->flags & RD_LineEditFlag_ExpanderPlaceholder) UI_Parent(box) UI_PrefWidth(ui_px(expander_size_px, 1.f)) UI_Focus(UI_FocusKind_Off) { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + UI_TagF("weak") UI_Flags(UI_BoxFlag_DrawSideLeft) RD_Font(RD_FontSlot_Icons) UI_TextAlignment(UI_TextAlign_Center) @@ -2696,9 +2700,8 @@ rd_line_edit(RD_LineEditParams *params, String8 string) ui_box_equip_fuzzy_match_ranges(box, params->fuzzy_matches); } } - else + else UI_TagF("weak") { - ui_set_next_flags(UI_BoxFlag_DrawTextWeak); UI_Box *box = ui_label(display_string).box; if(params->fuzzy_matches != 0) { @@ -2715,7 +2718,7 @@ rd_line_edit(RD_LineEditParams *params, String8 string) } else { - ui_set_next_flags(UI_BoxFlag_DrawTextWeak); + ui_set_next_tag(str8_lit("weak")); } UI_Box *box = ui_label(display_string).box; if(params->fuzzy_matches != 0) diff --git a/src/ui/generated/ui.meta.c b/src/ui/generated/ui.meta.c index 3b0a771b..89017afd 100644 --- a/src/ui/generated/ui.meta.c +++ b/src/ui/generated/ui.meta.c @@ -14,6 +14,7 @@ #define UI_PrefHeight(v) DeferLoop(ui_push_pref_height(v), ui_pop_pref_height()) #define UI_PermissionFlags(v) DeferLoop(ui_push_permission_flags(v), ui_pop_permission_flags()) #define UI_Flags(v) DeferLoop(ui_push_flags(v), ui_pop_flags()) +#define UI_OmitFlags(v) DeferLoop(ui_push_omit_flags(v), ui_pop_omit_flags()) #define UI_FocusHot(v) DeferLoop(ui_push_focus_hot(v), ui_pop_focus_hot()) #define UI_FocusActive(v) DeferLoop(ui_push_focus_active(v), ui_pop_focus_active()) #define UI_FastpathCodepoint(v) DeferLoop(ui_push_fastpath_codepoint(v), ui_pop_fastpath_codepoint()) @@ -45,13 +46,13 @@ internal UI_Size ui_top_pref_width(void) { UI_StackTopImpl(ui_state, PrefWidth, internal UI_Size ui_top_pref_height(void) { UI_StackTopImpl(ui_state, PrefHeight, pref_height) } internal UI_PermissionFlags ui_top_permission_flags(void) { UI_StackTopImpl(ui_state, PermissionFlags, permission_flags) } internal UI_BoxFlags ui_top_flags(void) { UI_StackTopImpl(ui_state, Flags, flags) } +internal UI_BoxFlags ui_top_omit_flags(void) { UI_StackTopImpl(ui_state, OmitFlags, omit_flags) } internal UI_FocusKind ui_top_focus_hot(void) { UI_StackTopImpl(ui_state, FocusHot, focus_hot) } internal UI_FocusKind ui_top_focus_active(void) { UI_StackTopImpl(ui_state, FocusActive, focus_active) } internal U32 ui_top_fastpath_codepoint(void) { UI_StackTopImpl(ui_state, FastpathCodepoint, fastpath_codepoint) } internal UI_Key ui_top_group_key(void) { UI_StackTopImpl(ui_state, GroupKey, group_key) } internal F32 ui_top_transparency(void) { UI_StackTopImpl(ui_state, Transparency, transparency) } internal UI_Palette* ui_top_palette(void) { UI_StackTopImpl(ui_state, Palette, palette) } -internal String8 ui_top_tag(void) { UI_StackTopImpl(ui_state, Tag, tag) } internal F32 ui_top_squish(void) { UI_StackTopImpl(ui_state, Squish, squish) } internal OS_Cursor ui_top_hover_cursor(void) { UI_StackTopImpl(ui_state, HoverCursor, hover_cursor) } internal FNT_Tag ui_top_font(void) { UI_StackTopImpl(ui_state, Font, font) } @@ -75,13 +76,13 @@ internal UI_Size ui_bottom_pref_width(void) { UI_StackBottomImpl(ui_state, PrefW internal UI_Size ui_bottom_pref_height(void) { UI_StackBottomImpl(ui_state, PrefHeight, pref_height) } internal UI_PermissionFlags ui_bottom_permission_flags(void) { UI_StackBottomImpl(ui_state, PermissionFlags, permission_flags) } internal UI_BoxFlags ui_bottom_flags(void) { UI_StackBottomImpl(ui_state, Flags, flags) } +internal UI_BoxFlags ui_bottom_omit_flags(void) { UI_StackBottomImpl(ui_state, OmitFlags, omit_flags) } internal UI_FocusKind ui_bottom_focus_hot(void) { UI_StackBottomImpl(ui_state, FocusHot, focus_hot) } internal UI_FocusKind ui_bottom_focus_active(void) { UI_StackBottomImpl(ui_state, FocusActive, focus_active) } internal U32 ui_bottom_fastpath_codepoint(void) { UI_StackBottomImpl(ui_state, FastpathCodepoint, fastpath_codepoint) } internal UI_Key ui_bottom_group_key(void) { UI_StackBottomImpl(ui_state, GroupKey, group_key) } internal F32 ui_bottom_transparency(void) { UI_StackBottomImpl(ui_state, Transparency, transparency) } internal UI_Palette* ui_bottom_palette(void) { UI_StackBottomImpl(ui_state, Palette, palette) } -internal String8 ui_bottom_tag(void) { UI_StackBottomImpl(ui_state, Tag, tag) } internal F32 ui_bottom_squish(void) { UI_StackBottomImpl(ui_state, Squish, squish) } internal OS_Cursor ui_bottom_hover_cursor(void) { UI_StackBottomImpl(ui_state, HoverCursor, hover_cursor) } internal FNT_Tag ui_bottom_font(void) { UI_StackBottomImpl(ui_state, Font, font) } @@ -105,13 +106,13 @@ internal UI_Size ui_push_pref_width(UI_Size v) { UI_StackPushImpl(ui_state, Pref internal UI_Size ui_push_pref_height(UI_Size v) { UI_StackPushImpl(ui_state, PrefHeight, pref_height, UI_Size, v) } internal UI_PermissionFlags ui_push_permission_flags(UI_PermissionFlags v) { UI_StackPushImpl(ui_state, PermissionFlags, permission_flags, UI_PermissionFlags, v) } internal UI_BoxFlags ui_push_flags(UI_BoxFlags v) { UI_StackPushImpl(ui_state, Flags, flags, UI_BoxFlags, v) } +internal UI_BoxFlags ui_push_omit_flags(UI_BoxFlags v) { UI_StackPushImpl(ui_state, OmitFlags, omit_flags, UI_BoxFlags, v) } internal UI_FocusKind ui_push_focus_hot(UI_FocusKind v) { UI_StackPushImpl(ui_state, FocusHot, focus_hot, UI_FocusKind, v) } internal UI_FocusKind ui_push_focus_active(UI_FocusKind v) { UI_StackPushImpl(ui_state, FocusActive, focus_active, UI_FocusKind, v) } internal U32 ui_push_fastpath_codepoint(U32 v) { UI_StackPushImpl(ui_state, FastpathCodepoint, fastpath_codepoint, U32, v) } internal UI_Key ui_push_group_key(UI_Key v) { UI_StackPushImpl(ui_state, GroupKey, group_key, UI_Key, v) } internal F32 ui_push_transparency(F32 v) { UI_StackPushImpl(ui_state, Transparency, transparency, F32, v) } internal UI_Palette* ui_push_palette(UI_Palette* v) { UI_StackPushImpl(ui_state, Palette, palette, UI_Palette* , v) } -internal String8 ui_push_tag(String8 v) { UI_StackPushImpl(ui_state, Tag, tag, String8, v) } internal F32 ui_push_squish(F32 v) { UI_StackPushImpl(ui_state, Squish, squish, F32, v) } internal OS_Cursor ui_push_hover_cursor(OS_Cursor v) { UI_StackPushImpl(ui_state, HoverCursor, hover_cursor, OS_Cursor, v) } internal FNT_Tag ui_push_font(FNT_Tag v) { UI_StackPushImpl(ui_state, Font, font, FNT_Tag, v) } @@ -135,13 +136,13 @@ internal UI_Size ui_pop_pref_width(void) { UI_StackPopImpl(ui_state, PrefWidth, internal UI_Size ui_pop_pref_height(void) { UI_StackPopImpl(ui_state, PrefHeight, pref_height) } internal UI_PermissionFlags ui_pop_permission_flags(void) { UI_StackPopImpl(ui_state, PermissionFlags, permission_flags) } internal UI_BoxFlags ui_pop_flags(void) { UI_StackPopImpl(ui_state, Flags, flags) } +internal UI_BoxFlags ui_pop_omit_flags(void) { UI_StackPopImpl(ui_state, OmitFlags, omit_flags) } internal UI_FocusKind ui_pop_focus_hot(void) { UI_StackPopImpl(ui_state, FocusHot, focus_hot) } internal UI_FocusKind ui_pop_focus_active(void) { UI_StackPopImpl(ui_state, FocusActive, focus_active) } internal U32 ui_pop_fastpath_codepoint(void) { UI_StackPopImpl(ui_state, FastpathCodepoint, fastpath_codepoint) } internal UI_Key ui_pop_group_key(void) { UI_StackPopImpl(ui_state, GroupKey, group_key) } internal F32 ui_pop_transparency(void) { UI_StackPopImpl(ui_state, Transparency, transparency) } internal UI_Palette* ui_pop_palette(void) { UI_StackPopImpl(ui_state, Palette, palette) } -internal String8 ui_pop_tag(void) { UI_StackPopImpl(ui_state, Tag, tag) } internal F32 ui_pop_squish(void) { UI_StackPopImpl(ui_state, Squish, squish) } internal OS_Cursor ui_pop_hover_cursor(void) { UI_StackPopImpl(ui_state, HoverCursor, hover_cursor) } internal FNT_Tag ui_pop_font(void) { UI_StackPopImpl(ui_state, Font, font) } @@ -165,13 +166,13 @@ internal UI_Size ui_set_next_pref_width(UI_Size v) { UI_StackSetNextImpl(ui_stat internal UI_Size ui_set_next_pref_height(UI_Size v) { UI_StackSetNextImpl(ui_state, PrefHeight, pref_height, UI_Size, v) } internal UI_PermissionFlags ui_set_next_permission_flags(UI_PermissionFlags v) { UI_StackSetNextImpl(ui_state, PermissionFlags, permission_flags, UI_PermissionFlags, v) } internal UI_BoxFlags ui_set_next_flags(UI_BoxFlags v) { UI_StackSetNextImpl(ui_state, Flags, flags, UI_BoxFlags, v) } +internal UI_BoxFlags ui_set_next_omit_flags(UI_BoxFlags v) { UI_StackSetNextImpl(ui_state, OmitFlags, omit_flags, UI_BoxFlags, v) } internal UI_FocusKind ui_set_next_focus_hot(UI_FocusKind v) { UI_StackSetNextImpl(ui_state, FocusHot, focus_hot, UI_FocusKind, v) } internal UI_FocusKind ui_set_next_focus_active(UI_FocusKind v) { UI_StackSetNextImpl(ui_state, FocusActive, focus_active, UI_FocusKind, v) } internal U32 ui_set_next_fastpath_codepoint(U32 v) { UI_StackSetNextImpl(ui_state, FastpathCodepoint, fastpath_codepoint, U32, v) } internal UI_Key ui_set_next_group_key(UI_Key v) { UI_StackSetNextImpl(ui_state, GroupKey, group_key, UI_Key, v) } internal F32 ui_set_next_transparency(F32 v) { UI_StackSetNextImpl(ui_state, Transparency, transparency, F32, v) } internal UI_Palette* ui_set_next_palette(UI_Palette* v) { UI_StackSetNextImpl(ui_state, Palette, palette, UI_Palette* , v) } -internal String8 ui_set_next_tag(String8 v) { UI_StackSetNextImpl(ui_state, Tag, tag, String8, v) } internal F32 ui_set_next_squish(F32 v) { UI_StackSetNextImpl(ui_state, Squish, squish, F32, v) } internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v) { UI_StackSetNextImpl(ui_state, HoverCursor, hover_cursor, OS_Cursor, v) } internal FNT_Tag ui_set_next_font(FNT_Tag v) { UI_StackSetNextImpl(ui_state, Font, font, FNT_Tag, v) } diff --git a/src/ui/generated/ui.meta.h b/src/ui/generated/ui.meta.h index 0adc1ad9..ccd7dc65 100644 --- a/src/ui/generated/ui.meta.h +++ b/src/ui/generated/ui.meta.h @@ -16,6 +16,7 @@ typedef struct UI_PrefWidthNode UI_PrefWidthNode; struct UI_PrefWidthNode{UI_Pre typedef struct UI_PrefHeightNode UI_PrefHeightNode; struct UI_PrefHeightNode{UI_PrefHeightNode *next; UI_Size v;}; typedef struct UI_PermissionFlagsNode UI_PermissionFlagsNode; struct UI_PermissionFlagsNode{UI_PermissionFlagsNode *next; UI_PermissionFlags v;}; typedef struct UI_FlagsNode UI_FlagsNode; struct UI_FlagsNode{UI_FlagsNode *next; UI_BoxFlags v;}; +typedef struct UI_OmitFlagsNode UI_OmitFlagsNode; struct UI_OmitFlagsNode{UI_OmitFlagsNode *next; UI_BoxFlags v;}; typedef struct UI_FocusHotNode UI_FocusHotNode; struct UI_FocusHotNode{UI_FocusHotNode *next; UI_FocusKind v;}; typedef struct UI_FocusActiveNode UI_FocusActiveNode; struct UI_FocusActiveNode{UI_FocusActiveNode *next; UI_FocusKind v;}; typedef struct UI_FastpathCodepointNode UI_FastpathCodepointNode; struct UI_FastpathCodepointNode{UI_FastpathCodepointNode *next; U32 v;}; @@ -49,6 +50,7 @@ UI_PrefWidthNode pref_width_nil_stack_top;\ UI_PrefHeightNode pref_height_nil_stack_top;\ UI_PermissionFlagsNode permission_flags_nil_stack_top;\ UI_FlagsNode flags_nil_stack_top;\ +UI_OmitFlagsNode omit_flags_nil_stack_top;\ UI_FocusHotNode focus_hot_nil_stack_top;\ UI_FocusActiveNode focus_active_nil_stack_top;\ UI_FastpathCodepointNode fastpath_codepoint_nil_stack_top;\ @@ -81,6 +83,7 @@ state->pref_width_nil_stack_top.v = ui_px(250.f, 1.f);\ state->pref_height_nil_stack_top.v = ui_px(30.f, 1.f);\ state->permission_flags_nil_stack_top.v = UI_PermissionFlag_All;\ state->flags_nil_stack_top.v = 0;\ +state->omit_flags_nil_stack_top.v = 0;\ state->focus_hot_nil_stack_top.v = UI_FocusKind_Null;\ state->focus_active_nil_stack_top.v = UI_FocusKind_Null;\ state->fastpath_codepoint_nil_stack_top.v = 0;\ @@ -115,6 +118,7 @@ struct { UI_PrefWidthNode *top; UI_Size bottom_val; UI_PrefWidthNode *free; U64 struct { UI_PrefHeightNode *top; UI_Size bottom_val; UI_PrefHeightNode *free; U64 gen; B32 auto_pop; } pref_height_stack;\ struct { UI_PermissionFlagsNode *top; UI_PermissionFlags bottom_val; UI_PermissionFlagsNode *free; U64 gen; B32 auto_pop; } permission_flags_stack;\ struct { UI_FlagsNode *top; UI_BoxFlags bottom_val; UI_FlagsNode *free; U64 gen; B32 auto_pop; } flags_stack;\ +struct { UI_OmitFlagsNode *top; UI_BoxFlags bottom_val; UI_OmitFlagsNode *free; U64 gen; B32 auto_pop; } omit_flags_stack;\ struct { UI_FocusHotNode *top; UI_FocusKind bottom_val; UI_FocusHotNode *free; U64 gen; B32 auto_pop; } focus_hot_stack;\ struct { UI_FocusActiveNode *top; UI_FocusKind bottom_val; UI_FocusActiveNode *free; U64 gen; B32 auto_pop; } focus_active_stack;\ struct { UI_FastpathCodepointNode *top; U32 bottom_val; UI_FastpathCodepointNode *free; U64 gen; B32 auto_pop; } fastpath_codepoint_stack;\ @@ -147,6 +151,7 @@ state->pref_width_stack.top = &state->pref_width_nil_stack_top; state->pref_widt state->pref_height_stack.top = &state->pref_height_nil_stack_top; state->pref_height_stack.bottom_val = ui_px(30.f, 1.f); state->pref_height_stack.free = 0; state->pref_height_stack.auto_pop = 0;\ state->permission_flags_stack.top = &state->permission_flags_nil_stack_top; state->permission_flags_stack.bottom_val = UI_PermissionFlag_All; state->permission_flags_stack.free = 0; state->permission_flags_stack.auto_pop = 0;\ state->flags_stack.top = &state->flags_nil_stack_top; state->flags_stack.bottom_val = 0; state->flags_stack.free = 0; state->flags_stack.auto_pop = 0;\ +state->omit_flags_stack.top = &state->omit_flags_nil_stack_top; state->omit_flags_stack.bottom_val = 0; state->omit_flags_stack.free = 0; state->omit_flags_stack.auto_pop = 0;\ state->focus_hot_stack.top = &state->focus_hot_nil_stack_top; state->focus_hot_stack.bottom_val = UI_FocusKind_Null; state->focus_hot_stack.free = 0; state->focus_hot_stack.auto_pop = 0;\ state->focus_active_stack.top = &state->focus_active_nil_stack_top; state->focus_active_stack.bottom_val = UI_FocusKind_Null; state->focus_active_stack.free = 0; state->focus_active_stack.auto_pop = 0;\ state->fastpath_codepoint_stack.top = &state->fastpath_codepoint_nil_stack_top; state->fastpath_codepoint_stack.bottom_val = 0; state->fastpath_codepoint_stack.free = 0; state->fastpath_codepoint_stack.auto_pop = 0;\ @@ -179,6 +184,7 @@ if(state->pref_width_stack.auto_pop) { ui_pop_pref_width(); state->pref_width_st if(state->pref_height_stack.auto_pop) { ui_pop_pref_height(); state->pref_height_stack.auto_pop = 0; }\ if(state->permission_flags_stack.auto_pop) { ui_pop_permission_flags(); state->permission_flags_stack.auto_pop = 0; }\ if(state->flags_stack.auto_pop) { ui_pop_flags(); state->flags_stack.auto_pop = 0; }\ +if(state->omit_flags_stack.auto_pop) { ui_pop_omit_flags(); state->omit_flags_stack.auto_pop = 0; }\ if(state->focus_hot_stack.auto_pop) { ui_pop_focus_hot(); state->focus_hot_stack.auto_pop = 0; }\ if(state->focus_active_stack.auto_pop) { ui_pop_focus_active(); state->focus_active_stack.auto_pop = 0; }\ if(state->fastpath_codepoint_stack.auto_pop) { ui_pop_fastpath_codepoint(); state->fastpath_codepoint_stack.auto_pop = 0; }\ @@ -210,6 +216,7 @@ internal UI_Size ui_top_pref_width(void); internal UI_Size ui_top_pref_height(void); internal UI_PermissionFlags ui_top_permission_flags(void); internal UI_BoxFlags ui_top_flags(void); +internal UI_BoxFlags ui_top_omit_flags(void); internal UI_FocusKind ui_top_focus_hot(void); internal UI_FocusKind ui_top_focus_active(void); internal U32 ui_top_fastpath_codepoint(void); @@ -240,6 +247,7 @@ internal UI_Size ui_bottom_pref_width(void); internal UI_Size ui_bottom_pref_height(void); internal UI_PermissionFlags ui_bottom_permission_flags(void); internal UI_BoxFlags ui_bottom_flags(void); +internal UI_BoxFlags ui_bottom_omit_flags(void); internal UI_FocusKind ui_bottom_focus_hot(void); internal UI_FocusKind ui_bottom_focus_active(void); internal U32 ui_bottom_fastpath_codepoint(void); @@ -270,6 +278,7 @@ internal UI_Size ui_push_pref_width(UI_Size v); internal UI_Size ui_push_pref_height(UI_Size v); internal UI_PermissionFlags ui_push_permission_flags(UI_PermissionFlags v); internal UI_BoxFlags ui_push_flags(UI_BoxFlags v); +internal UI_BoxFlags ui_push_omit_flags(UI_BoxFlags v); internal UI_FocusKind ui_push_focus_hot(UI_FocusKind v); internal UI_FocusKind ui_push_focus_active(UI_FocusKind v); internal U32 ui_push_fastpath_codepoint(U32 v); @@ -300,6 +309,7 @@ internal UI_Size ui_pop_pref_width(void); internal UI_Size ui_pop_pref_height(void); internal UI_PermissionFlags ui_pop_permission_flags(void); internal UI_BoxFlags ui_pop_flags(void); +internal UI_BoxFlags ui_pop_omit_flags(void); internal UI_FocusKind ui_pop_focus_hot(void); internal UI_FocusKind ui_pop_focus_active(void); internal U32 ui_pop_fastpath_codepoint(void); @@ -330,6 +340,7 @@ internal UI_Size ui_set_next_pref_width(UI_Size v); internal UI_Size ui_set_next_pref_height(UI_Size v); internal UI_PermissionFlags ui_set_next_permission_flags(UI_PermissionFlags v); internal UI_BoxFlags ui_set_next_flags(UI_BoxFlags v); +internal UI_BoxFlags ui_set_next_omit_flags(UI_BoxFlags v); internal UI_FocusKind ui_set_next_focus_hot(UI_FocusKind v); internal UI_FocusKind ui_set_next_focus_active(UI_FocusKind v); internal U32 ui_set_next_fastpath_codepoint(U32 v); diff --git a/src/ui/ui.mdesk b/src/ui/ui.mdesk index 36c794ff..b934c760 100644 --- a/src/ui/ui.mdesk +++ b/src/ui/ui.mdesk @@ -3,11 +3,11 @@ //- rjf: stack table -@table(name, name_lower, type, default) +@table(name, name_lower, type, default, manual_impl) UI_StackTable: { //- rjf: parents - { Parent parent `UI_Box *` `&ui_nil_box` } + { Parent parent `UI_Box *` `&ui_nil_box` } //- rjf: layout params { ChildLayoutAxis child_layout_axis Axis2 `Axis2_X` } @@ -23,6 +23,7 @@ UI_StackTable: //- rjf: flags { PermissionFlags permission_flags UI_PermissionFlags UI_PermissionFlag_All } { Flags flags UI_BoxFlags 0 } + { OmitFlags omit_flags UI_BoxFlags 0 } //- rjf: interaction { FocusHot focus_hot UI_FocusKind UI_FocusKind_Null } @@ -33,7 +34,7 @@ UI_StackTable: //- rjf: colors { Transparency transparency F32 0 } { Palette palette `UI_Palette* ` `&ui_g_nil_palette` } - { Tag tag String8 `str8_lit("")` } + { Tag tag String8 `str8_lit("")` 1 } //- rjf: squish { Squish squish F32 0 } @@ -149,13 +150,13 @@ UI_StackTable: @gen @c_file { @expand(UI_StackTable a) - `internal $(a.type) ui_top_$(a.name_lower)(void) { UI_StackTopImpl(ui_state, $(a.name), $(a.name_lower)) }`; + `$(a.manual_impl == "" -> "internal " .. a.type .. " ui_top_" .. a.name_lower .. "(void) { UI_StackTopImpl(ui_state, " .. a.name .. ", " .. a.name_lower .. ") }")`; @expand(UI_StackTable a) - `internal $(a.type) ui_bottom_$(a.name_lower)(void) { UI_StackBottomImpl(ui_state, $(a.name), $(a.name_lower)) }`; + `$(a.manual_impl == "" -> "internal " .. a.type .. " ui_bottom_" .. a.name_lower .. "(void) { UI_StackBottomImpl(ui_state, " .. a.name .. ", " .. a.name_lower .. ") }")`; @expand(UI_StackTable a) - `internal $(a.type) ui_push_$(a.name_lower)($(a.type) v) { UI_StackPushImpl(ui_state, $(a.name), $(a.name_lower), $(a.type), v) }`; + `$(a.manual_impl == "" -> "internal " .. a.type .. " ui_push_" .. a.name_lower .. "(" .. a.type .. " v) { UI_StackPushImpl(ui_state, " .. a.name .. ", " .. a.name_lower .. ", " .. a.type .. ", v) }")`; @expand(UI_StackTable a) - `internal $(a.type) ui_pop_$(a.name_lower)(void) { UI_StackPopImpl(ui_state, $(a.name), $(a.name_lower)) }`; + `$(a.manual_impl == "" -> "internal " .. a.type .. " ui_pop_" .. a.name_lower .. "(void) { UI_StackPopImpl(ui_state, " .. a.name .. ", " .. a.name_lower .. ") }")`; @expand(UI_StackTable a) - `internal $(a.type) ui_set_next_$(a.name_lower)($(a.type) v) { UI_StackSetNextImpl(ui_state, $(a.name), $(a.name_lower), $(a.type), v) }`; + `$(a.manual_impl == "" -> "internal " .. a.type .. " ui_set_next_" .. a.name_lower .. "(" .. a.type .. " v) { UI_StackSetNextImpl(ui_state, " .. a.name .. ", " .. a.name_lower .. ", " .. a.type .. ", v) }")`; } diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index 864302bc..8aba4805 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -1918,11 +1918,13 @@ ui_tooltip_begin_base(void) ui_push_flags(0); ui_push_text_raster_flags(ui_bottom_text_raster_flags()); ui_push_palette(ui_bottom_palette()); + ui_push_tag(str8_lit(".")); } internal void ui_tooltip_end_base(void) { + ui_pop_tag(); ui_pop_palette(); ui_pop_text_raster_flags(); ui_pop_flags(); @@ -2005,6 +2007,7 @@ ui_begin_ctx_menu(UI_Key key) ui_push_focus_hot(UI_FocusKind_Root); ui_push_focus_active(UI_FocusKind_Root); ui_push_palette(ui_state->widget_palette_info.ctx_menu_palette); + ui_push_tag(str8_lit(".")); B32 is_open = ui_key_match(key, ui_state->ctx_menu_key) && ui_state->ctx_menu_open; if(is_open != 0) { @@ -2033,6 +2036,7 @@ ui_end_ctx_menu(void) ui_state->is_in_open_ctx_menu = 0; ui_spacer(ui_em(1.f, 1.f)); } + ui_pop_tag(); ui_pop_palette(); ui_pop_focus_active(); ui_pop_focus_hot(); @@ -2262,7 +2266,7 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key) //- rjf: fill box { box->key = key; - box->flags = flags|ui_state->flags_stack.top->v; + box->flags = (flags | ui_state->flags_stack.top->v) & ~ui_state->omit_flags_stack.top->v; box->fastpath_codepoint = ui_state->fastpath_codepoint_stack.top->v; box->group_key = ui_state->group_key_stack.top->v; @@ -2357,7 +2361,14 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key) String8List tags = {0}; for(UI_TagNode *n = ui_state->tag_stack.top; n != 0; n = n->next) { - str8_list_push(ui_build_arena(), &tags, push_str8_copy(ui_build_arena(), n->v)); + if(n->v.size == 1 && n->v.str[0] == '.') + { + break; + } + if(n->v.size != 0) + { + str8_list_push(ui_build_arena(), &tags, push_str8_copy(ui_build_arena(), n->v)); + } } ui_state->current_gen_tags = str8_array_from_list(ui_build_arena(), &tags); scratch_end(scratch); @@ -3054,6 +3065,57 @@ ui_anim_(UI_Key key, UI_AnimParams *params) //////////////////////////////// //~ rjf: Stacks +#define UI_StackTopImpl(state, name_upper, name_lower) \ +return state->name_lower##_stack.top->v; + +#define UI_StackBottomImpl(state, name_upper, name_lower) \ +return state->name_lower##_stack.bottom_val; + +#define UI_StackPushImpl(state, name_upper, name_lower, type, new_value) \ +UI_##name_upper##Node *node = state->name_lower##_stack.free;\ +if(node != 0) {SLLStackPop(state->name_lower##_stack.free);}\ +else {node = push_array(ui_build_arena(), UI_##name_upper##Node, 1);}\ +type old_value = state->name_lower##_stack.top->v;\ +node->v = new_value;\ +SLLStackPush(state->name_lower##_stack.top, node);\ +if(node->next == &state->name_lower##_nil_stack_top)\ +{\ +state->name_lower##_stack.bottom_val = (new_value);\ +}\ +state->name_lower##_stack.auto_pop = 0;\ +state->name_lower##_stack.gen += 1;\ +return old_value; + +#define UI_StackPopImpl(state, name_upper, name_lower) \ +UI_##name_upper##Node *popped = state->name_lower##_stack.top;\ +if(popped != &state->name_lower##_nil_stack_top)\ +{\ +SLLStackPop(state->name_lower##_stack.top);\ +SLLStackPush(state->name_lower##_stack.free, popped);\ +state->name_lower##_stack.auto_pop = 0;\ +state->name_lower##_stack.gen += 1;\ +}\ +return popped->v;\ + +#define UI_StackSetNextImpl(state, name_upper, name_lower, type, new_value) \ +UI_##name_upper##Node *node = state->name_lower##_stack.free;\ +if(node != 0) {SLLStackPop(state->name_lower##_stack.free);}\ +else {node = push_array(ui_build_arena(), UI_##name_upper##Node, 1);}\ +type old_value = state->name_lower##_stack.top->v;\ +node->v = new_value;\ +SLLStackPush(state->name_lower##_stack.top, node);\ +state->name_lower##_stack.auto_pop = 1;\ +state->name_lower##_stack.gen += 1;\ +return old_value; + +//- rjf: manual implementations + +internal String8 ui_top_tag(void) { UI_StackTopImpl(ui_state, Tag, tag) } +internal String8 ui_bottom_tag(void) { UI_StackBottomImpl(ui_state, Tag, tag) } +internal String8 ui_push_tag(String8 v) { UI_StackPushImpl(ui_state, Tag, tag, String8, push_str8_copy(ui_build_arena(), v)) } +internal String8 ui_pop_tag(void) { UI_StackPopImpl(ui_state, Tag, tag) } +internal String8 ui_set_next_tag(String8 v) { UI_StackSetNextImpl(ui_state, Tag, tag, String8, push_str8_copy(ui_build_arena(), v)) } + //- rjf: helpers internal Rng2F32 @@ -3139,50 +3201,19 @@ ui_pop_corner_radius(void) ui_pop_corner_radius_11(); } +internal void +ui_push_tagf(char *fmt, ...) +{ + Temp scratch = scratch_begin(0, 0); + va_list args; + va_start(args, fmt); + String8 string = push_str8fv(scratch.arena, fmt, args); + ui_push_tag(string); + va_end(args); + scratch_end(scratch); +} + //////////////////////////////// //~ rjf: Generated Code -#define UI_StackTopImpl(state, name_upper, name_lower) \ -return state->name_lower##_stack.top->v; - -#define UI_StackBottomImpl(state, name_upper, name_lower) \ -return state->name_lower##_stack.bottom_val; - -#define UI_StackPushImpl(state, name_upper, name_lower, type, new_value) \ -UI_##name_upper##Node *node = state->name_lower##_stack.free;\ -if(node != 0) {SLLStackPop(state->name_lower##_stack.free);}\ -else {node = push_array(ui_build_arena(), UI_##name_upper##Node, 1);}\ -type old_value = state->name_lower##_stack.top->v;\ -node->v = new_value;\ -SLLStackPush(state->name_lower##_stack.top, node);\ -if(node->next == &state->name_lower##_nil_stack_top)\ -{\ -state->name_lower##_stack.bottom_val = (new_value);\ -}\ -state->name_lower##_stack.auto_pop = 0;\ -state->name_lower##_stack.gen += 1;\ -return old_value; - -#define UI_StackPopImpl(state, name_upper, name_lower) \ -UI_##name_upper##Node *popped = state->name_lower##_stack.top;\ -if(popped != &state->name_lower##_nil_stack_top)\ -{\ -SLLStackPop(state->name_lower##_stack.top);\ -SLLStackPush(state->name_lower##_stack.free, popped);\ -state->name_lower##_stack.auto_pop = 0;\ -state->name_lower##_stack.gen += 1;\ -}\ -return popped->v;\ - -#define UI_StackSetNextImpl(state, name_upper, name_lower, type, new_value) \ -UI_##name_upper##Node *node = state->name_lower##_stack.free;\ -if(node != 0) {SLLStackPop(state->name_lower##_stack.free);}\ -else {node = push_array(ui_build_arena(), UI_##name_upper##Node, 1);}\ -type old_value = state->name_lower##_stack.top->v;\ -node->v = new_value;\ -SLLStackPush(state->name_lower##_stack.top, node);\ -state->name_lower##_stack.auto_pop = 1;\ -state->name_lower##_stack.gen += 1;\ -return old_value; - #include "generated/ui.meta.c" diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index 0a23acb5..32bc53fd 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -948,6 +948,7 @@ internal U32 ui_top_fastpath_codepoint(void); internal UI_Key ui_top_group_key(void); internal F32 ui_top_transparency(void); internal UI_Palette* ui_top_palette(void); +internal String8 ui_top_tag(void); internal F32 ui_top_squish(void); internal OS_Cursor ui_top_hover_cursor(void); internal FNT_Tag ui_top_font(void); @@ -977,6 +978,7 @@ internal U32 ui_bottom_fastpath_codepoint(void); internal UI_Key ui_bottom_group_key(void); internal F32 ui_bottom_transparency(void); internal UI_Palette* ui_bottom_palette(void); +internal String8 ui_bottom_tag(void); internal F32 ui_bottom_squish(void); internal OS_Cursor ui_bottom_hover_cursor(void); internal FNT_Tag ui_bottom_font(void); @@ -1006,6 +1008,7 @@ internal U32 ui_push_fastpath_codepoint(U32 v); internal UI_Key ui_push_group_key(UI_Key v); internal F32 ui_push_transparency(F32 v); internal UI_Palette* ui_push_palette(UI_Palette* v); +internal String8 ui_push_tag(String8 v); internal F32 ui_push_squish(F32 v); internal OS_Cursor ui_push_hover_cursor(OS_Cursor v); internal FNT_Tag ui_push_font(FNT_Tag v); @@ -1035,6 +1038,7 @@ internal U32 ui_pop_fastpath_codepoint(void); internal UI_Key ui_pop_group_key(void); internal F32 ui_pop_transparency(void); internal UI_Palette* ui_pop_palette(void); +internal String8 ui_pop_tag(void); internal F32 ui_pop_squish(void); internal OS_Cursor ui_pop_hover_cursor(void); internal FNT_Tag ui_pop_font(void); @@ -1064,6 +1068,7 @@ internal U32 ui_set_next_fastpath_codepoint(U32 v); internal UI_Key ui_set_next_group_key(UI_Key v); internal F32 ui_set_next_transparency(F32 v); internal UI_Palette* ui_set_next_palette(UI_Palette* v); +internal String8 ui_set_next_tag(String8 v); internal F32 ui_set_next_squish(F32 v); internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v); internal FNT_Tag ui_set_next_font(FNT_Tag v); @@ -1087,6 +1092,7 @@ internal UI_Size ui_pop_pref_size(Axis2 axis); internal UI_Size ui_set_next_pref_size(Axis2 axis, UI_Size v); internal void ui_push_corner_radius(F32 v); internal void ui_pop_corner_radius(void); +internal void ui_push_tagf(char *fmt, ...); //////////////////////////////// //~ rjf: Macro Loop Wrappers @@ -1102,12 +1108,14 @@ internal void ui_pop_corner_radius(void); #define UI_PrefHeight(v) DeferLoop(ui_push_pref_height(v), ui_pop_pref_height()) #define UI_PermissionFlags(v) DeferLoop(ui_push_permission_flags(v), ui_pop_permission_flags()) #define UI_Flags(v) DeferLoop(ui_push_flags(v), ui_pop_flags()) +#define UI_OmitFlags(v) DeferLoop(ui_push_omit_flags(v), ui_pop_omit_flags()) #define UI_FocusHot(v) DeferLoop(ui_push_focus_hot(v), ui_pop_focus_hot()) #define UI_FocusActive(v) DeferLoop(ui_push_focus_active(v), ui_pop_focus_active()) #define UI_FastpathCodepoint(v) DeferLoop(ui_push_fastpath_codepoint(v), ui_pop_fastpath_codepoint()) #define UI_GroupKey(v) DeferLoop(ui_push_group_key(v), ui_pop_group_key()) #define UI_Transparency(v) DeferLoop(ui_push_transparency(v), ui_pop_transparency()) #define UI_Palette(v) DeferLoop(ui_push_palette(v), ui_pop_palette()) +#define UI_Tag(v) DeferLoop(ui_push_tag(v), ui_pop_tag()) #define UI_Squish(v) DeferLoop(ui_push_squish(v), ui_pop_squish()) #define UI_HoverCursor(v) DeferLoop(ui_push_hover_cursor(v), ui_pop_hover_cursor()) #define UI_Font(v) DeferLoop(ui_push_font(v), ui_pop_font()) @@ -1132,6 +1140,7 @@ internal void ui_pop_corner_radius(void); #define UI_CornerRadius(v) DeferLoop(ui_push_corner_radius(v), ui_pop_corner_radius()) #define UI_Focus(kind) DeferLoop((ui_push_focus_hot(kind), ui_push_focus_active(kind)), (ui_pop_focus_hot(), ui_pop_focus_active())) #define UI_FlagsAdd(v) DeferLoop(ui_push_flags(ui_top_flags()|(v)), ui_pop_flags()) +#define UI_TagF(...) DeferLoop(ui_push_tagf(__VA_ARGS__), ui_pop_tag()) //- rjf: tooltip #define UI_TooltipBase DeferLoop(ui_tooltip_begin_base(), ui_tooltip_end_base())