From b0cff76501e955b3c7cd20b834e0b103e1d28a39 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 19 Feb 2025 12:09:28 -0800 Subject: [PATCH] eliminate old palette system entirely --- src/raddbg/raddbg_core.c | 68 +--- src/raddbg/raddbg_core.h | 6 - src/raddbg/raddbg_views.c | 768 ++---------------------------------- src/raddbg/raddbg_widgets.c | 106 +++-- src/ui/generated/ui.meta.c | 18 +- src/ui/generated/ui.meta.h | 33 +- src/ui/ui.mdesk | 3 +- src/ui/ui_basic_widgets.c | 6 +- src/ui/ui_core.c | 53 +-- src/ui/ui_core.h | 93 +---- 10 files changed, 163 insertions(+), 991 deletions(-) diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 380ab03c..56af04b3 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -4262,41 +4262,6 @@ rd_window_frame(void) rd_regs()->panel = panel_tree.focused->cfg->id; rd_regs()->view = panel_tree.focused->selected_tab->id; - ////////////////////////////// - //- rjf: compute ui palettes from theme - // - { - RD_Theme *current = rd_state->theme; - for EachEnumVal(RD_PaletteCode, code) - { - ws->cfg_palettes[code].null = v4f32(1, 0, 1, 1); - } -#define fill_palette(name) \ -{\ -ws->cfg_palettes[RD_PaletteCode_##name].background = current->colors[RD_ThemeColor_##name##Background];\ -ws->cfg_palettes[RD_PaletteCode_##name].background_alt = current->colors[RD_ThemeColor_##name##BackgroundAlt];\ -ws->cfg_palettes[RD_PaletteCode_##name].background_good = current->colors[RD_ThemeColor_##name##BackgroundGood];\ -ws->cfg_palettes[RD_PaletteCode_##name].background_bad = current->colors[RD_ThemeColor_##name##BackgroundBad];\ -ws->cfg_palettes[RD_PaletteCode_##name].background_pop = current->colors[RD_ThemeColor_##name##BackgroundPop];\ -ws->cfg_palettes[RD_PaletteCode_##name].border = current->colors[RD_ThemeColor_##name##Border];\ -ws->cfg_palettes[RD_PaletteCode_##name].text = current->colors[RD_ThemeColor_##name##Text];\ -ws->cfg_palettes[RD_PaletteCode_##name].text_weak = current->colors[RD_ThemeColor_##name##TextWeak];\ -ws->cfg_palettes[RD_PaletteCode_##name].hover = current->colors[RD_ThemeColor_##name##Hover];\ -ws->cfg_palettes[RD_PaletteCode_##name].focus = current->colors[RD_ThemeColor_##name##Focus];\ -ws->cfg_palettes[RD_PaletteCode_##name].cursor = current->colors[RD_ThemeColor_##name##Cursor];\ -ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_ThemeColor_##name##Selection];\ -} - fill_palette(Base); - fill_palette(MenuBar); - fill_palette(Good); - fill_palette(Bad); - fill_palette(Pop); - fill_palette(ScrollBar); - fill_palette(Tab); - fill_palette(TabInactive); - fill_palette(DropSite); - } - ////////////////////////////// //- rjf: gather listers // @@ -4359,14 +4324,6 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The icon_info.icon_kind_text_map[UI_IconKind_CheckFilled] = rd_icon_kind_text_table[RD_IconKind_CheckFilled]; } - // rjf: build widget palette info - UI_WidgetPaletteInfo widget_palette_info = {0}; - { - widget_palette_info.tooltip_palette = rd_palette_from_code(RD_PaletteCode_Base); - widget_palette_info.ctx_menu_palette = rd_palette_from_code(RD_PaletteCode_Base); - widget_palette_info.scrollbar_palette = rd_palette_from_code(RD_PaletteCode_ScrollBar); - } - // rjf: build animation info UI_AnimationInfo animation_info = {0}; { @@ -4379,13 +4336,12 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The } // rjf: begin & push initial stack values - ui_begin_build(ws->os, &ws->ui_events, &icon_info, ws->theme, &widget_palette_info, &animation_info, rd_state->frame_dt, rd_state->frame_dt); + ui_begin_build(ws->os, &ws->ui_events, &icon_info, ws->theme, &animation_info, rd_state->frame_dt, rd_state->frame_dt); ui_push_font(main_font); ui_push_font_size(main_font_size); ui_push_text_padding(main_font_size*0.3f); ui_push_pref_width(ui_em(20.f, 1)); ui_push_pref_height(ui_em(2.75f, 1.f)); - ui_push_palette(rd_palette_from_code(RD_PaletteCode_Base)); ui_push_blur_size(10.f); FNT_RasterFlags text_raster_flags = 0; if(rd_setting_b32_from_name(str8_lit("smooth_main_text"))) {text_raster_flags |= FNT_RasterFlag_Smooth;} @@ -7125,9 +7081,6 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The 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_set_next_hover_cursor(OS_Cursor_HandPoint); UI_Box *close_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable| UI_BoxFlag_DrawBorder| @@ -7535,11 +7488,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The 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 = ui_color_from_tags_key_name(box->tags_key, str8_lit("background")); - } + Vec4F32 box_background_color = box->background_color; // rjf: draw background if(box->flags & UI_BoxFlag_DrawBackground) @@ -9471,17 +9420,6 @@ rd_theme_color_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8 str return color; } -//- rjf: code -> palette - -internal UI_Palette * -rd_palette_from_code(RD_PaletteCode code) -{ - RD_Cfg *wcfg = rd_cfg_from_id(rd_regs()->window); - RD_WindowState *ws = rd_window_state_from_cfg(wcfg); - UI_Palette *result = &ws->cfg_palettes[code]; - return result; -} - //- rjf: fonts/sizes internal FNT_Tag @@ -9608,7 +9546,7 @@ rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, CTRL_Event *event) CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, event->entity); DR_FStrList thread_fstrs = rd_title_fstrs_from_ctrl_entity(arena, thread, 0); DR_FStrList fstrs = {0}; - DR_FStrParams params = {ui_top_font(), ui_top_text_raster_flags(), ui_top_palette()->text, ui_top_font_size()}; + DR_FStrParams params = {ui_top_font(), ui_top_text_raster_flags(), ui_color_from_name(str8_lit("text")), ui_top_font_size()}; switch(event->cause) { default:{}break; diff --git a/src/raddbg/raddbg_core.h b/src/raddbg/raddbg_core.h index c8c5b42c..8c46be56 100644 --- a/src/raddbg/raddbg_core.h +++ b/src/raddbg/raddbg_core.h @@ -542,9 +542,6 @@ struct RD_WindowState // rjf: theme (recomputed each frame) UI_Theme *theme; - // rjf: config/settings - UI_Palette cfg_palettes[RD_PaletteCode_COUNT]; // derivative from theme - // rjf: dev interface state B32 dev_menu_is_open; @@ -1157,9 +1154,6 @@ 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); -//- rjf: code -> palette -internal UI_Palette *rd_palette_from_code(RD_PaletteCode code); - //- rjf: fonts/sizes internal FNT_Tag rd_font_from_slot(RD_FontSlot slot); internal F32 rd_font_size_from_slot(RD_FontSlot slot); diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 9ed4a54f..4d91d8a9 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -1463,9 +1463,9 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla { RD_CmdKind cmd_kind = (RD_CmdKind)result.eval.value.u64; String8 cmd_name = rd_cmd_kind_info_table[cmd_kind].string; - if(cell->px != 0) + if(cell->px != 0) UI_TagF("weak") { - DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Icons), rd_raster_flags_from_slot(RD_FontSlot_Icons), ui_top_palette()->text_weak, ui_top_font_size()}; + DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Icons), rd_raster_flags_from_slot(RD_FontSlot_Icons), ui_color_from_name(str8_lit("text")), ui_top_font_size()}; dr_fstrs_push_new(arena, &result.fstrs, ¶ms, rd_icon_kind_text_table[rd_icon_kind_from_code_name(cmd_name)]); } else @@ -1559,6 +1559,8 @@ RD_VIEW_UI_FUNCTION_DEF(watch) F32 row_string_max_size_px = dim_2f32(rect).x; EV_StringFlags string_flags = EV_StringFlag_ReadOnlyDisplayRules; String8 filter = rd_view_search(); + Vec4F32 pop_background_rgba = {0}; + UI_TagF("pop") pop_background_rgba = ui_color_from_name(str8_lit("background")); ////////////////////////////// //- rjf: decide if root should be implicit @@ -2748,7 +2750,6 @@ RD_VIEW_UI_FUNCTION_DEF(watch) // ProfBegin("determine row's flags & color palette"); UI_BoxFlags row_flags = UI_BoxFlag_DisableFocusOverlay; - UI_Palette *palette = ui_top_palette(); { if(row_is_fresh) { @@ -2770,7 +2771,6 @@ RD_VIEW_UI_FUNCTION_DEF(watch) //////////////////////// //- rjf: build row box // - ui_set_next_palette(palette); ui_set_next_flags(disabled_flags); ui_set_next_pref_width(ui_pct(1, 0)); ui_set_next_pref_height(ui_px(row_height_px*row->visual_size, 1.f)); @@ -2841,7 +2841,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch) //- rjf: determine cell's palette ProfBegin("determine cell's palette"); UI_BoxFlags cell_flags = 0; - UI_Palette *palette = ui_top_palette(); + Vec4F32 cell_background_color_override = {0}; String8 cell_tag = {0}; { if(cell_info.flags & RD_WatchCellFlag_IsErrored) @@ -2861,11 +2861,11 @@ RD_VIEW_UI_FUNCTION_DEF(watch) Vec4F32 rgba = linear_from_srgba(rd_color_from_cfg(cfg)); if(rgba.w == 0) { - rgba = ui_top_palette()->background_pop; + rgba = pop_background_rgba; } rgba.w *= 0.2f; rgba.w *= ui_anim(ui_key_from_stringf(ui_key_zero(), "###cfg_hover_t_%p", cfg), 1.f, .rate = entity_hover_t_rate); - palette = ui_build_palette(ui_top_palette(), .background_pop = rgba); + cell_background_color_override = rgba; cell_flags |= UI_BoxFlag_DrawBackground; } else if(ctrl_handle_match(cell_info.entity->handle, rd_get_hover_regs()->ctrl_entity) && @@ -2875,11 +2875,11 @@ RD_VIEW_UI_FUNCTION_DEF(watch) Vec4F32 rgba = rd_color_from_ctrl_entity(entity); if(rgba.w == 0) { - rgba = ui_top_palette()->background_pop;; + rgba = pop_background_rgba; } rgba.w *= 0.2f; rgba.w *= ui_anim(ui_key_from_stringf(ui_key_zero(), "###entity_hover_t_%p", entity), 1.f, .rate = entity_hover_t_rate); - palette = ui_build_palette(ui_top_palette(), .background_pop = rgba); + cell_background_color_override = rgba; cell_flags |= UI_BoxFlag_DrawBackground; } } @@ -2887,7 +2887,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch) //- rjf: build cell UI_Box *cell_box = &ui_nil_box; - UI_Palette(palette) UI_PrefWidth(ui_px(cell_width_px, 0.f)) + UI_PrefWidth(ui_px(cell_width_px, 0.f)) { ui_set_next_fixed_height(floor_f32(row->visual_size * row_height_px)); cell_box = ui_build_box_from_stringf(UI_BoxFlag_DrawSideLeft|cell_flags, "cell_%I64x_%I64x", row_hash, cell_id); @@ -2964,9 +2964,10 @@ RD_VIEW_UI_FUNCTION_DEF(watch) { UI_Parent(box) UI_Flags(0) UI_TextAlignment(UI_TextAlign_Center) { + Vec4F32 color = rd_color_from_ctrl_entity(row_info->callstack_thread); RD_Font(RD_FontSlot_Icons) UI_Flags(UI_BoxFlag_DisableTextTrunc) - UI_Palette(ui_build_palette(ui_top_palette(), .text = rd_color_from_ctrl_entity(row_info->callstack_thread))) + UI_TextColor(color) ui_label(rd_icon_kind_text_table[RD_IconKind_RightArrow]); } } @@ -3451,8 +3452,8 @@ RD_VIEW_UI_FUNCTION_DEF(text) UI_CornerRadius(ui_top_font_size()/3) UI_PrefWidth(ui_text_dim(10, 1)) UI_Focus(UI_FocusKind_On) - RD_Palette(RD_PaletteCode_Pop) UI_TextAlignment(UI_TextAlign_Center) + UI_TagF("pop") if(ui_clicked(ui_buttonf("Find alternative..."))) { rd_cmd(RD_CmdKind_RunCommand, .cmd_name = rd_cmd_kind_info_table[RD_CmdKind_PickFile].string); @@ -3523,18 +3524,12 @@ RD_VIEW_UI_FUNCTION_DEF(text) { ui_set_next_rect(shift_2f32(bottom_bar_rect, scale_2f32(rect.p0, -1.f))); ui_set_next_flags(UI_BoxFlag_DrawBackground); - UI_Palette *palette = ui_top_palette(); - if(file_is_out_of_date) - { - palette = rd_palette_from_code(RD_PaletteCode_Bad); - } - UI_Palette(palette) - UI_Row + UI_Row UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_text_dim(10, 1)) UI_TagF("weak") { - if(file_is_out_of_date) + if(file_is_out_of_date) UI_TagF("bad_pop") { UI_Box *box = &ui_nil_box; RD_Font(RD_FontSlot_Icons) @@ -3856,6 +3851,8 @@ RD_VIEW_UI_FUNCTION_DEF(memory) num_columns = ClampBot(1, num_columns); bytes_per_cell = ClampBot(1, bytes_per_cell); UI_ScrollPt2 scroll_pos = rd_view_scroll_pos(); + Vec4F32 selection_color = ui_color_from_name(str8_lit("selection")); + Vec4F32 border_color = ui_color_from_name(str8_lit("border")); ////////////////////////////// //- rjf: process commands @@ -4053,8 +4050,9 @@ RD_VIEW_UI_FUNCTION_DEF(memory) // DR_FStrList byte_fstrs[256] = {0}; { - Vec4F32 full_color = ui_top_palette()->text; - Vec4F32 zero_color = ui_top_palette()->text_weak; + Vec4F32 full_color = ui_color_from_name(str8_lit("text")); + Vec4F32 zero_color = full_color; + UI_TagF("weak") zero_color = ui_color_from_name(str8_lit("text")); for(U64 idx = 0; idx < ArrayCount(byte_fstrs); idx += 1) { U8 byte = (U8)idx; @@ -4446,11 +4444,11 @@ RD_VIEW_UI_FUNCTION_DEF(memory) if(selection.min <= global_byte_idx && global_byte_idx <= selection.max) { cell_flags |= UI_BoxFlag_DrawBackground; - cell_bg_rgba = ui_top_palette()->selection; + cell_bg_rgba = selection_color; } // rjf: build - ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = cell_bg_rgba)); + ui_set_next_background_color(cell_bg_rgba); UI_Box *cell_box = ui_build_box_from_key(UI_BoxFlag_DrawText|cell_flags, ui_key_zero()); ui_box_equip_display_fstrs(cell_box, &byte_fstrs[byte_value]); { @@ -4459,7 +4457,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory) { if(global_byte_idx == a->vaddr_range.min) UI_Parent(row_overlay_box) { - ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = annotation->color)); + ui_set_next_background_color(annotation->color); ui_set_next_fixed_x(big_glyph_advance*20.f + col_idx*cell_width_px + -cell_width_px/8.f + off); ui_set_next_fixed_y((row_idx-viz_range_rows.min)*row_height_px + -cell_width_px/8.f); ui_set_next_fixed_width(cell_width_px/4.f); @@ -4528,7 +4526,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory) ascii_box->rect.y0, text_pos.x + fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, selection_in_row.max+1-row_range_bytes.min)).x + font_size/4.f, ascii_box->rect.y1), - ui_top_palette()->selection, + selection_color, 0, 0, 1.f); } ui_box_equip_draw_bucket(ascii_box, bucket); @@ -4539,7 +4537,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory) DR_BucketScope(bucket) { Vec2F32 text_pos = ui_box_text_position(ascii_box); - Vec4F32 color = ui_top_palette()->border; + Vec4F32 color = border_color; dr_rect(r2f32p(text_pos.x + fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, mouse_hover_byte_num-1-row_range_bytes.min)).x - font_size/8.f, ascii_box->rect.y0, text_pos.x + fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, mouse_hover_byte_num+0-row_range_bytes.min)).x + font_size/4.f, @@ -4703,7 +4701,11 @@ internal UI_BOX_CUSTOM_DRAW(rd_bitmap_view_canvas_box_draw) Rng2F32 rect_cvs = rd_bitmap_canvas_from_screen_rect(draw_data->view_center_pos, draw_data->zoom, rect_scrn, rect_scrn); F32 grid_cell_size_cvs = box->font_size*10.f; F32 grid_line_thickness_px = Max(2.f, box->font_size*0.1f); - Vec4F32 grid_line_color = ui_top_palette()->background_alt; + Vec4F32 grid_line_color = {0}; + UI_TagF("alt") + { + grid_line_color = ui_color_from_name(str8_lit("background")); + } for EachEnumVal(Axis2, axis) { for(F32 v = rect_cvs.p0.v[axis] - mod_f32(rect_cvs.p0.v[axis], grid_cell_size_cvs); @@ -4993,7 +4995,7 @@ RD_VIEW_UI_FUNCTION_DEF(color_rgba) text_box = ui_build_box_from_key(UI_BoxFlag_DrawText, ui_key_zero()); DR_FStrList fstrs = {0}; { - DR_FStrParams params = {ui_top_font(), ui_top_text_raster_flags(), ui_top_palette()->text, ui_top_font_size()}; + DR_FStrParams params = {ui_top_font(), ui_top_text_raster_flags(), ui_color_from_name(str8_lit("text")), ui_top_font_size()}; dr_fstrs_push_new(scratch.arena, &fstrs, ¶ms, str8_lit("(")); dr_fstrs_push_new(scratch.arena, &fstrs, ¶ms, push_str8f(scratch.arena, "%.2f", rgba.x), .color = v4f32(1.f, 0.25f, 0.25f, 1.f), .underline_thickness = 4.f); dr_fstrs_push_new(scratch.arena, &fstrs, ¶ms, str8_lit(", ")); @@ -5014,7 +5016,7 @@ RD_VIEW_UI_FUNCTION_DEF(color_rgba) color_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable, "color_box"); UI_Parent(color_box) UI_PrefHeight(ui_em(1.875f, 1.f)) UI_Padding(ui_pct(1, 0)) { - UI_Palette(ui_build_palette(ui_top_palette(), .background = rgba)) UI_CornerRadius(ui_top_font_size()*0.5f) + UI_BackgroundColor(rgba) UI_CornerRadius(ui_top_font_size()*0.5f) ui_build_box_from_key(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder, ui_key_zero()); } } @@ -5241,709 +5243,3 @@ RD_VIEW_UI_FUNCTION_DEF(geo3d) geo_scope_close(geo_scope); scratch_end(scratch); } - -//////////////////////////////// -//~ rjf: settings @view_hook_impl - -#if 0 // TODO(rjf): @cfg -typedef enum RD_SettingsItemKind -{ - RD_SettingsItemKind_CategoryHeader, - RD_SettingsItemKind_GlobalSetting, - RD_SettingsItemKind_WindowSetting, - RD_SettingsItemKind_ThemeColor, - RD_SettingsItemKind_ThemePreset, - RD_SettingsItemKind_COUNT -} -RD_SettingsItemKind; - -typedef struct RD_SettingsItem RD_SettingsItem; -struct RD_SettingsItem -{ - RD_SettingsItemKind kind; - String8 kind_string; - String8 string; - FuzzyMatchRangeList kind_string_matches; - FuzzyMatchRangeList string_matches; - RD_IconKind icon_kind; - RD_SettingCode code; - RD_ThemeColor color; - RD_ThemePreset preset; - RD_SettingsItemKind category; -}; - -typedef struct RD_SettingsItemNode RD_SettingsItemNode; -struct RD_SettingsItemNode -{ - RD_SettingsItemNode *next; - RD_SettingsItem v; -}; - -typedef struct RD_SettingsItemList RD_SettingsItemList; -struct RD_SettingsItemList -{ - RD_SettingsItemNode *first; - RD_SettingsItemNode *last; - U64 count; -}; - -typedef struct RD_SettingsItemArray RD_SettingsItemArray; -struct RD_SettingsItemArray -{ - RD_SettingsItem *v; - U64 count; -}; - -internal int -rd_qsort_compare_settings_item(RD_SettingsItem *a, RD_SettingsItem *b) -{ - int result = 0; - if(a->string_matches.count > b->string_matches.count) - { - result = -1; - } - else if(a->string_matches.count < b->string_matches.count) - { - result = +1; - } - else if(a->kind_string_matches.count > b->kind_string_matches.count) - { - result = -1; - } - else if(a->kind_string_matches.count < b->kind_string_matches.count) - { - result = +1; - } - return result; -} -#endif - -#if 0 // TODO(rjf): @cfg -RD_VIEW_RULE_UI_FUNCTION_DEF(settings) -{ - ProfBeginFunction(); - Temp scratch = scratch_begin(0, 0); - F32 row_height_px = floor_f32(ui_top_font_size()*2.5f); - String8 query = string; - RD_Cfg *window = rd_cfg_from_id(rd_regs()->window); - UI_ScrollPt2 scroll_pos = rd_view_scroll_pos(); - - ////////////////////////////// - //- rjf: get state - // - typedef struct RD_SettingsViewState RD_SettingsViewState; - struct RD_SettingsViewState - { - B32 initialized; - Vec2S64 cursor; - TxtPt txt_cursor; - TxtPt txt_mark; - U8 txt_buffer[1024]; - U64 txt_size; - RD_ThemeColor color_ctx_menu_color; - Vec4F32 color_ctx_menu_color_hsva; - RD_ThemePreset preset_apply_confirm; - B32 category_opened[RD_SettingsItemKind_COUNT]; - }; - RD_SettingsViewState *sv = rd_view_state(RD_SettingsViewState); - if(!sv->initialized) - { - sv->initialized = 1; - sv->preset_apply_confirm = RD_ThemePreset_COUNT; - } - - ////////////////////////////// - //- rjf: gather all filtered settings items - // - RD_SettingsItemArray items = {0}; - { - RD_SettingsItemList items_list = {0}; - - //- rjf: global settings header - if(query.size == 0) - { - RD_SettingsItemNode *n = push_array(scratch.arena, RD_SettingsItemNode, 1); - SLLQueuePush(items_list.first, items_list.last, n); - items_list.count += 1; - n->v.kind = RD_SettingsItemKind_CategoryHeader; - n->v.string = str8_lit("Global Interface Settings"); - n->v.icon_kind = sv->category_opened[RD_SettingsItemKind_GlobalSetting] ? RD_IconKind_DownCaret : RD_IconKind_RightCaret; - n->v.category = RD_SettingsItemKind_GlobalSetting; - } - - //- rjf: gather all global settings - if(sv->category_opened[RD_SettingsItemKind_GlobalSetting] || query.size != 0) - { - for EachEnumVal(RD_SettingCode, code) - { - if(rd_setting_code_default_is_per_window_table[code]) - { - continue; - } - String8 kind_string = str8_lit("Global Interface Setting"); - String8 string = rd_setting_code_display_string_table[code]; - FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string); - FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string); - if(string_matches.count == string_matches.needle_part_count || - kind_string_matches.count == kind_string_matches.needle_part_count) - { - RD_SettingsItemNode *n = push_array(scratch.arena, RD_SettingsItemNode, 1); - SLLQueuePush(items_list.first, items_list.last, n); - items_list.count += 1; - n->v.kind = RD_SettingsItemKind_GlobalSetting; - n->v.kind_string = kind_string; - n->v.string = string; - n->v.kind_string_matches = kind_string_matches; - n->v.string_matches = string_matches; - n->v.icon_kind = RD_IconKind_Window; - n->v.code = code; - } - } - } - - //- rjf: window settings header - if(query.size == 0) - { - RD_SettingsItemNode *n = push_array(scratch.arena, RD_SettingsItemNode, 1); - SLLQueuePush(items_list.first, items_list.last, n); - items_list.count += 1; - n->v.kind = RD_SettingsItemKind_CategoryHeader; - n->v.string = str8_lit("Window Interface Settings"); - n->v.icon_kind = sv->category_opened[RD_SettingsItemKind_WindowSetting] ? RD_IconKind_DownCaret : RD_IconKind_RightCaret; - n->v.category = RD_SettingsItemKind_WindowSetting; - } - - //- rjf: gather all window settings - if(sv->category_opened[RD_SettingsItemKind_WindowSetting] || query.size != 0) - { - for EachEnumVal(RD_SettingCode, code) - { - if(!rd_setting_code_default_is_per_window_table[code]) - { - continue; - } - String8 kind_string = str8_lit("Window Interface Setting"); - String8 string = rd_setting_code_display_string_table[code]; - FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string); - FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string); - if(string_matches.count == string_matches.needle_part_count || - kind_string_matches.count == kind_string_matches.needle_part_count) - { - RD_SettingsItemNode *n = push_array(scratch.arena, RD_SettingsItemNode, 1); - SLLQueuePush(items_list.first, items_list.last, n); - items_list.count += 1; - n->v.kind = RD_SettingsItemKind_WindowSetting; - n->v.kind_string = kind_string; - n->v.string = string; - n->v.kind_string_matches = kind_string_matches; - n->v.string_matches = string_matches; - n->v.icon_kind = RD_IconKind_Window; - n->v.code = code; - } - } - } - - //- rjf: theme presets header - if(query.size == 0) - { - RD_SettingsItemNode *n = push_array(scratch.arena, RD_SettingsItemNode, 1); - SLLQueuePush(items_list.first, items_list.last, n); - items_list.count += 1; - n->v.kind = RD_SettingsItemKind_CategoryHeader; - n->v.string = str8_lit("Theme Presets"); - n->v.icon_kind = sv->category_opened[RD_SettingsItemKind_ThemePreset] ? RD_IconKind_DownCaret : RD_IconKind_RightCaret; - n->v.category = RD_SettingsItemKind_ThemePreset; - } - - //- rjf: gather theme presets - if(sv->category_opened[RD_SettingsItemKind_ThemePreset] || query.size != 0) - { - for EachEnumVal(RD_ThemePreset, preset) - { - String8 kind_string = str8_lit("Theme Preset"); - String8 string = rd_theme_preset_display_string_table[preset]; - FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string); - FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string); - if(string_matches.count == string_matches.needle_part_count || - kind_string_matches.count == kind_string_matches.needle_part_count) - { - RD_SettingsItemNode *n = push_array(scratch.arena, RD_SettingsItemNode, 1); - SLLQueuePush(items_list.first, items_list.last, n); - items_list.count += 1; - n->v.kind = RD_SettingsItemKind_ThemePreset; - n->v.kind_string = kind_string; - n->v.string = string; - n->v.kind_string_matches = kind_string_matches; - n->v.string_matches = string_matches; - n->v.icon_kind = RD_IconKind_Palette; - n->v.preset = preset; - } - } - } - - //- rjf: theme colors header - if(query.size == 0) - { - RD_SettingsItemNode *n = push_array(scratch.arena, RD_SettingsItemNode, 1); - SLLQueuePush(items_list.first, items_list.last, n); - items_list.count += 1; - n->v.kind = RD_SettingsItemKind_CategoryHeader; - n->v.string = str8_lit("Theme Colors"); - n->v.icon_kind = sv->category_opened[RD_SettingsItemKind_ThemeColor] ? RD_IconKind_DownCaret : RD_IconKind_RightCaret; - n->v.category = RD_SettingsItemKind_ThemeColor; - } - - //- rjf: gather all theme colors - if(sv->category_opened[RD_SettingsItemKind_ThemeColor] || query.size != 0) - { - for EachNonZeroEnumVal(RD_ThemeColor, color) - { - String8 kind_string = str8_lit("Theme Color"); - String8 string = rd_theme_color_display_string_table[color]; - FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string); - FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string); - if(string_matches.count == string_matches.needle_part_count || - kind_string_matches.count == kind_string_matches.needle_part_count) - { - RD_SettingsItemNode *n = push_array(scratch.arena, RD_SettingsItemNode, 1); - SLLQueuePush(items_list.first, items_list.last, n); - items_list.count += 1; - n->v.kind = RD_SettingsItemKind_ThemeColor; - n->v.kind_string = kind_string; - n->v.string = string; - n->v.kind_string_matches = kind_string_matches; - n->v.string_matches = string_matches; - n->v.icon_kind = RD_IconKind_Palette; - n->v.color = color; - } - } - } - - //- rjf: convert to array - items.count = items_list.count; - items.v = push_array(scratch.arena, RD_SettingsItem, items.count); - { - U64 idx = 0; - for(RD_SettingsItemNode *n = items_list.first; n != 0; n = n->next, idx += 1) - { - items.v[idx] = n->v; - } - } - } - - ////////////////////////////// - //- rjf: sort filtered settings item list - // - if(query.size != 0) - { - quick_sort(items.v, items.count, sizeof(items.v[0]), rd_qsort_compare_settings_item); - } - - ////////////////////////////// - //- rjf: produce per-color context menu keys - // - UI_Key *color_ctx_menu_keys = push_array(scratch.arena, UI_Key, RD_ThemeColor_COUNT); - { - for(RD_ThemeColor color = (RD_ThemeColor)(RD_ThemeColor_Null+1); - color < RD_ThemeColor_COUNT; - color = (RD_ThemeColor)(color+1)) - { - color_ctx_menu_keys[color] = ui_key_from_stringf(ui_key_zero(), "###settings_color_ctx_menu_%I64x", (U64)color); - } - } - - ////////////////////////////// - //- rjf: build color context menus - // - for(RD_ThemeColor color = (RD_ThemeColor)(RD_ThemeColor_Null+1); - color < RD_ThemeColor_COUNT; - color = (RD_ThemeColor)(color+1)) - { - RD_Palette(RD_PaletteCode_Floating) - UI_CtxMenu(color_ctx_menu_keys[color]) - UI_Padding(ui_em(1.5f, 1.f)) - UI_PrefWidth(ui_em(28.5f, 1)) UI_PrefHeight(ui_children_sum(1.f)) - { - // rjf: build title - UI_Row - { - ui_spacer(ui_em(1.5f, 1.f)); - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(rd_theme_color_display_string_table[color]); - } - - ui_spacer(ui_em(1.5f, 1.f)); - - // rjf: build picker - { - ui_set_next_pref_height(ui_em(22.f, 1.f)); - UI_Row UI_Padding(ui_pct(1, 0)) - { - UI_PrefWidth(ui_em(22.f, 1.f)) UI_PrefHeight(ui_em(22.f, 1.f)) UI_Flags(UI_BoxFlag_FocusNavSkip) - { - ui_sat_val_pickerf(sv->color_ctx_menu_color_hsva.x, &sv->color_ctx_menu_color_hsva.y, &sv->color_ctx_menu_color_hsva.z, "###settings_satval_picker"); - } - - ui_spacer(ui_em(0.75f, 1.f)); - - UI_PrefWidth(ui_em(1.5f, 1.f)) UI_PrefHeight(ui_em(22.f, 1.f)) UI_Flags(UI_BoxFlag_FocusNavSkip) - ui_hue_pickerf(&sv->color_ctx_menu_color_hsva.x, sv->color_ctx_menu_color_hsva.y, sv->color_ctx_menu_color_hsva.z, "###settings_hue_picker"); - - UI_PrefWidth(ui_em(1.5f, 1.f)) UI_PrefHeight(ui_em(22.f, 1.f)) UI_Flags(UI_BoxFlag_FocusNavSkip) - ui_alpha_pickerf(&sv->color_ctx_menu_color_hsva.w, "###settings_alpha_picker"); - } - } - - ui_spacer(ui_em(1.5f, 1.f)); - - // rjf: build line edits - UI_Row - UI_WidthFill - UI_Padding(ui_em(1.5f, 1.f)) - UI_PrefHeight(ui_children_sum(1.f)) - UI_Column - UI_PrefHeight(ui_em(2.25f, 1.f)) - { - Vec4F32 hsva = sv->color_ctx_menu_color_hsva; - Vec3F32 hsv = v3f32(hsva.x, hsva.y, hsva.z); - Vec3F32 rgb = rgb_from_hsv(hsv); - Vec4F32 rgba = v4f32(rgb.x, rgb.y, rgb.z, sv->color_ctx_menu_color_hsva.w); - String8 hex_string = hex_string_from_rgba_4f32(scratch.arena, rgba); - hex_string = push_str8f(scratch.arena, "#%S", hex_string); - String8 r_string = push_str8f(scratch.arena, "%.2f", rgba.x); - String8 g_string = push_str8f(scratch.arena, "%.2f", rgba.y); - String8 b_string = push_str8f(scratch.arena, "%.2f", rgba.z); - String8 h_string = push_str8f(scratch.arena, "%.2f", hsva.x); - String8 s_string = push_str8f(scratch.arena, "%.2f", hsva.y); - String8 v_string = push_str8f(scratch.arena, "%.2f", hsva.z); - String8 a_string = push_str8f(scratch.arena, "%.2f", rgba.w); - UI_Row RD_Font(RD_FontSlot_Code) - { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("Hex"); - UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, hex_string, "###hex_edit"); - if(ui_committed(sig)) - { - String8 string = str8(sv->txt_buffer, sv->txt_size); - Vec4F32 new_rgba = rgba_from_hex_string_4f32(string); - Vec4F32 new_hsva = hsva_from_rgba(new_rgba); - sv->color_ctx_menu_color_hsva = new_hsva; - } - } - ui_spacer(ui_em(0.75f, 1.f)); - UI_Row - { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("R"); - UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, r_string, "###r_edit"); - if(ui_committed(sig)) - { - String8 string = str8(sv->txt_buffer, sv->txt_size); - Vec4F32 new_rgba = v4f32((F32)f64_from_str8(string), rgba.y, rgba.z, rgba.w); - Vec4F32 new_hsva = hsva_from_rgba(new_rgba); - sv->color_ctx_menu_color_hsva = new_hsva; - } - } - UI_Row - { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("G"); - UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, g_string, "###g_edit"); - if(ui_committed(sig)) - { - String8 string = str8(sv->txt_buffer, sv->txt_size); - Vec4F32 new_rgba = v4f32(rgba.x, (F32)f64_from_str8(string), rgba.z, rgba.w); - Vec4F32 new_hsva = hsva_from_rgba(new_rgba); - sv->color_ctx_menu_color_hsva = new_hsva; - } - } - UI_Row - { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("B"); - UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, b_string, "###b_edit"); - if(ui_committed(sig)) - { - String8 string = str8(sv->txt_buffer, sv->txt_size); - Vec4F32 new_rgba = v4f32(rgba.x, rgba.y, (F32)f64_from_str8(string), rgba.w); - Vec4F32 new_hsva = hsva_from_rgba(new_rgba); - sv->color_ctx_menu_color_hsva = new_hsva; - } - } - ui_spacer(ui_em(0.75f, 1.f)); - UI_Row - { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("H"); - UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, h_string, "###h_edit"); - if(ui_committed(sig)) - { - String8 string = str8(sv->txt_buffer, sv->txt_size); - Vec4F32 new_hsva = v4f32((F32)f64_from_str8(string), hsva.y, hsva.z, hsva.w); - sv->color_ctx_menu_color_hsva = new_hsva; - } - } - UI_Row - { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("S"); - UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, s_string, "###s_edit"); - if(ui_committed(sig)) - { - String8 string = str8(sv->txt_buffer, sv->txt_size); - Vec4F32 new_hsva = v4f32(hsva.x, (F32)f64_from_str8(string), hsva.z, hsva.w); - sv->color_ctx_menu_color_hsva = new_hsva; - } - } - UI_Row - { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("V"); - UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, v_string, "###v_edit"); - if(ui_committed(sig)) - { - String8 string = str8(sv->txt_buffer, sv->txt_size); - Vec4F32 new_hsva = v4f32(hsva.x, hsva.y, (F32)f64_from_str8(string), hsva.w); - sv->color_ctx_menu_color_hsva = new_hsva; - } - } - ui_spacer(ui_em(0.75f, 1.f)); - UI_Row - { - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(4.5f, 1.f)) ui_labelf("A"); - UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border, 0, 0, &sv->txt_cursor, &sv->txt_mark, sv->txt_buffer, sizeof(sv->txt_buffer), &sv->txt_size, 0, a_string, "###a_edit"); - if(ui_committed(sig)) - { - String8 string = str8(sv->txt_buffer, sv->txt_size); - Vec4F32 new_hsva = v4f32(hsva.x, hsva.y, hsva.z, (F32)f64_from_str8(string)); - sv->color_ctx_menu_color_hsva = new_hsva; - } - } - } - - // rjf: commit state to theme - Vec4F32 hsva = sv->color_ctx_menu_color_hsva; - Vec3F32 hsv = v3f32(hsva.x, hsva.y, hsva.z); - Vec3F32 rgb = rgb_from_hsv(hsv); - Vec4F32 rgba = v4f32(rgb.x, rgb.y, rgb.z, sv->color_ctx_menu_color_hsva.w); - rd_state->cfg_theme_target.colors[sv->color_ctx_menu_color] = rgba; - } - } - - ////////////////////////////// - //- rjf: cancels - // - UI_Focus(UI_FocusKind_On) if(ui_is_focus_active() && sv->preset_apply_confirm < RD_ThemePreset_COUNT && ui_slot_press(UI_EventActionSlot_Cancel)) - { - sv->preset_apply_confirm = RD_ThemePreset_COUNT; - } - - ////////////////////////////// - //- rjf: build items list - // - Rng1S64 visible_row_range = {0}; - UI_ScrollListParams scroll_list_params = {0}; - { - Vec2F32 rect_dim = dim_2f32(rect); - scroll_list_params.flags = UI_ScrollListFlag_All; - scroll_list_params.row_height_px = row_height_px; - scroll_list_params.dim_px = v2f32(rect_dim.x, rect_dim.y); - scroll_list_params.cursor_range = r2s64(v2s64(0, 0), v2s64(0, items.count)); - scroll_list_params.item_range = r1s64(0, items.count); - scroll_list_params.cursor_min_is_empty_selection[Axis2_Y] = 1; - } - UI_ScrollListSignal scroll_list_sig = {0}; - UI_Focus(UI_FocusKind_On) - UI_ScrollList(&scroll_list_params, &scroll_pos.y, &sv->cursor, 0, &visible_row_range, &scroll_list_sig) - UI_Focus(UI_FocusKind_Null) - { - for(S64 row_num = visible_row_range.min; row_num <= visible_row_range.max && row_num < items.count; row_num += 1) - { - //- rjf: unpack item - RD_SettingsItem *item = &items.v[row_num]; - UI_Palette *palette = ui_top_palette(); - Vec4F32 rgba = ui_top_palette()->text_weak; - OS_Cursor cursor = OS_Cursor_HandPoint; - Rng1S32 s32_range = {0}; - B32 is_toggler = 0; - B32 is_toggled = 0; - B32 is_slider = 0; - S32 slider_s32_val = 0; - F32 slider_pct = 0.f; - UI_BoxFlags flags = UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawHotEffects|UI_BoxFlag_DrawActiveEffects; - RD_SettingVal *val_table = &rd_state->cfg_setting_vals[RD_CfgSrc_User][0]; - switch(item->kind) - { - case RD_SettingsItemKind_COUNT:{}break; - case RD_SettingsItemKind_CategoryHeader: - { - cursor = OS_Cursor_HandPoint; - flags = UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawHotEffects; - }break; - case RD_SettingsItemKind_ThemePreset: - { - Vec4F32 *colors = rd_theme_preset_colors_table[item->preset]; - Vec4F32 bg_color = colors[RD_ThemeColor_BaseBackground]; - Vec4F32 tx_color = colors[RD_ThemeColor_Text]; - Vec4F32 tw_color = colors[RD_ThemeColor_TextWeak]; - Vec4F32 bd_color = colors[RD_ThemeColor_BaseBorder]; - palette = ui_build_palette(ui_top_palette(), - .text = tx_color, - .text_weak = tw_color, - .border = bd_color, - .background = bg_color); - }break; - case RD_SettingsItemKind_ThemeColor: - { - rgba = rd_rgba_from_theme_color(item->color); - }break; - case RD_SettingsItemKind_WindowSetting: - { - val_table = &window->setting_vals[0]; - }goto setting; - case RD_SettingsItemKind_GlobalSetting:{}goto setting; - setting:; - { - s32_range = rd_setting_code_s32_range_table[item->code]; - if(s32_range.min != 0 || s32_range.max != 1) - { - cursor = OS_Cursor_LeftRight; - is_slider = 1; - slider_s32_val = val_table[item->code].s32; - slider_pct = (F32)(slider_s32_val - s32_range.min) / dim_1s32(s32_range); - } - else - { - is_toggler = 1; - is_toggled = !!val_table[item->code].s32; - } - }break; - } - - //- rjf: build item widget - UI_Box *item_box = &ui_nil_box; - UI_Row - { - if(query.size == 0 && item->kind != RD_SettingsItemKind_CategoryHeader) - { - ui_set_next_flags(UI_BoxFlag_DrawSideLeft); - ui_spacer(ui_em(2.f, 1.f)); - } - UI_Focus(row_num+1 == sv->cursor.y ? UI_FocusKind_On : UI_FocusKind_Off) UI_Palette(palette) - { - ui_set_next_hover_cursor(cursor); - item_box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|flags, "###option_%S_%S", item->kind_string, item->string); - UI_Parent(item_box) - { - if(item->icon_kind != RD_IconKind_Null) - { - UI_PrefWidth(ui_em(3.f, 1.f)) - RD_Font(RD_FontSlot_Icons) - UI_Palette(ui_build_palette(ui_top_palette(), .text = rgba)) - UI_TextAlignment(UI_TextAlign_Center) - ui_label(rd_icon_kind_text_table[item->icon_kind]); - } - if(query.size != 0 && item->kind_string.size != 0) UI_PrefWidth(ui_text_dim(10, 1)) - { - UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak, "%S", item->kind_string); - ui_box_equip_fuzzy_match_ranges(box, &item->kind_string_matches); - } - UI_PrefWidth(ui_text_dim(10, 1)) - { - UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "%S", item->string); - ui_box_equip_fuzzy_match_ranges(box, &item->string_matches); - } - if(is_slider) UI_PrefWidth(ui_text_dim(10, 1)) - { - UI_Flags(UI_BoxFlag_DrawTextWeak) - ui_labelf("(%i)", slider_s32_val); - UI_PrefWidth(ui_pct(slider_pct, 1.f)) UI_HeightFill UI_FixedX(0) UI_FixedY(0) - UI_Palette(ui_build_palette(ui_top_palette(), .background = rd_rgba_from_theme_color(RD_ThemeColor_HighlightOverlay))) - ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); - } - if(is_toggler) - { - ui_spacer(ui_pct(1, 0)); - UI_PrefWidth(ui_em(2.5f, 1.f)) - RD_Font(RD_FontSlot_Icons) - UI_Flags(UI_BoxFlag_DrawTextWeak) - ui_label(rd_icon_kind_text_table[is_toggled ? RD_IconKind_CheckFilled : RD_IconKind_CheckHollow]); - } - if(item->kind == RD_SettingsItemKind_ThemePreset && sv->preset_apply_confirm == item->preset) - { - ui_spacer(ui_pct(1, 0)); - UI_PrefWidth(ui_text_dim(10, 1)) - RD_Palette(RD_PaletteCode_NegativePopButton) - UI_CornerRadius(ui_top_font_size()*0.5f) - UI_FontSize(ui_top_font_size()*0.9f) - UI_TextAlignment(UI_TextAlign_Center) - ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawBackground, "Click Again To Apply"); - } - } - } - } - - //- rjf: interact - UI_Signal sig = ui_signal_from_box(item_box); - if(item->kind == RD_SettingsItemKind_ThemeColor && ui_pressed(sig)) - { - Vec3F32 rgb = v3f32(rgba.x, rgba.y, rgba.z); - Vec3F32 hsv = hsv_from_rgb(rgb); - Vec4F32 hsva = v4f32(hsv.x, hsv.y, hsv.z, rgba.w); - if(ui_ctx_menu_is_open(color_ctx_menu_keys[item->color])) - { - ui_ctx_menu_close(); - } - else - { - ui_ctx_menu_open(color_ctx_menu_keys[item->color], item_box->key, v2f32(0, dim_2f32(item_box->rect).y)); - } - sv->color_ctx_menu_color = item->color; - sv->color_ctx_menu_color_hsva = v4f32(hsv.x, hsv.y, hsv.z, rgba.w); - rd_cmd(RD_CmdKind_FocusPanel); - } - if((item->kind == RD_SettingsItemKind_GlobalSetting || item->kind == RD_SettingsItemKind_WindowSetting) && - is_toggler && ui_clicked(sig)) - { - val_table[item->code].s32 ^= 1; - val_table[item->code].set = 1; - } - if((item->kind == RD_SettingsItemKind_GlobalSetting || item->kind == RD_SettingsItemKind_WindowSetting) && - is_slider && ui_dragging(sig)) - { - if(ui_pressed(sig)) - { - ui_store_drag_struct(&slider_s32_val); - } - S32 pre_drag_val = *ui_get_drag_struct(S32); - Vec2F32 delta = ui_drag_delta(); - S32 pst_drag_val = pre_drag_val + (S32)(delta.x/(ui_top_font_size()*2.f)); - pst_drag_val = clamp_1s32(s32_range, pst_drag_val); - val_table[item->code].s32 = pst_drag_val; - val_table[item->code].set = 1; - } - if(item->kind == RD_SettingsItemKind_ThemePreset && ui_clicked(sig)) - { - if(sv->preset_apply_confirm == item->preset) - { - Vec4F32 *colors = rd_theme_preset_colors_table[item->preset]; - MemoryCopy(rd_state->cfg_theme_target.colors, colors, sizeof(rd_state->cfg_theme_target.colors)); - sv->preset_apply_confirm = RD_ThemePreset_COUNT; - } - else - { - sv->preset_apply_confirm = item->preset; - } - } - if(item->kind != RD_SettingsItemKind_ThemePreset && ui_pressed(sig)) - { - sv->preset_apply_confirm = RD_ThemePreset_COUNT; - } - if(item->kind != RD_SettingsItemKind_ThemePreset && ui_pressed(sig)) - { - sv->preset_apply_confirm = RD_ThemePreset_COUNT; - } - if(item->kind == RD_SettingsItemKind_CategoryHeader && ui_pressed(sig)) - { - sv->category_opened[item->category] ^= 1; - } - } - } - - rd_store_view_scroll_pos(scroll_pos); - scratch_end(scratch); - ProfEnd(); -} -#endif diff --git a/src/raddbg/raddbg_widgets.c b/src/raddbg/raddbg_widgets.c index 4edd7ef6..f2404cef 100644 --- a/src/raddbg/raddbg_widgets.c +++ b/src/raddbg/raddbg_widgets.c @@ -218,10 +218,13 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg) } // rjf: push qualifiers - for(String8Node *n = qualifiers.first; n != 0; n = n->next) + if(qualifiers.node_count != 0) UI_TagF("weak") { - String8 string = push_str8f(arena, "<%S> ", n->string); - dr_fstrs_push_new(arena, &result, ¶ms, string, .color = ui_top_palette()->text_weak); + for(String8Node *n = qualifiers.first; n != 0; n = n->next) + { + String8 string = push_str8f(arena, "<%S> ", n->string); + dr_fstrs_push_new(arena, &result, ¶ms, string, .color = ui_color_from_name(str8_lit("text"))); + } } // rjf: push file name @@ -307,7 +310,7 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg) if(src_string.size == 0) { src_string = str8_lit("(type)"); - src_color = ui_top_palette()->text_weak; + src_color = rgba_secondary; dr_fstrs_push_new(arena, &src_fstrs, ¶ms, src_string, .color = src_color); } else RD_Font(RD_FontSlot_Code) @@ -317,7 +320,7 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg) if(dst_string.size == 0) { dst_string = str8_lit("(view rule)"); - dst_color = ui_top_palette()->text_weak; + dst_color = rgba_secondary; dr_fstrs_push_new(arena, &dst_fstrs, ¶ms, dst_string, .color = dst_color); } else RD_Font(RD_FontSlot_Code) @@ -326,7 +329,7 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg) } dr_fstrs_concat_in_place(&result, &src_fstrs); dr_fstrs_push_new(arena, &result, ¶ms, str8_lit(" ")); - dr_fstrs_push_new(arena, &result, ¶ms, rd_icon_kind_text_table[RD_IconKind_RightArrow], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = ui_top_palette()->text_weak); + dr_fstrs_push_new(arena, &result, ¶ms, rd_icon_kind_text_table[RD_IconKind_RightArrow], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = rgba_secondary); dr_fstrs_push_new(arena, &result, ¶ms, str8_lit(" ")); dr_fstrs_concat_in_place(&result, &dst_fstrs); } @@ -341,16 +344,16 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg) if(src_string.size == 0) { src_string = str8_lit("(source path)"); - src_color = ui_top_palette()->text_weak; + src_color = rgba_secondary; } if(dst_string.size == 0) { dst_string = str8_lit("(destination path)"); - dst_color = ui_top_palette()->text_weak; + dst_color = rgba_secondary; } dr_fstrs_push_new(arena, &result, ¶ms, src_string, .color = src_color); dr_fstrs_push_new(arena, &result, ¶ms, str8_lit(" ")); - dr_fstrs_push_new(arena, &result, ¶ms, rd_icon_kind_text_table[RD_IconKind_RightArrow], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = ui_top_palette()->text_weak); + dr_fstrs_push_new(arena, &result, ¶ms, rd_icon_kind_text_table[RD_IconKind_RightArrow], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = rgba_secondary); dr_fstrs_push_new(arena, &result, ¶ms, str8_lit(" ")); dr_fstrs_push_new(arena, &result, ¶ms, dst_string, .color = dst_color); } @@ -373,7 +376,11 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e { color = ui_color_from_name(str8_lit("text")); } - Vec4F32 secondary_color = ui_top_palette()->text_weak; + Vec4F32 secondary_color = color; + UI_TagF("weak") + { + secondary_color = ui_color_from_name(str8_lit("text")); + } String8 name = rd_name_from_ctrl_entity(arena, entity); RD_IconKind icon_kind = RD_IconKind_Null; B32 name_is_code = 0; @@ -688,21 +695,10 @@ rd_cmd_binding_buttons(String8 name) } } - //- rjf: form color palette - UI_Palette *palette = ui_top_palette(); - if(has_conflicts) - { - palette = rd_palette_from_code(RD_PaletteCode_Bad); - } - if(rebinding_active_for_this_binding) - { - palette = rd_palette_from_code(RD_PaletteCode_Pop); - } - //- rjf: build box + ui_set_next_tag(has_conflicts ? str8_lit("bad_pop") : rebinding_active_for_this_binding ? str8_lit("pop") : str8_zero()); ui_set_next_hover_cursor(OS_Cursor_HandPoint); ui_set_next_text_alignment(UI_TextAlign_Center); - ui_set_next_palette(palette); ui_set_next_group_key(ui_key_zero()); ui_set_next_pref_width(ui_text_dim(ui_top_font_size()*1.f, 1)); UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText| @@ -754,7 +750,7 @@ rd_cmd_binding_buttons(String8 name) //- rjf: delete button if(rebinding_active_for_this_binding) UI_PrefWidth(ui_em(2.5f, 1.f)) - RD_Palette(RD_PaletteCode_Bad) + UI_TagF("bad_pop") { ui_set_next_group_key(ui_key_zero()); UI_Signal sig = rd_icon_button(RD_IconKind_X, 0, str8_lit("###delete_binding")); @@ -774,18 +770,12 @@ rd_cmd_binding_buttons(String8 name) str8_match(rd_state->bind_change_cmd_name, name, 0) && rd_state->bind_change_binding.key == OS_Key_Null && rd_state->bind_change_binding.modifiers == 0); - UI_Palette *palette = ui_top_palette(); - if(adding_new_binding) - { - palette = rd_palette_from_code(RD_PaletteCode_Pop); - } - RD_Font(RD_FontSlot_Icons) UI_Palette(palette) + RD_Font(RD_FontSlot_Icons) UI_TagF(adding_new_binding ? "pop" : "") { ui_set_next_hover_cursor(OS_Cursor_HandPoint); ui_set_next_text_alignment(UI_TextAlign_Center); ui_set_next_group_key(ui_key_zero()); ui_set_next_pref_width(ui_text_dim(ui_top_font_size()*1.f, 1)); - ui_set_next_palette(palette); UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText| UI_BoxFlag_Clickable| UI_BoxFlag_DrawActiveEffects| @@ -1153,6 +1143,11 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe B32 do_thread_glow = rd_setting_b32_from_name(str8_lit("thread_glow")); B32 do_bp_lines = rd_setting_b32_from_name(str8_lit("breakpoint_lines")); B32 do_bp_glow = rd_setting_b32_from_name(str8_lit("breakpoint_glow")); + Vec4F32 pop_color = {0}; + UI_TagF("pop") + { + pop_color = ui_color_from_name(str8_lit("background")); + } ////////////////////////////// //- rjf: build top-level container @@ -1180,17 +1175,20 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe Vec4F32 *line_bg_colors = push_array(scratch.arena, Vec4F32, dim_1s64(params->line_num_range)+1); { //- rjf: color line with stopper-thread red - U64 line_idx = 0; - for(S64 line_num = params->line_num_range.min; - line_num < params->line_num_range.max; - line_num += 1, line_idx += 1) + UI_TagF("bad_pop") { - CTRL_EntityList threads = params->line_ips[line_idx]; - for(CTRL_EntityNode *n = threads.first; n != 0; n = n->next) + U64 line_idx = 0; + for(S64 line_num = params->line_num_range.min; + line_num < params->line_num_range.max; + line_num += 1, line_idx += 1) { - if(n->v == stopper_thread && (stop_event.cause == CTRL_EventCause_InterruptedByTrap || stop_event.cause == CTRL_EventCause_InterruptedByException)) + CTRL_EntityList threads = params->line_ips[line_idx]; + for(CTRL_EntityNode *n = threads.first; n != 0; n = n->next) { - line_bg_colors[line_idx] = ui_top_palette()->background_bad; + if(n->v == stopper_thread && (stop_event.cause == CTRL_EventCause_InterruptedByTrap || stop_event.cause == CTRL_EventCause_InterruptedByException)) + { + line_bg_colors[line_idx] = ui_color_from_name(str8_lit("background")); + } } } } @@ -1276,8 +1274,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth); ui_set_next_pref_width(ui_pct(1, 0)); ui_set_next_pref_height(ui_pct(1, 0)); - ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color)); ui_set_next_text_alignment(UI_TextAlign_Center); + ui_set_next_text_color(color); UI_Key thread_box_key = ui_key_from_stringf(top_container_box->key, "###ip_%I64x_%p", line_num, thread); UI_Box *thread_box = ui_build_box_from_key(UI_BoxFlag_DisableTextTrunc| UI_BoxFlag_Clickable*!!(params->flags & RD_CodeSliceFlag_Clickable)| @@ -1430,8 +1428,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth); ui_set_next_pref_width(ui_pct(1, 0)); ui_set_next_pref_height(ui_pct(1, 0)); - ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color)); ui_set_next_text_alignment(UI_TextAlign_Center); + ui_set_next_text_color(color); UI_Key thread_box_key = ui_key_from_stringf(top_container_box->key, "###ip_%I64x_catchall_%p", line_num, thread); UI_Box *thread_box = ui_build_box_from_key(UI_BoxFlag_DisableTextTrunc| UI_BoxFlag_Clickable*!!(params->flags & RD_CodeSliceFlag_Clickable)| @@ -1545,8 +1543,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe ui_set_next_font_size(params->font_size * 1.f); ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth); ui_set_next_hover_cursor(OS_Cursor_HandPoint); - ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = bp_rgba)); ui_set_next_text_alignment(UI_TextAlign_Center); + ui_set_next_text_color(bp_rgba); UI_Box *bp_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText| UI_BoxFlag_Clickable*!!(params->flags & RD_CodeSliceFlag_Clickable)| UI_BoxFlag_DisableTextTrunc, @@ -1608,8 +1606,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe ui_set_next_font_size(params->font_size * 1.f); ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth); ui_set_next_hover_cursor(OS_Cursor_HandPoint); - ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color)); ui_set_next_text_alignment(UI_TextAlign_Center); + ui_set_next_text_color(color); UI_Box *pin_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText| UI_BoxFlag_Clickable*!!(params->flags & RD_CodeSliceFlag_Clickable)| UI_BoxFlag_DisableTextTrunc, @@ -1716,8 +1714,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe } // rjf: build line num box - ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = text_color, .background = bg_color)); - ui_build_box_from_stringf(UI_BoxFlag_DrawText|(UI_BoxFlag_DrawBackground*!!has_line_info), "%I64u##line_num", line_num); + UI_TextColor(text_color) UI_BackgroundColor(bg_color) + ui_build_box_from_stringf(UI_BoxFlag_DrawText|(UI_BoxFlag_DrawBackground*!!has_line_info), "%I64u##line_num", line_num); } } } @@ -1799,7 +1797,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { DR_FStrList explanation_fstrs = rd_stop_explanation_fstrs_from_ctrl_event(scratch.arena, &stop_event); UI_Parent(line_extras_boxes[line_idx]) UI_PrefWidth(ui_children_sum(1)) UI_PrefHeight(ui_px(params->line_height_px, 1.f)) - RD_Palette(RD_PaletteCode_Bad) + UI_TagF("bad_pop") { UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "###exception_info"); ui_box_equip_display_fstrs(box, &explanation_fstrs); @@ -1853,9 +1851,9 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe } UI_PrefWidth(ui_em(1.5f, 1.f)) RD_Font(RD_FontSlot_Icons) - UI_Palette(ui_build_palette(ui_top_palette(), .text = pin_color)) UI_TextAlignment(UI_TextAlign_Center) UI_Flags(UI_BoxFlag_DisableTextTrunc) + UI_TextColor(pin_color) { UI_Signal sig = ui_buttonf("%S###pin_nub", rd_icon_kind_text_table[RD_IconKind_Pin]); if(ui_dragging(sig) && !contains_2f32(sig.box->rect, ui_mouse())) @@ -1957,7 +1955,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe B32 line_drag_drop = 0; RD_Cfg *line_drag_cfg = &rd_nil_cfg; CTRL_Entity *line_drag_ctrl_entity = &ctrl_entity_nil; - Vec4F32 line_drag_drop_color = ui_top_palette()->background_pop; + Vec4F32 line_drag_drop_color = pop_color; { //- rjf: determine mouse drag range TxtRng mouse_drag_rng = txt_rng(mouse_pt, mouse_pt); @@ -2041,7 +2039,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe 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; + line_drag_drop_color = pop_color; } } if(rd_state->drag_drop_regs_slot == RD_RegSlot_Thread) @@ -2051,7 +2049,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe 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; + line_drag_drop_color = pop_color; } } } @@ -2272,7 +2270,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe if(line_bg_color.w != 0) { ui_set_next_flags(UI_BoxFlag_DrawBackground); - ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = line_bg_color)); + ui_set_next_background_color(line_bg_color); } ui_set_next_tab_size(params->tab_size); UI_Box *line_box = ui_build_box_from_key(UI_BoxFlag_DisableTextTrunc|UI_BoxFlag_DrawText|UI_BoxFlag_DisableIDString, line_key); @@ -2362,7 +2360,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe line_box->rect.x0+line_num_padding_px+match_column_pixel_off_range.max+2.f, line_box->rect.y1, }; - Vec4F32 color = ui_top_palette()->background_pop; + Vec4F32 color = pop_color; if(cursor->line == line_num && needle_pos+1 <= cursor->column && cursor->column < needle_pos+params->search_query.size+1) { color.x += (1.f - color.x) * 0.5f; @@ -3243,7 +3241,7 @@ rd_line_edit(RD_LineEditParams *params, String8 string) } else if(params->flags & RD_LineEditFlag_DisplayStringIsCode) { - UI_Box *box = rd_code_label(1.f, 1, ui_top_palette()->text, display_string); + UI_Box *box = rd_code_label(1.f, 1, ui_color_from_name(str8_lit("text")), display_string); if(params->fuzzy_matches != 0) { ui_box_equip_fuzzy_match_ranges(box, params->fuzzy_matches); @@ -3283,7 +3281,7 @@ rd_line_edit(RD_LineEditParams *params, String8 string) F32 total_editstr_width = total_text_width - !!(params->flags & (RD_LineEditFlag_Expander|RD_LineEditFlag_ExpanderSpace|RD_LineEditFlag_ExpanderPlaceholder)) * expander_size_px; ui_set_next_pref_width(ui_px(total_editstr_width+ui_top_font_size()*2, 0.f)); UI_Box *editstr_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DisableTextTrunc, "###editstr"); - DR_FStrList code_fstrs = rd_fstrs_from_code_string(scratch.arena, 1.f, 0, ui_top_palette()->text, edit_string); + DR_FStrList code_fstrs = rd_fstrs_from_code_string(scratch.arena, 1.f, 0, ui_color_from_name(str8_lit("text")), edit_string); if(autocomplete_hint_string.size != 0) { String8 query_word = rd_lister_query_word_from_input_string_off(edit_string, params->cursor->column-1); @@ -3305,7 +3303,7 @@ rd_line_edit(RD_LineEditParams *params, String8 string) DR_FStr *fstr = &autocomp_fstr_n->v; fstr->string = autocomplete_append_string; fstr->params.font = ui_top_font(); - fstr->params.color = ui_top_palette()->text; + fstr->params.color = ui_color_from_name(str8_lit("text")); fstr->params.color.w *= 0.5f; fstr->params.size = ui_top_font_size(); autocomp_fstr_n->next = prev_n ? prev_n->next : 0; diff --git a/src/ui/generated/ui.meta.c b/src/ui/generated/ui.meta.c index 89017afd..4748e2a6 100644 --- a/src/ui/generated/ui.meta.c +++ b/src/ui/generated/ui.meta.c @@ -20,8 +20,9 @@ #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_BackgroundColor(v) DeferLoop(ui_push_background_color(v), ui_pop_background_color()) +#define UI_TextColor(v) DeferLoop(ui_push_text_color(v), ui_pop_text_color()) #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()) @@ -52,7 +53,8 @@ internal UI_FocusKind ui_top_focus_active(void) { UI_StackTopImpl(ui_state, Focu 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 Vec4F32 ui_top_background_color(void) { UI_StackTopImpl(ui_state, BackgroundColor, background_color) } +internal Vec4F32 ui_top_text_color(void) { UI_StackTopImpl(ui_state, TextColor, text_color) } 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) } @@ -82,7 +84,8 @@ internal UI_FocusKind ui_bottom_focus_active(void) { UI_StackBottomImpl(ui_state 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 Vec4F32 ui_bottom_background_color(void) { UI_StackBottomImpl(ui_state, BackgroundColor, background_color) } +internal Vec4F32 ui_bottom_text_color(void) { UI_StackBottomImpl(ui_state, TextColor, text_color) } 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) } @@ -112,7 +115,8 @@ internal UI_FocusKind ui_push_focus_active(UI_FocusKind v) { UI_StackPushImpl(ui 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 Vec4F32 ui_push_background_color(Vec4F32 v) { UI_StackPushImpl(ui_state, BackgroundColor, background_color, Vec4F32, v) } +internal Vec4F32 ui_push_text_color(Vec4F32 v) { UI_StackPushImpl(ui_state, TextColor, text_color, Vec4F32, 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) } @@ -142,7 +146,8 @@ internal UI_FocusKind ui_pop_focus_active(void) { UI_StackPopImpl(ui_state, Focu 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 Vec4F32 ui_pop_background_color(void) { UI_StackPopImpl(ui_state, BackgroundColor, background_color) } +internal Vec4F32 ui_pop_text_color(void) { UI_StackPopImpl(ui_state, TextColor, text_color) } 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) } @@ -172,7 +177,8 @@ internal UI_FocusKind ui_set_next_focus_active(UI_FocusKind v) { UI_StackSetNext 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 Vec4F32 ui_set_next_background_color(Vec4F32 v) { UI_StackSetNextImpl(ui_state, BackgroundColor, background_color, Vec4F32, v) } +internal Vec4F32 ui_set_next_text_color(Vec4F32 v) { UI_StackSetNextImpl(ui_state, TextColor, text_color, Vec4F32, 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 ccd7dc65..3148b82e 100644 --- a/src/ui/generated/ui.meta.h +++ b/src/ui/generated/ui.meta.h @@ -22,8 +22,9 @@ typedef struct UI_FocusActiveNode UI_FocusActiveNode; struct UI_FocusActiveNode{ typedef struct UI_FastpathCodepointNode UI_FastpathCodepointNode; struct UI_FastpathCodepointNode{UI_FastpathCodepointNode *next; U32 v;}; typedef struct UI_GroupKeyNode UI_GroupKeyNode; struct UI_GroupKeyNode{UI_GroupKeyNode *next; UI_Key v;}; typedef struct UI_TransparencyNode UI_TransparencyNode; struct UI_TransparencyNode{UI_TransparencyNode *next; F32 v;}; -typedef struct UI_PaletteNode UI_PaletteNode; struct UI_PaletteNode{UI_PaletteNode *next; UI_Palette* v;}; typedef struct UI_TagNode UI_TagNode; struct UI_TagNode{UI_TagNode *next; String8 v;}; +typedef struct UI_BackgroundColorNode UI_BackgroundColorNode; struct UI_BackgroundColorNode{UI_BackgroundColorNode *next; Vec4F32 v;}; +typedef struct UI_TextColorNode UI_TextColorNode; struct UI_TextColorNode{UI_TextColorNode *next; Vec4F32 v;}; typedef struct UI_SquishNode UI_SquishNode; struct UI_SquishNode{UI_SquishNode *next; F32 v;}; typedef struct UI_HoverCursorNode UI_HoverCursorNode; struct UI_HoverCursorNode{UI_HoverCursorNode *next; OS_Cursor v;}; typedef struct UI_FontNode UI_FontNode; struct UI_FontNode{UI_FontNode *next; FNT_Tag v;}; @@ -56,8 +57,9 @@ UI_FocusActiveNode focus_active_nil_stack_top;\ UI_FastpathCodepointNode fastpath_codepoint_nil_stack_top;\ UI_GroupKeyNode group_key_nil_stack_top;\ UI_TransparencyNode transparency_nil_stack_top;\ -UI_PaletteNode palette_nil_stack_top;\ UI_TagNode tag_nil_stack_top;\ +UI_BackgroundColorNode background_color_nil_stack_top;\ +UI_TextColorNode text_color_nil_stack_top;\ UI_SquishNode squish_nil_stack_top;\ UI_HoverCursorNode hover_cursor_nil_stack_top;\ UI_FontNode font_nil_stack_top;\ @@ -89,8 +91,9 @@ state->focus_active_nil_stack_top.v = UI_FocusKind_Null;\ state->fastpath_codepoint_nil_stack_top.v = 0;\ state->group_key_nil_stack_top.v = ui_key_zero();\ state->transparency_nil_stack_top.v = 0;\ -state->palette_nil_stack_top.v = &ui_g_nil_palette;\ state->tag_nil_stack_top.v = str8_lit("");\ +state->background_color_nil_stack_top.v = v4f32(0, 0, 0, 0);\ +state->text_color_nil_stack_top.v = v4f32(0, 0, 0, 0);\ state->squish_nil_stack_top.v = 0;\ state->hover_cursor_nil_stack_top.v = OS_Cursor_Pointer;\ state->font_nil_stack_top.v = fnt_tag_zero();\ @@ -124,8 +127,9 @@ struct { UI_FocusActiveNode *top; UI_FocusKind bottom_val; UI_FocusActiveNode *f struct { UI_FastpathCodepointNode *top; U32 bottom_val; UI_FastpathCodepointNode *free; U64 gen; B32 auto_pop; } fastpath_codepoint_stack;\ struct { UI_GroupKeyNode *top; UI_Key bottom_val; UI_GroupKeyNode *free; U64 gen; B32 auto_pop; } group_key_stack;\ struct { UI_TransparencyNode *top; F32 bottom_val; UI_TransparencyNode *free; U64 gen; B32 auto_pop; } transparency_stack;\ -struct { UI_PaletteNode *top; UI_Palette* bottom_val; UI_PaletteNode *free; U64 gen; B32 auto_pop; } palette_stack;\ struct { UI_TagNode *top; String8 bottom_val; UI_TagNode *free; U64 gen; B32 auto_pop; } tag_stack;\ +struct { UI_BackgroundColorNode *top; Vec4F32 bottom_val; UI_BackgroundColorNode *free; U64 gen; B32 auto_pop; } background_color_stack;\ +struct { UI_TextColorNode *top; Vec4F32 bottom_val; UI_TextColorNode *free; U64 gen; B32 auto_pop; } text_color_stack;\ struct { UI_SquishNode *top; F32 bottom_val; UI_SquishNode *free; U64 gen; B32 auto_pop; } squish_stack;\ struct { UI_HoverCursorNode *top; OS_Cursor bottom_val; UI_HoverCursorNode *free; U64 gen; B32 auto_pop; } hover_cursor_stack;\ struct { UI_FontNode *top; FNT_Tag bottom_val; UI_FontNode *free; U64 gen; B32 auto_pop; } font_stack;\ @@ -157,8 +161,9 @@ state->focus_active_stack.top = &state->focus_active_nil_stack_top; state->focus 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;\ state->group_key_stack.top = &state->group_key_nil_stack_top; state->group_key_stack.bottom_val = ui_key_zero(); state->group_key_stack.free = 0; state->group_key_stack.auto_pop = 0;\ state->transparency_stack.top = &state->transparency_nil_stack_top; state->transparency_stack.bottom_val = 0; state->transparency_stack.free = 0; state->transparency_stack.auto_pop = 0;\ -state->palette_stack.top = &state->palette_nil_stack_top; state->palette_stack.bottom_val = &ui_g_nil_palette; state->palette_stack.free = 0; state->palette_stack.auto_pop = 0;\ state->tag_stack.top = &state->tag_nil_stack_top; state->tag_stack.bottom_val = str8_lit(""); state->tag_stack.free = 0; state->tag_stack.auto_pop = 0;\ +state->background_color_stack.top = &state->background_color_nil_stack_top; state->background_color_stack.bottom_val = v4f32(0, 0, 0, 0); state->background_color_stack.free = 0; state->background_color_stack.auto_pop = 0;\ +state->text_color_stack.top = &state->text_color_nil_stack_top; state->text_color_stack.bottom_val = v4f32(0, 0, 0, 0); state->text_color_stack.free = 0; state->text_color_stack.auto_pop = 0;\ state->squish_stack.top = &state->squish_nil_stack_top; state->squish_stack.bottom_val = 0; state->squish_stack.free = 0; state->squish_stack.auto_pop = 0;\ state->hover_cursor_stack.top = &state->hover_cursor_nil_stack_top; state->hover_cursor_stack.bottom_val = OS_Cursor_Pointer; state->hover_cursor_stack.free = 0; state->hover_cursor_stack.auto_pop = 0;\ state->font_stack.top = &state->font_nil_stack_top; state->font_stack.bottom_val = fnt_tag_zero(); state->font_stack.free = 0; state->font_stack.auto_pop = 0;\ @@ -190,8 +195,9 @@ if(state->focus_active_stack.auto_pop) { ui_pop_focus_active(); state->focus_act if(state->fastpath_codepoint_stack.auto_pop) { ui_pop_fastpath_codepoint(); state->fastpath_codepoint_stack.auto_pop = 0; }\ if(state->group_key_stack.auto_pop) { ui_pop_group_key(); state->group_key_stack.auto_pop = 0; }\ if(state->transparency_stack.auto_pop) { ui_pop_transparency(); state->transparency_stack.auto_pop = 0; }\ -if(state->palette_stack.auto_pop) { ui_pop_palette(); state->palette_stack.auto_pop = 0; }\ if(state->tag_stack.auto_pop) { ui_pop_tag(); state->tag_stack.auto_pop = 0; }\ +if(state->background_color_stack.auto_pop) { ui_pop_background_color(); state->background_color_stack.auto_pop = 0; }\ +if(state->text_color_stack.auto_pop) { ui_pop_text_color(); state->text_color_stack.auto_pop = 0; }\ if(state->squish_stack.auto_pop) { ui_pop_squish(); state->squish_stack.auto_pop = 0; }\ if(state->hover_cursor_stack.auto_pop) { ui_pop_hover_cursor(); state->hover_cursor_stack.auto_pop = 0; }\ if(state->font_stack.auto_pop) { ui_pop_font(); state->font_stack.auto_pop = 0; }\ @@ -222,8 +228,9 @@ internal UI_FocusKind ui_top_focus_active(void); 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 Vec4F32 ui_top_background_color(void); +internal Vec4F32 ui_top_text_color(void); internal F32 ui_top_squish(void); internal OS_Cursor ui_top_hover_cursor(void); internal FNT_Tag ui_top_font(void); @@ -253,8 +260,9 @@ internal UI_FocusKind ui_bottom_focus_active(void); 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 Vec4F32 ui_bottom_background_color(void); +internal Vec4F32 ui_bottom_text_color(void); internal F32 ui_bottom_squish(void); internal OS_Cursor ui_bottom_hover_cursor(void); internal FNT_Tag ui_bottom_font(void); @@ -284,8 +292,9 @@ internal UI_FocusKind ui_push_focus_active(UI_FocusKind v); 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 Vec4F32 ui_push_background_color(Vec4F32 v); +internal Vec4F32 ui_push_text_color(Vec4F32 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); @@ -315,8 +324,9 @@ internal UI_FocusKind ui_pop_focus_active(void); 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 Vec4F32 ui_pop_background_color(void); +internal Vec4F32 ui_pop_text_color(void); internal F32 ui_pop_squish(void); internal OS_Cursor ui_pop_hover_cursor(void); internal FNT_Tag ui_pop_font(void); @@ -346,8 +356,9 @@ internal UI_FocusKind ui_set_next_focus_active(UI_FocusKind v); 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 Vec4F32 ui_set_next_background_color(Vec4F32 v); +internal Vec4F32 ui_set_next_text_color(Vec4F32 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); diff --git a/src/ui/ui.mdesk b/src/ui/ui.mdesk index b934c760..b5945493 100644 --- a/src/ui/ui.mdesk +++ b/src/ui/ui.mdesk @@ -33,8 +33,9 @@ UI_StackTable: //- rjf: colors { Transparency transparency F32 0 } - { Palette palette `UI_Palette* ` `&ui_g_nil_palette` } { Tag tag String8 `str8_lit("")` 1 } + { BackgroundColor background_color Vec4F32 `v4f32(0, 0, 0, 0)` } + { TextColor text_color Vec4F32 `v4f32(0, 0, 0, 0)` } //- rjf: squish { Squish squish F32 0 } diff --git a/src/ui/ui_basic_widgets.c b/src/ui/ui_basic_widgets.c index 2917ed6a..7a5296be 100644 --- a/src/ui/ui_basic_widgets.c +++ b/src/ui/ui_basic_widgets.c @@ -480,7 +480,7 @@ ui_do_color_tooltip_hsv(Vec3F32 hsv) { UI_PrefWidth(ui_em(22.f, 1.f)) UI_PrefHeight(ui_em(6.f, 1.f)) UI_Row UI_Padding(ui_pct(1, 0)) { - UI_Palette(ui_build_palette(ui_top_palette(), .background = v4f32(rgb.x, rgb.y, rgb.z, 1.f))) + UI_BackgroundColor(v4f32(rgb.x, rgb.y, rgb.z, 1.f)) UI_CornerRadius(4.f) UI_PrefWidth(ui_em(6.f, 1.f)) UI_PrefHeight(ui_em(6.f, 1.f)) ui_build_box_from_string(UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground, str8_lit("")); @@ -519,7 +519,7 @@ ui_do_color_tooltip_hsva(Vec4F32 hsva) { UI_PrefWidth(ui_em(22.f, 1.f)) UI_PrefHeight(ui_em(6.f, 1.f)) UI_Row UI_Padding(ui_pct(1, 0)) { - UI_Palette(ui_build_palette(ui_top_palette(), .background = rgba)) + UI_BackgroundColor(rgba) UI_CornerRadius(4.f) UI_PrefWidth(ui_em(6.f, 1.f)) UI_PrefHeight(ui_em(6.f, 1.f)) ui_build_box_from_string(UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground, str8_lit("")); @@ -1212,7 +1212,6 @@ ui_scroll_list_item_from_row(UI_ScrollListRowBlockArray *blocks, U64 row) internal UI_ScrollPt ui_scroll_bar(Axis2 axis, UI_Size off_axis_size, UI_ScrollPt pt, Rng1S64 idx_range, S64 view_num_indices) { - ui_push_palette(ui_state->widget_palette_info.scrollbar_palette); ui_push_tag(str8_lit("scroll_bar")); //- rjf: unpack @@ -1334,7 +1333,6 @@ ui_scroll_bar(Axis2 axis, UI_Size off_axis_size, UI_ScrollPt pt, Rng1S64 idx_ran } ui_pop_tag(); - ui_pop_palette(); return new_pt; } diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index b60eb9ce..1ab48035 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -782,7 +782,7 @@ ui_box_from_key(UI_Key key) //~ rjf: Top-Level Building API internal void -ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, UI_Theme *theme, UI_WidgetPaletteInfo *widget_palette_info, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt) +ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, UI_Theme *theme, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt) { //- rjf: reset per-build ui state { @@ -862,7 +862,6 @@ ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, U { ui_state->icon_info.icon_kind_text_map[icon_kind] = push_str8_copy(ui_build_arena(), icon_info->icon_kind_text_map[icon_kind]); } - MemoryCopyStruct(&ui_state->widget_palette_info, widget_palette_info); MemoryCopyStruct(&ui_state->animation_info, animation_info); } @@ -1923,7 +1922,6 @@ ui_tooltip_begin_base(void) ui_push_parent(ui_state->tooltip_root); 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(".")); ui_push_tag(str8_lit("floating")); } @@ -1933,7 +1931,6 @@ ui_tooltip_end_base(void) { ui_pop_tag(); ui_pop_tag(); - ui_pop_palette(); ui_pop_text_raster_flags(); ui_pop_flags(); ui_pop_parent(); @@ -1944,7 +1941,6 @@ internal void ui_tooltip_begin(void) { ui_tooltip_begin_base(); - ui_push_palette(ui_state->widget_palette_info.tooltip_palette); ui_set_next_squish(0.25f-ui_state->tooltip_open_t*0.25f); ui_set_next_transparency(1-ui_state->tooltip_open_t); UI_Flags(UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBackgroundBlur|UI_BoxFlag_DrawDropShadow) @@ -1976,7 +1972,6 @@ ui_tooltip_end(void) ui_row_end(); UI_PrefWidth(ui_px(0, 1)) ui_spacer(ui_em(1.f, 1.f)); ui_column_end(); - ui_pop_palette(); ui_tooltip_end_base(); } @@ -2014,7 +2009,6 @@ ui_begin_ctx_menu(UI_Key key) ui_push_pref_height(ui_bottom_pref_height()); 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) UI_TagF("floating") @@ -2029,7 +2023,6 @@ ui_begin_ctx_menu(UI_Key key) ui_state->ctx_menu_root->flags |= UI_BoxFlag_Clickable; ui_state->ctx_menu_root->corner_radii[Corner_00] = ui_state->ctx_menu_root->corner_radii[Corner_01] = ui_state->ctx_menu_root->corner_radii[Corner_10] = ui_state->ctx_menu_root->corner_radii[Corner_11] = ui_top_font_size()*0.25f; ui_state->ctx_menu_root->tags_key = ui_top_tags_key(); - ui_state->ctx_menu_root->palette = ui_top_palette(); ui_state->ctx_menu_root->blur_size = ui_top_blur_size(); ui_spacer(ui_em(1.f, 1.f)); } @@ -2046,7 +2039,6 @@ ui_end_ctx_menu(void) ui_spacer(ui_em(1.f, 1.f)); } ui_pop_tag(); - ui_pop_palette(); ui_pop_focus_active(); ui_pop_focus_hot(); ui_pop_pref_width(); @@ -2180,29 +2172,6 @@ ui_set_auto_focus_hot_key(UI_Key key) } } -//- rjf: palette forming - -internal UI_Palette * -ui_build_palette_(UI_Palette *base, UI_Palette *overrides) -{ - UI_Palette *palette = push_array(ui_build_arena(), UI_Palette, 1); - if(base != 0) - { - MemoryCopyStruct(palette, base); - } - for EachEnumVal(UI_ColorCode, code) - { - if(overrides->colors[code].x != 0 || - overrides->colors[code].y != 0 || - overrides->colors[code].z != 0 || - overrides->colors[code].w != 0) - { - palette->colors[code] = overrides->colors[code]; - } - } - return palette; -} - //- rjf: current style tags key internal UI_Key @@ -2459,7 +2428,6 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key) box->text_align = ui_state->text_alignment_stack.top->v; box->child_layout_axis = ui_state->child_layout_axis_stack.top->v; - box->palette = ui_state->palette_stack.top->v; box->font = ui_state->font_stack.top->v; box->font_size = ui_state->font_size_stack.top->v; box->tab_size = ui_state->tab_size_stack.top->v; @@ -2479,6 +2447,22 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key) { box->tags_key = ui_state->tags_key_stack_top->key; } + if(ui_state->background_color_stack.top != &ui_state->background_color_nil_stack_top) + { + box->background_color = ui_state->background_color_stack.top->v; + } + else + { + box->background_color = ui_color_from_name(str8_lit("background")); + } + if(ui_state->text_color_stack.top != &ui_state->text_color_nil_stack_top) + { + box->text_color = ui_state->text_color_stack.top->v; + } + else + { + box->text_color = ui_color_from_name(str8_lit("text")); + } } //- rjf: auto-pop all stacks @@ -2552,9 +2536,9 @@ ui_box_equip_display_string(UI_Box *box, String8 string) ProfBeginFunction(); box->string = push_str8_copy(ui_build_arena(), string); box->flags |= UI_BoxFlag_HasDisplayString; + Vec4F32 text_color = box->text_color; if(box->flags & UI_BoxFlag_DrawText && (box->fastpath_codepoint == 0 || !(box->flags & UI_BoxFlag_DrawTextFastpathCodepoint))) { - Vec4F32 text_color = ui_color_from_name(str8_lit("text")); String8 display_string = ui_box_display_string(box); DR_FStrNode fstr_n = {0, {display_string, {box->font, box->text_raster_flags, text_color, box->font_size, 0, 0}}}; DR_FStrList fstrs = {&fstr_n, &fstr_n, 1}; @@ -2564,7 +2548,6 @@ ui_box_equip_display_string(UI_Box *box, String8 string) else if(box->flags & UI_BoxFlag_DrawText && box->flags & UI_BoxFlag_DrawTextFastpathCodepoint && box->fastpath_codepoint != 0) { Temp scratch = scratch_begin(0, 0); - Vec4F32 text_color = ui_color_from_name(str8_lit("text")); String8 display_string = ui_box_display_string(box); String32 fpcp32 = str32(&box->fastpath_codepoint, 1); String8 fpcp = str8_from_32(scratch.arena, fpcp32); diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index e36562e4..fcfcc0b2 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -233,61 +233,6 @@ struct UI_Theme U64 patterns_count; }; -//////////////////////////////// -//~ rjf: Palettes - -typedef enum UI_ColorCode -{ - UI_ColorCode_Null, - UI_ColorCode_Background, - UI_ColorCode_BackgroundAlt, - UI_ColorCode_BackgroundGood, - UI_ColorCode_BackgroundBad, - UI_ColorCode_BackgroundPop, - UI_ColorCode_Border, - UI_ColorCode_Text, - UI_ColorCode_TextWeak, - UI_ColorCode_Hover, - UI_ColorCode_Focus, - UI_ColorCode_Cursor, - UI_ColorCode_Selection, - UI_ColorCode_COUNT -} -UI_ColorCode; - -typedef struct UI_Palette UI_Palette; -struct UI_Palette -{ - union - { - Vec4F32 colors[UI_ColorCode_COUNT]; - struct - { - Vec4F32 null; - Vec4F32 background; - Vec4F32 background_alt; - Vec4F32 background_good; - Vec4F32 background_bad; - Vec4F32 background_pop; - Vec4F32 border; - Vec4F32 text; - Vec4F32 text_weak; - Vec4F32 hover; - Vec4F32 focus; - Vec4F32 cursor; - Vec4F32 selection; - }; - }; -}; - -typedef struct UI_WidgetPaletteInfo UI_WidgetPaletteInfo; -struct UI_WidgetPaletteInfo -{ - UI_Palette *tooltip_palette; - UI_Palette *ctx_menu_palette; - UI_Palette *scrollbar_palette; -}; - //////////////////////////////// //~ rjf: Animation Info @@ -449,7 +394,8 @@ struct UI_Box DR_Bucket *draw_bucket; UI_BoxCustomDrawFunctionType *custom_draw; void *custom_draw_user_data; - UI_Palette *palette; + Vec4F32 background_color; + Vec4F32 text_color; FNT_Tag font; F32 font_size; F32 tab_size; @@ -744,7 +690,6 @@ struct UI_State //- rjf: build parameters UI_IconInfo icon_info; UI_Theme *theme; - UI_WidgetPaletteInfo widget_palette_info; UI_AnimationInfo animation_info; OS_Handle window; UI_EventList *events; @@ -827,11 +772,6 @@ internal UI_Size ui_size(UI_SizeKind kind, F32 value, F32 strictness); #define ui_pct(value, strictness) ui_size(UI_SizeKind_ParentPct, value, strictness) #define ui_children_sum(strictness) ui_size(UI_SizeKind_ChildrenSum, 0.f, strictness) -//////////////////////////////// -//~ rjf: Color Scheme Type Functions - -read_only global UI_Palette ui_g_nil_palette = {0}; - //////////////////////////////// //~ rjf: Scroll Point Type Functions @@ -915,7 +855,7 @@ internal UI_Box * ui_box_from_key(UI_Key key); //////////////////////////////// //~ rjf: Top-Level Building API -internal void ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, UI_Theme *theme, UI_WidgetPaletteInfo *widget_palette_info, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt); +internal void ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, UI_Theme *theme, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt); internal void ui_end_build(void); internal void ui_calc_sizes_standalone__in_place_rec(UI_Box *root, Axis2 axis); internal void ui_calc_sizes_upwards_dependent__in_place_rec(UI_Box *root, Axis2 axis); @@ -954,10 +894,6 @@ internal B32 ui_is_key_auto_focus_hot(UI_Key key); internal void ui_set_auto_focus_active_key(UI_Key key); internal void ui_set_auto_focus_hot_key(UI_Key key); -//- rjf: palette forming -internal UI_Palette * ui_build_palette_(UI_Palette *base, UI_Palette *overrides); -#define ui_build_palette(base, ...) ui_build_palette_((base), &(UI_Palette){.text = v4f32(0, 0, 0, 0), __VA_ARGS__}) - //- rjf: current style tags key internal UI_Key ui_top_tags_key(void); @@ -1014,13 +950,15 @@ 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); 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 Vec4F32 ui_top_background_color(void); +internal Vec4F32 ui_top_text_color(void); internal F32 ui_top_squish(void); internal OS_Cursor ui_top_hover_cursor(void); internal FNT_Tag ui_top_font(void); @@ -1044,13 +982,15 @@ 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); 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 Vec4F32 ui_bottom_background_color(void); +internal Vec4F32 ui_bottom_text_color(void); internal F32 ui_bottom_squish(void); internal OS_Cursor ui_bottom_hover_cursor(void); internal FNT_Tag ui_bottom_font(void); @@ -1074,13 +1014,15 @@ 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); 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 Vec4F32 ui_push_background_color(Vec4F32 v); +internal Vec4F32 ui_push_text_color(Vec4F32 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); @@ -1104,13 +1046,15 @@ 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); 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 Vec4F32 ui_pop_background_color(void); +internal Vec4F32 ui_pop_text_color(void); internal F32 ui_pop_squish(void); internal OS_Cursor ui_pop_hover_cursor(void); internal FNT_Tag ui_pop_font(void); @@ -1134,13 +1078,15 @@ 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); 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 Vec4F32 ui_set_next_background_color(Vec4F32 v); +internal Vec4F32 ui_set_next_text_color(Vec4F32 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); @@ -1186,8 +1132,9 @@ internal void ui_push_tagf(char *fmt, ...); #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_BackgroundColor(v) DeferLoop(ui_push_background_color(v), ui_pop_background_color()) +#define UI_TextColor(v) DeferLoop(ui_push_text_color(v), ui_pop_text_color()) #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())