mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
Direct Selection: picked handles stay picked after a Cmd/Ctrl+Shift drag
With two direction handles picked, a Cmd/Ctrl+Shift press on one of them drags that handle alone with its opposite handle mirrored and its angle constrained. Shift kept the press from counting as a press on one of several picked handles, so the press did not record the picks, and its release after a drag, or Escape during it, left only the pressed handle. The press now records the picks for any mirroring press on one of several picked handles, with or without Shift. Shift still keeps a drag from moving every picked handle, and a Shift-click still adds or removes the pressed handle.
This commit is contained in:
1 parent
629b4f5b2c
commit
472d7f8e69
2 files changed
+28
-3
No files matched your search
@@ -150,6 +150,29 @@ fn picked_handles_stay_picked_after_a_cmd_drag_of_one_of_them() {
|
||||
near(anchor(&s, id, 2).h_in, Point::new(310.0, 140.0));
|
||||
}
|
||||
|
||||
/// Both handles stay picked after a Cmd/Ctrl+Shift drag of one of them, and after Escape during
|
||||
/// one.
|
||||
#[test]
|
||||
fn picked_handles_stay_picked_after_a_cmd_shift_drag_of_one_of_them() {
|
||||
for escape in [false, true] {
|
||||
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_shift = Mods { cmd: true, shift: true, ..Mods::default() };
|
||||
pointer(&mut s, PointerKind::Down, Point::new(180.0, 100.0), cmd_shift);
|
||||
pointer(&mut s, PointerKind::Drag, Point::new(220.0, 100.0), cmd_shift);
|
||||
if escape {
|
||||
s.tool_key(ToolKey::Escape, Mods::default(), view()).unwrap();
|
||||
}
|
||||
pointer(&mut s, PointerKind::Up, Point::new(220.0, 100.0), cmd_shift);
|
||||
let x = if escape { 180.0 } else { 220.0 };
|
||||
near(anchor(&s, id, 1).h_out, Point::new(x, 100.0));
|
||||
drag(&mut s, Point::new(300.0, 140.0), Point::new(310.0, 140.0), Mods::default());
|
||||
near(anchor(&s, id, 1).h_out, Point::new(x + 10.0, 100.0));
|
||||
near(anchor(&s, id, 2).h_in, Point::new(310.0, 140.0));
|
||||
}
|
||||
}
|
||||
|
||||
/// Escape during a Cmd/Ctrl drag of one of two picked handles puts the handle back and leaves both
|
||||
/// picked.
|
||||
#[test]
|
||||
|
||||
@@ -1932,7 +1932,7 @@ impl DirectSelectionTool {
|
||||
/// 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. The picked handles
|
||||
/// stay picked after such a Cmd/Ctrl drag of one of them.
|
||||
/// stay picked after such a Cmd/Ctrl or Cmd/Ctrl+Shift drag of one of them.
|
||||
fn press_handle(
|
||||
&mut self,
|
||||
cx: &ToolContext,
|
||||
@@ -1965,8 +1965,10 @@ impl DirectSelectionTool {
|
||||
};
|
||||
let handle = (id, (si, ai, out));
|
||||
let on = picks.get(&id).is_some_and(|set| set.contains(&handle.1));
|
||||
let among_several = on && !ev.mods.shift && picks.values().map(BTreeSet::len).sum::<usize>() > 1;
|
||||
let keeps_picks = among_several && self.mirrors(ev);
|
||||
let one_of_several = on && picks.values().map(BTreeSet::len).sum::<usize>() > 1;
|
||||
let among_several = one_of_several && !ev.mods.shift;
|
||||
// A mirroring drag keeps the picks with Shift held too.
|
||||
let keeps_picks = one_of_several && self.mirrors(ev);
|
||||
let begin = if among_several && !keeps_picks {
|
||||
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 };
|
||||
|
||||
Reference in new issue
Block a user