mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 22:33:08 +00:00
Group Selection: a marquee selects the objects it touches, whole
A Group Selection marquee selected the anchor points inside it, as a Direct Selection marquee does, so a path it crossed was only partly selected. The Selection tool hides its bounding box while anchors are picked, so after switching to it no box appeared around the objects. The marquee now selects every object it touches, whole (members of groups too, and with Shift it toggles them), as an Alt-drag marquee with Direct Selection already does; a compound path it touches is selected whole, as that marquee selects it. E during the drag still selects only the objects entirely inside the marquee. Fixes #8047
This commit is contained in:
@@ -361,10 +361,10 @@ fn a_group_selection_marquee_leaves_out_a_drop_shadow() {
|
||||
run(&mut s, "select.none", json!({}));
|
||||
let sel = marquee(&mut s, "groupSelection", (85.0, 40.0), (95.0, 60.0));
|
||||
assert!(sel.objects.is_empty() && sel.anchors.is_empty(), "{sel:?}");
|
||||
// Over the shadow and B's upper left corner: that anchor of B.
|
||||
// Over the shadow and B's upper left corner: B whole, and not A (#8047).
|
||||
let sel = marquee(&mut s, "groupSelection", (90.0, 5.0), (105.0, 30.0));
|
||||
assert_eq!(sel.objects, [b]);
|
||||
assert_eq!(picked_points(&s, b), [Point::new(100.0, 20.0)]);
|
||||
assert!(sel.partial(b).is_none(), "{sel:?}");
|
||||
// With E, a marquee around B that crosses A's shadow selects B whole, and not A.
|
||||
run(&mut s, "select.none", json!({}));
|
||||
let v = ViewInfo::default();
|
||||
|
||||
@@ -1255,9 +1255,11 @@ fn direct_selection_shift_marquee_toggles_anchors() {
|
||||
let st = s.doc().unwrap();
|
||||
assert_eq!(st.selection.objects, vec![a]);
|
||||
assert_eq!(st.selection.partial(a), None);
|
||||
// Group Selection's marquee toggles the same way.
|
||||
// Group Selection's marquee toggles the paths it touches whole: a leaves, b joins (#8047).
|
||||
gesture(&mut s, "groupSelection", &top, shift);
|
||||
assert_eq!(s.doc().unwrap().selection.partial(a).map(|p| p.len()), Some(2));
|
||||
let st = s.doc().unwrap();
|
||||
assert_eq!(st.selection.objects, vec![b]);
|
||||
assert_eq!(st.selection.partial(b), None);
|
||||
}
|
||||
|
||||
/// The Lasso: Shift adds anchors, Alt takes them away, and neither drops the rest of the
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
//! (the selected ones when anchors are selected; Alt-click cycles their kind, double-click opens
|
||||
//! the Corners dialog).
|
||||
//! Group Selection: click selects the leaf; each further click on it adds the next enclosing group;
|
||||
//! its marquee works as Direct Selection's, and E pressed during the drag makes it select only the
|
||||
//! objects entirely inside it (members of groups too), whole.
|
||||
//! its marquee selects every object it touches (members of groups too), whole, and E pressed during
|
||||
//! the drag makes it select only the objects entirely inside it, whole.
|
||||
//! In isolation mode both pick only the isolated object and what is inside it: anchors, segments,
|
||||
//! paths and groups outside it stay put.
|
||||
//! Both move objects selected as a whole as the Selection tool does, snapping alike. When the
|
||||
@@ -1644,9 +1644,9 @@ impl DirectSelectionTool {
|
||||
return vec![Action::Exec("select.none".into(), json!({}))];
|
||||
}
|
||||
// With Group Selection's enclosed marquee, the tool selects the objects inside it
|
||||
// (members of groups too), each whole, as a click selects one; with an Alt-marquee, every
|
||||
// object it touches, each whole.
|
||||
if enclosed || whole {
|
||||
// (members of groups too), each whole, as a click selects one; with Group Selection's
|
||||
// marquee or an Alt-marquee, every object it touches, each whole (#8047).
|
||||
if enclosed || whole || self.group {
|
||||
let mut touched = vectorcraft_doc::hit::marquee_in_view(cx.doc, r, cx.isolation, true, cx.outline);
|
||||
let editable = cx.doc.editable();
|
||||
touched.retain(|id| editable(*id));
|
||||
|
||||
@@ -465,10 +465,7 @@ fn a_marquee_selects_frame_anchors_of_area_type() {
|
||||
let mut g = DirectSelectionTool::new(true);
|
||||
g.pointer(&cx1, &ev(PointerKind::Down, 400.0, 280.0));
|
||||
g.pointer(&cx1, &ev(PointerKind::Drag, 440.0, 360.0));
|
||||
assert_eq!(
|
||||
g.pointer(&cx1, &ev(PointerKind::Up, 440.0, 360.0)),
|
||||
vec![Action::Exec("select.anchorsMany".into(), json!({"items": [{"id": text.0, "anchors": []}], "mode": "set"}))]
|
||||
);
|
||||
assert_eq!(g.pointer(&cx1, &ev(PointerKind::Up, 440.0, 360.0)), vec![Action::Exec("select.set".into(), json!({"ids": [text.0]}))]);
|
||||
}
|
||||
|
||||
/// A click without a drag on one of several selected frame anchors selects it alone, as a click on
|
||||
@@ -1233,8 +1230,9 @@ fn marquee_selects_type_it_touches() {
|
||||
assert_eq!(a, vec![Action::Exec("select.anchorsMany".into(), json!({"items": [{"id": rect.0, "anchors": [[0, 1]]}], "mode": "set"}))]);
|
||||
}
|
||||
|
||||
/// A marquee across a member of an Intertwine group selects the member's anchors, as in a
|
||||
/// plain group, and not the Intertwine group whole.
|
||||
/// A Direct Selection marquee across a member of an Intertwine group selects the member's anchors,
|
||||
/// as in a plain group, and not the Intertwine group whole; a Group Selection marquee selects the
|
||||
/// member whole.
|
||||
#[test]
|
||||
fn marquee_selects_the_anchors_of_intertwine_members() {
|
||||
let mut d = vectorcraft_doc::Document::new(500.0, 500.0);
|
||||
@@ -1258,11 +1256,17 @@ fn marquee_selects_the_anchors_of_intertwine_members() {
|
||||
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 150.0, 50.0));
|
||||
let actions = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 250.0, 150.0));
|
||||
let items = json!([{"id": a.0, "anchors": [[0, 1]]}]);
|
||||
assert_eq!(actions, vec![Action::Exec("select.anchorsMany".into(), json!({"items": items, "mode": "set"}))], "group: {group}");
|
||||
let want = if group {
|
||||
Action::Exec("select.set".into(), json!({"ids": [a.0]}))
|
||||
} else {
|
||||
Action::Exec("select.anchorsMany".into(), json!({"items": items, "mode": "set"}))
|
||||
};
|
||||
assert_eq!(actions, vec![want], "group: {group}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Shift-drag a marquee: the anchors inside toggle (#483), with Group Selection too.
|
||||
/// Shift-drag a marquee: the anchors inside toggle (#483); with Group Selection, the objects it
|
||||
/// touches toggle whole.
|
||||
#[test]
|
||||
fn shift_marquee_toggles_anchors() {
|
||||
let (d, id) = doc_with_rect();
|
||||
@@ -1275,10 +1279,46 @@ fn shift_marquee_toggles_anchors() {
|
||||
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 150.0, 50.0).with_mods(shift));
|
||||
t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 250.0, 150.0).with_mods(shift));
|
||||
let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 250.0, 150.0).with_mods(shift));
|
||||
assert_eq!(a, vec![Action::Exec("select.anchorsMany".into(), json!({"items": [{"id": id.0, "anchors": [[0, 1]]}], "mode": "toggle"}))]);
|
||||
let want = if group {
|
||||
Action::Exec("select.toggle".into(), json!({"ids": [id.0]}))
|
||||
} else {
|
||||
Action::Exec("select.anchorsMany".into(), json!({"items": [{"id": id.0, "anchors": [[0, 1]]}], "mode": "toggle"}))
|
||||
};
|
||||
assert_eq!(a, vec![want], "group: {group}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #8047: a Group Selection marquee across part of two members of a group selects both members
|
||||
/// whole, not the anchors inside it and not the group, and leaves the member it misses.
|
||||
#[test]
|
||||
fn a_group_selection_marquee_selects_the_members_it_touches_whole() {
|
||||
let mut d = vectorcraft_doc::Document::new(600.0, 400.0);
|
||||
let l = d.layers[0].id;
|
||||
let (g, a, b, c) = (d.alloc_id(), d.alloc_id(), d.alloc_id(), d.alloc_id());
|
||||
let path = |id, x: f64| {
|
||||
vectorcraft_doc::Node::path(
|
||||
id,
|
||||
vectorcraft_geom::shapes::rectangle(Rect::new(x, 120.0, x + 100.0, 240.0)),
|
||||
vectorcraft_doc::Appearance::default_art(),
|
||||
)
|
||||
};
|
||||
d.insert(Some(l), 0, vectorcraft_doc::Node::group(g, vec![])).unwrap();
|
||||
for (i, (id, x)) in [(a, 100.0), (b, 250.0), (c, 400.0)].into_iter().enumerate() {
|
||||
d.insert(Some(g), i, path(id, x)).unwrap();
|
||||
}
|
||||
let (s, p) = (Selection::default(), paint());
|
||||
let cx = cx(&d, &s, &p);
|
||||
let mut t = DirectSelectionTool::new(true);
|
||||
// From (150, 95) to (300, 265): the right side of A and the left side of B.
|
||||
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 150.0, 95.0));
|
||||
t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 300.0, 265.0));
|
||||
let up = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 300.0, 265.0));
|
||||
let Some(Action::Exec(cmd, params)) = up.first() else { panic!("{up:?}") };
|
||||
assert_eq!(cmd, "select.set");
|
||||
let ids: BTreeSet<String> = params["ids"].as_array().unwrap().iter().map(|v| v.to_string()).collect();
|
||||
assert_eq!(ids, [json!(a.0), json!(b.0)].iter().map(|v| v.to_string()).collect());
|
||||
}
|
||||
|
||||
/// #4890: Alt held at the press makes a Direct Selection marquee Group Selection's for the drag:
|
||||
/// it selects each path it touches whole (with Shift, toggles it), not the anchors inside it, and
|
||||
/// leaves the paths it misses; the Group Selection cursor stays until the release.
|
||||
|
||||
@@ -1143,7 +1143,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- **Shaper:** uneven squares and rectangles become live rectangles even when drawing begins mid-edge. Recognition uses uniformly spaced samples and closed-loop corners, fits rectangle edges/angles rather than requiring a nearly perfect bounding-box fill, and includes the pointer-release position. Rectangles/squares and ellipses snap to 45° steps, hexagons to 90°, and triangles point up or down; lines keep their free angle even with Shift. Shaper Groups retain the live originals, merge regions with the gesture-origin fill, punch fills independently from strokes, remove boundaries on exiting scribbles and trim protruding stroke pieces. Source moves/resizes re-evaluate the result in the same undo step; double-click enters construction editing, and with the Shaper or Selection tool a click on the arrow widget beside a Shaper Group's original shapes switches the group between Face Selection and Construction mode. Native save/reopen, face recoloring, Release and Expand are covered. Finer gesture heuristics remain.
|
||||
In Construction mode, a Selection-tool drag that drops an original shape wholly outside the bounds of the group's original shapes takes it out of the group in the move's undo step (Remove from Shaper Group, `shaper.releaseSource`): the shape becomes a path above the group and stays selected, and a group left with no shapes is removed. Engine tests drag a shape out of a two-shape group and back across the bounds, take the last shape out, undo, and save the result.
|
||||
With a Shaper Group or one of its faces selected, a Shaper click within 3 screen pixels of an original shape's outline enters Construction mode with that shape selected, even where the outline runs through a merged face (`shaper.select`'s `tolerance`; [help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/draw-shapes/create-shapes-with-the-shaper-tool.html)). Test: `tests::shaper::shaper_click_on_an_original_outline_enters_construction_mode`.
|
||||
- **Selection:** Selection, Direct/Group Selection, Magic Wand, Lasso. A Shift-drag marquee toggles what it reaches: objects with the Selection tool, anchors with Direct and Group Selection (#483); the Lasso adds with Shift and subtracts with Alt. Dragging a path segment with Direct Selection bends it when it's curved (its anchors stay) and moves its two anchors when it's straight, one undo step; the fill, Shift or Alt still pick the whole path (Alt-drag copies it).
|
||||
- **Selection:** Selection, Direct/Group Selection, Magic Wand, Lasso. A Shift-drag marquee toggles what it reaches: objects with the Selection tool, anchors with Direct Selection (#483), and with Group Selection the objects it touches, whole (#8047); the Lasso adds with Shift and subtracts with Alt. Dragging a path segment with Direct Selection bends it when it's curved (its anchors stay) and moves its two anchors when it's straight, one undo step; the fill, Shift or Alt still pick the whole path (Alt-drag copies it).
|
||||
The search for the segment of a path nearest a point, which Direct Selection runs to pick the cursor over a segment, skips each segment whose anchors and handles lie in a box farther from the point than a segment already measured, starting with a segment at the anchor nearest the point. The segment found is the same as before. Over a segment of an open path of 200,000 anchors, the cursor takes 51 ms instead of 59 ms in a release build (`cargo run --release -p vectorcraft-engine --example anchor_bench`).
|
||||
A Direct Selection marquee over part of a segment, with neither of its anchors inside, selects that segment as a click on it does (Shift toggles it), as [Selecting objects](http://web.archive.org/web/20211230015528/https://helpx.adobe.com/illustrator/using/selecting-objects.html) describes (#4654).
|
||||
To find those segments, the marquee skips each segment whose anchors and handles all lie past one side of it and tests only the rest exactly, without building a path for each segment. It selects the same segments as before, and a marquee over a path of many anchors finishes sooner.
|
||||
@@ -1157,7 +1157,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
When a clip group, a layer with a clipping mask or a single object in one is isolated, the Selection, Direct Selection and Group Selection tools also select the art that the mask hides, by a click or a marquee, and a drag from that art moves it (#3748). In isolation mode the canvas Unlock submenu also lists that art when it is locked. Outside isolation mode a click selects clipped art only inside the mask.
|
||||
A marquee selects a Shaper Group only when it reaches the art the group shows, not the original shapes kept under it, and Direct Selection's clicks and marquee do not select those shapes' anchor points. In Construction mode a marquee selects the original shapes, and Direct Selection selects their anchor points.
|
||||
While an opacity mask or a pattern is edited, a Shaper double-click on a Shaper Group in the mask or pattern art selects the original shape under the pointer without entering Construction mode, the Shaper Group's mode widget does not show, and a Shaper scribble, Release and Expand keep the editing layer isolated.
|
||||
A marquee selects an Intertwine group only when it reaches one of the group's members, as for a plain group, and it selects a repeat only when it reaches one of the copies the repeat draws. Direct and Group Selection's marquees select the anchor points of an Intertwine group's members, not the group, and Group Selection's E marquee selects the members inside it.
|
||||
A marquee selects an Intertwine group only when it reaches one of the group's members, as for a plain group, and it selects a repeat only when it reaches one of the copies the repeat draws. Direct Selection's marquee selects the anchor points of an Intertwine group's members, not the group; Group Selection's marquee selects the members it touches, whole, and its E marquee selects the members inside it.
|
||||
A key object needs another selected object outside it. A Shift-click or any other change that leaves one object selected clears the key, and `select.key` sets none on one object or on a group selected with only its own members. With one object selected, the Align panel, the Control bar and the Properties panel align it to the artboard whatever Align To is set to.
|
||||
With two or more objects selected and no key object, Align to Key Object makes the topmost of them the key, whatever order they were selected in, and the Align panel, the Control bar and the Properties panel align to it. Align To keeps its Selection or Artboard choice and shows it again once the key is cleared.
|
||||
The Control bar has an Align To menu after its Align buttons. The public documentation offers Align to Selection, Align to Key Object and Align to Artboard in the Control panel (VectorCraft's Control bar) as well as in the Align panel ([Move, align, and distribute objects](https://web.archive.org/web/20250115013546/https://helpx.adobe.com/illustrator/using/moving-aligning-distributing-objects.html)). The menu shows the icon of the choice the Align panel's Align To shows, and a pick sets the same choice as the Align panel's buttons do. Align to Key Object is off while no key object can be made. When the bar runs short of room, it drops the Distribute buttons first, then the Align To menu, then the Align buttons.
|
||||
|
||||
Reference in New Issue
Block a user