From 021a9474f8dda6cb449fbd534528fd05dd660b50 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 10 Oct 2026 06:08:17 +0700 Subject: [PATCH] Fix #824: the Artboard tool names its artboard once With the Artboard tool, the active artboard's name was drawn twice: by the canvas, as for every artboard, and by the tool, in blue and a little higher. The canvas now leaves that one to the tool, which draws it where the canvas names the others. Co-Authored-By: Claude Opus 5.5 --- crates/tools/src/xform/artboard.rs | 5 ++++- crates/ui-egui/src/canvas.rs | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/tools/src/xform/artboard.rs b/crates/tools/src/xform/artboard.rs index f3b9c0f7..6bfe21c7 100644 --- a/crates/tools/src/xform/artboard.rs +++ b/crates/tools/src/xform/artboard.rs @@ -346,7 +346,10 @@ impl Tool for ArtboardTool { for h in Handle::ALL { o.push(Overlay::Anchor { p: h.pos(r), color: BLUE, filled: false, size: 7.0 }); } - o.push(Overlay::Label { p: Point::new(r.x0, r.y0 - cx.tol(14.0)), text: format!("{:02} - {}", self.active + 1, ab.name), color: BLUE }); + // Where the canvas names the other artboards: on the top edge, flush with the left one + // (labels are drawn 8 px right of and 14 px above their point). + let at = Point::new(r.x0 - cx.tol(8.0), r.y0 - cx.tol(4.0)); + o.push(Overlay::Label { p: at, text: format!("{:02} - {}", self.active + 1, ab.name), color: BLUE }); if let (Some(Drag::Resize { began: true, .. }), true) = (self.drag, cx.measurement_labels) { o.push(Overlay::Measure { p: Point::new(r.x1, r.y1) + Vec2::new(cx.tol(12.0), cx.tol(12.0)), diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 1b81eb99..d59de728 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -349,8 +349,11 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { if app.ui.view.pixel_preview && v.zoom >= PIXEL_GRID_ZOOM && app.session.prefs.show_pixel_grid { grid(&painter, &xf, 1.0, 1, LineLook { color: PIXEL_GRID, dots: false }); } - // Artboard edges and names. + // Artboard edges and names. The Artboard tool labels its active artboard itself (following + // a move or resize): that one isn't named twice. let active_ab = 0; + let artboard_tool = app.session.tool_id() == "artboard"; + let tool_labelled = artboard_tool.then(|| app.session.tool_options()["active"].as_u64()).flatten(); for (i, ab) in doc.artboards.iter().enumerate() { let r = xf.rect_to_screen(ab.rect); let c = if i == active_ab { Color32::from_gray(0) } else { Color32::from_gray(120) }; @@ -359,7 +362,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { if doc.setup.has_bleed() { painter.add(Shape::closed_line(xf.quad(doc.setup.bleed_rect(ab.rect)), Stroke::new(1.0, t.bleed))); } - if app.session.tool_id() == "artboard" || doc.artboards.len() > 1 { + if (artboard_tool || doc.artboards.len() > 1) && tool_labelled != u64::try_from(i).ok() { painter.text( r.left_top() - vec2(0.0, 4.0), egui::Align2::LEFT_BOTTOM,