From 3e8d2932328b46dcb01d20a5a3561838ad37177d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 01:40:13 -0800 Subject: [PATCH 1/2] Direct Selection: a Shift-click on a member of a selected group deselects only that member With a group selected, a Direct Selection Shift-click on the fill of one of its paths ran select.toggle on the path, which added the path beside the group. The path stayed selected through the group, and so did everything else in it. The new select.remove command takes each target out of the selection. For a target inside a selected group or compound path, Selection::expand_to first selects the objects inside the outermost selected one on the way down to the target, in its place, so the rest of the group stays selected. Hidden and locked objects and a Shaper Group's original shapes are left out. Direct Selection's Shift-click on such a path runs select.remove, and a Shift-drag from there moves nothing. A Shift-click on one of the path's anchors runs select.anchors with mode toggle, which now opens the group the same way and deselects only that anchor. A path selected beside the group around it, as Group Selection leaves it, is taken out with the group. No public documentation describes this case, so this is VectorCraft's own rule. --- crates/doc/src/selection.rs | 42 ++++++++++++ crates/doc/src/selection/tests.rs | 66 +++++++++++++++++++ crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/engine/src/cmd/select.rs | 33 +++++++++- crates/engine/tests/it/selection_commands.rs | 43 +++++++++--- crates/tools/src/direct.rs | 13 +++- crates/tools/src/direct/tests.rs | 46 +++++++++++++ docs/mcp.md | 14 ++-- docs/target-app-parity.md | 1 + 9 files changed, 245 insertions(+), 14 deletions(-) diff --git a/crates/doc/src/selection.rs b/crates/doc/src/selection.rs index f0b8a5609f..90afaad022 100644 --- a/crates/doc/src/selection.rs +++ b/crates/doc/src/selection.rs @@ -187,6 +187,48 @@ impl Selection { self.key_anchor = None; } } + /// Select `id` itself in place of the selected object around it, keeping the rest of that + /// object selected. The outermost selected object that holds `id` (a group, or a compound path + /// selected whole) and every selected object between it and `id` leave the selection. In their + /// place go, at the outermost one's position, the objects inside them on the way down to `id`, + /// level by level: at each level the objects beside the one that holds `id`, and at the last + /// level `id` and the objects beside it, each level in stacking order. A Shaper Group's + /// original shapes, and objects that are hidden, locked or on a locked artboard + /// ([`Document::is_editable`]), are not taken in. + /// + /// When `id` is also selected itself, it keeps its place in the selection. + /// + /// Returns whether the selection changed. It does not change when `id` is not inside a selected + /// object, is inside one that is partly selected (anchors or segments), or is one of a selected + /// Shaper Group's original shapes. + pub fn expand_to(&mut self, doc: &Document, id: NodeId) -> bool { + let Some(chain) = doc.ancestry(id) else { return false }; + let Some(top) = chain.iter().position(|a| self.contains(*a)) else { return false }; + let holder = chain[top]; + if self.anchors.contains_key(&holder) || self.segments.contains_key(&holder) { + return false; + } + let editable = doc.editable(); + let mut members = Vec::new(); + for pair in chain[top..].windows(2) { + let Some(n) = doc.node(pair[0]) else { return false }; + let originals = usize::from(n.extras().shaper.is_some()); + let children = n.children().map(Vec::as_slice).unwrap_or_default(); + if children.iter().take(originals).any(|c| c.id == pair[1]) { + return false; + } + members.extend(children.iter().skip(originals).map(|c| c.id).filter(|c| *c == id || (*c != pair[1] && editable(*c)))); + } + if !members.contains(&id) { + return false; + } + let around: HashSet = chain[top..chain.len() - 1].iter().copied().collect(); + let at = self.objects.iter().take_while(|o| **o != holder).filter(|o| !around.contains(o)).count(); + self.remove_all(around); + let selected: HashSet = self.objects.iter().copied().collect(); + self.objects.splice(at..at, members.into_iter().filter(|m| !selected.contains(m))); + true + } /// [`Self::add`] for each of `ids` in order, going through the selected objects once. pub fn add_all(&mut self, ids: impl IntoIterator) { self.each(ids, false); diff --git a/crates/doc/src/selection/tests.rs b/crates/doc/src/selection/tests.rs index 60ad1b4328..d685b73bf7 100644 --- a/crates/doc/src/selection/tests.rs +++ b/crates/doc/src/selection/tests.rs @@ -45,6 +45,72 @@ fn remove_all_does_what_removing_each_does() { assert_eq!(none, s); } +/// `expand_to` selects a member of a selected group in the group's place, beside the group's other +/// objects at each level down to it, and leaves a selection it cannot open alone. +#[test] +fn expand_to_selects_a_member_in_place_of_its_selected_group() { + let rect = || vectorcraft_geom::shapes::rectangle(vectorcraft_geom::Rect::new(0.0, 0.0, 10.0, 10.0)); + let mut d = Document::new(100.0, 100.0); + let l = d.layers[0].id; + let [x, g, e, h, b, c, dd] = [(); 7].map(|_| d.alloc_id()); + let path = |id| Arc::new(Node::path(id, rect(), crate::Appearance::default_art())); + let inner = Node::group(h, vec![path(b), path(c)]); + let group = Node::group(g, vec![path(e), Arc::new(inner), path(dd)]); + d.insert(Some(l), 0, Node::path(x, rect(), crate::Appearance::default_art())).unwrap(); + d.insert(Some(l), 1, group).unwrap(); + let mut s = Selection::default(); + s.set([x, g]); + s.key = Some(g); + assert!(s.expand_to(&d, b)); + assert_eq!(s.objects, [x, e, dd, b, c], "the group's objects beside the inner group, then the inner group's"); + assert_eq!(s.key, None, "the group leaves the selection with its key"); + assert!(!s.expand_to(&d, b), "a member selected itself with nothing selected around it"); + assert!(!s.expand_to(&d, x), "an object inside nothing selected"); + // A member selected beside the group around it keeps its place. + let mut with_member = Selection::default(); + with_member.set([b, g]); + assert!(with_member.expand_to(&d, b)); + assert_eq!(with_member.objects, [b, e, dd, c]); + // An inner group selected beside the group leaves the selection too. + let mut both = Selection::default(); + both.set([h, g]); + assert!(both.expand_to(&d, b)); + assert_eq!(both.objects, [e, dd, b, c]); + // A group with anchors recorded for it is left as it is. + let mut partly = Selection::default(); + partly.set([g]); + partly.anchors.insert(g, BTreeSet::from([(0, 0)])); + let before = partly.clone(); + assert!(!partly.expand_to(&d, b)); + assert_eq!(partly, before); + // A Shaper Group opens to its faces and never to its original shapes. + let [shaper, sources, o1, o2, face] = [(); 5].map(|_| d.alloc_id()); + let mut sources_group = Node::group(sources, vec![path(o1), path(o2)]); + sources_group.name = Some(crate::shaper::SOURCES.into()); + let mut shaper_group = Node::group(shaper, vec![Arc::new(sources_group), path(face)]); + shaper_group.extras_mut().shaper = Some(Box::default()); + d.insert(Some(l), 2, shaper_group).unwrap(); + let mut shaped = Selection::default(); + shaped.set([shaper]); + let before = shaped.clone(); + assert!(!shaped.expand_to(&d, o1), "an original shape"); + assert_eq!(shaped, before); + assert!(shaped.expand_to(&d, face)); + assert_eq!(shaped.objects, [face]); + // Hidden and locked objects beside the member stay out of the selection. + let [k, shown, hidden, locked, last] = [(); 5].map(|_| d.alloc_id()); + let mut hidden_path = Node::path(hidden, rect(), crate::Appearance::default_art()); + hidden_path.visible = false; + let mut locked_path = Node::path(locked, rect(), crate::Appearance::default_art()); + locked_path.locked = true; + let kept = Node::group(k, vec![path(shown), Arc::new(hidden_path), Arc::new(locked_path), path(last)]); + d.insert(Some(l), 3, kept).unwrap(); + let mut with_locked = Selection::default(); + with_locked.set([k]); + assert!(with_locked.expand_to(&d, last)); + assert_eq!(with_locked.objects, [shown, last]); +} + /// A selection with every field set: objects 1 to 6 with 3 listed twice, anchors, segments, a key, /// a key anchor, a target, slices, guides, a key guide, new art, a symbol part and an on-path member. fn seeded() -> Selection { diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index 3d5723b7d3..60f6de583b 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -544,6 +544,7 @@ pub(super) const ALLOWED: &[&str] = &[ "select.object.strayPoints", "select.object.textObjects", "select.recall", + "select.remove", "select.reselect", "select.same.appearance", "select.same.appearanceAttribute", diff --git a/crates/engine/src/cmd/select.rs b/crates/engine/src/cmd/select.rs index b7a6043a98..e733204932 100644 --- a/crates/engine/src/cmd/select.rs +++ b/crates/engine/src/cmd/select.rs @@ -77,6 +77,15 @@ pub fn specs() -> Vec { has_doc, toggle ), + cmd!( + "select.remove", + "Remove from Selection", + [], + None, + "{id} or {ids: [id…]}: each one leaves the selection; one inside a selected group or compound path (Direct Selection's Shift-click on it) leaves it too, and the rest of that group stays selected: the outermost selected object around it gives way to the objects inside it on the way down, leaving out hidden and locked objects; an id that is neither selected nor inside a selected object is left alone; all ids must be non-negative integers naming existing objects → {count, ids} (resulting selection)", + has_doc, + remove + ), cmd!( "select.key", "Cancel Key Object", @@ -556,6 +565,25 @@ fn toggle(s: &mut Session, p: &Value) -> Result { selection_result(s) } +fn remove(s: &mut Session, p: &Value) -> Result { + const C: &str = "select.remove"; + let ids = if p.get("ids").is_some() { + checked_ids_param(s, p, "ids", C)? + } else { + let value = p.get("id").ok_or_else(|| bad(C, "missing id or ids"))?; + vec![checked_id(s, value, C)?] + }; + s.select(|d, sel| { + for id in ids { + sel.expand_to(d, id); + if sel.contains(id) { + sel.remove(id); + } + } + })?; + selection_result(s) +} + fn selection_result(s: &Session) -> Result { let selection = &s.doc()?.selection; Ok(json!({ "count": selection.len(), "ids": selection.objects })) @@ -930,7 +958,10 @@ fn anchors(s: &mut Session, p: &Value) -> Result { } // A path selected as a whole has every anchor selected: toggle and add start from them all, // but only when no partial anchor selection is active and only on a single isolated object. - let whole = sel.contains(id) && sel.partial(id).is_none() && sel.anchors.is_empty() && sel.objects.len() <= 1; + // A toggle on a path inside a selected group selects the path itself in the group's place, + // beside the group's other objects, and starts from all its anchors. + let inside = mode == "toggle" && sel.expand_to(d, id); + let whole = inside || (sel.contains(id) && sel.partial(id).is_none() && sel.anchors.is_empty() && sel.objects.len() <= 1); sel.add(id); // A segment pick's endpoints aren't selected anchors: start from none of them. if sel.segments.remove(&id).is_some() { diff --git a/crates/engine/tests/it/selection_commands.rs b/crates/engine/tests/it/selection_commands.rs index c5bcc1d9dd..6a1f69b96e 100644 --- a/crates/engine/tests/it/selection_commands.rs +++ b/crates/engine/tests/it/selection_commands.rs @@ -16,7 +16,7 @@ fn session() -> (Session, NodeId, NodeId) { #[test] fn selection_commands_reject_invalid_ids_without_changing_state() { - for command in ["select.set", "select.add", "select.toggle"] { + for command in ["select.set", "select.add", "select.toggle", "select.remove"] { let (mut s, a, b) = session(); s.execute("select.set", &json!({"ids": [b.0, a.0]})).unwrap(); s.execute("select.anchors", &json!({"id": a.0, "anchors": [[0, 0]], "mode": "add"})).unwrap(); @@ -37,7 +37,7 @@ fn selection_commands_reject_invalid_ids_without_changing_state() { #[test] fn selection_commands_require_an_id_array() { - for command in ["select.set", "select.add", "select.toggle"] { + for command in ["select.set", "select.add", "select.toggle", "select.remove"] { let (mut s, _, _) = session(); for params in [json!({}), json!({"ids": null}), json!({"ids": 2}), json!({"ids": "2"}), json!({"ids": true})] { let selection = s.active().unwrap().selection.clone(); @@ -78,13 +78,40 @@ fn toggle_and_add_handle_each_listed_id_in_order() { #[test] fn single_id_toggle_validates_before_mutating() { let (mut s, a, _) = session(); - for invalid in [json!(999), json!(-1), json!(2.5), json!("2"), Value::Null, json!(true)] { - let selection = s.active().unwrap().selection.clone(); - assert!(matches!(s.execute("select.toggle", &json!({"id": invalid})), Err(EngineError::BadParams { .. }))); - assert_eq!(s.active().unwrap().selection, selection); + for command in ["select.toggle", "select.remove"] { + for invalid in [json!(999), json!(-1), json!(2.5), json!("2"), Value::Null, json!(true)] { + let selection = s.active().unwrap().selection.clone(); + assert!(matches!(s.execute(command, &json!({"id": invalid})), Err(EngineError::BadParams { .. })), "{command}: {invalid}"); + assert_eq!(s.active().unwrap().selection, selection); + } + // A malformed array must not silently fall back to a valid single id. + assert!(s.execute(command, &json!({"ids": "bad", "id": a.0})).is_err()); } - // A malformed array must not silently fall back to a valid single id. - assert!(s.execute("select.toggle", &json!({"ids": "bad", "id": a.0})).is_err()); +} + +/// Direct Selection's Shift-click on a member of a selected group: `select.remove` deselects the +/// member and keeps the group's other objects selected, and `select.anchors` with mode toggle on +/// one of the member's anchors deselects only that anchor. +#[test] +fn remove_and_anchor_toggle_open_a_selected_group() { + let (mut s, a, b) = session(); + let c = NodeId(s.execute("shape.rectangle", &json!({"x": 40, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [a.0, b.0, c.0]})).unwrap(); + let group = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + let reset = |s: &mut Session| s.execute("select.set", &json!({"ids": [group.0]})).unwrap(); + reset(&mut s); + assert_eq!(s.execute("select.remove", &json!({"id": b.0})).unwrap(), json!({"count": 2, "ids": [a.0, c.0]})); + assert_eq!(s.execute("select.remove", &json!({"id": b.0})).unwrap(), json!({"count": 2, "ids": [a.0, c.0]}), "b is not selected"); + assert_eq!(s.execute("select.remove", &json!({"ids": [c.0]})).unwrap(), json!({"count": 1, "ids": [a.0]})); + // A member selected beside its group (as Group Selection leaves it) leaves the selection with the group. + s.execute("select.set", &json!({"ids": [group.0, b.0]})).unwrap(); + assert_eq!(s.execute("select.remove", &json!({"id": b.0})).unwrap(), json!({"count": 2, "ids": [a.0, c.0]})); + reset(&mut s); + s.execute("select.anchors", &json!({"id": a.0, "anchors": [[0, 1]], "mode": "toggle"})).unwrap(); + let sel = &s.active().unwrap().selection; + assert_eq!(sel.objects, [a, b, c]); + assert_eq!(sel.partial(a), Some(&[(0, 0), (0, 2), (0, 3)].into()), "the other anchors of a stay selected"); + assert_eq!((sel.partial(b), sel.partial(c)), (None, None), "b and c stay selected whole"); } #[test] diff --git a/crates/tools/src/direct.rs b/crates/tools/src/direct.rs index 02eb4e2202..392d44393f 100644 --- a/crates/tools/src/direct.rs +++ b/crates/tools/src/direct.rs @@ -1621,6 +1621,17 @@ impl DirectSelectionTool { } vec![] } + /// A Shift-press on the fill of object `id` toggles it. On an object inside a selected group or + /// other selected object, it deselects the object and keeps the rest of that group selected + /// (`select.remove`), and a drag from the press moves nothing. + fn shift_press(&mut self, cx: &ToolContext, id: NodeId) -> Vec { + let around = cx.doc.ancestry(id).is_some_and(|a| a.iter().rev().skip(1).any(|x| cx.selection.contains(*x))); + if around { + self.state = State::Idle; + return vec![Action::Exec("select.remove".into(), json!({"id": id.0}))]; + } + vec![Action::Exec("select.toggle".into(), json!({"id": id.0}))] + } fn press_object(&mut self, cx: &ToolContext, ev: &PointerEvent, p: Point, tol: f64, mut h: vectorcraft_doc::hit::Hit) -> Vec { if let Some(part) = cx.doc.node(h.leaf).and_then(|n| compound_part_at(n, p, tol)) { h.ancestry.push(part); @@ -1700,7 +1711,7 @@ impl DirectSelectionTool { self.click_group = next_group(cx, &h.ancestry); } if ev.mods.shift { - return vec![Action::Exec("select.toggle".into(), json!({"id": h.leaf.0}))]; + return self.shift_press(cx, h.leaf); } self.frame.clear(); // A press inside a selected group keeps the group: a drag moves it whole. diff --git a/crates/tools/src/direct/tests.rs b/crates/tools/src/direct/tests.rs index b4689642fd..8a83dea24c 100644 --- a/crates/tools/src/direct/tests.rs +++ b/crates/tools/src/direct/tests.rs @@ -1383,6 +1383,52 @@ fn a_press_inside_a_selected_group_keeps_the_group() { assert!(moves(&t.pointer(&c, &PointerEvent::new(PointerKind::Drag, 130.0, 115.0)))); } +/// With Direct Selection, a Shift-press on the fill of a path inside a selected group deselects +/// the path and keeps the group's other objects selected (`select.remove`), and a drag from it +/// moves nothing. A Shift-press on one of the path's anchors toggles that anchor, which the engine +/// deselects alone. A Shift-press on a path selected itself still toggles it. +#[test] +fn a_shift_press_inside_a_selected_group_deselects_the_path() { + let (d, inside, outside, _, outer) = nested_group_doc(); + let p = paint(); + let shift = Mods { shift: true, ..Mods::default() }; + let mut s = Selection::default(); + s.set([outer]); + let c = cx(&d, &s, &p); + let mut t = DirectSelectionTool::new(false); + assert_eq!( + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 150.0).with_mods(shift)), + vec![Action::Exec("select.remove".into(), json!({"id": inside.0}))], + "a Shift-press on the fill" + ); + assert!(t.pointer(&c, &PointerEvent::new(PointerKind::Drag, 180.0, 165.0).with_mods(shift)).is_empty(), "a Shift-drag from the fill"); + assert!(t.pointer(&c, &PointerEvent::new(PointerKind::Up, 180.0, 165.0).with_mods(shift)).is_empty()); + let mut t = DirectSelectionTool::new(false); + assert_eq!( + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 100.0, 100.0).with_mods(shift)), + vec![Action::Exec("select.anchors".into(), json!({"id": inside.0, "anchors": [[0, 0]], "mode": "toggle"}))], + "a Shift-press on an anchor" + ); + let mut both = Selection::default(); + both.set([inside, outer]); + let c = cx(&d, &both, &p); + let mut t = DirectSelectionTool::new(false); + assert_eq!( + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 150.0).with_mods(shift)), + vec![Action::Exec("select.remove".into(), json!({"id": inside.0}))], + "a Shift-press on a path selected beside the group around it" + ); + let mut own = Selection::default(); + own.set([outside]); + let c = cx(&d, &own, &p); + let mut t = DirectSelectionTool::new(false); + assert_eq!( + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 350.0, 350.0).with_mods(shift)), + vec![Action::Exec("select.toggle".into(), json!({"id": outside.0}))], + "a Shift-press on a path selected itself" + ); +} + /// Isolation mode: a marquee and an anchor click take the path inside the isolated group and /// leave the path beside it. Group Selection stops at the isolated group instead of adding /// the group around it. diff --git a/docs/mcp.md b/docs/mcp.md index fe44a42ff5..5f7eacffc0 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3750,12 +3750,18 @@ underlines clipping-path names. ## Object selection -`select.set {ids}` replaces the selection, `select.add {ids}` adds to it, and -`select.toggle {id}` or `select.toggle {ids}` toggles each target. +`select.set {ids}` replaces the selection, `select.add {ids}` adds to it, +`select.toggle {id}` or `select.toggle {ids}` toggles each target, and `select.remove {id}` or `select.remove {ids}` +takes each target out of the selection. +`select.remove` also takes out an object inside a selected group or compound path and keeps the rest of the group +selected: the outermost selected object around it leaves the selection, and the objects inside it on the way down to +the target are selected in its place, except hidden and locked objects and a Shaper Group's original shapes. Direct Selection's Shift-click on the fill of a path inside a selected group runs +it, and a Shift-drag from there moves nothing. A Shift-click on an anchor of such a path runs `select.anchors` with mode +`toggle`, which deselects only that anchor: the path's other anchors and the group's other objects stay selected. Every id must be a non-negative integer naming an existing object. A malformed or unknown id is an error naming that value; the entire selection is left unchanged. -All three commands return `{count, ids}` for the resulting selection, in selection order. -An empty array clears the selection for `select.set` and leaves it alone for Add and Toggle. +All four commands return `{count, ids}` for the resulting selection, in selection order. +An empty array clears the selection for `select.set` and leaves it alone for Add, Toggle and Remove. `select.key {id}` makes `id` the key object that Align aligns to and Distribute Spacing spaces from (`object.align` without `to`, `object.distributeSpacing` with `spacing`), and `select.key {}` cancels it. The id must name a selected top-level object. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 61acdd0dc5..c3fc233121 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -845,6 +845,7 @@ since 2026-10-01. - **Escape in more tool drags:** Escape during an Anchor Point drag, a Mesh tool drag, a Direct Selection drag of a mesh point, a corner widget or the brackets of type on a path, or a Shape Builder drag cancels it: the art goes back to how the press found it, no undo step is added, the release does nothing, and the tool stays chosen. Escape during a Measure tool drag brings back the measurement before it. Regression tests: `escape_cancels_*` in `draw2/anchor/tests.rs`, `meshedit.rs`, `direct/tests.rs`, `builder/tests.rs` and `xform/measure.rs`, and `escape_cancels_an_anchor_point_mesh_shape_builder_or_measure_drag` in `tests/toolescape.rs`. - **Shift-click on corner widgets (#5188):** with Direct Selection, when every corner of a path is selected (the path selected whole), a Shift-click on a corner widget picks that corner alone, so the next drag rounds just it. The other corners' widgets then hide; a Shift-click on another corner's anchor adds that corner and shows its widget, and a Shift-click on a showing widget deselects its corner. Adding a corner by Shift-clicking its widget while it is hidden stays open (#1232). Corner widgets are chosen by clicking one and Shift-clicking the others ([Logos By Nick, rounded corners in Illustrator](https://logosbynick.com/?p=15787)). Test: `corners::tests::a_shift_click_on_a_widget_of_a_whole_path_picks_its_corner`. - **A press inside a selected group** (VectorCraft's own rule): with Direct Selection, a path inside a selected group counts as selected whole. A click on its fill keeps the group selected, a drag from its fill or one of its anchors moves the group whole, and a click on an anchor or a segment selects it alone. The path's anchors show the selected-anchor cursor and highlight, and an object above the group does not take a press on one. Group Selection adds the group above the outermost selected one. This also applies to the Cmd/Ctrl press the Selection tool lends Direct Selection. Test: `direct::tests::a_press_inside_a_selected_group_keeps_the_group`. +- **A Shift-click inside a selected group** (VectorCraft's own rule): with Direct Selection, a Shift-click on the fill of a path inside a selected group deselects that path, and the group's other objects stay selected (`select.remove`); a Shift-drag from there moves nothing. A Shift-click on one of the path's anchors deselects only that anchor, and the path's other anchors and the group's other objects stay selected. Tests: `direct::tests::a_shift_press_inside_a_selected_group_deselects_the_path`, `selection_commands::remove_and_anchor_toggle_open_a_selected_group`, `selection::tests::expand_to_selects_a_member_in_place_of_its_selected_group`. - **TIFF in screen and asset export:** both format menus expose the existing TIFF encoder and Format Settings. Headless UI regressions choose TIFF and check scaled dimensions, artboard selection, filenames, encoding options, saved settings and collected-asset output. Public reference: [Export for Screens](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/export-for-screens.html), updated 2026-09-28, lists TIFF for both artboards and assets. Adobe staff [confirmed support in 30.2.1](https://illustrator.uservoice.com/forums/333657-illustrator-desktop-feature-requests/suggestions/49081034-add-tiff-format-into-export-for-screens-assets-d) on 2026-02-19; the older 2025 Collect assets guide omits TIFF. - **Lossy WebP with a Quality setting:** WebP Options has a Compression menu (Lossless, Lossy) and a Quality slider from 0 to 100 that is enabled for Lossy. Lossy writes a `VP8 ` WebP file, with an `ALPH` chunk that keeps the alpha exactly when some pixels are not opaque. `document.export`, `document.serialize` and Export for Screens take `lossless: false` with `quality` (default 90, VectorCraft's own value), in a format row or in `settings.webp`; Format Settings for WebP keeps both. Lossless stays the default, and a quality above 100 or one that is not a whole number is refused. Public reference: [export file format options](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/export-file-format-options-in-illustrator.html) describes Lossless and Lossy WebP and a Quality setting for Lossy (`webp_is_lossless_by_default_and_lossy_when_asked`, `lossy_webp_keeps_translucent_pixels`, `webp_quality_out_of_its_range_is_refused` in `crates/engine/src/cmd/fileio/tests_text.rs`, `webp_options_choose_lossless_or_lossy_at_a_quality`). - **Export for Screens of the selected artboards:** while the Artboard tool is in use, File › Export › Export for Screens… (`file.exportForScreens`) opens with the artboards the tool has selected checked on its Artboards tab, and Export Artboard writes only those. Shift-clicks on the canvas, or Shift- or Ctrl/Cmd-clicks on the Artboards panel's rows, select several. The other fields show the settings the document last exported with. With another tool in use, the dialog takes its artboard choice from those settings too. Public reference: [Export selected artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/export-artboards.html). From 65d9ba24692ace4150c671020255e58c0f4ff01e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 04:34:32 -0800 Subject: [PATCH 2/2] Direct Selection: a locked target does not open its group, and a second Shift-click deselects one anchor expand_to took in the target without checking that it is editable, so a locked or hidden object inside a selected group replaced the group with its contents. It now leaves the selection unchanged for such a target. select.anchors with mode toggle decided whether a path was selected whole from the rest of the selection, so after a Shift-click had opened a group, a Shift-click on an anchor of another path in it selected only that anchor. A toggle on a group member now decides it from the member's own selection; paths directly on a layer keep the existing rule. --- crates/doc/src/selection.rs | 6 +++--- crates/doc/src/selection/tests.rs | 8 ++++++++ crates/engine/src/cmd/select.rs | 11 ++++++++--- crates/engine/tests/it/selection_commands.rs | 12 ++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/crates/doc/src/selection.rs b/crates/doc/src/selection.rs index 90afaad022..02c4391921 100644 --- a/crates/doc/src/selection.rs +++ b/crates/doc/src/selection.rs @@ -199,8 +199,8 @@ impl Selection { /// When `id` is also selected itself, it keeps its place in the selection. /// /// Returns whether the selection changed. It does not change when `id` is not inside a selected - /// object, is inside one that is partly selected (anchors or segments), or is one of a selected - /// Shaper Group's original shapes. + /// object, is inside one that is partly selected (anchors or segments), is one of a selected + /// Shaper Group's original shapes, or is hidden, locked or on a locked artboard itself. pub fn expand_to(&mut self, doc: &Document, id: NodeId) -> bool { let Some(chain) = doc.ancestry(id) else { return false }; let Some(top) = chain.iter().position(|a| self.contains(*a)) else { return false }; @@ -217,7 +217,7 @@ impl Selection { if children.iter().take(originals).any(|c| c.id == pair[1]) { return false; } - members.extend(children.iter().skip(originals).map(|c| c.id).filter(|c| *c == id || (*c != pair[1] && editable(*c)))); + members.extend(children.iter().skip(originals).map(|c| c.id).filter(|c| editable(*c) && (*c == id || *c != pair[1]))); } if !members.contains(&id) { return false; diff --git a/crates/doc/src/selection/tests.rs b/crates/doc/src/selection/tests.rs index d685b73bf7..46f726f1e8 100644 --- a/crates/doc/src/selection/tests.rs +++ b/crates/doc/src/selection/tests.rs @@ -109,6 +109,14 @@ fn expand_to_selects_a_member_in_place_of_its_selected_group() { with_locked.set([k]); assert!(with_locked.expand_to(&d, last)); assert_eq!(with_locked.objects, [shown, last]); + // A locked or hidden member itself does not open the group. + for target in [locked, hidden] { + let mut s = Selection::default(); + s.set([k]); + let before = s.clone(); + assert!(!s.expand_to(&d, target), "{target:?}"); + assert_eq!(s, before); + } } /// A selection with every field set: objects 1 to 6 with 3 listed twice, anchors, segments, a key, diff --git a/crates/engine/src/cmd/select.rs b/crates/engine/src/cmd/select.rs index e733204932..eb504b6074 100644 --- a/crates/engine/src/cmd/select.rs +++ b/crates/engine/src/cmd/select.rs @@ -959,9 +959,14 @@ fn anchors(s: &mut Session, p: &Value) -> Result { // A path selected as a whole has every anchor selected: toggle and add start from them all, // but only when no partial anchor selection is active and only on a single isolated object. // A toggle on a path inside a selected group selects the path itself in the group's place, - // beside the group's other objects, and starts from all its anchors. - let inside = mode == "toggle" && sel.expand_to(d, id); - let whole = inside || (sel.contains(id) && sel.partial(id).is_none() && sel.anchors.is_empty() && sel.objects.len() <= 1); + // beside the group's other objects, and starts from all its anchors. A toggle on a group + // member that is itself selected whole (as an earlier toggle in the group leaves the other + // members) starts from all its anchors whatever else is selected. + let toggle = mode == "toggle"; + let inside = toggle && sel.expand_to(d, id); + let own = sel.contains(id) && sel.partial(id).is_none(); + let in_group = || d.ancestry(id).is_some_and(|c| c.len() >= 2 && d.node(c[c.len() - 2]).is_some_and(|n| !n.is_layer())); + let whole = inside || (own && ((sel.anchors.is_empty() && sel.objects.len() <= 1) || (toggle && in_group()))); sel.add(id); // A segment pick's endpoints aren't selected anchors: start from none of them. if sel.segments.remove(&id).is_some() { diff --git a/crates/engine/tests/it/selection_commands.rs b/crates/engine/tests/it/selection_commands.rs index 6a1f69b96e..7d9c01bf3b 100644 --- a/crates/engine/tests/it/selection_commands.rs +++ b/crates/engine/tests/it/selection_commands.rs @@ -112,6 +112,18 @@ fn remove_and_anchor_toggle_open_a_selected_group() { assert_eq!(sel.objects, [a, b, c]); assert_eq!(sel.partial(a), Some(&[(0, 0), (0, 2), (0, 3)].into()), "the other anchors of a stay selected"); assert_eq!((sel.partial(b), sel.partial(c)), (None, None), "b and c stay selected whole"); + // A second Shift-click, on an anchor of b, deselects only that anchor of b. + s.execute("select.anchors", &json!({"id": b.0, "anchors": [[0, 2]], "mode": "toggle"})).unwrap(); + let sel = &s.active().unwrap().selection; + assert_eq!(sel.objects, [a, b, c]); + assert_eq!(sel.partial(a), Some(&[(0, 0), (0, 2), (0, 3)].into())); + assert_eq!(sel.partial(b), Some(&[(0, 0), (0, 1), (0, 3)].into()), "the other anchors of b stay selected"); + assert_eq!(sel.partial(c), None); + // An anchor of a path that is not selected joins the selection by itself. + let d = NodeId(s.execute("shape.rectangle", &json!({"x": 60, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [c.0]})).unwrap(); + s.execute("select.anchors", &json!({"id": d.0, "anchors": [[0, 1]], "mode": "toggle"})).unwrap(); + assert_eq!(s.active().unwrap().selection.partial(d), Some(&[(0, 1)].into())); } #[test]