default expansion in eval visualization; apply to scheduler tree

This commit is contained in:
Ryan Fleury
2024-10-14 14:21:12 -07:00
parent 6a297113c5
commit 6fcdce4e0f
5 changed files with 75 additions and 44 deletions
@@ -705,6 +705,7 @@ ev_block_tree_from_expr(Arena *arena, EV_View *view, String8 filter, String8 str
U64 child_id; U64 child_id;
EV_ViewRuleList *view_rules; EV_ViewRuleList *view_rules;
U64 split_relative_idx; U64 split_relative_idx;
B32 default_expanded;
}; };
Task start_task = {0, tree.root, tree.root->expr, 1, top_level_view_rules, 0}; Task start_task = {0, tree.root, tree.root->expr, 1, top_level_view_rules, 0};
Task *first_task = &start_task; Task *first_task = &start_task;
@@ -717,6 +718,10 @@ ev_block_tree_from_expr(Arena *arena, EV_View *view, String8 filter, String8 str
// rjf: obtain expansion node & expansion state // rjf: obtain expansion node & expansion state
EV_ExpandNode *expand_node = ev_expand_node_from_key(view, key); EV_ExpandNode *expand_node = ev_expand_node_from_key(view, key);
B32 is_expanded = (expand_node != 0 && expand_node->expanded); B32 is_expanded = (expand_node != 0 && expand_node->expanded);
if(t->default_expanded)
{
is_expanded ^= 1;
}
// rjf: skip if not expanded // rjf: skip if not expanded
if(!is_expanded) if(!is_expanded)
@@ -757,21 +762,24 @@ ev_block_tree_from_expr(Arena *arena, EV_View *view, String8 filter, String8 str
expansion_block->expand_view_rule_info_user_data = expand_info.user_data; expansion_block->expand_view_rule_info_user_data = expand_info.user_data;
expansion_block->row_count = expand_info.row_count; expansion_block->row_count = expand_info.row_count;
expansion_block->single_item = expand_info.single_item; expansion_block->single_item = expand_info.single_item;
expansion_block->rows_default_expanded = expand_info.rows_default_expanded;
tree.total_row_count += expand_info.row_count; tree.total_row_count += expand_info.row_count;
tree.total_item_count += expand_info.single_item ? 1 : expand_info.row_count; tree.total_item_count += expand_info.single_item ? 1 : expand_info.row_count;
} }
// rjf: iterate children expansions, recurse // rjf: gather children expansions from expansion state
if(expand_node != 0 && expand_info.row_count != 0 && expand_view_rule_info->expr_expand_range_info) U64 child_count = 0;
EV_Key *child_keys = 0;
U64 *child_nums = 0;
if(!child_count && !expand_info.rows_default_expanded && expand_node != 0 && expand_info.row_count != 0 && expand_view_rule_info->expr_expand_range_info)
{ {
// rjf: count children // rjf: count children
U64 child_count = 0;
for(EV_ExpandNode *child = expand_node->first; child != 0; child = child->next, child_count += 1){} for(EV_ExpandNode *child = expand_node->first; child != 0; child = child->next, child_count += 1){}
// rjf: gather children keys & numbers // rjf: gather children keys & numbers
B32 needs_sort = 0; B32 needs_sort = 0;
EV_Key *child_keys = push_array(scratch.arena, EV_Key, child_count); child_keys = push_array(scratch.arena, EV_Key, child_count);
U64 *child_nums = push_array(scratch.arena, U64, child_count); child_nums = push_array(scratch.arena, U64, child_count);
{ {
U64 idx = 0; U64 idx = 0;
for(EV_ExpandNode *child = expand_node->first; child != 0; child = child->next, idx += 1) for(EV_ExpandNode *child = expand_node->first; child != 0; child = child->next, idx += 1)
@@ -807,6 +815,21 @@ ev_block_tree_from_expr(Arena *arena, EV_View *view, String8 filter, String8 str
} }
} }
} }
}
// rjf: gather children expansions from inverse of expansion state
if(!child_count && (expand_info.rows_default_expanded || expand_node == 0 && !expand_info.rows_default_expanded))
{
child_count = expand_info.row_count;
child_keys = push_array(scratch.arena, EV_Key, child_count);
child_nums = push_array(scratch.arena, U64, child_count);
for(U64 idx = 0; idx < child_count; idx += 1)
{
U64 child_id = expand_view_rule_info->expr_expand_id_from_num(idx+1, expand_info.user_data);
child_keys[idx] = ev_key_make(ev_hash_from_key(key), child_id);
child_nums[idx] = idx+1;
}
}
// rjf: iterate children expansions & generate recursion tasks // rjf: iterate children expansions & generate recursion tasks
for(U64 idx = 0; idx < child_count; idx += 1) for(U64 idx = 0; idx < child_count; idx += 1)
@@ -845,7 +868,7 @@ ev_block_tree_from_expr(Arena *arena, EV_View *view, String8 filter, String8 str
task->child_id = child_key.child_id; task->child_id = child_key.child_id;
task->view_rules = child_view_rules; task->view_rules = child_view_rules;
task->split_relative_idx = split_relative_idx; task->split_relative_idx = split_relative_idx;
} task->default_expanded = expand_info.rows_default_expanded;
} }
} }
} }
@@ -108,6 +108,7 @@ struct EV_ExpandInfo
U64 row_count; U64 row_count;
B32 single_item; // all rows form a single "item" - a singular, but large, row B32 single_item; // all rows form a single "item" - a singular, but large, row
B32 add_new_row; // also supports an 'add new row', as the final row, within `row_count` B32 add_new_row; // also supports an 'add new row', as the final row, within `row_count`
B32 rows_default_expanded;
}; };
typedef struct EV_ExpandRangeInfo EV_ExpandRangeInfo; typedef struct EV_ExpandRangeInfo EV_ExpandRangeInfo;
@@ -216,6 +217,7 @@ struct EV_Block
// rjf: expansion info // rjf: expansion info
U64 row_count; U64 row_count;
B32 single_item; B32 single_item;
B32 rows_default_expanded;
}; };
typedef struct EV_BlockTree EV_BlockTree; typedef struct EV_BlockTree EV_BlockTree;
+7 -1
View File
@@ -6657,7 +6657,7 @@ rd_window_frame(RD_Window *ws)
B32 row_is_expanded = ev_expansion_from_key(ev_view, row->key); B32 row_is_expanded = ev_expansion_from_key(ev_view, row->key);
if(row_is_expandable) if(row_is_expandable)
UI_PrefWidth(ui_em(1.f, 1)) UI_PrefWidth(ui_em(1.f, 1))
if(ui_pressed(ui_expanderf(row_is_expanded, "###%I64x_%I64x_is_expanded", row->key.parent_hash, row->key.child_id))) if(ui_pressed(ui_expanderf(row->block->rows_default_expanded ? !row_is_expanded : row_is_expanded, "###%I64x_%I64x_is_expanded", row->key.parent_hash, row->key.child_id)))
{ {
ev_key_set_expansion(ev_view, row->block->key, row->key, !row_is_expanded); ev_key_set_expansion(ev_view, row->block->key, row->key, !row_is_expanded);
} }
@@ -8654,6 +8654,7 @@ EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(scheduler_machine)
*processes_array = ctrl_entity_array_from_list(arena, &processes); *processes_array = ctrl_entity_array_from_list(arena, &processes);
info.user_data = processes_array; info.user_data = processes_array;
info.row_count = processes.count; info.row_count = processes.count;
info.rows_default_expanded = 1;
} }
scratch_end(scratch); scratch_end(scratch);
return info; return info;
@@ -9071,6 +9072,11 @@ rd_ev_view_rule_expr_expand_info__meta_ctrl_entities(Arena *arena, EV_View *view
} }
scratch_end(scratch); scratch_end(scratch);
EV_ExpandInfo info = {accel, accel->entities.count}; EV_ExpandInfo info = {accel, accel->entities.count};
// TODO(rjf): hack
if(kind == CTRL_EntityKind_Machine)
{
info.rows_default_expanded = 1;
}
return info; return info;
} }
+1 -1
View File
@@ -2652,7 +2652,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
case CTRL_EntityKind_Process:{slot = RD_RegSlot_Process; rd_regs()->process = ctrl_entity->handle;}break; case CTRL_EntityKind_Process:{slot = RD_RegSlot_Process; rd_regs()->process = ctrl_entity->handle;}break;
case CTRL_EntityKind_Module: {slot = RD_RegSlot_Module; rd_regs()->module = ctrl_entity->handle;}break; case CTRL_EntityKind_Module: {slot = RD_RegSlot_Module; rd_regs()->module = ctrl_entity->handle;}break;
} }
UI_PrefWidth(ui_em(2.f, 1.f)) if(ui_pressed(ui_expander(row_expanded, str8_lit("###expanded")))) UI_PrefWidth(ui_em(2.f, 1.f)) if(ui_pressed(ui_expander(row->block->rows_default_expanded ? !row_expanded : row_expanded, str8_lit("###expanded"))))
{ {
next_row_expanded = !row_expanded; next_row_expanded = !row_expanded;
} }