Direct Selection: Cmd/Ctrl mirrors an ordinary path's handle again

The handle drag that keeps Space translation sent path.setHandle without
`symmetric`, so Cmd/Ctrl no longer mirrored the opposite handle on an
ordinary path. The drag now records the mirror with the handle it accepts
and sends it on every preview, so the opposite handle stays mirrored while
Space moves the anchor. Alt still takes priority.
This commit is contained in:
dotCooCoo committed 2026-11-19 05:49:14 -08:00
1 parent 056059d8cb
commit 8b289bf6bb
2 files changed
+30

No files matched your search

@@ -122,6 +122,29 @@ fn direct_handle_baseline_cmd_added_mid_drag_mirrors_the_opposite() {
pointer(&mut s, PointerKind::Up, q, Mods { cmd: true, ..Mods::default() });
}
#[test]
fn direct_handle_cmd_mirror_holds_through_a_space_translation() {
let mut s = session();
let id = curve(&mut s, Point::new(50.0, 100.0));
press_handle(&mut s, Point::new(180.0, 100.0));
let q = Point::new(180.0, 160.0);
pointer(&mut s, PointerKind::Drag, q, cmd());
handles(anchor(&s, id), Point::new(20.0, 40.0), q, AnchorKind::Smooth);
// Space moves the anchor and both handles; the opposite handle stays mirrored.
let moved = Point::new(200.0, 190.0);
pointer(&mut s, PointerKind::Drag, moved, Mods { space: true, ..cmd() });
let a = anchor(&s, id);
near(a.p, Point::new(120.0, 130.0));
handles(a, Point::new(40.0, 70.0), Point::new(200.0, 190.0), AnchorKind::Smooth);
// Releasing Space without moving keeps the translated, mirrored handles.
pointer(&mut s, PointerKind::Drag, moved, cmd());
handles(anchor(&s, id), Point::new(40.0, 70.0), Point::new(200.0, 190.0), AnchorKind::Smooth);
let next = Point::new(220.0, 190.0);
pointer(&mut s, PointerKind::Drag, next, cmd());
assert_mirrored(anchor(&s, id), next, AnchorKind::Smooth);
pointer(&mut s, PointerKind::Up, next, cmd());
}
#[derive(Debug, PartialEq)]
struct Snapshot {
document: Value,
+7
View File
@@ -78,6 +78,8 @@ struct HandleDrag {
offset: Vec2,
space: bool,
independent: bool,
/// The opposite handle mirrors this one ([`DirectSelectionTool::mirrors`]).
symmetric: bool,
translated: bool,
}
@@ -948,6 +950,7 @@ impl Tool for DirectSelectionTool {
offset: Vec2::ZERO,
space: false,
independent: false,
symmetric: false,
translated: false,
})
}
@@ -1607,6 +1610,7 @@ impl DirectSelectionTool {
self.guides = guides;
drag.handle = q;
drag.independent = ev.mods.alt;
drag.symmetric = self.mirrors(ev);
}
}
drag.last = p;
@@ -1615,6 +1619,9 @@ impl DirectSelectionTool {
"id": id.0, "subpath": si, "anchor": ai, "which": if out { "out" } else { "in" },
"x": drag.handle.x, "y": drag.handle.y, "independent": drag.independent,
});
if drag.symmetric {
params["symmetric"] = json!(true);
}
if drag.translated {
params["at"] = json!([drag.at.x, drag.at.y]);
}