mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 10:17:02 -06:00
G1: limit Cmd+Alt Group Selection to active Direct Selection
Pen Cmd-borrow keeps Direct Selection when Alt is held so guide copy and other Alt modifiers on the lent tool still work. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
bflatastic
co-authored by
Cursor
parent
fface52206
commit
2dcceea8e1
@@ -1609,14 +1609,15 @@ fn pen_with_cmd_borrows_direct_selection_and_goes_on_drawing() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmd_alt_lends_group_selection_when_direct_selection_was_last() {
|
||||
fn cmd_alt_lends_group_selection_while_direct_selection_is_active() {
|
||||
let (cmd, cmd_alt) = (Mods { cmd: true, ..Mods::default() }, Mods { cmd: true, alt: true, ..Mods::default() });
|
||||
let v = view();
|
||||
let mut s = session();
|
||||
// Cmd+Alt while the Pen borrows Direct Selection keeps Direct Selection (Alt is copy/subtract).
|
||||
s.select_tool("directSelection", v).unwrap();
|
||||
s.select_tool("pen", v).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 50.0, 50.0).with_mods(cmd_alt), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "groupSelection");
|
||||
assert_eq!(s.tool_id(), "directSelection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 50.0, 50.0).with_mods(cmd_alt), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "pen");
|
||||
// Cmd alone still lends Direct Selection.
|
||||
|
||||
@@ -104,8 +104,9 @@ impl Session {
|
||||
|
||||
/// The selection tool Cmd lends tool `id` for a drag: the one chosen last; until one is,
|
||||
/// Direct Selection to the tools that edit anchors (the Pen) and Selection to the others.
|
||||
/// Cmd+Alt lends Group Selection when the lend would be Direct Selection (including while
|
||||
/// Direct Selection is active). None for the other selection tools and the view tools.
|
||||
/// Cmd+Alt lends Group Selection while Direct Selection is active. Cmd still lends the last
|
||||
/// selection tool from other tools (Alt on the lent Direct Selection gesture stays copy/subtract).
|
||||
/// None for the other selection tools and the view tools.
|
||||
fn lent_tool(&self, id: &str, mods: &Mods) -> Option<&'static str> {
|
||||
use vectorcraft_tools::catalog::{edits_anchors, is_selection_tool};
|
||||
if matches!(id, "hand" | "zoom" | "rotateView") {
|
||||
@@ -117,11 +118,7 @@ impl Session {
|
||||
if is_selection_tool(id) {
|
||||
return None;
|
||||
}
|
||||
let base = self.last_selection_tool.unwrap_or(if edits_anchors(id) { "directSelection" } else { "selection" });
|
||||
if mods.alt && base == "directSelection" {
|
||||
return Some("groupSelection");
|
||||
}
|
||||
Some(base)
|
||||
Some(self.last_selection_tool.unwrap_or(if edits_anchors(id) { "directSelection" } else { "selection" }))
|
||||
}
|
||||
|
||||
/// A press with Cmd held (Ctrl elsewhere) and any other tool than a selection tool: the
|
||||
|
||||
Reference in New Issue
Block a user