Fix View › Snap off still snapping via smart guides (storytold/photocraft#5782).

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 <cursoragent@cursor.com>
This commit is contained in:
nrq6993-a11y
2026-10-15 00:06:16 +03:00
co-authored by Cursor
parent ed7df56a24
commit c71f951b90
+16 -2
View File
@@ -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();