begin moving per-row style info to per-cell style info

This commit is contained in:
Ryan Fleury
2025-02-13 09:26:05 -08:00
parent fba0053e9b
commit 6498666619
4 changed files with 35 additions and 23 deletions
+1
View File
@@ -12691,6 +12691,7 @@ rd_frame(void)
E_TypeKey type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = name);
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
expr->type_key = type_key;
expr->space = e_space_make(RD_EvalSpaceKind_MetaCmdCollection);
e_string2expr_map_insert(scratch.arena, ctx->macro_map, name, expr);
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, name,
.info = E_LOOKUP_INFO_FUNCTION_NAME(commands),
+1
View File
@@ -84,6 +84,7 @@ enum
RD_EvalSpaceKind_CtrlEntity = E_SpaceKind_FirstUserDefined,
RD_EvalSpaceKind_MetaCfg,
RD_EvalSpaceKind_MetaCfgCollection,
RD_EvalSpaceKind_MetaCmdCollection,
RD_EvalSpaceKind_MetaCtrlEntity,
RD_EvalSpaceKind_MetaCmd,
};
+31 -21
View File
@@ -1004,30 +1004,29 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
{
if(0){}
// rjf: singular button for top-level cfg group elements
else if(info.eval.space.kind == RD_EvalSpaceKind_MetaCfg && row_eval_matches_group && info.group_cfg_parent == &rd_nil_cfg)
// rjf: singular button for cfgs
else if((info.eval.space.kind == RD_EvalSpaceKind_MetaCfg && row_eval_matches_group && info.group_cfg_parent == &rd_nil_cfg) ||
(row->block->parent == &ev_nil_block && evalled_cfg != &rd_nil_cfg))
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Button, .pct = 1.f, .fstrs = rd_title_fstrs_from_cfg(arena, info.group_cfg_child, ui_top_palette()->text_weak, ui_top_font_size()));
}
// rjf: singular button for top-level cfg roots
else if(row->block->parent == &ev_nil_block && evalled_cfg != &rd_nil_cfg)
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Button, .pct = 1.f, .fstrs = rd_title_fstrs_from_cfg(arena, evalled_cfg, ui_top_palette()->text_weak, ui_top_font_size()));
RD_Cfg *cfg = evalled_cfg;
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .is_button = 1, .pct = 1.f, .fstrs = rd_title_fstrs_from_cfg(arena, cfg, ui_top_palette()->text_weak, ui_top_font_size()));
}
// rjf: singular button for entities
else if(info.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity && info.group_entity != &ctrl_entity_nil)
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Button, .pct = 1.f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .is_button = 1, .pct = 1.f);
}
// rjf: singular button for commands
else if(info.eval.space.kind == RD_EvalSpaceKind_MetaCmd)
else if((block_eval.space.kind == RD_EvalSpaceKind_MetaCmdCollection ||
block_eval.space.kind == RD_EvalSpaceKind_MetaCfgCollection) &&
info.eval.space.kind == RD_EvalSpaceKind_MetaCmd &&
row_eval_matches_group)
{
RD_CmdKind cmd_kind = e_value_eval_from_eval(info.eval).value.u64;
RD_CmdKindInfo *cmd_kind_info = &rd_cmd_kind_info_table[cmd_kind];
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Button, .pct = 1.f, .fstrs = rd_title_fstrs_from_code_name(arena, cmd_kind_info->string, ui_top_palette()->text_weak, ui_top_font_size()));
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .is_button = 1, .pct = 1.f, .fstrs = rd_title_fstrs_from_code_name(arena, cmd_kind_info->string, ui_top_palette()->text_weak, ui_top_font_size()));
}
// rjf: singular cell for view ui
@@ -1221,9 +1220,14 @@ internal RD_WatchRowCellInfo
rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_flags, RD_WatchRowInfo *row_info, RD_WatchCell *cell, FNT_Tag font, F32 font_size, F32 max_size_px)
{
RD_WatchRowCellInfo result = {0};
//- rjf: fill basics/defaults
result.view_ui_rule = &rd_nil_view_ui_rule;
result.view_ui_tag = &e_expr_nil;
result.fstrs = cell->fstrs;
result.is_button = cell->is_button;
//- rjf: do per-kind fills
switch(cell->kind)
{
default:{}break;
@@ -1236,6 +1240,7 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
{
result.can_edit = 1;
}
result.eval = e_eval_from_expr(arena, row->expr);
result.string = row->string;
if(result.string.size == 0)
{
@@ -1269,7 +1274,7 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
}break;
case E_ExprKind_MemberAccess:
{
E_Eval row_eval = e_eval_from_expr(arena, row->expr);
E_Eval row_eval = result.eval;
String8 member_name = e_string_from_expr(arena, notable_expr->last);
B32 is_non_code = 0;
String8 string = push_str8f(arena, ".%S", member_name);
@@ -1342,6 +1347,7 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
result.eval = e_eval_from_expr(scratch.arena, root_expr);
result.string = rd_value_string_from_eval(arena, string_flags, 10, font, font_size, max_size_px, result.eval);
result.can_edit = (ev_type_key_is_editable(result.eval.type_key) && result.eval.mode == E_Mode_Offset);
scratch_end(scratch);
}break;
@@ -1360,13 +1366,18 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
result.view_ui_rule = row_info->view_ui_rule;
result.view_ui_tag = row_info->view_ui_tag;
}break;
//- rjf: button cells
case RD_WatchCellKind_Button:
{
result.is_button = 1;
}break;
}
//- rjf: adjust style based on evaluation
#if 0
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg)
{
RD_Cfg *cfg = rd_cfg_from_id(result.eval.value.u64);
result.fstrs = rd_title_fstrs_from_cfg(arena, cfg, ui_top_palette()->text_weak, ui_top_font_size());
result.is_button = 1;
}
#endif
return result;
}
@@ -2209,7 +2220,6 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
{
default:{}break;
case RD_WatchCellKind_Expr:
case RD_WatchCellKind_Button:
{
RD_Cfg *cfg = row_info.group_cfg_child;
if(cfg != &rd_nil_cfg)
@@ -3050,7 +3060,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
line_edit_params.edit_string_size_out = &cell_edit_state->input_size;
line_edit_params.expanded_out = &next_row_expanded;
line_edit_params.pre_edit_value = cell_info.string;
line_edit_params.fstrs = cell_info.fstrs;
line_edit_params.fstrs = cell_info.fstrs;
}
sig = rd_line_editf(&line_edit_params, "%S###%I64x_row_%I64x", str8_zero(), cell_x, row_hash);
#if 0 // TODO(rjf): @cfg
+2 -2
View File
@@ -47,7 +47,6 @@ typedef enum RD_WatchCellKind
RD_WatchCellKind_Tag, // strings to represent attached tags at row-granularity
RD_WatchCellKind_Eval, // an evaluation of the expression, with some optional modification - e.g. `$expr.some_member`, or `typeof($expr)`
RD_WatchCellKind_ViewUI, // an arbitrary user interface, supplied by a hook
RD_WatchCellKind_Button, // a fancy button dedicated to the entire row's evaluation, used for listers/etc.
RD_WatchCellKind_CallStackFrame, // a slot for a yellow arrow, to show call stack frame selection
}
RD_WatchCellKind;
@@ -59,6 +58,7 @@ struct RD_WatchCell
RD_WatchCellKind kind;
String8 string;
DR_FStrList fstrs;
B32 is_button;
F32 default_pct;
F32 pct;
F32 px;
@@ -96,8 +96,8 @@ struct RD_WatchRowCellInfo
E_Eval eval;
String8 string;
DR_FStrList fstrs;
B32 is_non_code;
B32 is_button;
B32 is_non_code;
B32 can_edit;
B32 is_errored;
String8 error_tooltip;