dead code elimination, eliminating old theme usage

This commit is contained in:
Ryan Fleury
2025-02-18 19:27:27 -08:00
parent 1b8e39c635
commit 8706e7c56d
9 changed files with 230 additions and 460 deletions
+1 -1
View File
@@ -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_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("theme:\n{\n background: 0x1b1b1bff,\n alt: background: 0x222222ff,\n pop: background: 0x355b6eff,\n border: 0x404040ff,\n text: 0xe5e5e5ff,\n weak: text: 0xa4a4a4ff,\n good: text: 0x32a852ff,\n bad: text: 0xcf5242ff,\n hover: 0xffffffff,\n focus: 0xfda200ff,\n cursor: 0x8aff00ff,\n selection: 0x99ccffff,\n inactive: background: 0x0000002f,\n drop_shadow: 0x0000007f,\n\n good_pop:\n {\n background: 0x2c5b36ff,\n border: 0x568761ff,\n hover: 0xe3f5d3ff,\n weak: text: 0xe3f5d3ff,\n }\n\n bad_pop:\n {\n background: 0x803425ff,\n hover: 0xff825cff,\n }\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: 0x0000005f,\n border: 0xbfbfbf1f,\n scroll_bar:\n {\n background: 0x3b3b3b5f,\n border: 0x5f5f5f5f,\n }\n }\n\n menu_bar:\n {\n background: 0x2b3740ff,\n border: 0x3e4c57ff,\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(""),
+23 -24
View File
@@ -989,14 +989,12 @@ RD_ThemePresetTable:
{
background: 0x1b1b1bff,
alt: 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,
weak: text: 0xa4a4a4ff,
good: text: 0x32a852ff,
bad: text: 0xcf5242ff,
hover: 0xffffffff,
focus: 0xfda200ff,
cursor: 0x8aff00ff,
@@ -1004,6 +1002,20 @@ RD_ThemePresetTable:
inactive: background: 0x0000002f,
drop_shadow: 0x0000007f,
good_pop:
{
background: 0x2c5b36ff,
border: 0x568761ff,
hover: 0xe3f5d3ff,
weak: text: 0xe3f5d3ff,
}
bad_pop:
{
background: 0x803425ff,
hover: 0xff825cff,
}
code_default: 0xcbcbcbff,
code_symbol: 0x42a2cfff,
code_type: 0xfec746ff,
@@ -1039,8 +1051,13 @@ RD_ThemePresetTable:
floating:
{
background: 0x2222225f,
background: alt: 0x2222225f,
background: alt: 0x0000005f,
border: 0xbfbfbf1f,
scroll_bar:
{
background: 0x3b3b3b5f,
border: 0x5f5f5f5f,
}
}
menu_bar:
@@ -1049,24 +1066,6 @@ RD_ThemePresetTable:
border: 0x3e4c57ff,
}
good:
{
background: 0x2c5b36ff,
border: 0x3f3f3fff,
}
bad:
{
background: 0x803425ff,
border: 0xe88774ff,
}
pop:
{
background: 0x355b6eff,
border: 0x355b6eff,
}
scroll_bar:
{
background: 0x2b2b2bff,
+47 -351
View File
@@ -2105,10 +2105,15 @@ 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_color_from_cfg(cfg));
Vec4F32 rgba = rd_color_from_cfg(cfg);
if(rgba.w == 0)
{
rgba = ui_top_palette()->text;
rgba = ui_color_from_name(str8_lit("text"));
}
Vec4F32 rgba_secondary = rgba;
UI_TagF("weak")
{
rgba_secondary = ui_color_from_name(str8_lit("text"));
}
RD_IconKind icon_kind = rd_icon_kind_from_code_name(cfg->string);
B32 is_from_command_line = 0;
@@ -2172,19 +2177,19 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg)
//
DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Main), rd_raster_flags_from_slot(RD_FontSlot_Main), rgba, ui_top_font_size()};
B32 running_is_secondary = 0;
#define start_secondary() if(!running_is_secondary){running_is_secondary = 1; params.color = ui_top_palette()->text_weak; params.size = ui_top_font_size()*0.95f;}
#define start_secondary() if(!running_is_secondary){running_is_secondary = 1; params.color = rgba_secondary; params.size = ui_top_font_size()*0.95f;}
//- rjf: push icon
if(icon_kind != RD_IconKind_Null)
{
dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[icon_kind], .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, &params, rd_icon_kind_text_table[icon_kind], .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, &params, str8_lit(" "));
}
//- rjf: push warning icon for command-line entities
if(is_from_command_line)
{
dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[RD_IconKind_Info], .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, &params, rd_icon_kind_text_table[RD_IconKind_Info], .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, &params, str8_lit(" "));
}
@@ -2702,11 +2707,11 @@ rd_color_from_ctrl_entity(CTRL_Entity *entity)
CTRL_Entity *main_thread = ctrl_entity_child_from_kind(process, CTRL_EntityKind_Thread);
if(main_thread != entity)
{
result = rd_color_from_tags(str8_array_zero(), str8_lit("thread_1"));
result = ui_color_from_name(str8_lit("thread_1"));
}
else
{
result = rd_color_from_tags(str8_array_zero(), str8_lit("thread_0"));
result = ui_color_from_name(str8_lit("thread_0"));
}
}break;
}
@@ -2813,7 +2818,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"));
Vec4F32 symbol_color = ui_color_from_name(str8_lit("code_symbol"));
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
DI_Scope *di_scope = di_scope_open();
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity, CTRL_EntityKind_Process);
@@ -4585,7 +4590,7 @@ rd_window_frame(void)
struct ThemePatternNode
{
ThemePatternNode *next;
RD_ThemePattern pattern;
UI_ThemePattern pattern;
};
ThemePatternNode *first_pattern = 0;
ThemePatternNode *last_pattern = 0;
@@ -4616,9 +4621,9 @@ rd_window_frame(void)
}
//- rjf: convert to final pattern array
ws->theme = push_array(rd_frame_arena(), RD_Theme, 1);
ws->theme = push_array(rd_frame_arena(), UI_Theme, 1);
ws->theme->patterns_count = pattern_count;
ws->theme->patterns = push_array(rd_frame_arena(), RD_ThemePattern, ws->theme->patterns_count);
ws->theme->patterns = push_array(rd_frame_arena(), UI_ThemePattern, ws->theme->patterns_count);
{
U64 idx = 0;
for(ThemePatternNode *n = first_pattern; n != 0; n = n->next, idx += 1)
@@ -4797,7 +4802,7 @@ 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, &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, &widget_palette_info, &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);
@@ -4940,7 +4945,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"));
Vec4F32 symbol_color = ui_color_from_name(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);
@@ -5975,254 +5980,6 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
}
#endif
}
#endif
}break;
//////////////////////
//- rjf: ctrl entities
//
case RD_RegSlot_Machine: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->machine); goto ctrl_entity_title;
case RD_RegSlot_Process: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->process); goto ctrl_entity_title;
case RD_RegSlot_Module: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->module); goto ctrl_entity_title;
case RD_RegSlot_Thread: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->thread); goto ctrl_entity_title;
case RD_RegSlot_CtrlEntity: ctrl_entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, regs->ctrl_entity); goto ctrl_entity_title;
ctrl_entity_title:;
{
#if 0 // TODO(rjf): @cfg
//- rjf: title
UI_Row
UI_PrefWidth(ui_text_dim(5, 1))
UI_TextAlignment(UI_TextAlign_Center)
UI_TextPadding(ui_top_font_size()*1.5f)
{
DR_FStrList fstrs = rd_title_fstrs_from_ctrl_entity(scratch.arena, ctrl_entity, 0);
UI_Box *title_box = ui_build_box_from_key(UI_BoxFlag_DrawText, ui_key_zero());
ui_box_equip_display_fstrs(title_box, &fstrs);
if(ctrl_entity->kind == CTRL_EntityKind_Thread)
{
ui_spacer(ui_em(0.5f, 1.f));
UI_FontSize(ui_top_font_size() - 1.f)
UI_CornerRadius(ui_top_font_size()*0.5f)
UI_TextPadding(ui_top_font_size()*0.5f)
{
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak|UI_BoxFlag_DrawBorder) ui_label(string_from_arch(ctrl_entity->arch));
ui_spacer(ui_em(0.5f, 1.f));
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak|UI_BoxFlag_DrawBorder) ui_labelf("TID: %i", (U32)ctrl_entity->id);
}
}
}
ui_divider(ui_em(1.f, 1.f));
//- rjf: name editor
if(ctrl_entity->kind == CTRL_EntityKind_Thread) RD_Font(RD_FontSlot_Code) UI_TextPadding(ui_top_font_size()*1.5f)
{
#if 0 // TODO(rjf): @cfg
UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border|RD_LineEditFlag_CodeContents, 0, 0, &ws->ctx_menu_input_cursor, &ws->ctx_menu_input_mark, ws->ctx_menu_input_buffer, ws->ctx_menu_input_buffer_size, &ws->ctx_menu_input_string_size, 0, ctrl_entity->string, "Name###ctrl_entity_string_edit_%p", ctrl_entity);
if(ui_committed(sig))
{
rd_cmd(RD_CmdKind_SetEntityName, .ctrl_entity = ctrl_entity->handle, .string = str8(ws->ctx_menu_input_buffer, ws->ctx_menu_input_string_size));
}
#endif
}
// rjf: copy full path
if(ctrl_entity->kind == CTRL_EntityKind_Module) if(ui_clicked(rd_icon_buttonf(RD_IconKind_Clipboard, 0, "Copy Full Path")))
{
os_set_clipboard_text(ctrl_entity->string);
ui_ctx_menu_close();
}
// rjf: copy ID
if((ctrl_entity->kind == CTRL_EntityKind_Thread ||
ctrl_entity->kind == CTRL_EntityKind_Process) &&
ui_clicked(rd_icon_buttonf(RD_IconKind_Clipboard, 0, "Copy ID")))
{
String8 string = str8_from_u64(scratch.arena, ctrl_entity->id, 10, 0, 0);
os_set_clipboard_text(string);
ui_ctx_menu_close();
}
// rjf: find
if(ctrl_entity->kind == CTRL_EntityKind_Thread)
{
if(ui_clicked(rd_icon_buttonf(RD_IconKind_FileOutline, 0, "Find")))
{
rd_cmd(RD_CmdKind_FindThread, .thread = ctrl_entity->handle);
ui_ctx_menu_close();
}
}
// rjf: selection
if(ctrl_entity->kind == CTRL_EntityKind_Thread)
{
B32 is_selected = ctrl_handle_match(rd_base_regs()->thread, ctrl_entity->handle);
if(is_selected)
{
rd_icon_buttonf(RD_IconKind_Thread, 0, "[Selected]###select_entity");
}
else if(ui_clicked(rd_icon_buttonf(RD_IconKind_Thread, 0, "Select###select_entity")))
{
rd_cmd(RD_CmdKind_SelectThread, .thread = ctrl_entity->handle);
ui_ctx_menu_close();
}
}
// rjf: freezing
if(ctrl_entity->kind == CTRL_EntityKind_Thread ||
ctrl_entity->kind == CTRL_EntityKind_Process ||
ctrl_entity->kind == CTRL_EntityKind_Machine)
{
B32 is_frozen = ctrl_entity_tree_is_frozen(ctrl_entity);
ui_set_next_palette(rd_palette_from_code(is_frozen ? RD_PaletteCode_NegativePopButton : RD_PaletteCode_PositivePopButton));
if(is_frozen && ui_clicked(rd_icon_buttonf(RD_IconKind_Locked, 0, "Thaw###freeze_thaw")))
{
rd_cmd(RD_CmdKind_ThawThread, .ctrl_entity = ctrl_entity->handle);
}
if(!is_frozen && ui_clicked(rd_icon_buttonf(RD_IconKind_Unlocked, 0, "Freeze###freeze_thaw")))
{
rd_cmd(RD_CmdKind_FreezeThread, .ctrl_entity = ctrl_entity->handle);
}
}
// rjf: callstack
#if 0
RD_Palette(RD_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f));
if(ctrl_entity->kind == CTRL_EntityKind_Thread) UI_TextPadding(ui_top_font_size()*1.5f)
{
DI_Scope *di_scope = di_scope_open();
CTRL_Entity *thread = ctrl_entity;
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
CTRL_Unwind base_unwind = d_query_cached_unwind_from_thread(thread);
CTRL_CallStack rich_unwind = ctrl_call_stack_from_unwind(scratch.arena, di_scope, process, &base_unwind);
for(U64 idx = 0; idx < rich_unwind.concrete_frame_count; idx += 1)
{
CTRL_CallStackFrame *f = &rich_unwind.frames[idx];
RDI_Parsed *rdi = f->rdi;
RDI_Procedure *procedure = f->procedure;
U64 rip_vaddr = regs_rip_from_arch_block(thread->arch, f->regs);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
String8 module_name = module == &ctrl_entity_nil ? str8_lit("???") : str8_skip_last_slash(module->string);
// rjf: inline frames
for(CTRL_CallStackInlineFrame *fin = f->last_inline_frame; fin != 0; fin = fin->prev)
{
UI_Box *row = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_ClickToFocus, "###callstack_row_%I64x", idx);
UI_Signal sig = ui_signal_from_box(row);
ui_push_parent(row);
String8 name = {0};
name.str = rdi_string_from_idx(rdi, fin->inline_site->name_string_idx, &name.size);
UI_TextAlignment(UI_TextAlign_Left) RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(16.f, 1)) ui_labelf("0x%I64x", rip_vaddr);
RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) 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);
}
}
else
{
RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_labelf("[??? in %S]", module_name);
}
ui_pop_parent();
}
// rjf: concrete frame
{
UI_Box *row = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_ClickToFocus, "###callstack_row_%I64x", idx);
UI_Signal sig = ui_signal_from_box(row);
ui_push_parent(row);
String8 name = {0};
name.str = rdi_name_from_procedure(rdi, procedure, &name.size);
UI_TextAlignment(UI_TextAlign_Left) RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(16.f, 1)) ui_labelf("0x%I64x", rip_vaddr);
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);
}
}
else
{
RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_labelf("[??? in %S]", module_name);
}
ui_pop_parent();
}
}
di_scope_close(di_scope);
}
#endif
// rjf: color editor
#if 0
RD_Palette(RD_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f));
{
UI_Padding(ui_em(1.5f, 1.f))
{
ui_set_next_pref_height(ui_em(9.f, 1.f));
UI_Row UI_Padding(ui_pct(1, 0))
{
UI_PrefWidth(ui_em(1.5f, 1.f)) UI_PrefHeight(ui_em(9.f, 1.f)) UI_Column UI_PrefHeight(ui_em(1.5f, 0.f))
{
Vec4F32 presets[] =
{
v4f32(1.0f, 0.2f, 0.1f, 1.0f),
v4f32(1.0f, 0.8f, 0.2f, 1.0f),
v4f32(0.3f, 0.8f, 0.2f, 1.0f),
v4f32(0.1f, 0.8f, 0.4f, 1.0f),
v4f32(0.1f, 0.6f, 0.8f, 1.0f),
v4f32(0.5f, 0.3f, 0.8f, 1.0f),
v4f32(0.8f, 0.3f, 0.5f, 1.0f),
};
UI_CornerRadius(ui_em(0.3f, 1.f).value)
for(U64 preset_idx = 0; preset_idx < ArrayCount(presets); preset_idx += 1)
{
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = presets[preset_idx]));
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawBackground|
UI_BoxFlag_DrawBorder|
UI_BoxFlag_Clickable|
UI_BoxFlag_DrawHotEffects|
UI_BoxFlag_DrawActiveEffects,
"###color_preset_%i", (int)preset_idx);
UI_Signal sig = ui_signal_from_box(box);
if(ui_clicked(sig))
{
Vec3F32 hsv = hsv_from_rgb(v3f32(presets[preset_idx].x, presets[preset_idx].y, presets[preset_idx].z));
Vec4F32 hsva = v4f32(hsv.x, hsv.y, hsv.z, 1);
entity->color_hsva = hsva;
}
ui_spacer(ui_em(0.3f, 1.f));
}
}
ui_spacer(ui_em(0.75f, 1.f));
UI_PrefWidth(ui_em(9.f, 1.f)) UI_PrefHeight(ui_em(9.f, 1.f))
{
ui_sat_val_pickerf(entity->color_hsva.x, &entity->color_hsva.y, &entity->color_hsva.z, "###ent_satval_picker");
}
ui_spacer(ui_em(0.75f, 1.f));
UI_PrefWidth(ui_em(1.5f, 1.f)) UI_PrefHeight(ui_em(9.f, 1.f))
ui_hue_pickerf(&entity->color_hsva.x, entity->color_hsva.y, entity->color_hsva.z, "###ent_hue_picker");
}
}
UI_Row UI_Padding(ui_pct(1, 0)) UI_PrefWidth(ui_em(16.f, 1.f)) UI_CornerRadius(8.f) UI_TextAlignment(UI_TextAlign_Center)
RD_Palette(RD_PaletteCode_Floating)
{
if(ui_clicked(rd_icon_buttonf(RD_IconKind_Trash, 0, "Remove Color###color_toggle")))
{
entity->flags &= ~RD_EntityFlag_HasColor;
}
}
ui_spacer(ui_em(1.5f, 1.f));
}
#endif
#endif
}break;
}
@@ -6777,7 +6534,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))
UI_TagF(can_play ? "good" : "")
UI_TagF(can_play ? "good" : "weak")
{
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);
@@ -6840,6 +6597,7 @@ 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)
UI_TagF("weak")
{
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);
@@ -6865,7 +6623,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)
UI_TagF(can_stop ? "bad" : "")
UI_TagF(can_stop ? "bad" : "weak")
{
UI_Signal sig = {0};
{
@@ -6894,6 +6652,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
//- rjf: step over button
UI_TextAlignment(UI_TextAlign_Center) UI_Flags((can_play ? 0 : UI_BoxFlag_Disabled))
UI_TagF("weak")
{
UI_Signal sig = ui_button(rd_icon_kind_text_table[RD_IconKind_StepOver]);
os_window_push_custom_title_bar_client_area(ws->os, sig.box->rect);
@@ -6922,6 +6681,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
//- rjf: step into button
UI_TextAlignment(UI_TextAlign_Center) UI_Flags((can_play ? 0 : UI_BoxFlag_Disabled))
UI_TagF("weak")
{
UI_Signal sig = ui_button(rd_icon_kind_text_table[RD_IconKind_StepInto]);
os_window_push_custom_title_bar_client_area(ws->os, sig.box->rect);
@@ -6950,6 +6710,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
//- rjf: step out button
UI_TextAlignment(UI_TextAlign_Center) UI_Flags(can_step ? 0 : UI_BoxFlag_Disabled)
UI_TagF("weak")
{
UI_Signal sig = ui_button(rd_icon_kind_text_table[RD_IconKind_StepOut]);
os_window_push_custom_title_bar_client_area(ws->os, sig.box->rect);
@@ -7282,10 +7043,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
{
B32 is_running = d_ctrl_targets_running() && d_ctrl_last_run_frame_idx() < d_frame_index();
CTRL_Event stop_event = d_ctrl_last_stop_event();
UI_Palette *positive_scheme = rd_palette_from_code(RD_PaletteCode_Good);
UI_Palette *running_scheme = rd_palette_from_code(RD_PaletteCode_Pop);
UI_Palette *negative_scheme = rd_palette_from_code(RD_PaletteCode_Bad);
UI_Palette *palette = running_scheme;
String8 tag = str8_lit("pop");
if(!is_running)
{
switch(stop_event.cause)
@@ -7293,32 +7051,19 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
default:
case CTRL_EventCause_Finished:
{
palette = positive_scheme;
tag = str8_lit("good_pop");
}break;
case CTRL_EventCause_UserBreakpoint:
case CTRL_EventCause_InterruptedByException:
case CTRL_EventCause_InterruptedByTrap:
case CTRL_EventCause_InterruptedByHalt:
{
palette = negative_scheme;
tag = str8_lit("bad_pop");
}break;
}
}
if(ws->error_t > 0.01f)
{
UI_Palette *blended_scheme = push_array(ui_build_arena(), UI_Palette, 1);
MemoryCopyStruct(blended_scheme, palette);
for EachEnumVal(UI_ColorCode, code)
{
for(U64 idx = 0; idx < 4; idx += 1)
{
blended_scheme->colors[code].v[idx] += (negative_scheme->colors[code].v[idx] - blended_scheme->colors[code].v[idx]) * ws->error_t;
}
}
palette = blended_scheme;
}
UI_Flags(UI_BoxFlag_DrawBackground) UI_CornerRadius(0)
UI_Palette(palette)
UI_Tag(tag)
UI_Pane(bottom_bar_rect, str8_lit("###bottom_bar")) UI_WidthFill UI_Row
UI_Flags(0)
{
@@ -8686,9 +8431,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"));
Vec4F32 base_background_color = ui_color_from_name(str8_lit("background"));
Vec4F32 base_border_color = ui_color_from_name(str8_lit("border"));
Vec4F32 drop_shadow_color = ui_color_from_name(str8_lit("drop_shadow"));
//- rjf: set up heatmap buckets
F32 heatmap_bucket_size = 32.f;
@@ -8779,7 +8524,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
Vec4F32 box_background_color = {0};
if(box->flags & UI_BoxFlag_DrawBackground)
{
box_background_color = rd_color_from_tags(box->tags, str8_lit("background"));
box_background_color = ui_color_from_tags_name(box->tags, str8_lit("background"));
}
// rjf: draw background
@@ -8801,7 +8546,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
// rjf: hot effect extension
if(box->flags & UI_BoxFlag_DrawHotEffects)
{
Vec4F32 hover_color = rd_color_from_tags(box->tags, str8_lit("hover"));
Vec4F32 hover_color = ui_color_from_tags_name(box->tags, str8_lit("hover"));
// rjf: brighten
{
@@ -8901,7 +8646,9 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
dr_truncated_fancy_run_list(text_position, &box->display_fruns, max_x, ellipses_run);
if(box->flags & UI_BoxFlag_HasFuzzyMatchRanges)
{
Vec4F32 match_color = box->palette->background_pop;
String8 tags[] = {str8_lit("pop")};
String8Array tags_array = {tags, ArrayCount(tags)};
Vec4F32 match_color = ui_color_from_tags_name(tags_array, str8_lit("background"));
dr_truncated_fancy_run_fuzzy_matches(text_position, &box->display_fruns, max_x, &box->fuzzy_match_ranges, match_color);
}
}
@@ -8988,17 +8735,10 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
dr_pop_clip();
}
// rjf: draw overlay
if(b->flags & UI_BoxFlag_DrawOverlay)
{
R_Rect2DInst *inst = dr_rect(b->rect, b->palette->colors[UI_ColorCode_Background], 0, 0, 1.f);
MemoryCopyArray(inst->corner_radii, b->corner_radii);
}
// rjf: draw border
if(b->flags & UI_BoxFlag_DrawBorder)
{
Vec4F32 border_color = rd_color_from_tags(box->tags, str8_lit("border"));
Vec4F32 border_color = ui_color_from_tags_name(box->tags, str8_lit("border"));
Rng2F32 b_border_rect = pad_2f32(b->rect, 1.f);
R_Rect2DInst *inst = dr_rect(b_border_rect, border_color, 0, 1.f, 1.f);
MemoryCopyArray(inst->corner_radii, b->corner_radii);
@@ -9006,7 +8746,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
// rjf: hover effect
if(b->flags & UI_BoxFlag_DrawHotEffects)
{
Vec4F32 color = rd_color_from_tags(box->tags, str8_lit("hover"));
Vec4F32 color = ui_color_from_tags_name(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;
@@ -9023,32 +8763,34 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
}
// rjf: draw sides
if(b->flags & UI_BoxFlag_DrawSideTop|UI_BoxFlag_DrawSideBottom|UI_BoxFlag_DrawSideLeft|UI_BoxFlag_DrawSideRight)
{
Vec4F32 border_color = ui_color_from_tags_name(box->tags, str8_lit("border"));
Rng2F32 r = b->rect;
F32 half_thickness = 1.f;
F32 softness = 0.f;
if(b->flags & UI_BoxFlag_DrawSideTop)
{
dr_rect(r2f32p(r.x0, r.y0, r.x1, r.y0+2*half_thickness), b->palette->colors[UI_ColorCode_Border], 0, 0, softness);
dr_rect(r2f32p(r.x0, r.y0, r.x1, r.y0+2*half_thickness), border_color, 0, 0, softness);
}
if(b->flags & UI_BoxFlag_DrawSideBottom)
{
dr_rect(r2f32p(r.x0, r.y1-2*half_thickness, r.x1, r.y1), b->palette->colors[UI_ColorCode_Border], 0, 0, softness);
dr_rect(r2f32p(r.x0, r.y1-2*half_thickness, r.x1, r.y1), border_color, 0, 0, softness);
}
if(b->flags & UI_BoxFlag_DrawSideLeft)
{
dr_rect(r2f32p(r.x0, r.y0, r.x0+2*half_thickness, r.y1), b->palette->colors[UI_ColorCode_Border], 0, 0, softness);
dr_rect(r2f32p(r.x0, r.y0, r.x0+2*half_thickness, r.y1), border_color, 0, 0, softness);
}
if(b->flags & UI_BoxFlag_DrawSideRight)
{
dr_rect(r2f32p(r.x1-2*half_thickness, r.y0, r.x1, r.y1), b->palette->colors[UI_ColorCode_Border], 0, 0, softness);
dr_rect(r2f32p(r.x1-2*half_thickness, r.y0, r.x1, r.y1), border_color, 0, 0, softness);
}
}
// rjf: draw focus overlay
if(b->flags & UI_BoxFlag_Clickable && !(b->flags & UI_BoxFlag_DisableFocusOverlay) && b->focus_hot_t > 0.01f)
{
Vec4F32 color = rd_color_from_tags(box->tags, str8_lit("focus"));
Vec4F32 color = ui_color_from_tags_name(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);
@@ -9063,7 +8805,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 = rd_color_from_tags(box->tags, str8_lit("focus"));
Vec4F32 color = ui_color_from_tags_name(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);
@@ -9120,7 +8862,7 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
{
String8 tags[] = {str8_lit("bad")};
String8Array tags_array = {tags, ArrayCount(tags)};
Vec4F32 color = rd_color_from_tags(tags_array, str8_lit("text"));
Vec4F32 color = ui_color_from_tags_name(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);
@@ -10591,52 +10333,6 @@ rd_push_search_string(Arena *arena)
//- rjf: colors
internal Vec4F32
rd_color_from_tags(String8Array tags, String8 name)
{
Vec4F32 result = {0};
{
RD_Cfg *window = rd_cfg_from_id(rd_regs()->window);
RD_WindowState *ws = rd_window_state_from_cfg(window);
RD_Theme *theme = ws->theme;
RD_ThemePattern *pattern = 0;
U64 best_match_count = 0;
for(U64 idx = 0; idx < theme->patterns_count; idx += 1)
{
RD_ThemePattern *p = &theme->patterns[idx];
U64 match_count = 0;
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], key_string, 0))
{
name_matches = (key_tags_idx == tags.count);
match_count += 1;
break;
}
}
}
if(name_matches && match_count > best_match_count)
{
pattern = p;
best_match_count = match_count;
}
if(match_count == tags.count+1)
{
break;
}
}
if(pattern != 0)
{
result = pattern->linear;
}
}
return result;
}
internal Vec4F32
rd_rgba_from_theme_color(RD_ThemeColor color)
{
+2 -12
View File
@@ -419,18 +419,9 @@ struct RD_RegsNode
////////////////////////////////
//~ rjf: Structured Theme Types, Parsed From Config
typedef struct RD_ThemePattern RD_ThemePattern;
struct RD_ThemePattern
{
String8Array tags;
Vec4F32 linear;
};
typedef struct RD_Theme RD_Theme;
struct RD_Theme
{
RD_ThemePattern *patterns;
U64 patterns_count;
Vec4F32 colors[RD_ThemeColor_COUNT];
};
@@ -548,8 +539,8 @@ struct RD_WindowState
B32 window_temporarily_focused_ipc;
B32 window_layout_reset;
// rjf: theme
RD_Theme *theme;
// rjf: theme (recomputed each frame)
UI_Theme *theme;
// rjf: config/settings
UI_Palette cfg_palettes[RD_PaletteCode_COUNT]; // derivative from theme
@@ -1164,7 +1155,6 @@ internal String8 rd_push_search_string(Arena *arena);
//~ rjf: Colors, Fonts, Config
//- rjf: colors
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);
+17 -22
View File
@@ -126,13 +126,13 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
//////////////////////////////
//- rjf: calculate line-range-dependent info
//
F32 line_num_width_px = big_glyph_advance * (log10(visible_line_num_range.max) + 3);
F32 line_num_width_px = floor_f32(big_glyph_advance * (log10(visible_line_num_range.max) + 3));
F32 priority_margin_width_px = 0;
F32 catchall_margin_width_px = 0;
if(flags & RD_CodeViewBuildFlag_Margins)
{
priority_margin_width_px = big_glyph_advance*3.5f;
catchall_margin_width_px = big_glyph_advance*3.5f;
priority_margin_width_px = floor_f32(big_glyph_advance*3.5f);
catchall_margin_width_px = floor_f32(big_glyph_advance*3.5f);
}
TXT_LineTokensSlice slice = txt_line_tokens_slice_from_info_data_line_range(scratch.arena, text_info, text_data, visible_line_num_range);
@@ -185,7 +185,7 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
code_slice_params.catchall_margin_width_px = catchall_margin_width_px;
code_slice_params.line_num_width_px = line_num_width_px;
code_slice_params.line_text_max_width_px = (F32)line_size_x;
code_slice_params.margin_float_off_px = scroll_pos.x.idx + scroll_pos.x.off;
code_slice_params.margin_float_off_px = scroll_pos.x.idx + floor_f32(scroll_pos.x.off);
// rjf: fill text info
{
@@ -2792,7 +2792,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
ui_set_next_fixed_x(0);
ui_set_next_fixed_y(0);
ui_set_next_fixed_height(ui_top_font_size()*0.2f);
ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = rd_rgba_from_theme_color(RD_ThemeColor_CacheLineBoundary)));
ui_set_next_tag(str8_lit("pop"));
ui_build_box_from_key(UI_BoxFlag_Floating|UI_BoxFlag_DrawBackground, ui_key_zero());
}
}
@@ -2813,9 +2813,8 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
ui_set_next_fixed_x(0);
ui_set_next_fixed_y(row_height_px - ui_top_font_size()*0.5f);
ui_set_next_fixed_height(ui_top_font_size()*1.f);
Vec4F32 boundary_color = rd_rgba_from_theme_color(RD_ThemeColor_CacheLineBoundary);
boundary_color.w *= 0.5f;
ui_set_next_palette(ui_build_palette(ui_top_palette(), .background = boundary_color));
ui_set_next_tag(str8_lit("pop"));
ui_set_next_transparency(0.5f);
ui_build_box_from_key(UI_BoxFlag_Floating|UI_BoxFlag_DrawBackground, ui_key_zero());
}
}
@@ -2841,14 +2840,17 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
ProfBegin("determine cell's palette");
UI_BoxFlags cell_flags = 0;
UI_Palette *palette = ui_top_palette();
String8 cell_tag = {0};
{
if(cell_info.flags & RD_WatchCellFlag_IsErrored)
{
cell_flags |= UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBad;
cell_tag = str8_lit("bad");
}
else if(cell_info.inheritance_tooltip.size != 0)
{
cell_flags |= UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawPop;
cell_tag = str8_lit("pop");
}
else if(cell_info.cfg->id == rd_get_hover_regs()->cfg &&
rd_state->hover_regs_slot == RD_RegSlot_Cfg)
@@ -2896,6 +2898,7 @@ 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_TagF(cell->kind == RD_WatchCellKind_Expr ? "weak" : "")
{
// rjf: cell has errors? -> build error box
if(cell_info.flags & RD_WatchCellFlag_IsErrored) RD_Font(RD_FontSlot_Main)
@@ -3148,7 +3151,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
UI_PrefWidth(ui_children_sum(1)) UI_Row UI_PrefWidth(ui_text_dim(1, 1)) UI_TextPadding(0)
{
ui_labelf("Inherited from ");
RD_Font(RD_FontSlot_Code) rd_code_label(1.f, 0, rd_rgba_from_theme_color(RD_ThemeColor_CodeDefault), cell_info.inheritance_tooltip);
RD_Font(RD_FontSlot_Code) rd_code_label(1.f, 0, ui_color_from_name(str8_lit("code_default")), cell_info.inheritance_tooltip);
}
}
@@ -4099,7 +4102,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
CTRL_Unwind unwind = d_query_cached_unwind_from_thread(thread);
//- rjf: fill unwind frame annotations
if(unwind.frames.count != 0)
if(unwind.frames.count != 0) UI_Tag(str8_lit("weak"))
{
U64 last_stack_top = regs_rsp_from_arch_block(thread->arch, unwind.frames.v[0].regs);
for(U64 idx = 1; idx < unwind.frames.count; idx += 1)
@@ -4119,7 +4122,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
Annotation *annotation = push_array(scratch.arena, Annotation, 1);
annotation->name_string = symbol_name.size != 0 ? symbol_name : str8_lit("[external code]");
annotation->kind_string = str8_lit("Call Stack Frame");
annotation->color = symbol_name.size != 0 ? rd_rgba_from_theme_color(RD_ThemeColor_CodeSymbol) : ui_top_palette()->text_weak;
annotation->color = symbol_name.size != 0 ? ui_color_from_name(str8_lit("code_symbol")) : ui_color_from_name(str8_lit("text"));
annotation->vaddr_range = frame_vaddr_range;
for(U64 vaddr = frame_vaddr_range_in_viz.min; vaddr < frame_vaddr_range_in_viz.max; vaddr += 1)
{
@@ -4157,14 +4160,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
DI_Scope *scope = di_scope_open();
Vec4F32 color_gen_table[] =
{
rd_rgba_from_theme_color(RD_ThemeColor_Thread0),
rd_rgba_from_theme_color(RD_ThemeColor_Thread1),
rd_rgba_from_theme_color(RD_ThemeColor_Thread2),
rd_rgba_from_theme_color(RD_ThemeColor_Thread3),
rd_rgba_from_theme_color(RD_ThemeColor_Thread4),
rd_rgba_from_theme_color(RD_ThemeColor_Thread5),
rd_rgba_from_theme_color(RD_ThemeColor_Thread6),
rd_rgba_from_theme_color(RD_ThemeColor_Thread7),
ui_color_from_name(str8_lit("code_local")),
};
U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, rd_regs()->unwind_count);
for(E_String2NumMapNode *n = e_parse_state->ctx->locals_map->first; n != 0; n = n->order_next)
@@ -4388,8 +4384,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
if(row_range_bytes.min%64 == 0)
{
row_is_boundary = 1;
Vec4F32 row_boundary_color = rd_rgba_from_theme_color(RD_ThemeColor_CacheLineBoundary);
ui_set_next_palette(ui_build_palette(ui_top_palette(), .border = row_boundary_color));
ui_set_next_tag(str8_lit("pop"));
}
UI_Box *row = ui_build_box_from_stringf(UI_BoxFlag_DrawSideTop*!!row_is_boundary, "row_%I64x", row_range_bytes.min);
UI_Parent(row)
@@ -4487,7 +4482,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
}
if(a->type_string.size != 0)
{
rd_code_label(1.f, 1, rd_rgba_from_theme_color(RD_ThemeColor_CodeType), a->type_string);
rd_code_label(1.f, 1, ui_color_from_name(str8_lit("code_type")), a->type_string);
}
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(str8_from_memory_size(scratch.arena, dim_1u64(a->vaddr_range)));
if(a->next != 0)
+20 -19
View File
@@ -484,7 +484,7 @@ internal UI_BOX_CUSTOM_DRAW(rd_thread_box_draw_extensions)
F32 lock_icon_off = ui_top_font_size()*0.2f;
String8 tags[] = {str8_lit("bad")};
String8Array tags_array = {tags, ArrayCount(tags)};
Vec4F32 color = rd_color_from_tags(tags_array, str8_lit("text"));
Vec4F32 color = ui_color_from_tags_name(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,
@@ -593,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_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")),
ui_color_from_name(str8_lit("line_info_0")),
ui_color_from_name(str8_lit("line_info_1")),
ui_color_from_name(str8_lit("line_info_2")),
ui_color_from_name(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)));
@@ -698,18 +698,18 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{
if(color.w == 0)
{
color = rd_rgba_from_theme_color(RD_ThemeColor_Thread1);
color = ui_color_from_name(str8_lit("thread_1"));
}
if(unwind_count != 0)
{
color = rd_rgba_from_theme_color(RD_ThemeColor_ThreadUnwound);
color = ui_color_from_name(str8_lit("thread_unwound"));
}
else if(thread == stopper_thread &&
(stop_event.cause == CTRL_EventCause_InterruptedByHalt ||
stop_event.cause == CTRL_EventCause_InterruptedByTrap ||
stop_event.cause == CTRL_EventCause_InterruptedByException))
{
color = rd_rgba_from_theme_color(RD_ThemeColor_ThreadError);
color = ui_color_from_name(str8_lit("thread_error"));
}
if(d_ctrl_targets_running() && d_ctrl_last_run_frame_idx() < d_frame_index())
{
@@ -852,18 +852,18 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{
if(color.w == 0)
{
color = rd_rgba_from_theme_color(RD_ThemeColor_Thread1);
color = ui_color_from_name(str8_lit("thread_1"));
}
if(unwind_count != 0)
{
color = rd_rgba_from_theme_color(RD_ThemeColor_ThreadUnwound);
color = ui_color_from_name(str8_lit("thread_unwound"));
}
else if(thread == stopper_thread &&
(stop_event.cause == CTRL_EventCause_InterruptedByHalt ||
stop_event.cause == CTRL_EventCause_InterruptedByTrap ||
stop_event.cause == CTRL_EventCause_InterruptedByException))
{
color = rd_rgba_from_theme_color(RD_ThemeColor_ThreadError);
color = ui_color_from_name(str8_lit("thread_error"));
}
if(d_ctrl_targets_running() && d_ctrl_last_run_frame_idx() < d_frame_index())
{
@@ -959,7 +959,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
Vec4F32 bp_rgba = rd_color_from_cfg(bp);
if(bp_rgba.w == 0)
{
bp_rgba = rd_rgba_from_theme_color(RD_ThemeColor_Breakpoint);
bp_rgba = ui_color_from_name(str8_lit("breakpoint"));
}
B32 bp_is_disabled = rd_disabled_from_cfg(bp);
if(bp_is_disabled)
@@ -1052,7 +1052,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
Vec4F32 color = rd_color_from_cfg(pin);
if(color.w == 0)
{
color = rd_rgba_from_theme_color(RD_ThemeColor_CodeDefault);
color = ui_color_from_name(str8_lit("code_default"));
}
// rjf: build box for watch
@@ -1667,16 +1667,16 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{
TxtRngColorPairNode *n = push_array(scratch.arena, TxtRngColorPairNode, 1);
n->rng = txt_rng(*cursor, *mark);
n->color = ui_top_palette()->colors[UI_ColorCode_Selection];
n->color = ui_color_from_name(str8_lit("selection"));
SLLQueuePush(first_txt_rng_color_pair, last_txt_rng_color_pair, n);
}
// rjf: push for ctrlified mouse expr
if(ctrlified && !txt_pt_match(result.mouse_expr_rng.max, result.mouse_expr_rng.min))
if(ctrlified && !txt_pt_match(result.mouse_expr_rng.max, result.mouse_expr_rng.min)) UI_Tag(str8_lit("pop"))
{
TxtRngColorPairNode *n = push_array(scratch.arena, TxtRngColorPairNode, 1);
n->rng = result.mouse_expr_rng;
n->color = ui_top_palette()->background_pop;
n->color = ui_color_from_name(str8_lit("background"));
SLLQueuePush(first_txt_rng_color_pair, last_txt_rng_color_pair, n);
}
}
@@ -1870,6 +1870,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
ceil_f32(line_box->rect.y1) + 1.f,
};
Vec4F32 color = n->color;
color.w = ClampTop(color.w, 0.1f);
if(!is_focused)
{
color.w *= 0.5f;
@@ -1898,7 +1899,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
ui_box_text_position(line_box).x+cursor_off_pixels+cursor_thickness/2.f,
line_box->rect.y1+params->font_size*0.25f,
};
Vec4F32 cursor_color = ui_top_palette()->cursor;
Vec4F32 cursor_color = ui_color_from_name(str8_lit("cursor"));
if(!is_focused)
{
cursor_color.w *= 0.5f;
@@ -2192,7 +2193,7 @@ rd_label(String8 string)
{
fstr.string = p->string;
fstr.params.font = ui_top_font();
fstr.params.color = ui_top_palette()->colors[UI_ColorCode_Text];
fstr.params.color = ui_color_from_name(str8_lit("text"));
fstr.params.size = ui_top_font_size();
if(p->flags & StringPartFlag_Code)
{
@@ -2686,7 +2687,7 @@ rd_line_edit(RD_LineEditParams *params, String8 string)
if(!(params->flags & RD_LineEditFlag_PreferDisplayString) && params->pre_edit_value.size != 0)
{
display_string = params->pre_edit_value;
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);
+5 -3
View File
@@ -134,10 +134,10 @@ internal UI_BOX_CUSTOM_DRAW(ui_line_edit_draw)
FNT_Tag font = box->font;
F32 font_size = box->font_size;
F32 tab_size = box->tab_size;
Vec4F32 cursor_color = box->palette->colors[UI_ColorCode_Cursor];
Vec4F32 cursor_color = ui_color_from_tags_name(box->tags, str8_lit("cursor"));
cursor_color.w *= box->parent->parent->focus_active_t;
Vec4F32 select_color = box->palette->colors[UI_ColorCode_Selection];
select_color.w *= (box->parent->parent->focus_active_t*0.2f + 0.8f);
Vec4F32 select_color = ui_color_from_tags_name(box->tags, str8_lit("selection"));
select_color.w *= 0.1f*(box->parent->parent->focus_active_t*0.2f + 0.8f);
Vec2F32 text_position = ui_box_text_position(box);
String8 edited_string = draw_data->edited_string;
TxtPt cursor = draw_data->cursor;
@@ -1213,6 +1213,7 @@ 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
S64 idx_range_dim = Max(dim_1s64(idx_range), 1);
@@ -1332,6 +1333,7 @@ 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;
}
+89 -27
View File
@@ -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_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_WidgetPaletteInfo *widget_palette_info, UI_AnimationInfo *animation_info, F32 real_dt, F32 animation_dt)
{
//- rjf: reset per-build ui state
{
@@ -844,6 +844,7 @@ ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, U
//- rjf: fill build phase parameters
{
ui_state->theme = theme;
ui_state->events = events;
ui_state->window = window;
ui_state->mouse = (os_window_is_focused(window) || ui_state->last_time_mousemoved_us+500000 >= os_now_microseconds()) ? os_mouse_from_window(window) : v2f32(-100, -100);
@@ -2194,6 +2195,86 @@ ui_build_palette_(UI_Palette *base, UI_Palette *overrides)
return palette;
}
//- rjf: tag gathering
internal String8Array
ui_top_tags(void)
{
if(ui_state->current_gen_tags_gen != ui_state->tag_stack.gen)
{
ui_state->current_gen_tags_gen = ui_state->tag_stack.gen;
Temp scratch = scratch_begin(0, 0);
String8List tags = {0};
for(UI_TagNode *n = ui_state->tag_stack.top; n != 0; n = n->next)
{
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);
}
return ui_state->current_gen_tags;
}
//- rjf: theme color lookups
internal Vec4F32
ui_color_from_name(String8 name)
{
Vec4F32 result = ui_color_from_tags_name(ui_top_tags(), name);
return result;
}
internal Vec4F32
ui_color_from_tags_name(String8Array tags, String8 name)
{
Vec4F32 result = {0};
{
UI_Theme *theme = ui_state->theme;
UI_ThemePattern *pattern = 0;
U64 best_match_count = 0;
for(U64 idx = 0; idx < theme->patterns_count; idx += 1)
{
UI_ThemePattern *p = &theme->patterns[idx];
U64 match_count = 0;
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], key_string, 0))
{
name_matches = (key_tags_idx == tags.count);
match_count += 1;
break;
}
}
}
if(name_matches && match_count > best_match_count)
{
pattern = p;
best_match_count = match_count;
}
if(match_count == tags.count+1)
{
break;
}
}
if(pattern != 0)
{
result = pattern->linear;
}
}
return result;
}
//- rjf: box node construction
internal UI_Box *
@@ -2354,26 +2435,7 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key)
box->text_padding = ui_state->text_padding_stack.top->v;
box->hover_cursor = ui_state->hover_cursor_stack.top->v;
box->custom_draw = 0;
if(ui_state->current_gen_tags_gen != ui_state->tag_stack.gen)
{
ui_state->current_gen_tags_gen = ui_state->tag_stack.gen;
Temp scratch = scratch_begin(0, 0);
String8List tags = {0};
for(UI_TagNode *n = ui_state->tag_stack.top; n != 0; n = n->next)
{
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);
}
box->tags = ui_state->current_gen_tags;
box->tags = ui_top_tags();
}
//- rjf: auto-pop all stacks
@@ -2445,13 +2507,13 @@ internal void
ui_box_equip_display_string(UI_Box *box, String8 string)
{
ProfBeginFunction();
Vec4F32 text_color = ui_color_from_name(str8_lit("text"));
box->string = push_str8_copy(ui_build_arena(), string);
box->flags |= UI_BoxFlag_HasDisplayString;
UI_ColorCode text_color_code = (box->flags & UI_BoxFlag_DrawTextWeak ? UI_ColorCode_TextWeak : UI_ColorCode_Text);
if(box->flags & UI_BoxFlag_DrawText && (box->fastpath_codepoint == 0 || !(box->flags & UI_BoxFlag_DrawTextFastpathCodepoint)))
{
String8 display_string = ui_box_display_string(box);
DR_FStrNode fstr_n = {0, {display_string, {box->font, box->text_raster_flags, box->palette->colors[text_color_code], box->font_size, 0, 0}}};
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};
box->display_fstrs = dr_fstrs_copy(ui_build_arena(), &fstrs);
box->display_fruns = dr_fruns_from_fstrs(ui_build_arena(), box->tab_size, &box->display_fstrs);
@@ -2465,16 +2527,16 @@ ui_box_equip_display_string(UI_Box *box, String8 string)
U64 fpcp_pos = str8_find_needle(display_string, 0, fpcp, StringMatchFlag_CaseInsensitive);
if(fpcp_pos < display_string.size)
{
DR_FStrNode pst_fstr_n = {0, {str8_skip(display_string, fpcp_pos+fpcp.size), {box->font, box->text_raster_flags, box->palette->colors[text_color_code], box->font_size, 0, 0}}};
DR_FStrNode cdp_fstr_n = {&pst_fstr_n, {str8_substr(display_string, r1u64(fpcp_pos, fpcp_pos+fpcp.size)), {box->font, box->text_raster_flags, box->palette->colors[text_color_code], box->font_size, 3.f, 0}}};
DR_FStrNode pre_fstr_n = {&cdp_fstr_n, {str8_prefix(display_string, fpcp_pos), {box->font, box->text_raster_flags, box->palette->colors[text_color_code], box->font_size, 0, 0}}};
DR_FStrNode pst_fstr_n = {0, {str8_skip(display_string, fpcp_pos+fpcp.size), {box->font, box->text_raster_flags, text_color, box->font_size, 0, 0}}};
DR_FStrNode cdp_fstr_n = {&pst_fstr_n, {str8_substr(display_string, r1u64(fpcp_pos, fpcp_pos+fpcp.size)), {box->font, box->text_raster_flags, text_color, box->font_size, 3.f, 0}}};
DR_FStrNode pre_fstr_n = {&cdp_fstr_n, {str8_prefix(display_string, fpcp_pos), {box->font, box->text_raster_flags, text_color, box->font_size, 0, 0}}};
DR_FStrList fstrs = {&pre_fstr_n, &pst_fstr_n, 3};
box->display_fstrs = dr_fstrs_copy(ui_build_arena(), &fstrs);
box->display_fruns = dr_fruns_from_fstrs(ui_build_arena(), box->tab_size, &box->display_fstrs);
}
else
{
DR_FStrNode fstr_n = {0, {display_string, {box->font, box->text_raster_flags, box->palette->colors[UI_ColorCode_Text], box->font_size, 0, 0}}};
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};
box->display_fstrs = dr_fstrs_copy(ui_build_arena(), &fstrs);
box->display_fruns = dr_fruns_from_fstrs(ui_build_arena(), box->tab_size, &box->display_fstrs);
+26 -1
View File
@@ -216,6 +216,23 @@ struct UI_Size
F32 strictness;
};
////////////////////////////////
//~ rjf: Themes
typedef struct UI_ThemePattern UI_ThemePattern;
struct UI_ThemePattern
{
String8Array tags;
Vec4F32 linear;
};
typedef struct UI_Theme UI_Theme;
struct UI_Theme
{
UI_ThemePattern *patterns;
U64 patterns_count;
};
////////////////////////////////
//~ rjf: Palettes
@@ -679,6 +696,7 @@ 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;
@@ -850,7 +868,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_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_WidgetPaletteInfo *widget_palette_info, 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);
@@ -893,6 +911,13 @@ internal void ui_set_auto_focus_hot_key(UI_Key key);
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: tag gathering
internal String8Array ui_top_tags(void);
//- rjf: theme color lookups
internal Vec4F32 ui_color_from_name(String8 name);
internal Vec4F32 ui_color_from_tags_name(String8Array tags, String8 name);
//- rjf: box node construction
internal UI_Box * ui_build_box_from_key(UI_BoxFlags flags, UI_Key key);
internal UI_Key ui_active_seed_key(void);