dead code elimination, user/project setting evaluation, work on color view ui

This commit is contained in:
Ryan Fleury
2025-04-21 14:57:31 -07:00
parent 0ce9925ba6
commit 20ba4a6af9
14 changed files with 283 additions and 387 deletions
+6 -4
View File
@@ -4,7 +4,7 @@
//- GENERATED CODE
C_LINKAGE_BEGIN
RD_VocabInfo rd_vocab_info_table[314] =
RD_VocabInfo rd_vocab_info_table[315] =
{
{str8_lit_comp("auto_view_rule"), str8_lit_comp("auto_view_rules"), str8_lit_comp("Auto View Rule"), str8_lit_comp("Auto View Rules"), RD_IconKind_Binoculars},
{str8_lit_comp("file_path_map"), str8_lit_comp("file_path_maps"), str8_lit_comp("File Path Map"), str8_lit_comp("File Path Maps"), RD_IconKind_FileOutline},
@@ -110,6 +110,7 @@ RD_VocabInfo rd_vocab_info_table[314] =
{str8_lit_comp("font_size"), str8_lit_comp(""), str8_lit_comp("Font Size"), str8_lit_comp(""), RD_IconKind_Null},
{str8_lit_comp("row_height"), str8_lit_comp(""), str8_lit_comp("Row Height"), str8_lit_comp(""), RD_IconKind_Null},
{str8_lit_comp("tab_height"), str8_lit_comp(""), str8_lit_comp("Tab Height"), str8_lit_comp(""), RD_IconKind_Null},
{str8_lit_comp("rgba"), str8_lit_comp(""), str8_lit_comp("RGBA"), str8_lit_comp(""), RD_IconKind_Palette},
{str8_lit_comp("launch_and_run"), str8_lit_comp(""), str8_lit_comp("Launch and Run"), str8_lit_comp(""), RD_IconKind_Play},
{str8_lit_comp("launch_and_step_into"), str8_lit_comp(""), str8_lit_comp("Launch and Step Into"), str8_lit_comp(""), RD_IconKind_PlayStepForward},
{str8_lit_comp("kill"), str8_lit_comp(""), str8_lit_comp("Kill"), str8_lit_comp(""), RD_IconKind_X},
@@ -322,9 +323,10 @@ RD_VocabInfo rd_vocab_info_table[314] =
{str8_lit_comp("log_marker"), str8_lit_comp(""), str8_lit_comp("Log Marker"), str8_lit_comp(""), RD_IconKind_Null},
};
RD_NameSchemaInfo rd_name_schema_info_table[20] =
RD_NameSchemaInfo rd_name_schema_info_table[21] =
{
{str8_lit_comp("settings"), str8_lit_comp("x:\n{\n @default(1) 'hover_animations': bool,\n @default(1) 'press_animations': bool,\n @default(0) 'focus_animations': bool,\n @default(1) 'tooltip_animations': bool,\n @default(1) 'menu_animations': bool,\n @default(1) 'scrolling_animations': bool,\n @default(1) 'background_blur': bool,\n @default(1) 'thread_lines': bool,\n @default(1) 'breakpoint_lines': bool,\n @default(1) 'thread_glow': bool,\n @default(1) 'breakpoint_glow': bool,\n @default(0) 'opaque_backgrounds': bool,\n @default(1) 'smooth_ui_text': bool,\n @default(0) 'smooth_code_text': bool,\n @default(1) 'hint_ui_text': bool,\n @default(1) 'hint_code_text': bool,\n @default(2) 'tab_width': @range[1, 32] u64,\n @default(11) 'font_size': @range[6, 72] u64,\n @default(3.f) 'row_height': @range[1.75f, 5.f] f32,\n @default(3.f) 'tab_height': @range[1.75f, 5.f] f32,\n}\n")},
{str8_lit_comp("user"), str8_lit_comp("x:\n{\n @default(2) @display_name('User Tab Width') 'tab_width': @range[1, 32] u64,\n}\n")},
{str8_lit_comp("project"), str8_lit_comp("x:\n{\n @default(2) @display_name('Project Tab Width') 'tab_width': @range[1, 32] u64,\n}\n")},
{str8_lit_comp("window"), str8_lit_comp("x:\n{\n //- rjf: animations\n @default(1) 'hover_animations': bool,\n @default(1) 'press_animations': bool,\n @default(0) 'focus_animations': bool,\n @default(1) 'tooltip_animations': bool,\n @default(1) 'menu_animations': bool,\n @default(1) 'scrolling_animations': bool,\n\n //- rjf: thread & breakpoint decorations\n @default(1) @display_name('Thread Lines') @description(\"Controls whether or not a long horizontal line is drawn before the next line or instruction that the selected thread will execute in source and disassembly views.\")\n 'thread_lines': bool,\n @default(1) @display_name('Thread Glow') @description(\"Controls whether or not a glowing effect is drawn on the selected thread in source and disassembly views.\")\n 'thread_glow': bool,\n @default(1) @display_name('Breakpoint Lines') @description(\"Controls whether or not a long horizontal line is drawn before the line or instruction at which a breakpoint is placed, in source and disassembly views.\")\n 'breakpoint_lines': bool,\n @default(1) @display_name('Breakpoint Glow') @description(\"Controls whether or not a glowing effect is drawn on breakpoints in source and disassembly views.\")\n 'breakpoint_glow': bool,\n\n //- rjf: occluding background settings\n @default(0) @display_name('Opaque Backgrounds') @description(\"Controls whether or not all floating background colors are forced to be fully opaque.\")\n 'opaque_backgrounds': bool,\n @default(1) @display_name('Background Blur') @description(\"Controls whether or not occluded regions behind floating elements are blurred.\")\n 'background_blur': bool,\n\n //- rjf: text rasterization settings\n @default(1) @display_name('Smooth UI Text') @description(\"Controls whether or not UI text is fully anti-aliased, for a smoother appearance.\")\n 'smooth_ui_text': bool,\n @default(1) @display_name('Hint UI Text') @description(\"Controls whether or not UI text is hinted, for better text readability at small sizes.\")\n 'hint_ui_text': bool,\n @default(0) @display_name('Smooth Code Text') @description(\"Controls whether or not code text is fully anti-aliased, for a smoother appearance.\")\n 'smooth_code_text': bool,\n @default(1) @display_name('Hint Code Text') @description(\"Controls whether or not code text is hinted, for better text readability at small sizes.\")\n 'hint_code_text': bool,\n @default(11) @display_name('Window Font Size') @description(\"Controls the window's default font size. Does not apply to tabs with their own font size set.\")\n 'font_size': @range[6, 72] u64,\n\n //- rjf: size settings\n @default(3.f) @display_name('Window Row Height') @description(\"Controls the window's default row height, in multiples of the font size. Does not apply to tabs with their own row height set.\")\n 'row_height': @range[1.75f, 5.f] f32,\n @default(3.f) @description(\"Controls the height of tabs, in multiples of the font size.\")\n 'tab_height': @range[1.75f, 5.f] f32,\n}\n")},
{str8_lit_comp("tab"), str8_lit_comp("x:\n{\n @default(11) @display_name('Tab Font Size') 'font_size': @range[6, 72] u64,\n}\n")},
{str8_lit_comp("watch"), str8_lit_comp("@inherit(tab) x:\n{\n @default(3.f) @display_name('Tab Row Height') 'row_height': @range[1.75f, 5.f] f32,\n}\n")},
@@ -409,7 +411,7 @@ RD_CmdKindInfo rd_cmd_kind_info_table[211] =
{ str8_lit_comp("halt"), str8_lit_comp("Halts all attached processes."), str8_lit_comp("pause"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("soft_halt_refresh"), str8_lit_comp("Interrupts all attached processes to collect data, and then resumes them."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("set_thread_ip"), str8_lit_comp("Sets the specified thread's instruction pointer at the specified address."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*1)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_Vaddr, str8_lit_comp(""), str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("run_to_line"), str8_lit_comp("Runs until a particular source line is hit."), str8_lit_comp(""), str8_lit_comp("$text_pt,"), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("run_to_line"), str8_lit_comp("Runs until a particular source line is hit."), str8_lit_comp(""), str8_lit_comp("$text_pt,"), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("run"), str8_lit_comp("Runs all targets after starting them if they have not been started yet."), str8_lit_comp("play"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("restart"), str8_lit_comp("Kills all attached processes, then launches all active targets."), str8_lit_comp("restart,retry"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("step_into"), str8_lit_comp("Steps once, possibly into function calls, for either source lines or instructions (whichever is selected)."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), CTRL_EntityKind_Null}},
+2 -2
View File
@@ -640,8 +640,8 @@ RD_Query query;
.os_event = rd_regs()->os_event,\
C_LINKAGE_BEGIN
extern RD_VocabInfo rd_vocab_info_table[314];
extern RD_NameSchemaInfo rd_name_schema_info_table[20];
extern RD_VocabInfo rd_vocab_info_table[315];
extern RD_NameSchemaInfo rd_name_schema_info_table[21];
extern Rng1U64 rd_reg_slot_range_table[42];
extern String8 rd_binding_version_remap_old_name_table[8];
extern String8 rd_binding_version_remap_new_name_table[8];
+15 -84
View File
@@ -123,6 +123,7 @@ RD_VocabTable:
{font_size "" "Font Size" "" Null }
{row_height "" "Row Height" "" Null }
{tab_height "" "Tab Height" "" Null }
{rgba "" "RGBA" "" Palette }
}
@struct RD_VocabInfo:
@@ -146,31 +147,22 @@ RD_VocabTable:
@table(name schema) RD_SchemaTable:
{
//- rjf: settings
//- rjf: users / projects
{
settings,
```x:
user
```
x:
{
@default(1) 'hover_animations': bool,
@default(1) 'press_animations': bool,
@default(0) 'focus_animations': bool,
@default(1) 'tooltip_animations': bool,
@default(1) 'menu_animations': bool,
@default(1) 'scrolling_animations': bool,
@default(1) 'background_blur': bool,
@default(1) 'thread_lines': bool,
@default(1) 'breakpoint_lines': bool,
@default(1) 'thread_glow': bool,
@default(1) 'breakpoint_glow': bool,
@default(0) 'opaque_backgrounds': bool,
@default(1) 'smooth_ui_text': bool,
@default(0) 'smooth_code_text': bool,
@default(1) 'hint_ui_text': bool,
@default(1) 'hint_code_text': bool,
@default(2) 'tab_width': @range[1, 32] u64,
@default(11) 'font_size': @range[6, 72] u64,
@default(3.f) 'row_height': @range[1.75f, 5.f] f32,
@default(3.f) 'tab_height': @range[1.75f, 5.f] f32,
@default(2) @display_name('User Tab Width') 'tab_width': @range[1, 32] u64,
}
```
}
{
project
```
x:
{
@default(2) @display_name('Project Tab Width') 'tab_width': @range[1, 32] u64,
}
```
}
@@ -1102,67 +1094,6 @@ RD_IconTable:
@expand(RD_IconTable a) `str8_lit_comp("$(a.text)")`;
}
////////////////////////////////
//~ rjf: View Rules
@table(name name_lower display_name params_schema icon can_filter filter_is_code typing_automatically_filters can_use_in_watch_table can_fill_value_cell can_expand show_in_docs description)
RD_ViewRuleTable:
{
//- rjf: basics
{ Empty empty "" "" Null 0 0 0 0 0 0 0 "" }
{ GettingStarted getting_started "Getting Started" "" QuestionMark 0 0 0 0 0 0 0 "" }
//- rjf: meta (settings)
{ Settings settings "Settings" "" Gear 0 0 0 0 0 0 1 "An interface to modify general settings for the debugger's appearance and behavior." }
//- rjf: temporary view for loading files - must analyze file before picking viewer
{ PendingFile pending_file "Pending File" "" FileOutline 0 0 0 0 0 0 0 "" }
//- rjf: visualizers
{ Watch watch "Watch" "" Binoculars 1 1 1 0 0 0 1 "The familiar 'watch window' debugger interface. Allows the inputting of a number of expressions. Each expression in the table is evaluated within the context of the selected thread's selected call stack frame. If applicable (depending on visualization rules and the expression's type), these expressions may be hierarchically expanded, which displays children as more rows in the table. The values of these expressions may also be edited, and if possible, can be used to write to registers or memory in attached processes. Also contains a new *view rule* column, not found in other major debuggers, which allows per-row specification of various visualization rules. These view rules may be used to visualize and inspect the evaluation of expressions in a variety of ways. To learn more, read the 'View Rules' section." }
{ Text text "Text" "x:{'lang':lang, 'size':expr}" FileOutline 0 0 0 1 0 1 0 "" }
{ Disasm disasm "Disassembly" "x:{'arch':arch, 'size':expr, 'addresses':bool, 'code_bytes':bool}" Glasses 0 0 0 1 0 1 1 "Displays disassembled instructions in a textual form from the selected thread's containing process virtual address space." }
{ Memory memory "Memory" "x:{'size':expr}" Grid 0 0 0 1 0 1 1 "A hex-editor-like grid interface for viewing memory." }
{ Bitmap bitmap "Bitmap" "x:{'w':expr, 'h':expr, 'fmt':tex2dformat}" Binoculars 0 0 0 1 0 1 1 "Visualizes memory as a bitmap." }
{ Checkbox checkbox "Checkbox" "" CheckFilled 0 0 0 1 1 0 1 "Visualizes memory as an RGBA color." }
{ ColorRGBA color_rgba "Color (RGBA)" "" Palette 0 0 0 1 1 1 1 "Visualizes memory as an RGBA color." }
{ Geo3D geo3d "Geometry (3D)" "x:{'count':expr, 'vtx':expr, 'vtx_size':expr}" Binoculars 0 0 0 1 0 1 1 "Visualizes memory as 3D geometry." }
}
/*
@enum RD_ViewRuleKind:
{
Null,
@expand(RD_ViewRuleTable a) `$(a.name)`,
COUNT
}
@struct RD_ViewRuleInfo:
{
`String8 string`;
`String8 description`;
`String8 display_name`;
`String8 params_schema`;
`RD_IconKind icon_kind`;
`RD_ViewRuleInfoFlags flags`;
`EV_ExpandRuleInfoHookFunctionType *expr_expand_info`;
`RD_ViewRuleUIFunctionType *ui`;
}
@gen
{
`RD_VIEW_RULE_UI_FUNCTION_DEF(null);`,
@expand(RD_ViewRuleTable a) `$(a.can_use_in_watch_table != 0 && a.can_expand != 0 -> "EV_EXPAND_RULE_INFO_FUNCTION_DEF(" .. a.name_lower .. ");")`,
@expand(RD_ViewRuleTable a) `RD_VIEW_RULE_UI_FUNCTION_DEF($(a.name_lower));`,
}
@data(RD_ViewRuleInfo) rd_view_rule_kind_info_table:
{
`{{0}, {0}, {0}, {0}, RD_IconKind_Null, 0, EV_EXPAND_RULE_INFO_FUNCTION_NAME(nil), RD_VIEW_RULE_UI_FUNCTION_NAME(null)}`,
@expand(RD_ViewRuleTable a) `{str8_lit_comp("$(a.name_lower)"), str8_lit_comp("$(a.description)"), str8_lit_comp("$(a.display_name)"), str8_lit_comp("$(a.params_schema)"), RD_IconKind_$(a.icon), (RD_ViewRuleInfoFlag_ShowInDocs*$(a.show_in_docs)|RD_ViewRuleInfoFlag_CanFilter*$(a.can_filter)|RD_ViewRuleInfoFlag_FilterIsCode*$(a.filter_is_code)|RD_ViewRuleInfoFlag_TypingAutomaticallyFilters*$(a.typing_automatically_filters)|RD_ViewRuleInfoFlag_CanUseInWatchTable*$(a.can_use_in_watch_table)|RD_ViewRuleInfoFlag_CanFillValueCell*$(a.can_fill_value_cell)|RD_ViewRuleInfoFlag_CanExpand*$(a.can_expand)), $(a.can_expand != 0 -> "EV_EXPAND_RULE_INFO_FUNCTION_NAME(" .. a.name_lower .. ")") $(a.can_expand == 0 -> "EV_EXPAND_RULE_INFO_FUNCTION_NAME(nil)"), RD_VIEW_RULE_UI_FUNCTION_NAME($(a.name_lower))}`,
}
*/
////////////////////////////////
//~ rjf: Theme Tables
+71 -28
View File
@@ -1176,17 +1176,9 @@ rd_setting_from_name(String8 name)
{
String8 result = {0};
{
// rjf: find most-granular config scope to begin looking for the setting
// rjf: find most-granular config scopes to begin looking for the setting
RD_Cfg *view_cfg = rd_cfg_from_id(rd_regs()->view);
RD_Cfg *start_cfg = view_cfg;
for(RD_Cfg *p = start_cfg->parent; p != &rd_nil_cfg; p = p->parent)
{
if(str8_match(p->string, str8_lit("transient"), 0))
{
start_cfg = &rd_nil_cfg;
break;
}
}
RD_Cfg *start_cfg = &rd_nil_cfg;
if(start_cfg == &rd_nil_cfg) { start_cfg = rd_cfg_from_id(rd_regs()->panel); }
if(start_cfg == &rd_nil_cfg) { start_cfg = rd_cfg_from_id(rd_regs()->window); }
@@ -1200,23 +1192,27 @@ rd_setting_from_name(String8 name)
// rjf: return resultant child string stored under this key
result = setting->first->string;
// rjf: no result -> look for default in settings
// rjf: no result -> look for default in schemas
if(result.size == 0) ProfScope("default setting schema lookup")
{
Temp scratch = scratch_begin(0, 0);
String8 schema_names[] =
MD_Node *schema = &md_nil_node;
{
view_cfg->string,
str8_lit("settings"),
};
for EachElement(idx, schema_names)
{
MD_NodePtrList schemas = rd_schemas_from_name(schema_names[idx]);
for(MD_NodePtrNode *n = schemas.first; n != 0; n = n->next)
MD_NodePtrList schemas = rd_schemas_from_name(view_cfg->string);
for(MD_NodePtrNode *n = schemas.first; n != 0 && schema == &md_nil_node; n = n->next)
{
MD_Node *schema = n->v;
MD_Node *setting = md_child_from_string(schema, name, 0);
MD_Node *default_tag = md_tag_from_string(setting, str8_lit("default"), 0);
schema = md_child_from_string(n->v, name, 0);
}
for(RD_Cfg *cfg = start_cfg; cfg != &rd_nil_cfg && schema == &md_nil_node; cfg = cfg->parent)
{
MD_NodePtrList schemas = rd_schemas_from_name(cfg->string);
for(MD_NodePtrNode *n = schemas.first; n != 0 && schema == &md_nil_node; n = n->next)
{
schema = md_child_from_string(n->v, name, 0);
}
}
if(schema != &md_nil_node)
{
MD_Node *default_tag = md_tag_from_string(schema, str8_lit("default"), 0);
if(default_tag != &md_nil_node)
{
result = default_tag->first->string;
@@ -1225,7 +1221,6 @@ rd_setting_from_name(String8 name)
}
}
end_default_search:;
scratch_end(scratch);
}
}
return result;
@@ -2990,6 +2985,19 @@ rd_view_ui(Rng2F32 rect)
RD_Cfg *cfg = rd_cfg_from_eval_space(eval.space);
rd_cmd(RD_CmdKind_CompleteQuery, .cfg = cfg->id);
}break;
case RD_EvalSpaceKind_MetaCtrlEntity:
{
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space);
RD_RegsScope(.ctrl_entity = entity->handle)
{
if(0){}
else if(entity->kind == CTRL_EntityKind_Thread) { rd_regs()->thread = entity->handle; }
else if(entity->kind == CTRL_EntityKind_Module) { rd_regs()->module = entity->handle; }
else if(entity->kind == CTRL_EntityKind_Process) { rd_regs()->process = entity->handle; }
else if(entity->kind == CTRL_EntityKind_Machine) { rd_regs()->machine = entity->handle; }
rd_cmd(RD_CmdKind_CompleteQuery);
}
}break;
case RD_EvalSpaceKind_MetaUnattachedProcess:
{
U64 pid = eval.value.u128.u64[0];
@@ -4725,7 +4733,11 @@ rd_view_ui(Rng2F32 rect)
RD_ViewUIRule *view_ui_rule = rd_view_ui_rule_from_string(view_name);
E_Eval expr_eval = e_eval_from_string(scratch.arena, expr_string);
E_IRTreeAndType *prev_overridden_irtree = e_ir_state->overridden_irtree;
e_ir_state->overridden_irtree = expr_eval.irtree.prev;
e_ir_state->overridden_irtree = &expr_eval.irtree;
for(E_IRTreeAndType *prev = expr_eval.irtree.prev; prev != 0; prev = prev->prev)
{
e_ir_state->overridden_irtree = prev;
}
view_ui_rule->ui(expr_eval, rect);
e_ir_state->overridden_irtree = prev_overridden_irtree;
scratch_end(scratch);
@@ -12100,6 +12112,26 @@ rd_frame(void)
}
}
//- rjf: add macros for user/project
{
E_TypeKey type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, str8_lit("user"));
E_Space space = rd_eval_space_from_cfg(rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user")));
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
expr->space = space;
expr->mode = E_Mode_Offset;
expr->type_key = type_key;
e_string2expr_map_insert(scratch.arena, ctx->macro_map, str8_lit("user_settings"), expr);
}
{
E_TypeKey type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, str8_lit("project"));
E_Space space = rd_eval_space_from_cfg(rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("project")));
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
expr->space = space;
expr->mode = E_Mode_Offset;
expr->type_key = type_key;
e_string2expr_map_insert(scratch.arena, ctx->macro_map, str8_lit("project_settings"), expr);
}
//- rjf: add macros for evallable control entities
String8 evallable_ctrl_names[] =
{
@@ -12479,8 +12511,7 @@ rd_frame(void)
{str8_lit("disasm"), 0, 0, 0, 0, 0, {0}, RD_VIEW_UI_FUNCTION_NAME(disasm), EV_EXPAND_RULE_INFO_FUNCTION_NAME(disasm)},
{str8_lit("memory"), 0, 0, 0, 0, 0, {0}, RD_VIEW_UI_FUNCTION_NAME(memory), EV_EXPAND_RULE_INFO_FUNCTION_NAME(memory)},
{str8_lit("bitmap"), 0, 0, 0, 0, 0, {0}, RD_VIEW_UI_FUNCTION_NAME(bitmap), EV_EXPAND_RULE_INFO_FUNCTION_NAME(bitmap)},
{str8_lit("checkbox"), 0, 0, 0, 0, 0, {0}, RD_VIEW_UI_FUNCTION_NAME(checkbox), 0},
{str8_lit("color_rgba"), 0, 0, 0, 0, 0, {0}, RD_VIEW_UI_FUNCTION_NAME(color_rgba), EV_EXPAND_RULE_INFO_FUNCTION_NAME(color_rgba)},
{str8_lit("color"), 0, 0, 0, 0, 0, {0}, RD_VIEW_UI_FUNCTION_NAME(color), EV_EXPAND_RULE_INFO_FUNCTION_NAME(color)},
{str8_lit("geo3d"), 0, 0, 0, 0, 0, {0}, RD_VIEW_UI_FUNCTION_NAME(geo3d), EV_EXPAND_RULE_INFO_FUNCTION_NAME(geo3d)},
};
@@ -12639,7 +12670,19 @@ rd_frame(void)
//- rjf: open lister
case RD_CmdKind_OpenLister:
{
String8 expr = push_str8f(scratch.arena, "query:commands, query:$%I64x, query:$%I64x, query:recent_files, query:recent_projects, query:procedures, query:processes, query:threads, query:modules", rd_regs()->view, rd_regs()->window);
String8 expr = push_str8f(scratch.arena,
"query:commands, "
"query:$%I64x, "
"query:$%I64x, "
"query:recent_files, "
"query:recent_projects, "
"query:procedures, "
"query:processes, "
"query:threads, "
"query:modules, "
"query:user_settings, "
"query:project_settings, ",
rd_regs()->view, rd_regs()->window);
rd_cmd(RD_CmdKind_PushQuery, .expr = expr, .do_implicit_root = 1, .do_lister = 1, .do_big_rows = 1);
}break;
+164 -60
View File
@@ -3307,7 +3307,7 @@ RD_VIEW_UI_FUNCTION_DEF(bitmap)
//- rjf: image-region canvas interaction
//
Vec2S32 mouse_bmp = {-1, -1};
if(ui_hovering(canvas_sig) && !ui_dragging(canvas_sig))
if(ui_hovering(canvas_sig) && !ui_dragging(canvas_sig)) RD_Font(RD_FontSlot_Code)
{
Vec2F32 mouse_scr = sub_2f32(ui_mouse(), rect.p0);
Vec2F32 mouse_cvs = rd_bitmap_canvas_from_screen_pos(view_center_pos, zoom, canvas_rect, mouse_scr);
@@ -3380,43 +3380,118 @@ RD_VIEW_UI_FUNCTION_DEF(bitmap)
}
////////////////////////////////
//~ rjf: "checkbox"
//~ rjf: rgba @view_hook_impl
RD_VIEW_UI_FUNCTION_DEF(checkbox)
typedef struct RD_EvalColor RD_EvalColor;
struct RD_EvalColor
{
E_Eval value_eval = e_value_eval_from_eval(eval);
if(ui_clicked(rd_icon_buttonf(value_eval.value.u64 == 0 ? RD_IconKind_CheckHollow : RD_IconKind_CheckFilled, 0, "###check")))
{
rd_commit_eval_value_string(eval, value_eval.value.u64 == 0 ? str8_lit("1") : str8_lit("0"));
}
}
Vec4F32 rgba;
E_Eval rgba_evals[4];
};
////////////////////////////////
//~ rjf: color_rgba @view_hook_impl
internal Vec4F32
rd_rgba_from_eval_params(E_Eval eval, MD_Node *params)
internal RD_EvalColor
rd_eval_color_from_eval(E_Eval eval)
{
Vec4F32 rgba = {0};
Temp scratch = scratch_begin(0, 0);
//- rjf: walk eval's type tree, find all four component evaluations
E_Eval component_evals[4] = {0};
{
E_Eval value_eval = e_value_eval_from_eval(eval);
E_TypeKey type_key = eval.irtree.type_key;
E_TypeKind type_kind = e_type_kind_from_key(type_key);
U64 type_size = e_type_byte_size_from_key(type_key);
if(16 <= type_size)
typedef struct LeafTask LeafTask;
struct LeafTask
{
e_space_read(eval.space, &rgba, r1u64(eval.value.u64, eval.value.u64 + 16));
}
else if(4 <= type_size)
LeafTask *next;
E_Eval eval;
};
U64 num_components_left = 4;
LeafTask start_task = {0, eval};
LeafTask *first_task = &start_task;
LeafTask *last_task = first_task;
for(LeafTask *t = first_task; t != 0 && num_components_left > 0; t = t->next)
{
U32 hex_val = value_eval.value.u32;
rgba = rgba_from_u32(hex_val);
E_Type *type = e_type_from_key__cached(e_type_key_unwrap(t->eval.irtree.type_key, E_TypeUnwrapFlag_AllDecorative));
switch(type->kind)
{
default:{}break;
// rjf: leaf u32 -> take all 4 components
case E_TypeKind_U32:
{
component_evals[0] = e_value_eval_from_eval(e_eval_wrapf(scratch.arena, t->eval, "(float32)(($ & 0xff000000) >> 24) / 255.f"));
component_evals[1] = e_value_eval_from_eval(e_eval_wrapf(scratch.arena, t->eval, "(float32)(($ & 0x00ff0000) >> 16) / 255.f"));
component_evals[2] = e_value_eval_from_eval(e_eval_wrapf(scratch.arena, t->eval, "(float32)(($ & 0x0000ff00) >> 8) / 255.f"));
component_evals[3] = e_value_eval_from_eval(e_eval_wrapf(scratch.arena, t->eval, "(float32)(($ & 0x000000ff) >> 0) / 255.f"));
num_components_left -= 4;
}break;
//- rjf: array -> generate tasks for first four elements
case E_TypeKind_Array:
{
component_evals[0] = e_value_eval_from_eval(e_eval_wrapf(scratch.arena, t->eval, "(float32)($[0])"));
component_evals[1] = e_value_eval_from_eval(e_eval_wrapf(scratch.arena, t->eval, "(float32)($[1])"));
component_evals[2] = e_value_eval_from_eval(e_eval_wrapf(scratch.arena, t->eval, "(float32)($[2])"));
component_evals[3] = e_value_eval_from_eval(e_eval_wrapf(scratch.arena, t->eval, "(float32)($[3])"));
num_components_left -= 4;
}break;
}
}
}
return rgba;
//- rjf: swizzle / extract the component values from the evals, depending on this lens
// (the lens implicitly tells us the format)
RD_EvalColor result = {0};
{
E_Type *lens_type = e_type_from_key__cached(eval.irtree.type_key);
for(E_Type *t = lens_type; t->kind == E_TypeKind_Lens; t = e_type_from_key__cached(t->direct_type_key))
{
if(str8_match(t->name, str8_lit("color"), 0))
{
lens_type = t;
break;
}
}
if(lens_type->kind == E_TypeKind_Lens)
{
if(lens_type->count < 1 || str8_match(lens_type->args[0]->string, str8_lit("rgba"), 0))
{
result.rgba_evals[0] = component_evals[0];
result.rgba_evals[1] = component_evals[1];
result.rgba_evals[2] = component_evals[2];
result.rgba_evals[3] = component_evals[3];
}
else if(str8_match(lens_type->args[0]->string, str8_lit("argb"), 0))
{
result.rgba_evals[0] = component_evals[1];
result.rgba_evals[1] = component_evals[2];
result.rgba_evals[2] = component_evals[3];
result.rgba_evals[3] = component_evals[0];
}
else if(str8_match(lens_type->args[0]->string, str8_lit("bgra"), 0))
{
result.rgba_evals[0] = component_evals[2];
result.rgba_evals[1] = component_evals[1];
result.rgba_evals[2] = component_evals[0];
result.rgba_evals[3] = component_evals[3];
}
else if(str8_match(lens_type->args[0]->string, str8_lit("abgr"), 0))
{
result.rgba_evals[0] = component_evals[3];
result.rgba_evals[1] = component_evals[2];
result.rgba_evals[2] = component_evals[1];
result.rgba_evals[3] = component_evals[0];
}
for EachIndex(idx, 4)
{
result.rgba.v[idx] = e_value_eval_from_eval(result.rgba_evals[idx]).value.f32;
}
}
}
scratch_end(scratch);
return result;
}
EV_EXPAND_RULE_INFO_FUNCTION_DEF(color_rgba)
EV_EXPAND_RULE_INFO_FUNCTION_DEF(color)
{
EV_ExpandInfo info = {0};
info.row_count = 8;
@@ -3424,16 +3499,26 @@ EV_EXPAND_RULE_INFO_FUNCTION_DEF(color_rgba)
return info;
}
RD_VIEW_UI_FUNCTION_DEF(color_rgba)
RD_VIEW_UI_FUNCTION_DEF(color)
{
Temp scratch = scratch_begin(0, 0);
Vec2F32 dim = dim_2f32(rect);
F32 padding = ui_top_font_size()*3.f;
Vec4F32 rgba = {0}; // TODO(rjf): @cfg rd_rgba_from_eval_params(eval, params);
F32 sv_dim_px = Min(dim.x, dim.y);
if(sv_dim_px == dim.x)
{
padding = ui_top_font_size()*30.f;
}
sv_dim_px -= padding*2.f;
sv_dim_px = Min(sv_dim_px, ui_top_font_size()*70.f);
RD_EvalColor eval_color = rd_eval_color_from_eval(eval);
Vec4F32 rgba = eval_color.rgba;
Vec4F32 hsva = hsva_from_rgba(rgba);
//////////////////////////////
//- rjf: too small -> just show components
if(dim.y <= ui_top_font_size()*8.f)
//
if(dim.y <= ui_top_font_size()*12.f)
{
//- rjf: build text box
UI_Box *text_box = &ui_nil_box;
@@ -3444,11 +3529,11 @@ RD_VIEW_UI_FUNCTION_DEF(color_rgba)
{
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, &params, str8_lit("("));
dr_fstrs_push_new(scratch.arena, &fstrs, &params, 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, &params, push_str8f(scratch.arena, "%.2f", rgba.x), .color = linear_from_srgba(v4f32(1.f, 0.25f, 0.25f, 1.f)), .underline_thickness = 4.f);
dr_fstrs_push_new(scratch.arena, &fstrs, &params, str8_lit(", "));
dr_fstrs_push_new(scratch.arena, &fstrs, &params, push_str8f(scratch.arena, "%.2f", rgba.y), .color = v4f32(0.25f, 1.f, 0.25f, 1.f), .underline_thickness = 4.f);
dr_fstrs_push_new(scratch.arena, &fstrs, &params, push_str8f(scratch.arena, "%.2f", rgba.y), .color = linear_from_srgba(v4f32(0.25f, 1.f, 0.25f, 1.f)), .underline_thickness = 4.f);
dr_fstrs_push_new(scratch.arena, &fstrs, &params, str8_lit(", "));
dr_fstrs_push_new(scratch.arena, &fstrs, &params, push_str8f(scratch.arena, "%.2f", rgba.z), .color = v4f32(0.25f, 0.25f, 1.f, 1.f), .underline_thickness = 4.f);
dr_fstrs_push_new(scratch.arena, &fstrs, &params, push_str8f(scratch.arena, "%.2f", rgba.z), .color = linear_from_srgba(v4f32(0.25f, 0.25f, 1.f, 1.f)), .underline_thickness = 4.f);
dr_fstrs_push_new(scratch.arena, &fstrs, &params, str8_lit(", "));
dr_fstrs_push_new(scratch.arena, &fstrs, &params, push_str8f(scratch.arena, "%.2f", rgba.w), .color = v4f32(1.f, 1.f, 1.f, 1.f), .underline_thickness = 4.f);
dr_fstrs_push_new(scratch.arena, &fstrs, &params, str8_lit(")"));
@@ -3479,45 +3564,64 @@ RD_VIEW_UI_FUNCTION_DEF(color_rgba)
}
}
//////////////////////////////
//- rjf: large enough -> full color picker
//
else
{
UI_WidthFill UI_HeightFill UI_Column UI_Padding(ui_px(padding, 1.f)) UI_Row UI_Padding(ui_pct(1.f, 0.f)) UI_HeightFill
UI_WidthFill UI_HeightFill
UI_PrefHeight(ui_children_sum(1)) UI_Column UI_Padding(ui_pct(1.f, 0.f))
UI_PrefHeight(ui_children_sum(1)) UI_Row UI_Padding(ui_pct(1.f, 0.f))
UI_PrefWidth(ui_px(sv_dim_px, 1.f))
UI_PrefHeight(ui_px(sv_dim_px, 1.f))
RD_Font(RD_FontSlot_Code)
{
UI_PrefWidth(ui_px(dim.y - padding*2, 1.f))
{
UI_Signal sv_sig = ui_sat_val_pickerf(hsva.x, &hsva.y, &hsva.z, "sat_val_picker");
}
UI_Signal sv_sig = ui_sat_val_pickerf(hsva.x, &hsva.y, &hsva.z, "sat_val_picker");
ui_spacer(ui_em(1.f, 1.f));
UI_PrefWidth(ui_em(3.f, 1.f))
{
UI_Signal h_sig = ui_hue_pickerf(&hsva.x, hsva.y, hsva.z, "hue_picker");
}
UI_PrefWidth(ui_children_sum(1)) UI_Column UI_PrefWidth(ui_text_dim(10, 1)) UI_PrefHeight(ui_em(2.f, 0.f)) RD_Font(RD_FontSlot_Code)
UI_TagF("weak")
ui_spacer(ui_em(1.f, 1.f));
UI_PrefWidth(ui_children_sum(1)) UI_Column
{
ui_labelf("Hex");
ui_labelf("R");
ui_labelf("G");
ui_labelf("B");
ui_labelf("H");
ui_labelf("S");
ui_labelf("V");
ui_labelf("A");
}
UI_PrefWidth(ui_children_sum(1)) UI_Column UI_PrefWidth(ui_text_dim(10, 1)) UI_PrefHeight(ui_em(2.f, 0.f)) RD_Font(RD_FontSlot_Code)
{
String8 hex_string = hex_string_from_rgba_4f32(scratch.arena, rgba);
ui_label(hex_string);
ui_labelf("%.2f", rgba.x);
ui_labelf("%.2f", rgba.y);
ui_labelf("%.2f", rgba.z);
ui_labelf("%.2f", hsva.x);
ui_labelf("%.2f", hsva.y);
ui_labelf("%.2f", hsva.z);
ui_labelf("%.2f", rgba.w);
UI_PrefWidth(ui_em(6.f, 0.f)) UI_PrefHeight(ui_em(6.f, 0.f))
UI_BackgroundColor(linear_from_srgba(v4f32(rgba.x, rgba.y, rgba.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(""));
ui_spacer(ui_em(2.f, 1.f));
UI_PrefWidth(ui_children_sum(1)) UI_PrefHeight(ui_children_sum(1)) UI_Row
{
UI_PrefWidth(ui_children_sum(1)) UI_Column UI_PrefWidth(ui_text_dim(10, 1)) UI_PrefHeight(ui_em(2.f, 0.f)) RD_Font(RD_FontSlot_Code)
UI_TagF("weak")
{
ui_labelf("Hex");
ui_labelf("R");
ui_labelf("G");
ui_labelf("B");
ui_labelf("H");
ui_labelf("S");
ui_labelf("V");
ui_labelf("A");
}
UI_PrefWidth(ui_children_sum(1)) UI_Column UI_PrefWidth(ui_text_dim(10, 1)) UI_PrefHeight(ui_em(2.f, 0.f)) RD_Font(RD_FontSlot_Code)
{
String8 hex_string = hex_string_from_rgba_4f32(scratch.arena, rgba);
ui_label(hex_string);
ui_labelf("%.2f", rgba.x);
ui_labelf("%.2f", rgba.y);
ui_labelf("%.2f", rgba.z);
ui_labelf("%.2f", hsva.x);
ui_labelf("%.2f", hsva.y);
ui_labelf("%.2f", hsva.z);
ui_labelf("%.2f", rgba.w);
}
}
}
}
}
scratch_end(scratch);
}
+2 -3
View File
@@ -245,15 +245,14 @@ EV_EXPAND_RULE_INFO_FUNCTION_DEF(text);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(disasm);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(memory);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(bitmap);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(color_rgba);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(color);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(geo3d);
RD_VIEW_UI_FUNCTION_DEF(text);
RD_VIEW_UI_FUNCTION_DEF(disasm);
RD_VIEW_UI_FUNCTION_DEF(memory);
RD_VIEW_UI_FUNCTION_DEF(bitmap);
RD_VIEW_UI_FUNCTION_DEF(checkbox);
RD_VIEW_UI_FUNCTION_DEF(color_rgba);
RD_VIEW_UI_FUNCTION_DEF(color);
RD_VIEW_UI_FUNCTION_DEF(geo3d);
#endif // RADDBG_VIEWS_H
+17
View File
@@ -129,6 +129,23 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg)
}
}
//- rjf: push bucket name
if(cfg->parent == rd_state->root_cfg)
{
if(str8_match(cfg->string, str8_lit("user"), 0))
{
dr_fstrs_push_new(arena, &result, &params, str8_lit("User"), .font = rd_font_from_slot(RD_FontSlot_Main), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Main));
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
start_secondary();
}
else if(str8_match(cfg->string, str8_lit("project"), 0))
{
dr_fstrs_push_new(arena, &result, &params, str8_lit("Project"), .font = rd_font_from_slot(RD_FontSlot_Main), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Main));
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
start_secondary();
}
}
//- rjf: push label
if(label_string.size != 0)
{