From c71f951b903cafcc2f3bfbf1801470033aeada2e Mon Sep 17 00:00:00 2001 From: nrq6993-a11y Date: Thu, 15 Oct 2026 00:06:16 +0300 Subject: [PATCH] =?UTF-8?q?Fix=20View=20=E2=80=BA=20Snap=20off=20still=20s?= =?UTF-8?q?napping=20via=20smart=20guides=20(storytold/photocraft#5782).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Smart-guide targets were built even when the master snap switch was off; gate them on snap_on like other targets. Co-authored-by: Cursor --- crates/ui-egui/src/snap_ui.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/snap_ui.rs b/crates/ui-egui/src/snap_ui.rs index 56fecd01eb..b0cb95e2fc 100644 --- a/crates/ui-egui/src/snap_ui.rs +++ b/crates/ui-egui/src/snap_ui.rs @@ -39,7 +39,7 @@ pub struct ActiveSnap { pub gesture: Gesture, pub start: [f64; 2], pub targets: SnapTargets, - /// Layer alignments only (smart guides), used when View › Snap is off. + /// Layer alignments only (smart guides), when View › Snap and Smart Guides are on. pub smart: SnapTargets, pub disabled: bool, } @@ -228,7 +228,8 @@ fn begin(app: &mut PhotocraftApp, p: [f64; 2], mods: egui::Modifiers) { // A moving selection never snaps back to where it started. targets = targets.filtered(|k| k != SnapKind::Selection); } - let smart = if matches!(gesture, Gesture::Move { .. }) && smart_on(app) { build(app, &exclude, true) } else { SnapTargets::default() }; + let smart = + if snap_on(app) && matches!(gesture, Gesture::Move { .. }) && smart_on(app) { build(app, &exclude, true) } else { SnapTargets::default() }; app.prefs_rt.snap = Some(ActiveSnap { gesture, start: p, targets, smart, disabled: false }); } @@ -571,6 +572,19 @@ mod tests { } } + #[test] + fn view_snap_off_blocks_smart_guide_snapping() { + let mut app = app_with_box(); + app.ui.tool = Tool::Move; + app.ui.view.show.smart_guides = true; + app.ui.extras.snap = false; + app.ui.tool_options.move_auto_select = false; + let m = egui::Modifiers::NONE; + crate::canvas::tool_event(&mut app, ToolEvent::Down { x: 60.0, y: 60.0, pressure: 1.0 }, m); + crate::canvas::tool_event(&mut app, ToolEvent::Up { x: 323.0, y: 100.0 }, m); + assert_eq!(mover_bounds(&app).x0, 303, "View › Snap off must not snap via smart guides"); + } + #[test] fn ctrl_or_snap_off_disables_snapping() { let mut app = app_with_box();