correctly hook up watch window commands to their associated cfg; plug in ctrl entity detection / fancy rows

This commit is contained in:
Ryan Fleury
2025-02-14 09:04:46 -08:00
parent 87ee37d19e
commit 35ba41f712
4 changed files with 66 additions and 16 deletions
+9
View File
@@ -12716,6 +12716,7 @@ rd_frame(void)
E_TypeKey collection_type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = collection_name);
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
expr->type_key = collection_type_key;
expr->space = e_space_make(RD_EvalSpaceKind_MetaCtrlEntityCollection);
e_string2expr_map_insert(scratch.arena, ctx->macro_map, collection_name, expr);
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, collection_name,
.info = E_LOOKUP_INFO_FUNCTION_NAME(ctrl_entities),
@@ -14787,6 +14788,14 @@ Z(getting_started)
disasm_dst_panel = &rd_nil_panel_node;
}
// rjf: if disasm is not preferred, and we have no disassembly view
// *selected* at all, cancel disasm, so that it doesn't open if the user
// doesn't want it.
if(!rd_regs()->prefer_disasm && view_w_disasm != &rd_nil_cfg && rd_cfg_child_from_string(view_w_disasm, str8_lit("selected")) == &rd_nil_cfg)
{
disasm_dst_panel = &rd_nil_panel_node;
}
// rjf: given the above, find source code location.
if(file_path.size != 0 && src_code_dst_panel != &rd_nil_panel_node)
{
+2 -1
View File
@@ -84,9 +84,10 @@ enum
RD_EvalSpaceKind_CtrlEntity = E_SpaceKind_FirstUserDefined,
RD_EvalSpaceKind_MetaCfg,
RD_EvalSpaceKind_MetaCfgCollection,
RD_EvalSpaceKind_MetaCmd,
RD_EvalSpaceKind_MetaCmdCollection,
RD_EvalSpaceKind_MetaCtrlEntity,
RD_EvalSpaceKind_MetaCmd,
RD_EvalSpaceKind_MetaCtrlEntityCollection,
};
////////////////////////////////
+50 -6
View File
@@ -962,6 +962,12 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
}
}
// rjf: determine ctrl entity
if(block_type_kind == E_TypeKind_Set && block_eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntityCollection)
{
info.group_entity = rd_ctrl_entity_from_eval_space(info.eval.space);
}
// rjf: determine cfg group name / parent
if(block_type_kind == E_TypeKind_Set && block_eval.space.kind == RD_EvalSpaceKind_MetaCfgCollection)
{
@@ -1048,7 +1054,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
// rjf: entity rows
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_Expr, .flags = RD_WatchCellFlag_Button, .pct = 1.f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .flags = RD_WatchCellFlag_Button, .pct = 1.f, .fstrs = rd_title_fstrs_from_ctrl_entity(arena, info.group_entity, ui_top_palette()->text_weak, ui_top_font_size(), 1));
}
// rjf: singular button for commands
@@ -1078,7 +1084,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
else if(info.eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
info.eval.space.kind == RD_EvalSpaceKind_MetaCfgCollection ||
info.eval.space.kind == RD_EvalSpaceKind_MetaCmd ||
info.eval.space.kind == RD_EvalSpaceKind_MetaCmdCollection)
info.eval.space.kind == RD_EvalSpaceKind_MetaCmdCollection ||
info.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity ||
info.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntityCollection)
{
info.cell_style_key = str8_lit("expr_and_eval");
RD_Cfg *view = rd_cfg_from_id(rd_regs()->view);
@@ -1300,8 +1308,18 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
default:{}break;
case RD_WatchCellKind_Expr:
{
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg &&
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity &&
result.eval.value.u64 == 0)
{
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(result.eval.space);
E_TypeKey cfg_type = e_string2typekey_map_lookup(rd_state->meta_name2type_map, ctrl_entity_kind_code_name_table[entity->kind]);
if(e_type_key_match(cfg_type, result.eval.type_key))
{
result.entity = entity;
}
}
else if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg &&
result.eval.value.u64 == 0)
{
RD_Cfg *cfg = rd_cfg_from_eval_space(result.eval.space);
E_TypeKey cfg_type = e_string2typekey_map_lookup(rd_state->meta_name2type_map, cfg->string);
@@ -1319,8 +1337,20 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
}break;
case RD_WatchCellKind_Eval:
{
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg &&
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity &&
result.eval.value.u64 == 0)
{
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(result.eval.space);
E_TypeKey cfg_type = e_string2typekey_map_lookup(rd_state->meta_name2type_map, ctrl_entity_kind_code_name_table[entity->kind]);
if(e_type_key_match(cfg_type, result.eval.type_key))
{
result.fstrs = rd_title_fstrs_from_ctrl_entity(arena, entity, ui_top_palette()->text_weak, ui_top_font_size(), 1);
result.flags |= RD_WatchCellFlag_Button;
result.entity = entity;
}
}
else if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg &&
result.eval.value.u64 == 0)
{
RD_Cfg *cfg = rd_cfg_from_eval_space(result.eval.space);
E_TypeKey cfg_type = e_string2typekey_map_lookup(rd_state->meta_name2type_map, cfg->string);
@@ -2612,7 +2642,11 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
{
if(row_is_fresh)
{
palette = ui_build_palette(ui_top_palette(), .background = rd_rgba_from_theme_color(RD_ThemeColor_HighlightOverlay));
Vec4F32 start_color = rd_rgba_from_theme_color(RD_ThemeColor_NegativePopButtonBackground);
start_color.w *= 0.5f;
Vec4F32 end_color = rd_rgba_from_theme_color(RD_ThemeColor_HighlightOverlay);
Vec4F32 color = mix_4f32(start_color, end_color, ui_anim(ui_key_from_stringf(ui_key_zero(), "row_fresh_%I64x", row_hash), 1.f));
palette = ui_build_palette(ui_top_palette(), .background = color);
row_flags |= UI_BoxFlag_DrawBackground;
}
else if(global_row_idx & 1)
@@ -2876,6 +2910,15 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
RD_RegsScope(.cfg = cell_info.cfg->id) rd_set_hover_regs(RD_RegSlot_Cfg);
}
// rjf: dragging -> drag/drop
if(ui_dragging(sig) && !contains_2f32(sig.box->rect, ui_mouse()))
{
if(cell_info.cfg != &rd_nil_cfg)
{
RD_RegsScope(.cfg = cell_info.cfg->id) rd_drag_begin(RD_RegSlot_Cfg);
}
}
// rjf: (normally) single-click -> move selection here
if(!(cell_info.flags & RD_WatchCellFlag_ActivateWithSingleClick) && ui_pressed(sig))
{
@@ -2896,8 +2939,9 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
// rjf: has a command name? -> push command
if(cell_info.cmd_name.size != 0)
{
RD_Cfg *cfg = rd_cfg_from_eval_space(row_info->eval.space);
RD_CmdKind kind = rd_cmd_kind_from_string(cell_info.cmd_name);
rd_cmd(kind, .cfg = row_info->group_cfg_child->id);
rd_cmd(kind, .cfg = cfg->id);
}
// rjf: row has callstack info? -> select unwind
+5 -9
View File
@@ -795,7 +795,7 @@ ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, U
ui_state->build_box_count = 0;
ui_state->tooltip_open = 0;
ui_state->ctx_menu_changed = 0;
ui_state->default_animation_rate = 1 - pow_f32(2, (-50.f * ui_state->animation_dt));
ui_state->default_animation_rate = 1 - pow_f32(2, (-80.f * ui_state->animation_dt));
}
//- rjf: prune unused animation nodes
@@ -1306,19 +1306,15 @@ ui_end_build(void)
ui_state->is_animating = (ui_state->is_animating || abs_f32(n->params.target - n->current) > n->params.epsilon);
}
}
F32 vast_rate = 1 - pow_f32(2, (-60.f * ui_state->animation_dt));
F32 fast_rate = 1 - pow_f32(2, (-50.f * ui_state->animation_dt));
F32 fish_rate = 1 - pow_f32(2, (-40.f * ui_state->animation_dt));
F32 fast_rate = ui_state->default_animation_rate;
F32 slow_rate = 1 - pow_f32(2, (-30.f * ui_state->animation_dt));
F32 slug_rate = 1 - pow_f32(2, (-15.f * ui_state->animation_dt));
F32 slaf_rate = 1 - pow_f32(2, (-8.f * ui_state->animation_dt));
ui_state->ctx_menu_open_t += ((F32)!!ui_state->ctx_menu_open - ui_state->ctx_menu_open_t) * (ui_state->animation_info.flags & UI_AnimationInfoFlag_ContextMenuAnimations ? vast_rate : 1);
ui_state->ctx_menu_open_t += ((F32)!!ui_state->ctx_menu_open - ui_state->ctx_menu_open_t) * (ui_state->animation_info.flags & UI_AnimationInfoFlag_ContextMenuAnimations ? fast_rate : 1);
ui_state->is_animating = (ui_state->is_animating || abs_f32((F32)!!ui_state->ctx_menu_open - ui_state->ctx_menu_open_t) > 0.01f);
if(ui_state->ctx_menu_open_t >= 0.99f && ui_state->ctx_menu_open)
{
ui_state->ctx_menu_open_t = 1.f;
}
ui_state->tooltip_open_t += ((F32)!!ui_state->tooltip_open - ui_state->tooltip_open_t) * (ui_state->animation_info.flags & UI_AnimationInfoFlag_TooltipAnimations ? vast_rate : 1);
ui_state->tooltip_open_t += ((F32)!!ui_state->tooltip_open - ui_state->tooltip_open_t) * (ui_state->animation_info.flags & UI_AnimationInfoFlag_TooltipAnimations ? fast_rate : 1);
ui_state->is_animating = (ui_state->is_animating || abs_f32((F32)!!ui_state->tooltip_open - ui_state->tooltip_open_t) > 0.01f);
if(ui_state->tooltip_open_t >= 0.99f && ui_state->tooltip_open)
{
@@ -1374,7 +1370,7 @@ ui_end_build(void)
// rjf: animate interaction transition states
box->hot_t += hot_rate * ((F32)is_hot - box->hot_t);
box->active_t += active_rate * ((F32)is_active - box->active_t);
box->active_t = is_active ? 1.f : box->active_t + (active_rate * ((F32)is_active - box->active_t));
box->disabled_t += disabled_rate * ((F32)is_disabled - box->disabled_t);
box->focus_hot_t += focus_rate * ((F32)is_focus_hot - box->focus_hot_t);
box->focus_active_t += focus_rate * ((F32)is_focus_active - box->focus_active_t);