From 5ca427ff2d09df4573c510798d0e165074aaf1ba Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 20 Nov 2026 15:15:06 -0800 Subject: [PATCH] Dimension: a guide member of a compound path does not hold a preview-bounds corner With Use Preview Bounds on, the member of a stroked compound path whose own box reaches nearest a corner holds the Linear point placed there. A visible, unlocked member made into a guide could hold it, so the dimension was linked to the guide, although paths made into guides give no corners. A guide member now gives no corner, as a hidden or locked member does. --- crates/tools/src/dimension.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/tools/src/dimension.rs b/crates/tools/src/dimension.rs index 5e2e179bdf..b9ac881910 100644 --- a/crates/tools/src/dimension.rs +++ b/crates/tools/src/dimension.rs @@ -313,12 +313,12 @@ fn preview_corner(cx: &ToolContext, p: Point, cache: &mut PreviewBoxes) -> Optio } // The path whose own box reaches furthest towards the corner holds it: in a // compound path, the member that puts that corner where it is. A hidden or - // locked member gives no corner. + // locked member, or one made into a guide, gives no corner. let mut holder: Option<(f64, NodeId, bool)> = None; for m in members() { let Some(b) = *w.cache.geometric.entry(m.id).or_insert_with(|| m.geometric_bounds()) else { continue }; let gap = corners(b).get(k).map_or(f64::INFINITY, |c| c.distance(q)); - let editable = m.visible && !m.locked; + let editable = m.visible && !m.locked && !m.is_guide(); if holder.is_none_or(|(near, _, was)| gap < near || (gap == near && editable && !was)) { holder = Some((gap, m.id, editable)); } @@ -1781,6 +1781,23 @@ mod tests { let (q, _) = t.snap_linear(&c, Point::new(81.0, 81.0)); assert!(!near(q, Point::new(80.0, 80.0)) && t.corner.is_none(), "{kind}: {q:?}"); } + // A visible, unlocked member of a stroked compound path made into a guide does not hold + // the corner its box puts there. + let mut d = vectorcraft_doc::Document::new(500.0, 500.0); + let (l, hole, part, whole) = (d.layers[0].id, d.alloc_id(), d.alloc_id(), d.alloc_id()); + let mut guide = Node::path(part, vectorcraft_geom::shapes::rectangle(Rect::new(100.0, 100.0, 200.0, 200.0)), Default::default()); + if let NodeKind::Path { guide, .. } = &mut guide.kind { + *guide = true; + } + let small = Node::path(hole, vectorcraft_geom::shapes::rectangle(Rect::new(140.0, 140.0, 160.0, 160.0)), Default::default()); + let mut n = + Node::new(whole, NodeKind::Compound { children: vec![std::sync::Arc::new(small), std::sync::Arc::new(guide)], rule: Default::default() }); + n.appearance = vectorcraft_doc::Appearance::default_art().into(); + d.insert(Some(l), 0, n).expect("the compound path"); + let c = ToolContext { preview_bounds: true, ..cx(&d, &s, &p) }; + let mut t = DimensionTool::default(); + let (q, _) = t.snap_linear(&c, Point::new(99.6, 99.6)); + assert!(t.corner.is_none() && !near(q, Point::new(99.5, 99.5)), "{q:?} {:?}", t.corner); // Two stroked rectangles sharing the edge x = 200; the right one is on top. let (mut d, left) = doc_with_rect(); let (l, right) = (d.layers[0].id, d.alloc_id());