From 70fda8a8537712e86d8acf46be97b13feb23bd00 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 12:55:44 +0000 Subject: [PATCH] merge-c3: Magnetic Lasso cursor reads the canvas's precise cursor (cx.precise()); MagneticLassoTool::precise_cursor removed --- crates/imaging/src/ui/select/magnetic.rs | 20 +++++--------------- crates/imaging/tests/it/select.rs | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/crates/imaging/src/ui/select/magnetic.rs b/crates/imaging/src/ui/select/magnetic.rs index 4548b10e9..f46b7a05b 100644 --- a/crates/imaging/src/ui/select/magnetic.rs +++ b/crates/imaging/src/ui/select/magnetic.rs @@ -255,8 +255,8 @@ fn pen_pressure(pointer: &ToolPointer) -> Option { /// drops it. No selection drag: a press inside the selection draws. /// /// Drawn: the outline as ants, a square with an edge at each fastening point, and over the first point the closing -/// ring beside the pointer. The cursor is the lasso icon; with Other Cursors > Precise -/// ([`precise_cursor`](Self::precise_cursor)) or Caps Lock it is the width circle. +/// ring beside the pointer. The cursor is the lasso icon; under the canvas's precise cursor (Other Cursors > Precise, +/// swapped by Caps Lock: `ToolContext::precise`) it is the width circle. #[derive(Clone, Debug)] pub struct MagneticLassoTool { tracer: T, @@ -265,8 +265,6 @@ pub struct MagneticLassoTool { outline: Option, /// The modifiers of the last pass, to see Alt pressed or released during a drag. mods: Mods, - /// Other Cursors › Precise: the width circle shows round the crosshair. - precise: bool, report: Report, } @@ -279,7 +277,6 @@ impl MagneticLassoTool { bar: SelectionOperation::New, outline: None, mods: Mods::NONE, - precise: false, report: Report::default(), } } @@ -305,13 +302,6 @@ impl MagneticLassoTool { self } - /// Preferences › Cursors › Other Cursors is Precise (`CursorOptions::other_precise`): the - /// width circle shows round the crosshair. - pub fn precise_cursor(&mut self, precise: bool) -> &mut Self { - self.precise = precise; - self - } - /// The tool as the `CanvasTool` for one pass, asking `probe` about the document. pub fn pass<'a>(&'a mut self, probe: &'a dyn SelectionProbe) -> SelectToolPass<'a, Self> { SelectToolPass::new(self, probe) @@ -486,11 +476,11 @@ impl CanvasTool for SelectToolPass<'_, MagneticLassoTool> { if self.tool.outline.as_ref().is_some_and(|o| !o.down) { ToolClaims::NONE.keyboard().deletes() } else { ToolClaims::NONE } } - /// The width circle with Other Cursors > Precise or Caps Lock (`width * zoom`, at least the slop); otherwise the - /// lasso icon with the operation's badge. + /// The width circle under the canvas's precise cursor (`width * zoom`, at least the slop); otherwise the lasso + /// icon with the operation's badge. fn cursor(&self, cx: &ToolContext<'_>) -> Cursor { let tool = &*self.tool; - if (tool.precise || cx.caps_lock) + if cx.precise() && let Some(place) = Place::of(cx) { let (min, max) = MagneticSettings::WIDTH_RANGE; diff --git a/crates/imaging/tests/it/select.rs b/crates/imaging/tests/it/select.rs index 0ac9f6f02..1c73f777c 100644 --- a/crates/imaging/tests/it/select.rs +++ b/crates/imaging/tests/it/select.rs @@ -891,3 +891,22 @@ fn magnetic_closes_by_start_click_double_click_or_enter_and_retracts_to_the_firs // narrows it. // While the outline is open the tool is one accessible object with its point count (fastening points and the live trace). + +// The Magnetic Lasso's cursor follows the canvas's precise cursor (Other Cursors > Precise, swapped by Caps Lock): +// the width circle while it is on, the lasso icon otherwise (#11690). +#[trial] +fn the_magnetic_lasso_shows_the_width_circle_under_the_precise_cursor() { + use craft_behavior::{Cursor, PaintedCursor}; + let (mut rig, _) = magnetic(); + let over = rig.canvas().center(); + let ctx = rig.fixture().ctx().clone(); + rig.fixture().frame(vec![pointer::moved(over)]); + for caps_lock in [false, true, false] { + craft_ui::runtime::windows::WindowHost::of(&ctx).set_caps_lock(Some(caps_lock)); + rig.fixture().frame(Vec::new()); + rig.fixture().frame(Vec::new()); + let cursor = craft_ui::runtime::cursor::current(&ctx); + let circle = matches!(cursor, Some(Cursor::Painted(PaintedCursor::Circle { .. }))); + assert_eq!(circle, caps_lock, "Caps Lock {caps_lock}: {cursor:?}"); + } +}