merge-c3: Magnetic Lasso cursor reads the canvas's precise cursor (cx.precise()); MagneticLassoTool::precise_cursor removed

This commit is contained in:
aiongg
2026-11-16 12:55:44 +00:00
parent 80f7fc1519
commit 70fda8a853
2 changed files with 24 additions and 15 deletions
+5 -15
View File
@@ -255,8 +255,8 @@ fn pen_pressure(pointer: &ToolPointer) -> Option<f32> {
/// 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<T> {
tracer: T,
@@ -265,8 +265,6 @@ pub struct MagneticLassoTool<T> {
outline: Option<MagneticOutline>,
/// 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<T: EdgeTracer> MagneticLassoTool<T> {
bar: SelectionOperation::New,
outline: None,
mods: Mods::NONE,
precise: false,
report: Report::default(),
}
}
@@ -305,13 +302,6 @@ impl<T: EdgeTracer> MagneticLassoTool<T> {
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<T: EdgeTracer> CanvasTool for SelectToolPass<'_, MagneticLassoTool<T>> {
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;
+19
View File
@@ -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:?}");
}
}