diff --git a/crates/tools/src/corners.rs b/crates/tools/src/corners.rs index c3be27432..b710fc7c7 100644 --- a/crates/tools/src/corners.rs +++ b/crates/tools/src/corners.rs @@ -374,7 +374,10 @@ impl CornerDrag { if !self.began { return vec![]; } - let mut out = vec![Overlay::Measure { p: self.at, text: format!("Radius: {}", cx.len(self.radius)) }]; + let mut out = vec![]; + if cx.measurement_labels { + out.push(Overlay::Measure { p: self.at, text: format!("Radius: {}", cx.len(self.radius)) }); + } if self.at_limit { out.push(Overlay::Path { path: self.corners_at_limit(), color: crate::builder::HIGHLIGHT_RED, width: 2.0, dashed: false }); } @@ -465,6 +468,8 @@ mod tests { assert!((radius(&a[1]) - 15.0).abs() < 1e-9); assert!(matches!(&a[1], Action::Preview(_, v) if v["id"] == id.0)); assert!(t.overlays(&cx).iter().any(|o| matches!(o, Overlay::Measure { text, .. } if text == "Radius: 15.00 pt"))); + let quiet = ToolContext { measurement_labels: false, ..crate::testutil::cx(&d, &s, &p) }; + assert!(!t.overlays(&quiet).iter().any(|o| matches!(o, Overlay::Measure { .. }))); // Past the middle the corner is fully round; back outside it is square. assert_eq!(radius(&t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 100.0, 100.0))[0]), 50.0); assert_eq!(radius(&t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 260.0, 260.0))[0]), 0.0); diff --git a/crates/tools/src/dimension.rs b/crates/tools/src/dimension.rs index aed41c829..4f4760471 100644 --- a/crates/tools/src/dimension.rs +++ b/crates/tools/src/dimension.rs @@ -399,7 +399,9 @@ impl Tool for DimensionTool { for p in [a, b] { out.push(Overlay::Anchor { p, color, filled: true, size: 6.0 }); } - if let Ok(text) = self.style.label(a.distance(b), false) { + if cx.measurement_labels + && let Ok(text) = self.style.label(a.distance(b), false) + { out.push(Overlay::Measure { p: self.at + Vec2::new(12.0, 12.0), text }); } } diff --git a/crates/tools/src/distort/perspective.rs b/crates/tools/src/distort/perspective.rs index b105a1562..4f172760b 100644 --- a/crates/tools/src/distort/perspective.rs +++ b/crates/tools/src/distort/perspective.rs @@ -1262,7 +1262,9 @@ impl Tool for PerspectiveSelectionTool { } } } - if let Some((p, t)) = &self.measure { + if cx.measurement_labels + && let Some((p, t)) = &self.measure + { out.push(Overlay::Measure { p: *p, text: t.clone() }); } out diff --git a/crates/tools/src/distort/width.rs b/crates/tools/src/distort/width.rs index e6c29e9e0..ebe7d7ab5 100644 --- a/crates/tools/src/distort/width.rs +++ b/crates/tools/src/distort/width.rs @@ -435,7 +435,9 @@ impl Tool for WidthTool { let q = d.spot.p; out.push(Overlay::Line { a: q + d.spot.n * d.left, b: q - d.spot.n * d.right, color: BLUE, dashed: false }); out.push(Overlay::Path { path: diamond(q, r), color: BLUE, width: 2.0, dashed: false }); - out.push(Overlay::Measure { p: q + d.spot.n * (d.left + r * 3.0), text: format!("W: {}", cx.stroke_unit.readout(d.left + d.right)) }); + if cx.measurement_labels { + out.push(Overlay::Measure { p: q + d.spot.n * (d.left + r * 3.0), text: format!("W: {}", cx.stroke_unit.readout(d.left + d.right)) }); + } } else if let Some(h) = &self.hover { out.push(Overlay::Line { a: h.p + h.n * h.left, b: h.p - h.n * h.right, color: BLUE, dashed: true }); out.push(Overlay::Path { path: diamond(h.p, r), color: BLUE, width: 1.0, dashed: false }); diff --git a/crates/tools/src/pie.rs b/crates/tools/src/pie.rs index 957c8d371..e173d0a55 100644 --- a/crates/tools/src/pie.rs +++ b/crates/tools/src/pie.rs @@ -187,8 +187,8 @@ impl PieDrag { } /// The angle readout next to the pointer. - pub fn overlays(&self) -> Vec { - if !self.began { + pub fn overlays(&self, cx: &ToolContext) -> Vec { + if !self.began || !cx.measurement_labels { return vec![]; } vec![Overlay::Measure { p: self.at, text: format!("{:.1}°", self.angle) }] @@ -275,6 +275,8 @@ mod tests { assert!(v.get("pieStart").is_none(), "{v}"); assert!(t.transforming()); assert!(t.overlays(&c).iter().any(|o| matches!(o, Overlay::Measure { text, .. } if text == "90.0°"))); + let quiet = ToolContext { measurement_labels: false, ..cx(&d, &s, &p) }; + assert!(!t.overlays(&quiet).iter().any(|o| matches!(o, Overlay::Measure { .. }))); // Below the center and to the left: 225°, on the ellipse's own angles (not the page's). let a = t.pointer(&c, &ev(PointerKind::Drag, Point::new(100.0, 200.0))); assert!(matches!(&a[0], Action::Preview(_, v) if (v["pieEnd"].as_f64().unwrap() - 225.0).abs() < 1e-9), "{a:?}"); diff --git a/crates/tools/src/printtiling.rs b/crates/tools/src/printtiling.rs index 7a443ba6c..b4e0e06d0 100644 --- a/crates/tools/src/printtiling.rs +++ b/crates/tools/src/printtiling.rs @@ -79,7 +79,7 @@ impl Tool for PrintTilingTool { fn overlays(&self, cx: &ToolContext) -> Vec { match self.drag { // How far the corner is from the artboard's. - Some((_, Some(r))) if self.began => { + Some((_, Some(r))) if self.began && cx.measurement_labels => { vec![Overlay::Measure { p: self.last, text: cx.offset_label(self.last.x - r.x0, self.last.y - r.y0) }] } _ => vec![], @@ -122,6 +122,8 @@ mod tests { let a = t.pointer(&c, &ev(PointerKind::Drag, 2.0, 497.0)); assert_eq!(a, vec![Action::Preview("print.tiling.set".into(), json!({"origin": [0.0, 500.0], "artboard": 0}))]); assert!(matches!(t.overlays(&c).as_slice(), [Overlay::Measure { .. }])); + let quiet = ToolContext { measurement_labels: false, ..cx(&d, &s, &pd) }; + assert!(t.overlays(&quiet).is_empty()); assert_eq!(t.pointer(&c, &ev(PointerKind::Up, 2.0, 497.0)), vec![Action::Commit]); assert!(!t.busy()); // A click alone changes nothing; a double click resets. diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs index f373aa09c..5a88ab104 100644 --- a/crates/tools/src/select.rs +++ b/crates/tools/src/select.rs @@ -714,7 +714,7 @@ impl Tool for SelectionTool { match &self.state { State::Marquee { start, cur, .. } => o.push(Overlay::Marquee(Rect::from_points(*start, *cur))), State::Corner(c) => o.extend(c.overlays(cx)), - State::Pie(d) => o.extend(d.overlays()), + State::Pie(d) => o.extend(d.overlays(cx)), State::Loaded { press: Some((start, cur)), .. } => o.push(Overlay::Marquee(Rect::from_points(*start, *cur))), _ => {} }