From a4888055e2d96a42c29bb2a0ef991ef3e14ea830 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 14 Mar 2025 21:16:19 -0700 Subject: [PATCH] better disabled/conditional rendering of breakpoints --- src/raddbg/raddbg_core.c | 32 ++++++++++++++++++-------------- src/raddbg/raddbg_widgets.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 1d386e02..1f47ae9b 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -5256,6 +5256,7 @@ rd_view_ui(Rng2F32 rect) UI_TextAlignment(UI_TextAlign_Center) UI_HoverCursor(OS_Cursor_HandPoint) RD_Font(RD_FontSlot_Icons) + UI_FontSize(ui_top_font_size()*0.8f) { UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable| UI_BoxFlag_Floating| @@ -9447,6 +9448,7 @@ rd_window_frame(void) F32 max_tab_width_px = ui_top_font_size()*20.f; if(build_panel) { + B32 reset = (ws->window_layout_reset || ws->frames_alive < 5 || is_changing_panel_boundaries); for(RD_CfgNode *n = panel->tabs.first; n != 0; n = n->next) { RD_Cfg *tab = n->v; @@ -9457,8 +9459,9 @@ rd_window_frame(void) TabTask *t = push_array(scratch.arena, TabTask, 1); t->tab = tab; t->fstrs = rd_title_fstrs_from_cfg(scratch.arena, tab); - t->tab_width = dr_dim_from_fstrs(&t->fstrs).x + tab_close_width_px + ui_top_font_size()*1.f; - t->tab_width = Min(max_tab_width_px, t->tab_width); + F32 tab_width_target = dr_dim_from_fstrs(&t->fstrs).x + tab_close_width_px + ui_top_font_size()*1.f; + tab_width_target = Min(max_tab_width_px, tab_width_target); + t->tab_width = floor_f32(ui_anim(ui_key_from_stringf(ui_key_zero(), "tab_width_%p", tab), tab_width_target, .initial = reset ? tab_width_target : 0)); SLLQueuePush(first_tab_task, last_tab_task, t); tab_task_count += 1; } @@ -16362,25 +16365,26 @@ Z(getting_started) } if(file_path.size != 0 || expr.size != 0) { - B32 removed_already_existing = 0; - if(kind == RD_CmdKind_ToggleBreakpoint) + B32 already_exists = 0; + RD_CfgList bps = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("breakpoint")); + for(RD_CfgNode *n = bps.first; n != 0; n = n->next) { - RD_CfgList bps = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("breakpoint")); - for(RD_CfgNode *n = bps.first; n != 0; n = n->next) + RD_Cfg *bp = n->v; + RD_Cfg *cnd = rd_cfg_child_from_string(bp, str8_lit("condition")); + RD_Location loc = rd_location_from_cfg(bp); + B32 loc_matches_file_pt = (file_path.size != 0 && path_match_normalized(loc.file_path, file_path) && loc.pt.line == pt.line); + B32 loc_matches_expr = (expr.size != 0 && str8_match(expr, loc.expr, 0)); + if((loc_matches_file_pt || loc_matches_expr) && cnd->first->string.size == 0) { - RD_Cfg *bp = n->v; - RD_Location loc = rd_location_from_cfg(bp); - B32 loc_matches_file_pt = (file_path.size != 0 && path_match_normalized(loc.file_path, file_path) && loc.pt.line == pt.line); - B32 loc_matches_expr = (expr.size != 0 && str8_match(expr, loc.expr, 0)); - if(loc_matches_file_pt || loc_matches_expr) + if(kind == RD_CmdKind_ToggleBreakpoint) { rd_cfg_release(bp); - removed_already_existing = 1; - break; } + already_exists = 1; + break; } } - if(!removed_already_existing) + if(!already_exists) { RD_Cfg *project = rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("project")); RD_Cfg *bp = rd_cfg_new(project, str8_lit("breakpoint")); diff --git a/src/raddbg/raddbg_widgets.c b/src/raddbg/raddbg_widgets.c index bad4f9ec..b39dbc6f 100644 --- a/src/raddbg/raddbg_widgets.c +++ b/src/raddbg/raddbg_widgets.c @@ -1072,6 +1072,8 @@ struct RD_BreakpointBoxDrawExtData F32 remap_px_delta; B32 do_lines; B32 do_glow; + B32 is_disabled; + B32 is_conditioned; }; internal UI_BOX_CUSTOM_DRAW(rd_bp_box_draw_extensions) @@ -1141,6 +1143,33 @@ internal UI_BOX_CUSTOM_DRAW(rd_bp_box_draw_extensions) remap_color, rd_icon_kind_text_table[RD_IconKind_CircleFilled]); } + + // rjf: draw conditioned marker + if(u->is_conditioned) UI_TagF(u->is_disabled ? "weak" : "") + { + Temp scratch = scratch_begin(0, 0); + Vec4F32 color = ui_color_from_name(str8_lit("text")); + FNT_Run run = fnt_push_run_from_string(scratch.arena, rd_font_from_slot(RD_FontSlot_Code), box->font_size*0.95f, 0, 0, FNT_RasterFlag_Smooth, str8_lit("?")); + Vec2F32 p = center_2f32(box->rect); + p.x -= run.dim.x*0.5f; + p.y += run.descent; + dr_text_run(p, color, run); + scratch_end(scratch); + } + + // rjf: draw disabled marker + if(u->is_disabled) + { + Temp scratch = scratch_begin(0, 0); + Vec4F32 color = ui_color_from_name(str8_lit("breakpoint")); + FNT_Run run = fnt_push_run_from_string(scratch.arena, rd_font_from_slot(RD_FontSlot_Icons), box->font_size*0.95f, 0, 0, FNT_RasterFlag_Smooth, str8_lit("x")); + Vec2F32 box_dim = dim_2f32(box->rect); + Vec2F32 p = center_2f32(box->rect); + p.x += box_dim.x*0.1f; + p.y -= box_dim.y*0.2f; + dr_text_run(p, color, run); + scratch_end(scratch); + } } internal RD_CodeSliceSignal @@ -1554,6 +1583,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe bp_draw->hover_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "cfg_hover_t_%p", bp), (F32)!!is_hovering, .rate = entity_hover_t_rate); bp_draw->do_lines = do_bp_lines; bp_draw->do_glow = do_bp_glow; + bp_draw->is_disabled = bp_is_disabled; + bp_draw->is_conditioned = (rd_cfg_child_from_string(bp, str8_lit("condition"))->first->string.size != 0); if(params->line_vaddrs[line_idx] == 0) { D_LineList *lines = ¶ms->line_infos[line_idx];