diff --git a/crates/ui-egui/src/canvas/rulers.rs b/crates/ui-egui/src/canvas/rulers.rs index 34a6a223b9..a72e55995f 100644 --- a/crates/ui-egui/src/canvas/rulers.rs +++ b/crates/ui-egui/src/canvas/rulers.rs @@ -62,7 +62,7 @@ pub(crate) fn units() -> &'static [UnitKind] { } /// Lengths stored in points and shown in `unit`, a bare number read as Numbers Without Units Are Points says. -fn lengths(app: &VectorcraftApp, unit: Unit) -> LengthUnits { +pub(crate) fn lengths(app: &VectorcraftApp, unit: Unit) -> LengthUnits { crate::fields::bare_points( LengthUnits::new(UnitKind::Points, unit_kind(unit), PIXELS_PER_INCH), app.session.prefs.numbers_without_units_are_points, diff --git a/crates/ui-egui/src/dialogs/command.rs b/crates/ui-egui/src/dialogs/command.rs index e2bb683ddd..6d8741d342 100644 --- a/crates/ui-egui/src/dialogs/command.rs +++ b/crates/ui-egui/src/dialogs/command.rs @@ -59,6 +59,9 @@ struct Open { struct Setting { cmyk: bool, units: LengthUnits, + /// Hairline Slivers' widths: the stroke unit (Preferences › Units › Stroke), or points when + /// that unit's field rounds the narrowest width to 0. + sliver_units: LengthUnits, } impl Setting { @@ -67,8 +70,23 @@ impl Setting { cmyk: app.session.active().is_some_and(|s| s.doc.color_mode == vectorcraft_doc::ColorMode::Cmyk), // PLAN: assumed `canvas::rulers::general_lengths(&VectorcraftApp) -> LengthUnits` (cv.B5) units: crate::canvas::rulers::general_lengths(app), + sliver_units: crate::canvas::rulers::lengths(app, sliver_unit(app.session.stroke_unit())), } } + + /// The length units of `command`'s distance rows. + fn units_for(self, command: &str) -> LengthUnits { + match command { + "object.path.cleanUp" | "select.object.hairlineSlivers" => self.sliver_units, + _ => self.units, + } + } +} + +/// The unit Hairline Slivers' widths show in for the stroke unit `stroke`: `stroke`, or points +/// when `stroke` rounds the narrowest width to 0. +fn sliver_unit(stroke: vectorcraft_doc::Unit) -> vectorcraft_doc::Unit { + if stroke.number(*vectorcraft_engine::HAIRLINE_SLIVER_WIDTH_RANGE.start()) == "0" { vectorcraft_doc::Unit::Points } else { stroke } } /// Opens the parameter dialog of `command`, headed `label`, on `params` (a menu item's own values, `__params` for the @@ -283,7 +301,7 @@ fn row(command: &str, key: &str, value: &Value, setting: Setting) -> Option