first rough pass on theme editing

This commit is contained in:
Ryan Fleury
2025-04-26 19:01:35 -07:00
parent 282f6022e1
commit 1e82d31eba
5 changed files with 131 additions and 160 deletions
File diff suppressed because one or more lines are too long
+78 -127
View File
@@ -362,7 +362,7 @@ RD_VocabTable:
@collection_commands(add_color, import_colors) x:
{
@display_name('Tags') tags: string,
color: @color @hex u32,
@display_name('Value') value: @color @hex u32,
}
```
}
@@ -1299,132 +1299,83 @@ RD_ThemePresetTable:
DefaultDark default_dark "Default (Dark)",
```theme:
{
background: 0x1b1b1bff,
alt: background: 0x222222ff,
pop: background: 0x355b6eff,
fresh: background: 0x31393dff,
match: background: 0x31393dff,
border: 0x404040ff,
text: 0xe5e5e5ff,
weak: text: 0xa4a4a4ff,
good: text: 0x32a852ff,
bad: text: 0xcf5242ff,
hover: 0xffffffff,
focus: 0xfda200ff,
cursor: 0x8aff00ff,
selection: 0x99ccffff,
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,
code_local: 0x98bc80ff,
code_register: 0xb7afd5ff,
code_keyword: 0xb38d4cff,
code_delimiter_or_operator: 0x767676ff,
code_numeric: 0x98abb1ff,
code_numeric_alt_digit_group: 0x738287ff,
code_string: 0x98abb1ff,
code_meta: 0xd96759ff,
code_comment: 0x717171ff,
line_info_0: 0x4f3022ff,
line_info_1: 0x4f3e15ff,
line_info_2: 0x434e2aff,
line_info_3: 0x36241fff,
line_info_4: 0x4f3022ff,
line_info_5: 0x4f3e15ff,
line_info_6: 0x434e2aff,
line_info_7: 0x36241fff,
thread_0: 0xffcb7fff,
thread_1: 0xb2ff65ff,
thread_2: 0xff99e5ff,
thread_3: 0x6598ffff,
thread_4: 0x65ffcbff,
thread_5: 0xff9819ff,
thread_6: 0x9932ffff,
thread_7: 0x65ff4cff,
thread_unwound: 0xb2ccd8ff,
thread_error: 0xb23219ff,
breakpoint: 0xa72911ff,
floating:
{
background: 0x1b1b1baf,
background: alt: 0x0000005f,
background: fresh: 0x31393d5f,
border: 0xbfbfbf1f,
scroll_bar:
{
background: 0x3b3b3b5f,
border: 0x5f5f5f5f,
}
}
menu_bar:
{
background: 0x2b3740ff,
border: 0x3e4c57ff,
}
scroll_bar:
{
background: 0x2b2b2bff,
border: 0x3f3f3fff,
}
implicit:
{
background: 0x00000000,
border: 0x00000000,
}
hollow:
{
background: 0x00000000,
border: 0xffffff1f,
}
tab:
{
background: 0x6f5135ff,
border: 0x8a6e54ff,
inactive:
{
background: 0x2b3740ff,
border: 0x3e4c57ff,
}
auto:
{
background: 0x693847ff,
border: 0x9e6274ff,
inactive:
{
background: 0x2f2633ff,
border: 0x685073ff,
}
}
}
drop_site:
{
background: 0xffffff05,
border: 0xffffff0f,
}
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 }
}
```
}
+35 -28
View File
@@ -5498,27 +5498,23 @@ rd_window_frame(void)
// that windows can have their own colors, and have those override higher-up settings.
RD_Cfg *preset_cfg = &rd_nil_cfg;
RD_CfgList colors_cfgs = {0};
RD_Cfg *scan_parents[] = {window, rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("project")), rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("theme")), rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user"))};
RD_Cfg *scan_parents[] = {window, rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("project")), rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user"))};
for EachElement(idx, scan_parents)
{
for(RD_Cfg *parent_cfg = scan_parents[idx]; parent_cfg != &rd_nil_cfg; parent_cfg = parent_cfg->parent)
RD_Cfg *parent_cfg = scan_parents[idx];
if(preset_cfg != &rd_nil_cfg)
{
if(preset_cfg != &rd_nil_cfg)
RD_Cfg *possible_preset_cfg = rd_cfg_child_from_string(parent_cfg, str8_lit("color_preset"));
if(possible_preset_cfg != &rd_nil_cfg)
{
RD_Cfg *possible_preset_cfg = rd_cfg_child_from_string(parent_cfg, str8_lit("color_preset"));
if(possible_preset_cfg != &rd_nil_cfg)
{
preset_cfg = possible_preset_cfg;
}
preset_cfg = possible_preset_cfg;
}
RD_Cfg *colors_cfg = rd_cfg_child_from_string(parent_cfg, str8_lit("colors"));
if(colors_cfg != &rd_nil_cfg)
}
for(RD_Cfg *child = parent_cfg->first; child != &rd_nil_cfg; child = child->next)
{
if(str8_match(child->string, str8_lit("color"), 0))
{
rd_cfg_list_push_front(scratch.arena, &colors_cfgs, colors_cfg);
}
if(preset_cfg != &rd_nil_cfg && colors_cfg != &rd_nil_cfg)
{
break;
rd_cfg_list_push_front(scratch.arena, &colors_cfgs, child);
}
}
}
@@ -5553,7 +5549,7 @@ rd_window_frame(void)
for(RD_CfgNode *n = colors_cfgs.first; n != 0; n = n->next)
{
ThemeTask *t = push_array(scratch.arena, ThemeTask, 1);
SLLQueuePush(first_task, last_task, t);
SLLQueuePushFront(first_task, last_task, t);
t->tree = md_tree_from_string(scratch.arena, rd_string_from_cfg_tree(scratch.arena, n->v));
}
}
@@ -5574,17 +5570,14 @@ 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(n->flags & MD_NodeFlag_Numeric && md_node_is_nil(n->first))
if(str8_match(n->string, str8_lit("color"), 0))
{
U64 color_srgba_u64 = 0;
try_u64_from_str8_c_rules(n->string, &color_srgba_u64);
Vec4F32 color_srgba = rgba_from_u32((U32)color_srgba_u64);
Vec4F32 color_linear = linear_from_srgba(color_srgba);
String8List tags = {0};
for(MD_Node *parent = n->parent; parent != tree_root && !md_node_is_nil(parent); parent = parent->parent)
{
str8_list_push(scratch.arena, &tags, push_str8_copy(rd_frame_arena(), parent->string));
}
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);
U8 split_char = ' ';
String8List tags = str8_split(scratch.arena, tags_child->first->string, &split_char, 1, 0);
U32 color_u32 = e_value_from_string(value_child->first->string).u32;
Vec4F32 color_linear = linear_from_srgba(rgba_from_u32(color_u32));
ThemePatternNode *node = push_array(scratch.arena, ThemePatternNode, 1);
node->pattern.tags = str8_array_from_list(rd_frame_arena(), &tags);
node->pattern.linear = color_linear;
@@ -15209,8 +15202,22 @@ rd_frame(void)
{
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("color_preset"));
String8 color_file = rd_setting_from_name(str8_lit("color_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))
{
RD_Cfg *color = rd_cfg_new(parent, str8_lit("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);
rd_cfg_new(value, md_child_from_string(n, str8_lit("value"), 0)->first->string);
}
}
}break;
//- rjf: watches
+14 -1
View File
@@ -3648,10 +3648,11 @@ RD_VIEW_UI_FUNCTION_DEF(color)
RD_Font(RD_FontSlot_Code)
{
UI_Signal sv_sig = ui_sat_val_pickerf(hsva.x, &hsva.y, &hsva.z, "sat_val_picker");
UI_Signal h_sig = {0};
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");
h_sig = ui_hue_pickerf(&hsva.x, hsva.y, hsva.z, "hue_picker");
}
ui_spacer(ui_em(1.f, 1.f));
UI_PrefWidth(ui_children_sum(1)) UI_Column
@@ -3690,6 +3691,18 @@ RD_VIEW_UI_FUNCTION_DEF(color)
}
}
}
if(ui_dragging(h_sig) || ui_dragging(sv_sig))
{
// 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)
{
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);
}
}
}
}
+2 -2
View File
@@ -397,9 +397,9 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg)
if(str8_match(cfg->string, str8_lit("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("color"))->first->string;
String8 color_string = rd_cfg_child_from_string(cfg, str8_lit("value"))->first->string;
U32 color_u32 = e_value_from_stringf("(uint32)(%S)", color_string).u32;
Vec4F32 color = rgba_from_u32(color_u32);
Vec4F32 color = linear_from_srgba(rgba_from_u32(color_u32));
if(tags.size != 0)
{
dr_fstrs_push_new(arena, &result, &params, tags, .color = color);