Direct Selection: Ctrl held before pressing a handle mirrors the opposite handle

With Direct Selection chosen, Cmd/Ctrl lends the Selection tool for the
press. That loan also took presses on the end of a shown direction handle,
so a Ctrl-drag on a handle moved the whole object (and anything selected
with it), or drew a marquee where no object was under the handle. Only Ctrl
added after the drag began mirrored the opposite handle.

A new Tool::keeps_cmd_press lets the active tool keep a Cmd/Ctrl press.
Direct Selection keeps one without Alt on the end of a shown handle of a
path, of type on a path, or of a selected blend spine anchor, so the drag
mirrors the opposite handle, with Shift constraining it. The session's
lent_tool_at asks it, so the press, the cursor and the status bar agree. A
press elsewhere, on a handle of the bounding box the lent Selection tool
shows, or with Cmd+Alt (Group Selection) is still lent as before.

docs/gaps.md and docs/ui-parity.md describe the press.
This commit is contained in:
dotCooCoo committed 2026-12-03 11:33:13 -08:00
1 parent 3055e36ad5
commit 48ef8740e9
6 files changed
+120 -4

No files matched your search

+5 -2
View File
@@ -409,11 +409,14 @@ impl Session {
/// The selection tool a press at `p` with `mods` borrows ([`Self::lent_tool`]): none when
/// the Selection tool keeps a Cmd press on a selected object to select the object behind it
/// (Selection & Anchor Display › Command Click to Select Objects Behind), which an earlier Cmd
/// press armed ([`Self::behind_armed`]).
/// press armed ([`Self::behind_armed`]); none either when the active tool keeps the press
/// ([`vectorcraft_tools::Tool::keeps_cmd_press`]), as Direct Selection keeps one on a shown
/// direction handle to mirror the opposite handle.
fn lent_tool_at(&mut self, p: Point, mods: &Mods, view: ViewInfo) -> Option<&'static str> {
let id = self.lent_tool(self.tool.id(), mods)?;
let behind = self.tool.id() == "selection" && self.with_tool_cx(view, |_, cx| vectorcraft_tools::select::selects_behind_at(cx, p));
(!behind).then_some(id)
let kept = !behind && self.with_tool_cx(view, |t, cx| t.keeps_cmd_press(cx, p, *mods));
(!behind && !kept).then_some(id)
}
/// Is the press `ev` lent a selection tool ([`Self::lend_selection_tool`])? The frontend asks
@@ -332,6 +332,70 @@ fn direct_handle_cmd_before_press_still_lends_selection_and_returns_direct() {
assert_eq!(s.doc().unwrap().history.undo.len(), before.undo);
}
#[test]
fn direct_handle_cmd_held_before_pressing_a_handle_mirrors_instead_of_moving_the_path() {
let mut s = session();
let id = curve(&mut s, Point::new(50.0, 100.0));
let before = node(&s, id);
let undo = s.doc().unwrap().history.undo.len();
let end = Point::new(180.0, 100.0);
pointer(&mut s, PointerKind::Down, end, cmd());
assert_eq!(s.tool_id(), "directSelection", "a Cmd press on a shown handle is not lent to the Selection tool");
let q = Point::new(180.0, 160.0);
pointer(&mut s, PointerKind::Drag, q, cmd());
assert_mirrored(anchor(&s, id), q, AnchorKind::Smooth);
assert_other_geometry(&s, id, &before);
pointer(&mut s, PointerKind::Up, q, cmd());
assert_mirrored(anchor(&s, id), q, AnchorKind::Smooth);
assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1);
assert_eq!(s.tool_id(), "directSelection");
}
#[test]
fn direct_handle_cmd_shift_held_before_pressing_a_handle_constrains_and_mirrors() {
let mut s = session();
let id = curve(&mut s, Point::new(50.0, 100.0));
let before = node(&s, id);
let p = anchor(&s, id).p;
let shifted = Mods { shift: true, ..cmd() };
pointer(&mut s, PointerKind::Down, Point::new(180.0, 100.0), shifted);
assert_eq!(s.tool_id(), "directSelection");
let raw = Point::new(180.0, 150.0);
pointer(&mut s, PointerKind::Drag, raw, shifted);
assert_mirrored(anchor(&s, id), constrained(p, raw), AnchorKind::Smooth);
assert_other_geometry(&s, id, &before);
pointer(&mut s, PointerKind::Up, raw, shifted);
}
#[test]
fn direct_handle_cmd_press_on_a_handle_under_a_bounding_box_handle_still_lends_selection() {
let mut s = session();
let id = curve(&mut s, Point::new(50.0, 100.0));
// A second object widens the selection's bounding box so its top-middle handle lands on the
// curve's outgoing handle end at (180, 100).
let rect = run(&mut s, "path.create", json!({"anchors": [{"x": 330, "y": 150}, {"x": 340, "y": 150}, {"x": 340, "y": 200}], "closed": true}));
run(&mut s, "select.set", json!({"ids": [id.0, rect["id"]]}));
let boxed = ViewInfo { show_bbox: true, ..view() };
let end = Point::new(180.0, 100.0);
s.pointer(&PointerEvent::new(PointerKind::Down, end.x, end.y).with_mods(cmd()), boxed).unwrap();
assert_eq!(s.tool_id(), "selection", "the bounding box handle keeps the press for the lent Selection tool");
s.pointer(&PointerEvent::new(PointerKind::Up, end.x, end.y).with_mods(cmd()), boxed).unwrap();
assert_eq!(s.tool_id(), "directSelection");
}
#[test]
fn direct_handle_cmd_alt_before_pressing_a_handle_still_lends_group_selection() {
let mut s = session();
let id = curve(&mut s, Point::new(50.0, 100.0));
let a = anchor(&s, id);
let both = Mods { alt: true, ..cmd() };
pointer(&mut s, PointerKind::Down, Point::new(180.0, 100.0), both);
assert_eq!(s.tool_id(), "groupSelection", "Cmd+Alt keeps its Group Selection loan on a handle");
pointer(&mut s, PointerKind::Up, Point::new(180.0, 100.0), both);
assert_eq!(s.tool_id(), "directSelection");
assert_eq!(anchor(&s, id), a);
}
#[test]
fn direct_handle_cmd_that_lends_direct_selection_from_the_pen_does_not_mirror() {
let mut s = session();
@@ -490,6 +554,22 @@ fn direct_handle_pinned_blend_spine_cmd_shift_preserves_keys_and_mapping() {
assert_content(&s, &after);
}
#[test]
fn direct_handle_cmd_held_before_pressing_a_blend_spine_handle_mirrors() {
let mut s = session();
let id = blend(&mut s);
let (a, keys, _) = blend_state(&s, id);
pointer(&mut s, PointerKind::Down, a.h_out, cmd());
assert_eq!(s.tool_id(), "directSelection", "a Cmd press on a spine handle is not lent to the Selection tool");
let q = Point::new(180.0, 160.0);
pointer(&mut s, PointerKind::Drag, q, cmd());
pointer(&mut s, PointerKind::Up, q, cmd());
let (after, after_keys, _) = blend_state(&s, id);
near(after.p, a.p);
assert_mirrored(after, q, AnchorKind::Smooth);
assert_eq!(after_keys, keys, "the key objects did not move");
}
#[test]
fn direct_handle_incoming_drag_mirrors_outgoing_and_release_restores_ordinary_length() {
let mut s = session();
+27
View File
@@ -1046,6 +1046,33 @@ impl Tool for DirectSelectionTool {
self.lent_cmd = value.as_bool().unwrap_or(false);
}
}
/// A Cmd/Ctrl press without Alt on the end of a shown direction handle (a path's, type on a
/// path's or a selected blend spine anchor's) stays with Direct Selection, so the drag mirrors
/// the opposite handle ([`DirectSelectionTool::mirrors`]). A press on a handle of the bounding
/// box the lent Selection tool shows still goes to that tool, and so does a press anywhere else,
/// including one that a press of the tool gives to something it checks before the handles (a
/// corner widget, a bracket of type on a path, a gradient mesh point).
fn keeps_cmd_press(&self, cx: &ToolContext, p: Point, mods: Mods) -> bool {
if self.group || mods.alt || crate::select::bbox_handle_at(cx, p) {
return false;
}
let point = cx.point_tol();
// The order of the checks is the order `pointer` tries them in on a press.
let ev = PointerEvent::new(PointerKind::Down, p.x, p.y).with_mods(mods);
if CornerDrag::hit(cx, &ev, true).is_some_and(|c| !(c.on_unpicked() && c.widget_center().is_some_and(|w| yields_to_point(cx, p, w)))) {
return false;
}
if !over_path_type_anchor(cx, p) && BracketDrag::hit_any(cx, &ev).is_some() {
return false;
}
if self.spine.filter(|(id, _)| cx.selection.contains(*id)).and_then(|sel| hit_spine_handle(cx, sel, p, point)).is_some() {
return true;
}
if self.mesh.hit(cx, &cx.selection.objects, p).is_some() {
return false;
}
hit_handle(cx, p, point).is_some()
}
/// Escape during a drag (anchors, handles, segments, objects, type areas, blend spines, mesh
/// points, corner widgets, the brackets of type on a path, a marquee) cancels it: what it moved
/// goes back and the tool waits for the next press (#1743).
+6
View File
@@ -278,6 +278,12 @@ pub trait Tool: Send {
fn hover_object(&self, _cx: &ToolContext, _p: Point, _mods: Mods) -> Option<NodeId> {
None
}
/// Does a press at `p` with Cmd/Ctrl and `mods` held stay with the tool, instead of going to
/// the selection tool the session lends for Cmd/Ctrl? Direct Selection keeps a press on a shown
/// direction handle, where Cmd/Ctrl mirrors the opposite handle.
fn keeps_cmd_press(&self, _cx: &ToolContext, _p: Point, _mods: Mods) -> bool {
false
}
/// What the Info panel shows for the tool as it is now: the drag in progress (a move of the
/// selection, a gradient vector, a handle the Pen pulls out, a Scale, Rotate, Reflect or Shear
/// tool drag), or the Paintbrush's brush. None for a tool with nothing of its own to show.
+1 -1
View File
@@ -189,7 +189,7 @@ from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall
macOS cursor delivery (#2292) is narrowed to a native host adapter using the existing artwork and aligned 1×/2× representations. Headless tests cover visible fallbacks, preparation and ownership; native focus/menu/handback timing, mixed displays, Spotlight and full-screen Spaces remain open validation work (see [hardware parity](hardware-parity.md)). This does not close the interaction-fidelity gap or change its score/estimate.
- **Temporary handle mirroring (#7842):** with Direct Selection, add Control (Command on macOS) after a direction-handle drag begins to mirror the opposite handle at equal length. This includes ordinary paths, type on a path and blend spines; a missing opposite handle is pulled out while the modifier is held. At an open end, where no segment leaves the anchor on the other side, the handle moves as it does without the modifier. Letting go returns to the drag's normal handle behavior, Shift constrains before mirroring, and Alt takes independent-handle priority. The existing Control/Command-before-press Selection-tool loan is unchanged, and the Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again. This does not add a persistent coupling mode or change Pen, mesh or warp gestures; the broader G1 scope and estimates remain.
- **Temporary handle mirroring (#7842):** with Direct Selection, add Control (Command on macOS) after a direction-handle drag begins to mirror the opposite handle at equal length. This includes ordinary paths, type on a path and blend spines; a missing opposite handle is pulled out while the modifier is held. At an open end, where no segment leaves the anchor on the other side, the handle moves as it does without the modifier. Letting go returns to the drag's normal handle behavior, Shift constrains before mirroring, and Alt takes independent-handle priority. Control/Command held before pressing the end of a shown direction handle also mirrors: that press stays with Direct Selection, while a press anywhere else, or on a handle of the bounding box, is still lent to the Selection tool. The Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again. This does not add a persistent coupling mode or change Pen, mesh or warp gestures; the broader G1 scope and estimates remain.
- **Selection fill eligibility (#6625):** Path and compound-path interiors use any enabled non-None fill row (#6625). A lower visible fill remains selectable beneath a top None row in the same object; hidden-only and true-None interiors miss. Zero-opacity fills remain selectable. Original CPU-render and document-hit regressions in `crates/engine/tests/it/path_fill_hits.rs` cover seven Path and five Compound cases, including stroke edges, geometric outlines, Outline/path-only modes and compound holes. Hidden-fill and no-fill stroked paths must respect butt, round and square caps and bevel, round and miter joins. Focused cap/join CPU regressions passed. Scores and estimates unchanged.
+1 -1
View File
@@ -283,7 +283,7 @@ Every parity table on this page has a Headless column: the Summary table (12 are
| Drag a curved segment to bend it, a straight one to move its anchors | done | | unknown |
| Drag by an anchor of a path selected whole moves the whole path; Alt-drag by an anchor or a segment copies it, Alt toggles the copy during the drag, and the copy snaps by the anchor pressed, onto the original too | done | #1104 | unknown |
| Handles shown are the handles that drag; tolerance from Selection & Anchor Display | done | #494 | unknown |
| Drag a handle with Shift (45° about its anchor), Alt (move one handle alone), Control/Command added mid-drag (mirror the opposite handle), Space (ordinary paths: move its anchor and both handles) | done | handles snap to smart guides; handle and anchor drags no longer stall when the pointer leaves and re-enters the window, and a move in the release's frame lands (#834); #7842: temporary mirroring covers paths, transformed type on a path and blend spines, preserves the anchor mode and the pre-press selection-tool loan, and keeps Alt independent priority; the Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again; `crates/engine/tests/it/direct_handle_mirror.rs`; Space pressed during an ordinary path's handle drag moves its owning anchor and both handles; releasing Space while keeping the mouse down resumes handle adjustment. This also applies while Cmd/Ctrl lends Direct Selection to the Pen, which then continues the same path (#7237, request 3 only) | unknown |
| Drag a handle with Shift (45° about its anchor), Alt (move one handle alone), Control/Command added mid-drag or held before pressing the handle (mirror the opposite handle), Space (ordinary paths: move its anchor and both handles) | done | handles snap to smart guides; handle and anchor drags no longer stall when the pointer leaves and re-enters the window, and a move in the release's frame lands (#834); #7842: temporary mirroring covers paths, transformed type on a path and blend spines, preserves the anchor mode and the pre-press selection-tool loan away from handle ends and on bounding box handles, and keeps Alt independent priority; the Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again; `crates/engine/tests/it/direct_handle_mirror.rs`; Space pressed during an ordinary path's handle drag moves its owning anchor and both handles; releasing Space while keeping the mouse down resumes handle adjustment. This also applies while Cmd/Ctrl lends Direct Selection to the Pen, which then continues the same path (#7237, request 3 only) | unknown |
| Show handles when multiple anchors are selected; Highlight anchors on mouse over; anchor and handle size | done | Preferences › Selection & Anchor Display | unknown |
| Convert selected anchors to corner/smooth from the Control bar and Properties | done | | unknown |
| Cut path at selected anchors, Remove Anchor Points, Delete removes segments | done | Open-path anchor Delete removes adjoining segments without bridging the gap; #3380 (deletion only): disconnected survivors of an ordinary contour become independent selected sibling objects, while multi-subpath paths and compound members stay intact; targeted core and full-frame Delete/Backspace regressions pass for survivor selection and Undo/Redo. Explicit Remove Anchor Points keeps its reconnect/refit behavior; #1278: segment Delete preserves neighboring edges and endpoint anchors; a second Delete removes all selected surviving objects; explicit anchor Delete retains its behavior; #1674: Delete removes every selected anchor of a closed path and objects selected whole along with them, and keeps the surviving objects selected; #2241: Remove Anchor Points then selects the next anchor along the path (the one before at an open end), so it can be run again without picking each anchor | unknown |