cell description rendering

This commit is contained in:
Ryan Fleury
2025-04-20 20:21:54 -07:00
parent 9453f62cf4
commit cbe1365244
7 changed files with 75 additions and 14 deletions
+16 -6
View File
@@ -4347,6 +4347,12 @@ rd_view_ui(Rng2F32 rect)
cell_params.fstrs = cell_info.fstrs;
cell_params.fuzzy_matches = &fuzzy_matches;
// rjf: apply description
if(row_height_px > ui_top_font_size()*3.5f)
{
cell_params.description = cell_info.description;
}
// rjf: apply expander (or substitute space)
if(row_is_expandable && cell == row_info->cells.first)
{
@@ -6348,7 +6354,6 @@ rd_window_frame(void)
{
FloatingViewTask *next;
RD_Cfg *view;
F32 row_height_px;
Rng2F32 rect;
String8 view_name;
String8 expr;
@@ -6479,7 +6484,6 @@ rd_window_frame(void)
SLLQueuePush(first_floating_view_task, last_floating_view_task, t);
hover_eval_floating_view_task = t;
t->view = view;
t->row_height_px = row_height_px;
t->rect = rect;
t->view_name = view_name;
t->expr = hover_eval_expr;
@@ -6580,11 +6584,20 @@ rd_window_frame(void)
// rjf: evaluate query expression
E_Eval query_eval = e_eval_from_string(scratch.arena, query_expr);
// rjf: determine & store row-height setting
if(!query_is_anchored && cmd_name.size == 0)
{
F32 row_height = 5.f;
F32 row_height_px = row_height * ui_top_font_size();
RD_Cfg *row_height_root = rd_cfg_child_from_string_or_alloc(view, str8_lit("row_height"));
rd_cfg_new_replacef(row_height_root, "%f", row_height);
}
// rjf: compute query view's top-level rectangle
F32 row_height_px = floor_f32(ui_top_px_height());
Rng2F32 rect = {0};
RD_RegsScope(.view = view->id)
{
F32 row_height_px = ui_top_px_height();
Vec2F32 content_rect_center = center_2f32(content_rect);
Vec2F32 content_rect_dim = dim_2f32(content_rect);
EV_BlockTree predicted_block_tree = ev_block_tree_from_expr(scratch.arena, rd_view_eval_view(), rd_view_query_input(), query_eval.expr);
@@ -6619,7 +6632,6 @@ rd_window_frame(void)
SLLQueuePush(first_floating_view_task, last_floating_view_task, t);
query_floating_view_task = t;
t->view = view;
t->row_height_px = row_height_px;
t->rect = rect;
t->view_name = str8_lit("watch");
t->expr = query_expr;
@@ -6644,7 +6656,6 @@ rd_window_frame(void)
{
// rjf: unpack
RD_Cfg *view = t->view;
F32 row_height_px = t->row_height_px;
Rng2F32 rect = t->rect;
String8 view_name = t->view_name;
String8 expr = t->expr;
@@ -6674,7 +6685,6 @@ rd_window_frame(void)
// rjf: build
UI_Focus(is_focused ? UI_FocusKind_On : UI_FocusKind_Off)
UI_PrefHeight(ui_px(row_height_px, 1.f))
{
// rjf: build top-level container box
UI_Box *container = &ui_nil_box;
+8 -2
View File
@@ -10,7 +10,10 @@ E_TYPE_ACCESS_FUNCTION_DEF(commands)
if(expr->kind == E_ExprKind_MemberAccess)
{
String8 cmd_name = expr->first->next->string;
result.type_key = e_type_key_cons(.kind = E_TypeKind_U64, .name = str8_lit("command"));
RD_CmdKindInfo *cmd_info = rd_cmd_kind_info_from_string(cmd_name);
E_TypeKey cmd_type = e_type_key_cons(.kind = E_TypeKind_U64, .name = str8_lit("command"));
cmd_type = e_type_key_cons_meta_description(cmd_type, cmd_info->description);
result.type_key = cmd_type;
result.mode = E_Mode_Value;
result.root = e_irtree_set_space(arena, e_space_make(RD_EvalSpaceKind_MetaCmd), e_irtree_const_u(arena, e_id_from_string(cmd_name)));
}
@@ -59,8 +62,11 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(commands)
for(U64 idx = idx_range.min; idx < idx_range.max; idx += 1, out_idx += 1)
{
String8 cmd_name = accel->v[idx];
RD_CmdKindInfo *cmd_info = rd_cmd_kind_info_from_string(cmd_name);
E_TypeKey cmd_type = e_type_key_cons(.kind = E_TypeKind_U64, .name = str8_lit("command"));
cmd_type = e_type_key_cons_meta_description(cmd_type, cmd_info->description);
E_Expr *expr = e_push_expr(arena, E_ExprKind_LeafValue, 0);
expr->type_key = e_type_key_cons(.kind = E_TypeKind_U64, .name = str8_lit("command"));
expr->type_key = cmd_type;
expr->space = e_space_make(RD_EvalSpaceKind_MetaCmd);
expr->value.u64 = e_id_from_string(cmd_name);
exprs_out[out_idx] = expr;
+14
View File
@@ -1471,6 +1471,20 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
}
}
//////////////////////////////
//- rjf: determine cell description
//
for(E_Type *type = cell_type;
type->kind != E_TypeKind_Null;
type = e_type_from_key__cached(type->direct_type_key))
{
if(type->kind == E_TypeKind_MetaDescription)
{
result.description = type->name;
break;
}
}
//////////////////////////////
//- rjf: determine cell editability
//
+1
View File
@@ -112,6 +112,7 @@ struct RD_WatchRowCellInfo
String8 cmd_name;
String8 file_path;
DR_FStrList fstrs;
String8 description;
String8 error_tooltip;
String8 inheritance_tooltip;
RD_ViewUIRule *view_ui_rule;
+30 -1
View File
@@ -3215,11 +3215,24 @@ rd_cell(RD_CellParams *params, String8 string)
}
}
//////////////////////////////
//- rjf: build left-hand-side container box
//
UI_Box *lhs_box = &ui_nil_box;
UI_Parent(box) UI_WidthFill UI_ChildLayoutAxis(Axis2_Y)
{
lhs_box = ui_build_box_from_stringf(0, "lhs_box");
UI_Parent(lhs_box)
{
ui_spacer(ui_em(3.f, 0.f));
}
}
//////////////////////////////
//- rjf: build scrollable container box
//
UI_Box *scrollable_box = &ui_nil_box;
UI_Parent(box) UI_WidthFill
UI_Parent(lhs_box) UI_WidthFill UI_HeightFill
{
scrollable_box = ui_build_box_from_stringf(is_focus_active*(UI_BoxFlag_AllowOverflowX), "scroll_box_%p", params->edit_buffer);
}
@@ -3654,6 +3667,22 @@ rd_cell(RD_CellParams *params, String8 string)
}
}
//////////////////////////////
//- rjf: build description
//
if(params->description.size != 0) UI_Parent(lhs_box) UI_HeightFill RD_Font(RD_FontSlot_Main) UI_FontSize(ui_top_font_size()*0.85f)
{
UI_Row
{
ui_spacer(ui_em(0.5f, 1.f));
ui_label(params->description);
}
}
UI_Parent(lhs_box)
{
ui_spacer(ui_em(3.f, 0.f));
}
//////////////////////////////
//- rjf: click+drag
//
+2 -1
View File
@@ -40,12 +40,13 @@ enum
typedef struct RD_CellParams RD_CellParams;
struct RD_CellParams
{
//- rjf: catachall parameters
//- rjf: catchall parameters
RD_CellFlags flags;
S32 depth;
FuzzyMatchRangeList *fuzzy_matches;
String8 pre_edit_value;
DR_FStrList fstrs;
String8 description;
//- rjf: expander r/w info
B32 *expanded_out;
+4 -4
View File
@@ -147,16 +147,16 @@ internal UI_BOX_CUSTOM_DRAW(ui_line_edit_draw)
Rng2F32 cursor_rect =
{
text_position.x + cursor_pixel_off - cursor_thickness*0.50f,
box->rect.y0+ui_top_font_size()*0.5f,
box->parent->parent->rect.y0+ui_top_font_size()*0.5f,
text_position.x + cursor_pixel_off + cursor_thickness*0.50f,
box->rect.y1-ui_top_font_size()*0.5f,
box->parent->parent->rect.y1-ui_top_font_size()*0.5f,
};
Rng2F32 mark_rect =
{
text_position.x + mark_pixel_off - cursor_thickness*0.50f,
box->rect.y0+ui_top_font_size()*0.5f,
box->parent->parent->rect.y0+ui_top_font_size()*0.5f,
text_position.x + mark_pixel_off + cursor_thickness*0.50f,
box->rect.y1-ui_top_font_size()*0.5f,
box->parent->parent->rect.y1-ui_top_font_size()*0.5f,
};
Rng2F32 select_rect = union_2f32(cursor_rect, mark_rect);
dr_rect(select_rect, select_color, font_size/2.f, 0, 1.f);