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.
This commit is contained in:
dotCooCoo committed 2026-12-03 12:59:09 -08:00
1 parent c4856b8830
commit b44dbefe12
2 files changed
+22 -4

No files matched your search

+17
View File
@@ -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]
+5 -4
View File
@@ -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::<usize>() > 1;
let several = on && !ev.mods.shift && !self.mirrors(ev) && picks.values().map(BTreeSet::len).sum::<usize>() > 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 };