From bb529a0d88ca54d5f2f220732a76dc2cbe7d34a8 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Fri, 6 Nov 2026 14:57:48 -0800 Subject: [PATCH] Match measured Move marquee lock eligibility --- crates/engine/src/cmd/pick_cmds.rs | 15 +++--- crates/ui-egui/src/move_shift_click_tests.rs | 48 ++++++++++++++++++++ 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/pick_cmds.rs b/crates/engine/src/cmd/pick_cmds.rs index 24f352cfee..7ef0775a10 100644 --- a/crates/engine/src/cmd/pick_cmds.rs +++ b/crates/engine/src/cmd/pick_cmds.rs @@ -126,10 +126,10 @@ fn pick(s: &mut Session, p: &Value) -> Result { Ok(json!({ "layer": target.0 })) } -/// Layers whose content touches document rect `r`, top to bottom: visible, not fully locked, not -/// the locked Background (as Select › All Layers). A layer on an artboard counts only where the -/// board shows it, and without artboards only where the canvas does (#10665). With `group`, each -/// counts as its outermost group (deduplicated). +/// Visible layers whose content touches document rect `r`, top to bottom. The Move marquee skips +/// the locked Background and layers with effective Position or All locks (#11102). A layer on an +/// artboard counts only where the board shows it, and without artboards only where the canvas +/// does (#10665). With `group`, each counts as its outermost group (deduplicated). pub fn layers_in_rect(doc: &Document, r: Rect, group: bool) -> Vec { let mut out = Vec::new(); let canvas = doc.bounds(); @@ -140,7 +140,10 @@ pub fn layers_in_rect(doc: &Document, r: Rect, group: bool) -> Vec { for (path, _, l) in doc.walk().iter().rev() { if matches!(l.content, LayerContent::Group(_) | LayerContent::Adjustment(_)) || doc.is_background(l.id) - || doc.effective_locks(l.id).all + || { + let locks = doc.effective_locks(l.id); + locks.position || locks.all + } || !(1..=path.len()).all(|n| doc.layer_at(&path[..n]).is_some_and(|a| a.visible)) { continue; @@ -196,7 +199,7 @@ pub fn specs() -> Vec { label: "Select Layers in Marquee", menu: &[], shortcut: None, - params: r##"{"x":px,"y":px,"width":px,"height":px,"target":"layer|group"="layer","mode":"replace|add"="replace"} → {layers} (the layers whose content touches the rect, topmost first; no hits clears in replace mode, preserves in add mode)"##, + params: r##"{"x":px,"y":px,"width":px,"height":px,"target":"layer|group"="layer","mode":"replace|add"="replace"} → {layers} (layers whose content touches the rect, topmost first, skipping Position and All locks; no hits clears in replace mode, preserves in add mode)"##, enabled: has_doc, journal: true, run: select_in_rect, diff --git a/crates/ui-egui/src/move_shift_click_tests.rs b/crates/ui-egui/src/move_shift_click_tests.rs index 23b9e82035..ac191b3deb 100644 --- a/crates/ui-egui/src/move_shift_click_tests.rs +++ b/crates/ui-egui/src/move_shift_click_tests.rs @@ -103,6 +103,33 @@ fn point_clicks_toggle_members_but_keep_the_singleton_and_plain_multi_selection( assert_eq!(f.bounds(), before, "selection-only gestures move no pixels"); } +/// Shift-press changes the selected set immediately, and only that set moves on drag (#11102). +#[test] +fn shift_drag_moves_the_layers_selected_after_the_press() { + for (x, moving) in [(14.0, &[1_usize][..]), (38.0, &[0][..]), (62.0, &[0, 1, 2][..])] { + let mut f = Fixture::new(); + let [a, b, _] = f.layers; + f.select(&[a, b]); + let selected: Vec<_> = moving.iter().map(|&index| f.layers[index]).collect(); + let before = f.bounds(); + let shift = Modifiers::SHIFT; + + tool_event(&mut f.app, ToolEvent::Down { x, y: 14.0, pressure: 1.0 }, shift); + f.assert_selected(&selected); + assert_eq!(f.bounds(), before, "the press only selects"); + let x = x + 6.0; + tool_event(&mut f.app, ToolEvent::Move { x, y: 14.0, pressure: 1.0 }, shift); + tool_event(&mut f.app, ToolEvent::Up { x, y: 14.0 }, shift); + + f.assert_selected(&selected); + let mut expected = before; + for &index in moving { + expected[index + 1] = expected[index + 1].translate(6, 0); + } + assert_eq!(f.bounds(), expected, "only the layers selected after the press moved"); + } +} + #[test] fn locked_only_click_clears_each_measured_selection_and_shift_keeps_its_base() { let mut f = Fixture::new(); @@ -186,3 +213,24 @@ fn background_marquee_adds_with_shift_and_replaces_without_it_including_empty_hi assert_eq!(f.bounds(), before, "marquees select without moving pixels"); } } + +/// A Background marquee crosses A and B while C starts selected. Only movable hits join the +/// selection with Shift, or replace it without Shift (#11102). +#[test] +fn background_marquee_skips_position_and_all_locked_layers() { + for (locks, mods, expected) in [ + (json!({"position": true}), Modifiers::SHIFT, &[1_usize, 2][..]), + (json!({"position": true}), Modifiers::NONE, &[1][..]), + (json!({"all": true}), Modifiers::SHIFT, &[1, 2][..]), + (json!({}), Modifiers::SHIFT, &[0, 1, 2][..]), + ] { + let mut f = Fixture::new(); + let [a, _, c] = f.layers; + f.app.run("layer.setProps", json!({"layer": a.0, "locks": locks})).unwrap(); + f.select(&[c]); + let before = f.bounds(); + f.gesture([4.0, 26.0], [49.0, 13.0], mods); + f.assert_selected(&expected.iter().map(|&index| f.layers[index]).collect::>()); + assert_eq!(f.bounds(), before, "marquees select without moving pixels"); + } +}