color visualizer / theme editing work

This commit is contained in:
Ryan Fleury
2025-04-29 12:15:41 -07:00
parent ddbb2148a4
commit 09372bd7c1
11 changed files with 301 additions and 260 deletions
+1
View File
@@ -961,6 +961,7 @@ e_eval_from_bundle(E_CacheBundle *bundle)
E_Eval eval =
{
.key = bundle->key,
.parent_key= bundle->parent_key,
.string = bundle->string,
.expr = e_parse_from_bundle(bundle).expr,
.irtree = e_irtree_from_bundle(bundle),
+2 -1
View File
@@ -340,6 +340,7 @@ typedef struct E_Eval E_Eval;
struct E_Eval
{
E_Key key;
E_Key parent_key;
String8 string;
E_Expr *expr;
E_IRTreeAndType irtree;
@@ -993,7 +994,7 @@ read_only global E_String2NumMap e_string2num_map_nil = {0};
read_only global E_String2ExprMap e_string2expr_map_nil = {0};
read_only global E_Expr e_expr_nil = {&e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil};
read_only global E_IRNode e_irnode_nil = {&e_irnode_nil, &e_irnode_nil, &e_irnode_nil};
read_only global E_Eval e_eval_nil = {{0}, {0}, &e_expr_nil, {&e_irnode_nil}};
read_only global E_Eval e_eval_nil = {{0}, {0}, {0}, &e_expr_nil, {&e_irnode_nil}};
read_only global E_Module e_module_nil = {&rdi_parsed_nil};
read_only global E_CacheBundle e_cache_bundle_nil = {0, {0}, {0}, {0}, {{0}, 0, &e_expr_nil, &e_expr_nil}, {&e_irnode_nil}};
thread_static E_BaseCtx *e_base_ctx = 0;
@@ -294,7 +294,7 @@ global read_only EV_Block ev_nil_block =
{0},
0,
{0},
{{0}, {0}, &e_expr_nil, &e_irnode_nil},
{{0}, {0}, {0}, &e_expr_nil, &e_irnode_nil},
{0},
&e_type_expand_rule__default,
{0},
File diff suppressed because one or more lines are too long
+6 -4
View File
@@ -230,8 +230,10 @@ RD_CmdKind_DisableBreakpoint,
RD_CmdKind_AddWatchPin,
RD_CmdKind_ToggleWatchPin,
RD_CmdKind_AddAutoViewRule,
RD_CmdKind_AddColor,
RD_CmdKind_ImportColors,
RD_CmdKind_OpenTheme,
RD_CmdKind_AddThemeColor,
RD_CmdKind_ForkLoadedThemeColors,
RD_CmdKind_SaveThemeColors,
RD_CmdKind_SetNextStatement,
RD_CmdKind_AddTarget,
RD_CmdKind_SelectTarget,
@@ -673,8 +675,8 @@ Z(getting_started)\
C_LINKAGE_BEGIN
extern String8 rd_tab_fast_path_view_name_table[20];
extern String8 rd_tab_fast_path_query_name_table[20];
extern RD_VocabInfo rd_vocab_info_table[319];
extern RD_NameSchemaInfo rd_name_schema_info_table[22];
extern RD_VocabInfo rd_vocab_info_table[322];
extern RD_NameSchemaInfo rd_name_schema_info_table[23];
extern Rng1U64 rd_reg_slot_range_table[43];
extern String8 rd_binding_version_remap_old_name_table[8];
extern String8 rd_binding_version_remap_new_name_table[8];
+103 -90
View File
@@ -91,6 +91,7 @@ RD_VocabTable:
{address_location _ "Address Location" _ Null }
{target _ "Target" _ Target }
{color _ "Color" _ Palette }
{theme_color _ "Theme Color" _ Palette }
{executable _ "Executable" _ Module }
{arguments arguments "Arguments" "Arguments" Null }
{exe exes "Executable" _ Module }
@@ -230,13 +231,13 @@ RD_VocabTable:
@display_name('Code Font') @description("The name of, or path to, the font used when displaying code.")
'code_font': string,
//- rjf: colors
@display_name('Color Preset')
'color_preset': string,
@display_name('Color File')
'color_file': path,
@display_name('Colors')
'colors': query,
//- rjf: theme
@display_name('Theme Preset') @description("The selected built-in theme preset.")
'theme_preset': string,
@no_expand @display_name('Theme File') @description("The path from which theme data is loaded, overriding the preset.")
'theme_file': path,
@display_name('Theme Colors') @description("Additional theme colors which are applied on top of the theme file or preset.")
'theme_colors': query,
//- rjf: thread & breakpoint decorations
@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.")
@@ -357,11 +358,11 @@ RD_VocabTable:
```
}
//- rjf: colors
//- rjf: theme colors
{
color,
theme_color,
```
@collection_commands(add_color, import_colors) x:
@collection_commands(add_theme_color, fork_loaded_theme_colors, save_theme_colors) x:
{
@display_name('Tags') tags: string,
@display_name('Value') value: @color @hex u32,
@@ -492,6 +493,16 @@ RD_VocabTable:
}
```
}
{
color,
```
@inherit(tab) x:
{
@display_name("Value") @description("An expression to describe the value or location of the color.")
'expression': code_string,
}
```
}
{
geo3d,
```
@@ -920,9 +931,11 @@ RD_CmdTable: // | | | |
//- rjf: auto view rule
{AddAutoViewRule 1 1 0 0 "" String null Nil Null 0 0 0 0 0 0 0 Binoculars "add_auto_view_rule" "Add Auto View Rule" "Adds a new auto view rule." "" "$auto_view_rules," }
//- rjf: colors
{AddColor 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Palette "add_color" "Add Color" "Adds a new color." "" "" }
{ImportColors 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Palette "import_colors" "Import Colors" "Imports all colors from a loaded color theme file or color theme preset." "" "" }
//- rjf: themes
{OpenTheme 1 1 0 0 `folder:\\"$input\\"` FilePath null Nil Null 1 0 0 0 0 1 1 Palette "open_theme" "Open Theme" "Opens a theme file." "color" "" }
{AddThemeColor 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Palette "add_theme_color" "Add Theme Color" "Adds a new theme color." "" "" }
{ForkLoadedThemeColors 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Palette "fork_loaded_theme_colors" "Fork Loaded Theme Colors" "Imports all colors from a loaded color theme file or color theme preset, so they can be individually edited." "" "" }
{SaveThemeColors 0 0 0 0 `folder:\\"$input\\"` FilePath null Nil Null 1 0 0 0 0 1 1 Save "save_theme_colors" "Save Theme Colors" "Saves all theme colors to a new theme file." "" "" }
//- rjf: line operations
{SetNextStatement 1 1 1 0 "" Null null Nil Null 0 0 0 0 0 0 0 RightArrow "set_next_statement" "Set Next Statement" "Sets the selected thread's instruction pointer to the cursor's position." "" "$text_pt," }
@@ -1302,83 +1315,83 @@ RD_ThemePresetTable:
DefaultDark default_dark "Default (Dark)",
```theme:
{
color: {tags:"background", value: 0x1b1b1bff }
color: {tags:"alt background", value: 0x222222ff }
color: {tags:"pop background", value: 0x355b6eff }
color: {tags:"fresh background", value: 0x31393dff }
color: {tags:"match background", value: 0x31393dff }
color: {tags:"border", value: 0x404040ff }
color: {tags:"text", value: 0xe5e5e5ff }
color: {tags:"weak text", value: 0xa4a4a4ff }
color: {tags:"good text", value: 0x32a852ff }
color: {tags:"bad text", value: 0xcf5242ff }
color: {tags:"hover", value: 0xffffffff }
color: {tags:"focus", value: 0xfda200ff }
color: {tags:"cursor", value: 0x8aff00ff }
color: {tags:"selection", value: 0x99ccffff }
color: {tags:"inactive background", value: 0x0000002f }
color: {tags:"drop_shadow", value: 0x0000007f }
color: {tags:"good_pop background", value: 0x2c5b36ff }
color: {tags:"good_pop border", value: 0x568761ff }
color: {tags:"good_pop hover", value: 0xe3f5d3ff }
color: {tags:"good_pop weak text", value: 0xe3f5d3ff }
color: {tags:"bad_pop background", value: 0x803425ff }
color: {tags:"bad_pop hover", value: 0xff825cff }
color: {tags:"code_default", value: 0xcbcbcbff }
color: {tags:"code_symbol", value: 0x42a2cfff }
color: {tags:"code_type", value: 0xfec746ff }
color: {tags:"code_local", value: 0x98bc80ff }
color: {tags:"code_register", value: 0xb7afd5ff }
color: {tags:"code_keyword", value: 0xb38d4cff }
color: {tags:"code_delimiter_or_operator", value: 0x767676ff }
color: {tags:"code_numeric", value: 0x98abb1ff }
color: {tags:"code_numeric_alt_digit_group", value: 0x738287ff }
color: {tags:"code_string", value: 0x98abb1ff }
color: {tags:"code_meta", value: 0xd96759ff }
color: {tags:"code_comment", value: 0x717171ff }
color: {tags:"line_info_0", value: 0x4f3022ff }
color: {tags:"line_info_1", value: 0x4f3e15ff }
color: {tags:"line_info_2", value: 0x434e2aff }
color: {tags:"line_info_3", value: 0x36241fff }
color: {tags:"line_info_4", value: 0x4f3022ff }
color: {tags:"line_info_5", value: 0x4f3e15ff }
color: {tags:"line_info_6", value: 0x434e2aff }
color: {tags:"line_info_7", value: 0x36241fff }
color: {tags:"thread_0", value: 0xffcb7fff }
color: {tags:"thread_1", value: 0xb2ff65ff }
color: {tags:"thread_2", value: 0xff99e5ff }
color: {tags:"thread_3", value: 0x6598ffff }
color: {tags:"thread_4", value: 0x65ffcbff }
color: {tags:"thread_5", value: 0xff9819ff }
color: {tags:"thread_6", value: 0x9932ffff }
color: {tags:"thread_7", value: 0x65ff4cff }
color: {tags:"thread_unwound", value: 0xb2ccd8ff }
color: {tags:"thread_error", value: 0xb23219ff }
color: {tags:"breakpoint", value: 0xa72911ff }
color: {tags:"floating background", value: 0x1b1b1baf }
color: {tags:"floating background alt", value: 0x0000005f }
color: {tags:"floating background fresh", value: 0x31393d5f }
color: {tags:"floating border", value: 0xbfbfbf1f }
color: {tags:"floating scroll_bar background", value: 0x3b3b3b5f }
color: {tags:"floating scroll_bar border", value: 0x5f5f5f5f }
color: {tags:"menu_bar background", value: 0x2b3740ff }
color: {tags:"menu_bar border", value: 0x3e4c57ff }
color: {tags:"scroll_bar background", value: 0x2b2b2bff }
color: {tags:"scroll_bar border", value: 0x3f3f3fff }
color: {tags:"implicit background", value: 0x00000000 }
color: {tags:"implicit border", value: 0x00000000 }
color: {tags:"hollow background", value: 0x00000000 }
color: {tags:"hollow border", value: 0xffffff1f }
color: {tags:"tab background", value: 0x6f5135ff }
color: {tags:"tab border", value: 0x8a6e54ff }
color: {tags:"tab inactive background", value: 0x2b3740ff }
color: {tags:"tab inactive border", value: 0x3e4c57ff }
color: {tags:"tab auto background", value: 0x693847ff }
color: {tags:"tab auto border", value: 0x9e6274ff }
color: {tags:"tab auto inactive background", value: 0x2f2633ff }
color: {tags:"tab auto inactive border", value: 0x685073ff }
color: {tags:"drop_site background", value: 0xffffff05 }
color: {tags:"drop_site border", value: 0xffffff0f }
theme_color: {tags:"background", value: 0x1b1b1bff }
theme_color: {tags:"alt background", value: 0x222222ff }
theme_color: {tags:"pop background", value: 0x355b6eff }
theme_color: {tags:"fresh background", value: 0x31393dff }
theme_color: {tags:"match background", value: 0x31393dff }
theme_color: {tags:"border", value: 0x404040ff }
theme_color: {tags:"text", value: 0xe5e5e5ff }
theme_color: {tags:"weak text", value: 0xa4a4a4ff }
theme_color: {tags:"good text", value: 0x32a852ff }
theme_color: {tags:"bad text", value: 0xcf5242ff }
theme_color: {tags:"hover", value: 0xffffffff }
theme_color: {tags:"focus", value: 0xfda200ff }
theme_color: {tags:"cursor", value: 0x8aff00ff }
theme_color: {tags:"selection", value: 0x99ccffff }
theme_color: {tags:"inactive background", value: 0x0000002f }
theme_color: {tags:"drop_shadow", value: 0x0000007f }
theme_color: {tags:"good_pop background", value: 0x2c5b36ff }
theme_color: {tags:"good_pop border", value: 0x568761ff }
theme_color: {tags:"good_pop hover", value: 0xe3f5d3ff }
theme_color: {tags:"good_pop weak text", value: 0xe3f5d3ff }
theme_color: {tags:"bad_pop background", value: 0x803425ff }
theme_color: {tags:"bad_pop hover", value: 0xff825cff }
theme_color: {tags:"code_default", value: 0xcbcbcbff }
theme_color: {tags:"code_symbol", value: 0x42a2cfff }
theme_color: {tags:"code_type", value: 0xfec746ff }
theme_color: {tags:"code_local", value: 0x98bc80ff }
theme_color: {tags:"code_register", value: 0xb7afd5ff }
theme_color: {tags:"code_keyword", value: 0xb38d4cff }
theme_color: {tags:"code_delimiter_or_operator", value: 0x767676ff }
theme_color: {tags:"code_numeric", value: 0x98abb1ff }
theme_color: {tags:"code_numeric_alt_digit_group", value: 0x738287ff }
theme_color: {tags:"code_string", value: 0x98abb1ff }
theme_color: {tags:"code_meta", value: 0xd96759ff }
theme_color: {tags:"code_comment", value: 0x717171ff }
theme_color: {tags:"line_info_0", value: 0x4f3022ff }
theme_color: {tags:"line_info_1", value: 0x4f3e15ff }
theme_color: {tags:"line_info_2", value: 0x434e2aff }
theme_color: {tags:"line_info_3", value: 0x36241fff }
theme_color: {tags:"line_info_4", value: 0x4f3022ff }
theme_color: {tags:"line_info_5", value: 0x4f3e15ff }
theme_color: {tags:"line_info_6", value: 0x434e2aff }
theme_color: {tags:"line_info_7", value: 0x36241fff }
theme_color: {tags:"thread_0", value: 0xffcb7fff }
theme_color: {tags:"thread_1", value: 0xb2ff65ff }
theme_color: {tags:"thread_2", value: 0xff99e5ff }
theme_color: {tags:"thread_3", value: 0x6598ffff }
theme_color: {tags:"thread_4", value: 0x65ffcbff }
theme_color: {tags:"thread_5", value: 0xff9819ff }
theme_color: {tags:"thread_6", value: 0x9932ffff }
theme_color: {tags:"thread_7", value: 0x65ff4cff }
theme_color: {tags:"thread_unwound", value: 0xb2ccd8ff }
theme_color: {tags:"thread_error", value: 0xb23219ff }
theme_color: {tags:"breakpoint", value: 0xa72911ff }
theme_color: {tags:"floating background", value: 0x1b1b1baf }
theme_color: {tags:"floating background alt", value: 0x0000005f }
theme_color: {tags:"floating background fresh", value: 0x31393d5f }
theme_color: {tags:"floating border", value: 0xbfbfbf1f }
theme_color: {tags:"floating scroll_bar background", value: 0x3b3b3b5f }
theme_color: {tags:"floating scroll_bar border", value: 0x5f5f5f5f }
theme_color: {tags:"menu_bar background", value: 0x2b3740ff }
theme_color: {tags:"menu_bar border", value: 0x3e4c57ff }
theme_color: {tags:"scroll_bar background", value: 0x2b2b2bff }
theme_color: {tags:"scroll_bar border", value: 0x3f3f3fff }
theme_color: {tags:"implicit background", value: 0x00000000 }
theme_color: {tags:"implicit border", value: 0x00000000 }
theme_color: {tags:"hollow background", value: 0x00000000 }
theme_color: {tags:"hollow border", value: 0xffffff1f }
theme_color: {tags:"tab background", value: 0x6f5135ff }
theme_color: {tags:"tab border", value: 0x8a6e54ff }
theme_color: {tags:"tab inactive background", value: 0x2b3740ff }
theme_color: {tags:"tab inactive border", value: 0x3e4c57ff }
theme_color: {tags:"tab auto background", value: 0x693847ff }
theme_color: {tags:"tab auto border", value: 0x9e6274ff }
theme_color: {tags:"tab auto inactive background", value: 0x2f2633ff }
theme_color: {tags:"tab auto inactive border", value: 0x685073ff }
theme_color: {tags:"drop_site background", value: 0xffffff05 }
theme_color: {tags:"drop_site border", value: 0xffffff0f }
}
```
}
+47 -33
View File
@@ -2326,24 +2326,27 @@ rd_view_from_eval(RD_Cfg *parent, E_Eval eval)
RD_Cfg *view = rd_cfg_child_from_string_or_alloc(parent, schema_name);
rd_cfg_child_from_string_or_alloc(view, str8_lit("selected"));
{
MD_NodePtrList schemas = rd_schemas_from_name(schema_name);
E_Expr *primary_expr = eval.expr;
E_Expr **args = 0;
U64 args_count = 0;
// rjf: get expression evaluation
E_Eval expr_eval = eval;
if(eval.expr->kind == E_ExprKind_Call)
{
primary_expr = eval.expr->first->next;
expr_eval = e_eval_from_expr(eval.expr->first->next);
}
// rjf: get arguments to view
E_Expr **args = 0;
U64 args_count = 0;
if(type->args != 0)
{
args = type->args;
args_count = type->count;
}
E_Eval primary_eval = e_eval_from_expr(primary_expr);
// rjf: reflect expr & arguments in cfg tree
RD_Cfg *expr_root = rd_cfg_child_from_string_or_alloc(view, str8_lit("expression"));
rd_cfg_new_replace(expr_root, e_full_expr_string_from_key(scratch.arena, primary_eval.key));
rd_cfg_new_replace(expr_root, e_full_expr_string_from_key(scratch.arena, expr_eval.key));
{
MD_NodePtrList schemas = rd_schemas_from_name(schema_name);
U64 unnamed_order_idx = 0;
for EachIndex(arg_idx, args_count)
{
@@ -3284,13 +3287,17 @@ rd_view_ui(Rng2F32 rect)
}
else if(e_type_kind_from_key(e_type_key_unwrap(eval.irtree.type_key, E_TypeUnwrapFlag_AllDecorative)) == E_TypeKind_Set)
{
rd_cmd(RD_CmdKind_PushQuery, .expr = e_string_from_expr(scratch.arena, eval.expr, str8_zero()));
rd_cmd(RD_CmdKind_PushQuery, .expr = e_full_expr_string_from_key(scratch.arena, eval.key));
}
else
{
did_cmd = 0;
}
}break;
case RD_EvalSpaceKind_MetaQuery:
{
rd_cmd(RD_CmdKind_PushQuery, .expr = e_full_expr_string_from_key(scratch.arena, eval.key));
}break;
case RD_EvalSpaceKind_MetaUnattachedProcess:
{
U64 pid = eval.value.u128.u64[0];
@@ -4496,14 +4503,14 @@ rd_view_ui(Rng2F32 rect)
UI_Flags(0)
{
// rjf: 'pull out' button
UI_TagF(".") UI_TagF("tab") UI_Rect(r2f32p(ui_top_font_size()*1.5f,
ui_top_font_size()*1.5f,
ui_top_font_size()*1.5f + ui_top_font_size()*3.f,
ui_top_font_size()*1.5f + ui_top_font_size()*3.f))
UI_CornerRadius(ui_top_font_size()*1.5f)
UI_TagF(".") UI_TagF("tab") UI_Rect(r2f32p(floor_f32(ui_top_font_size()*1.5f),
floor_f32(ui_top_font_size()*1.5f),
floor_f32(ui_top_font_size()*1.5f + ui_top_font_size()*3.f),
floor_f32(ui_top_font_size()*1.5f + ui_top_font_size()*3.f)))
UI_CornerRadius(floor_f32(ui_top_font_size()*1.5f))
UI_TextAlignment(UI_TextAlign_Center)
RD_Font(RD_FontSlot_Icons)
UI_FontSize(ui_top_font_size()*0.8f)
UI_FontSize(floor_f32(ui_top_font_size()*0.9f))
{
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|
UI_BoxFlag_Floating|
@@ -4786,6 +4793,8 @@ rd_view_ui(Rng2F32 rect)
// rjf: has a command name? -> push command
else if(cell_info.cmd_name.size != 0)
{
String8 cmd_name = cell_info.cmd_name;
RD_CmdKindInfo *cmd_kind_info = rd_cmd_kind_info_from_string(cmd_name);
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(row->eval.space);
RD_Cfg *cfg = rd_cfg_from_eval_space(row->eval.space);
if(cfg == &rd_nil_cfg)
@@ -4794,13 +4803,13 @@ rd_view_ui(Rng2F32 rect)
}
RD_RegsScope(.cfg = cfg->id, .ctrl_entity = entity->handle)
{
if(cfg != &rd_nil_cfg || entity != &ctrl_entity_nil)
if(!(cmd_kind_info->query.flags & RD_QueryFlag_Required))
{
rd_push_cmd(cell_info.cmd_name, rd_regs());
}
else
{
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = cell_info.cmd_name);
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = cmd_name);
}
}
}
@@ -5548,7 +5557,7 @@ rd_window_frame(void)
}
for(RD_Cfg *child = parent_cfg->first; child != &rd_nil_cfg; child = child->next)
{
if(str8_match(child->string, str8_lit("color"), 0))
if(str8_match(child->string, str8_lit("theme_color"), 0))
{
rd_cfg_list_push_front(scratch.arena, &colors_cfgs, child);
}
@@ -5606,7 +5615,7 @@ rd_window_frame(void)
MD_Node *tree_root = t->tree;
for(MD_Node *n = tree_root; !md_node_is_nil(n); n = md_node_rec_depth_first_pre(n, tree_root).next)
{
if(str8_match(n->string, str8_lit("color"), 0))
if(str8_match(n->string, str8_lit("theme_color"), 0))
{
MD_Node *tags_child = md_child_from_string(n, str8_lit("tags"), 0);
MD_Node *value_child = md_child_from_string(n, str8_lit("value"), 0);
@@ -11638,8 +11647,8 @@ rd_frame(void)
RD_Theme *theme_srgba = push_array(scratch.arena, RD_Theme, 1);
//- rjf: gather globally-applying config options
RD_CfgList preset_roots = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("color_preset"));
RD_CfgList colors_roots = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("colors"));
RD_CfgList preset_roots = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("theme_preset"));
RD_CfgList colors_roots = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("theme_colors"));
//- rjf: assume default-dark
MemoryCopy(theme_srgba->colors, rd_theme_preset_colors_table[RD_ThemePreset_DefaultDark], sizeof(rd_theme_preset_colors__default_dark));
@@ -12349,10 +12358,9 @@ rd_frame(void)
{
.info = E_TYPE_EXPAND_INFO_FUNCTION_NAME(call_stack),
}));
e_string2typekey_map_insert(rd_frame_arena(), rd_state->meta_name2type_map, str8_lit("colors"),
e_string2typekey_map_insert(rd_frame_arena(), rd_state->meta_name2type_map, str8_lit("theme_colors"),
e_type_key_cons(.kind = E_TypeKind_Set,
.flags = E_TypeFlag_EditableChildren,
.name = str8_lit("colors"),
.name = str8_lit("theme_colors"),
.irext = E_TYPE_IREXT_FUNCTION_NAME(cfgs_slice),
.access = E_TYPE_ACCESS_FUNCTION_NAME(cfgs_slice),
.expand =
@@ -15227,33 +15235,39 @@ rd_frame(void)
rd_cfg_new(project, str8_lit("auto_view_rule"));
}break;
//- rjf: colors
case RD_CmdKind_AddColor:
//- rjf: themes
case RD_CmdKind_OpenTheme:
{
RD_Cfg *user = rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user"));
RD_Cfg *theme_file = rd_cfg_child_from_string_or_alloc(user, str8_lit("theme_file"));
rd_cfg_new_replace(theme_file, rd_regs()->file_path);
}break;
case RD_CmdKind_AddThemeColor:
{
RD_Cfg *parent = rd_cfg_from_id(rd_regs()->cfg);
RD_Cfg *color = rd_cfg_new(parent, str8_lit("color"));
RD_Cfg *color = rd_cfg_new(parent, str8_lit("theme_color"));
rd_cfg_new(color, str8_lit("tags"));
RD_Cfg *value = rd_cfg_new(color, str8_lit("value"));
rd_cfg_new(value, str8_lit("0xffffffff"));
}break;
case RD_CmdKind_ImportColors:
case RD_CmdKind_ForkLoadedThemeColors:
{
RD_Cfg *parent = rd_cfg_from_id(rd_regs()->cfg);
RD_CfgList colors = rd_cfg_child_list_from_string(scratch.arena, parent, str8_lit("color"));
RD_CfgList colors = rd_cfg_child_list_from_string(scratch.arena, parent, str8_lit("theme_color"));
for(RD_CfgNode *n = colors.first; n != 0; n = n->next)
{
rd_cfg_release(n->v);
}
String8 color_preset = rd_setting_from_name(str8_lit("color_preset"));
String8 color_file = rd_setting_from_name(str8_lit("color_file"));
String8 color_preset = rd_setting_from_name(str8_lit("theme_preset"));
String8 color_file = rd_setting_from_name(str8_lit("theme_file"));
RD_ThemePreset preset = RD_ThemePreset_DefaultDark;
// TODO(rjf): map preset via string
MD_Node *theme_tree = rd_state->theme_preset_trees[preset];
for(MD_Node *n = theme_tree; !md_node_is_nil(n); n = md_node_rec_depth_first_pre(n, theme_tree).next)
{
if(str8_match(n->string, str8_lit("color"), 0))
if(str8_match(n->string, str8_lit("theme_color"), 0))
{
RD_Cfg *color = rd_cfg_new(parent, str8_lit("color"));
RD_Cfg *color = rd_cfg_new(parent, str8_lit("theme_color"));
RD_Cfg *tags = rd_cfg_new(color, str8_lit("tags"));
RD_Cfg *value = rd_cfg_new(color, str8_lit("value"));
rd_cfg_new(tags, md_child_from_string(n, str8_lit("tags"), 0)->first->string);
+4 -4
View File
@@ -188,10 +188,6 @@
// [ ] config hot-reloading, using cfg wins
// [ ] undo/redo, using cfg wins
// [ ] back/forward, using cfg wins
// [ ] autocompletion lister, file lister, function lister, command lister,
// etc., all need to be merged, and optionally contextualized/filtered.
// right-clicking a tab should be equivalent to spawning a command lister,
// but only with commands that are directly
//
// [ ] crash bug, release mode - filter globals view (try with debugging raddbg, typing `dev` in globals view)
//
@@ -463,6 +459,10 @@
// since that's not normally how Windows fonts work.
// [x] I had to go into the user file to change the font. That should probably
// be in the theme window?
// [x] autocompletion lister, file lister, function lister, command lister,
// etc., all need to be merged, and optionally contextualized/filtered.
// right-clicking a tab should be equivalent to spawning a command lister,
// but only with commands that are directly
////////////////////////////////
//~ rjf: Build Options
+78 -96
View File
@@ -3485,8 +3485,11 @@ rd_eval_color_from_eval(E_Eval eval)
{
default:{}break;
// rjf: leaf u32 -> take all 4 components
// rjf: leaf >u32/s32 -> take all 4 components
case E_TypeKind_U32:
case E_TypeKind_S32:
case E_TypeKind_U64:
case E_TypeKind_S64:
{
component_evals[0] = e_value_eval_from_eval(e_eval_wrapf(t->eval, "(float32)(($ & 0xff000000) >> 24) / 255.f"));
component_evals[1] = e_value_eval_from_eval(e_eval_wrapf(t->eval, "(float32)(($ & 0x00ff0000) >> 16) / 255.f"));
@@ -3521,40 +3524,42 @@ rd_eval_color_from_eval(E_Eval eval)
break;
}
}
if(lens_type->kind == E_TypeKind_Lens)
String8 format_string = str8_lit("rgba");
if(lens_type->kind == E_TypeKind_Lens && lens_type->count > 0)
{
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;
}
format_string = lens_type->args[0]->string;
}
if(str8_match(format_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(format_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(format_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(format_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;
}
}
@@ -3573,72 +3578,43 @@ EV_EXPAND_RULE_INFO_FUNCTION_DEF(color)
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;
F32 sv_dim_px = Min(dim.x, dim.y);
if(sv_dim_px == dim.x)
//////////////////////////////
//- rjf: unpack state
//
typedef struct RD_ColorViewState RD_ColorViewState;
struct RD_ColorViewState
{
padding = ui_top_font_size()*30.f;
B32 initialized;
U32 start_rgba_u32;
Vec4F32 hsva;
};
RD_ColorViewState *state = rd_view_state(RD_ColorViewState);
RD_EvalColor eval_color = rd_eval_color_from_eval(eval);
U32 rgba_u32 = u32_from_rgba(eval_color.rgba);
if(!state->initialized || rgba_u32 != state->start_rgba_u32)
{
Vec4F32 rgba = eval_color.rgba;
Vec4F32 hsva = hsva_from_rgba(rgba);
state->initialized = 1;
state->start_rgba_u32 = rgba_u32;
state->hsva = hsva;
}
Vec4F32 hsva = state->hsva;
Vec4F32 rgba = rgba_from_hsva(hsva);
//////////////////////////////
//- rjf: calculate dimensions
//
Vec2F32 dim = dim_2f32(rect);
F32 sv_dim_px = Min(dim.x, dim.y);
F32 padding = sv_dim_px*0.2f;
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
//- rjf: build UI
//
if(dim.y <= ui_top_font_size()*12.f)
{
//- rjf: build text box
UI_Box *text_box = &ui_nil_box;
UI_WidthFill RD_Font(RD_FontSlot_Code)
{
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_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 = 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 = 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 = 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(")"));
}
ui_box_equip_display_fstrs(text_box, &fstrs);
}
//- rjf: build color box
UI_Box *color_box = &ui_nil_box;
UI_PrefWidth(ui_em(1.875f, 1.f)) UI_ChildLayoutAxis(Axis2_Y)
{
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_BackgroundColor(rgba) UI_CornerRadius(ui_top_font_size()*0.5f)
ui_build_box_from_key(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder, ui_key_zero());
}
}
//- rjf: space
ui_spacer(ui_em(0.375f, 1.f));
//- rjf: hover color box -> show components
UI_Signal sig = ui_signal_from_box(color_box);
if(ui_hovering(sig))
{
ui_do_color_tooltip_hsva(hsva);
}
}
//////////////////////////////
//- rjf: large enough -> full color picker
//
else
{
UI_WidthFill UI_HeightFill
UI_PrefHeight(ui_children_sum(1)) UI_Column UI_Padding(ui_pct(1.f, 0.f))
@@ -3701,17 +3677,23 @@ RD_VIEW_UI_FUNCTION_DEF(color)
{
// TODO(rjf): hard-coding U32 committing for now
E_Type *type = e_type_from_key__cached(e_type_key_unwrap(eval.irtree.type_key, E_TypeUnwrapFlag_AllDecorative));
if(type->kind == E_TypeKind_U32)
if(type->kind == E_TypeKind_U32 ||
type->kind == E_TypeKind_S32 ||
type->kind == E_TypeKind_U64 ||
type->kind == E_TypeKind_S64)
{
Vec4F32 new_rgba = rgba_from_hsva(hsva);
U32 u32 = u32_from_rgba(new_rgba);
String8 string = push_str8f(scratch.arena, "0x%x", u32);
rd_commit_eval_value_string(eval, string);
if(rd_commit_eval_value_string(eval, string))
{
state->start_rgba_u32 = u32;
state->hsva = hsva;
}
}
}
}
}
scratch_end(scratch);
}
+4 -2
View File
@@ -394,7 +394,7 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg)
}
//- rjf: special case: colors
if(str8_match(cfg->string, str8_lit("color"), 0))
if(str8_match(cfg->string, str8_lit("theme_color"), 0))
{
String8 tags = rd_cfg_child_from_string(cfg, str8_lit("tags"))->first->string;
String8 color_string = rd_cfg_child_from_string(cfg, str8_lit("value"))->first->string;
@@ -402,12 +402,14 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg)
Vec4F32 color = linear_from_srgba(rgba_from_u32(color_u32));
if(tags.size != 0)
{
dr_fstrs_push_new(arena, &result, &params, tags, .color = color);
dr_fstrs_push_new(arena, &result, &params, tags);
}
else
{
dr_fstrs_push_new(arena, &result, &params, str8_lit("Color"), .color = rgba_secondary);
}
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[RD_IconKind_CircleFilled], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = color);
}
#undef start_secondary
+39 -19
View File
@@ -565,20 +565,40 @@ internal UI_BOX_CUSTOM_DRAW(ui_sat_val_picker_draw)
// rjf: hue => rgb
Vec3F32 hue_rgb = rgb_from_hsv(v3f32(data->hue, 1, 1));
Vec3F32 hue_rgb_linear = linear_from_srgb(hue_rgb);
// rjf: white -> rgb background
// rjf: rgb background
{
R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, -1.f), v4f32(hue_rgb.x, hue_rgb.y, hue_rgb.z, 1), 4.f, 0, 1.f);
dr_rect(pad_2f32(box->rect, -1.f), v4f32(hue_rgb_linear.x, hue_rgb_linear.y, hue_rgb_linear.z, 1), 4.f, 0, 1.f);
}
// rjf: white gradient overlay
{
R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, -1.f), v4f32(hue_rgb_linear.x, hue_rgb_linear.y, hue_rgb_linear.z, 0), 4.f, 0, 1.f);
inst->colors[Corner_00] = inst->colors[Corner_01] = v4f32(1, 1, 1, 1);
}
// rjf: black gradient overlay
// rjf: black gradient overlay pt. 1
{
R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, -1.f), v4f32(0, 0, 0, 0), 4.f, 0, 1.f);
inst->colors[Corner_01] = v4f32(0, 0, 0, 1.f);
inst->colors[Corner_11] = v4f32(0, 0, 0, 1.f);
}
// rjf: black gradient overlay pt. 2
{
R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, -1.f), v4f32(0, 0, 0, 0), 4.f, 0, 1.f);
inst->colors[Corner_01] = v4f32(0, 0, 0, 1);
inst->colors[Corner_11] = v4f32(0, 0, 0, 1);
}
// rjf: black gradient overlay pt. 3
{
R_Rect2DInst *inst = dr_rect(pad_2f32(box->rect, -1.f), v4f32(0, 0, 0, 0), 4.f, 0, 1.f);
inst->colors[Corner_01] = v4f32(0, 0, 0, 0.2f);
inst->colors[Corner_11] = v4f32(0, 0, 0, 0.2f);
}
// rjf: indicator
{
Vec2F32 box_rect_dim = dim_2f32(box->rect);
@@ -588,7 +608,7 @@ internal UI_BOX_CUSTOM_DRAW(ui_sat_val_picker_draw)
center.y - half_size,
center.x + half_size,
center.y + half_size);
dr_rect(rect, v4f32(1, 1, 1, 1), half_size/2, 2.f, 1.f);
dr_rect(rect, v4f32(1, 1, 1, 1), half_size/2.f, 2.f, 1.f);
}
}
@@ -677,13 +697,13 @@ internal UI_BOX_CUSTOM_DRAW(ui_hue_picker_draw)
F32 hue1 = (F32)(seg+1)/6;
Vec3F32 rgb0 = rgb_from_hsv(v3f32(hue0, 1, 1));
Vec3F32 rgb1 = rgb_from_hsv(v3f32(hue1, 1, 1));
Vec4F32 rgba0 = v4f32(rgb0.x, rgb0.y, rgb0.z, 1);
Vec4F32 rgba1 = v4f32(rgb1.x, rgb1.y, rgb1.z, 1);
Vec4F32 rgba0_linear = linear_from_srgba(v4f32(rgb0.x, rgb0.y, rgb0.z, 1));
Vec4F32 rgba1_linear = linear_from_srgba(v4f32(rgb1.x, rgb1.y, rgb1.z, 1));
R_Rect2DInst *inst = dr_rect(rect, v4f32(0, 0, 0, 0), 0, 0, 0.f);
inst->colors[Corner_00] = rgba0;
inst->colors[Corner_01] = rgba1;
inst->colors[Corner_10] = rgba0;
inst->colors[Corner_11] = rgba1;
inst->colors[Corner_00] = rgba0_linear;
inst->colors[Corner_01] = rgba1_linear;
inst->colors[Corner_10] = rgba0_linear;
inst->colors[Corner_11] = rgba1_linear;
rect.y0 += segment_dim;
rect.y1 += segment_dim;
}
@@ -691,13 +711,13 @@ internal UI_BOX_CUSTOM_DRAW(ui_hue_picker_draw)
// rjf: indicator
{
Vec2F32 box_rect_dim = dim_2f32(box->rect);
Vec2F32 center = v2f32((box->rect.x0+box->rect.x1)/2, box->rect.y0 + data->hue*box_rect_dim.y);
F32 half_size = box->font_size * (0.5f + box->active_t*0.2f);
Vec2F32 center = v2f32((box->rect.x0+box->rect.x1)/2, box->rect.y0 + (data->hue)*box_rect_dim.y);
F32 half_size = box_rect_dim.x * (0.52f + 0.02f * box->active_t);
Rng2F32 rect = r2f32p(center.x - half_size,
center.y - 2.f,
center.y - box->font_size * (0.5f + 0.1f * box->active_t),
center.x + half_size,
center.y + 2.f);
dr_rect(rect, v4f32(1, 1, 1, 1), half_size/2, 2.f, 1.f);
center.y + box->font_size * (0.5f + 0.1f * box->active_t));
dr_rect(rect, v4f32(1, 1, 1, 1), 1.f, 2.f, 1.f);
}
}
@@ -779,12 +799,12 @@ internal UI_BOX_CUSTOM_DRAW(ui_alpha_picker_draw)
{
Vec2F32 box_rect_dim = dim_2f32(box->rect);
Vec2F32 center = v2f32((box->rect.x0+box->rect.x1)/2, box->rect.y0 + (1-data->alpha)*box_rect_dim.y);
F32 half_size = box->font_size * (0.5f + box->active_t*0.2f);
F32 half_size = box_rect_dim.x * (0.52f + 0.02f * box->active_t);
Rng2F32 rect = r2f32p(center.x - half_size,
center.y - 2.f,
center.y - box->font_size * (0.5f + 0.1f * box->active_t),
center.x + half_size,
center.y + 2.f);
dr_rect(rect, v4f32(1, 1, 1, 1), half_size/2, 2.f, 1.f);
center.y + box->font_size * (0.5f + 0.1f * box->active_t));
dr_rect(rect, v4f32(1, 1, 1, 1), 1.f, 2.f, 1.f);
}
}