From b44dbefe1243d0f4d337d77c24e4b3a5d0f257f6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 12:59:09 -0800 Subject: [PATCH] Direct Selection: a Cmd/Ctrl drag of one of several picked handles mirrors With two or more direction handles picked, a press without Shift on one of them started a drag of all the picked handles (path.moveHandles), which never mirrors. A Cmd/Ctrl press that Direct Selection now keeps on a shown handle therefore translated every picked handle instead of mirroring the opposite one. press_handle now drags the pressed handle alone when the press mirrors (Cmd/Ctrl without Alt, and not the press that lent the tool from another tool), so the drag mirrors its opposite handle and the other picked handles stay where they are. A drag without Cmd/Ctrl still moves every picked handle. --- crates/engine/tests/it/several_handles.rs | 17 +++++++++++++++++ crates/tools/src/direct.rs | 9 +++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/engine/tests/it/several_handles.rs b/crates/engine/tests/it/several_handles.rs index 7b5469c278..0d314f68ea 100644 --- a/crates/engine/tests/it/several_handles.rs +++ b/crates/engine/tests/it/several_handles.rs @@ -119,6 +119,23 @@ fn picked_handles_stay_picked_after_they_are_dragged() { near(anchor(&s, id, 2).h_in, Point::new(310.0, 170.0)); } +/// With two handles picked, Cmd/Ctrl held before the press on one of them drags that handle alone +/// and mirrors its opposite handle; the other picked handle stays where it is. +#[test] +fn a_cmd_drag_of_one_of_two_picked_handles_mirrors_its_opposite_handle() { + let (mut s, id) = session(); + click(&mut s, Point::new(180.0, 100.0), Mods::default()); + click(&mut s, Point::new(300.0, 140.0), shift()); + let cmd = Mods { cmd: true, ..Mods::default() }; + drag(&mut s, Point::new(180.0, 100.0), Point::new(180.0, 160.0), cmd); + assert_eq!(s.tool_id(), "directSelection"); + let a = anchor(&s, id, 1); + near(a.h_out, Point::new(180.0, 160.0)); + near(a.h_in, Point::new(20.0, 40.0)); + assert_eq!(a.kind, AnchorKind::Smooth); + near(anchor(&s, id, 2).h_in, Point::new(300.0, 140.0)); +} + /// A Shift-click on a picked handle takes it away, and Escape lets every picked handle go: a drag /// then moves only the handle pressed. #[test] diff --git a/crates/tools/src/direct.rs b/crates/tools/src/direct.rs index 06723b8fcf..9fa0fd754f 100644 --- a/crates/tools/src/direct.rs +++ b/crates/tools/src/direct.rs @@ -1923,9 +1923,10 @@ impl DirectSelectionTool { self.state = State::Handle { id, si, ai, out, drag: Some(drag) }; vec![Action::Preview("path.setHandle".into(), params)] } - /// A press on the end of the direction handle `(id, si, ai, out)`. Without Shift on one of two or - /// more picked handles (`picks`, as they were before the press), a drag moves them all; any - /// other press drags that handle alone, as before handles could be picked. + /// A press on the end of the direction handle `(id, si, ai, out)`. Without Shift or a mirroring + /// Cmd/Ctrl ([`Self::mirrors`]) on one of two or more picked handles (`picks`, as they were + /// before the press), a drag moves them all; any other press drags that handle alone, as before + /// handles could be picked, so a Cmd/Ctrl drag mirrors its opposite handle. fn press_handle( &mut self, cx: &ToolContext, @@ -1958,7 +1959,7 @@ impl DirectSelectionTool { }; let handle = (id, (si, ai, out)); let on = picks.get(&id).is_some_and(|set| set.contains(&handle.1)); - let several = on && !ev.mods.shift && picks.values().map(BTreeSet::len).sum::() > 1; + let several = on && !ev.mods.shift && !self.mirrors(ev) && picks.values().map(BTreeSet::len).sum::() > 1; let begin = if several { let items = picks.iter().flat_map(|(id, set)| set.iter().map(|h| (*id, *h))).collect(); self.state = State::Handles { handle, from, start: p, items, began: false };