Merge pull request #8842 from storytold/train/carry8644

Fix #8639: target circles ignore Ctrl/Cmd-click and Shift-click ranges that layer names honor (#8644)
This commit is contained in:
BFlat authored and GitHub committed 2026-11-20 23:59:46 +07:00
commit 8ae8169846
6 files changed
+154 -10

No files matched your search

+22
View File
@@ -480,6 +480,28 @@ impl Selection {
}
self.target = None;
}
/// Shift-clicking a range of target circles: the art of every row in `ids` (a layer: its
/// visible, unlocked art, its sublayers' too; anything else: itself) is selected, or joins the
/// selection when `add` is set. Several objects are then selected, none targeted. Art on a
/// locked artboard is left out, as [`Selection::toggle_target`] leaves it out.
pub fn target_range(&mut self, doc: &Document, ids: &[NodeId], add: bool) {
let locks = doc.locked_artboards();
let mut art = Vec::new();
for &id in ids {
match doc.node(id) {
Some(n) if n.is_layer() => art.extend(n.layer_art(true)),
Some(_) => art.push(id),
None => {}
}
}
art.retain(|i| !locks.holds_id(*i));
if add {
self.add_all(art);
} else {
self.set(art);
}
self.target = None;
}
/// What appearance and transparency edits act on: the targeted object, group or layer, else
/// the selected objects.
pub fn subjects(&self) -> &[NodeId] {
+29 -1
View File
@@ -192,7 +192,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Target",
[],
None,
"{id, add?: bool (Shift-click: the item joins the selection, or leaves it when all selected; nothing is targeted)} target a layer, group or object as clicking its target circle in the Layers panel does: a layer gets its visible, unlocked art (its sublayers' too) selected and becomes the current layer, and appearance.*, effect.*, transparency.* and the opacity-mask commands without `ids` then act on the layer itself; anything else is selected. Any other selection change ends the targeting (`document.inspect` → target) → {id, selected: [..]}",
"{id, add?: bool} or {range: [id…], add?: bool} target a layer, group or object as clicking its target circle in the Layers panel does: a layer gets its visible, unlocked art (its sublayers' too) selected and becomes the current layer, and appearance.*, effect.*, transparency.* and the opacity-mask commands without `ids` then act on the layer itself; anything else is selected. `add` (Ctrl/Cmd-click): the item joins the selection, or leaves it when all selected; nothing is targeted. `range` (Shift-click, the rows from the last circle clicked to this one): the art of every listed row that is visible, unlocked and inside the isolated group is selected, or added to the selection with `add` (Shift+Ctrl/Cmd-click); nothing is targeted. Any other selection change ends the targeting (`document.inspect` → target) → {id, selected: [..]} (with `range`: {range, selected})",
has_doc,
target
),
@@ -433,6 +433,9 @@ fn paste_remembers_layers(s: &mut Session, p: &Value) -> Result<Value> {
/// The Layers panel's target circle.
fn target(s: &mut Session, p: &Value) -> Result<Value> {
const C: &str = "layer.target";
if let Some(ids) = ids_param(p, "range", C)? {
return target_range(s, p, ids);
}
let id = object_param(p, "id", C)?.ok_or_else(|| bad(C, "missing id"))?;
let st = s.doc()?;
let n = st.doc.node(id).ok_or(EngineError::NoNode(id))?;
@@ -458,6 +461,31 @@ fn target(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({ "id": id.0, "selected": st.selection.objects.iter().map(|i| i.0).collect::<Vec<_>>() }))
}
/// `layer.target` with `range`, a Shift-click range of target circles: the art of every listed row
/// that is visible, unlocked and inside the isolated group is selected, or added to the selection
/// with `add`. Nothing is targeted, and the highlighted rows stay. The current layer follows the
/// selection, as with any selection change ([`Session::select`]).
fn target_range(s: &mut Session, p: &Value, mut ids: Vec<NodeId>) -> Result<Value> {
const C: &str = "layer.target";
ids.truncate(MAX_ROWS);
let add = switch_or(p, "add", false, C)?;
let rows = {
let st = s.doc()?;
// Measures the locked artboards once for every row, not once per row.
let editable = st.doc.editable();
ids.retain(|id| st.doc.node(*id).is_some() && editable(*id) && in_isolation(&st.doc, st.isolation, *id));
st.layer_rows.clone()
};
if ids.is_empty() {
return Err(bad(C, "no row in the range is visible, unlocked and inside the isolated group"));
}
s.select(|d, sel| sel.target_range(d, &ids, add))?;
let st = s.doc_mut()?;
// Targeting doesn't change which rows are highlighted.
st.layer_rows = rows;
Ok(json!({ "range": ids.iter().map(|i| i.0).collect::<Vec<_>>(), "selected": st.selection.objects.iter().map(|i| i.0).collect::<Vec<_>>() }))
}
/// The Layers panel's clipping mask button: the top object of a layer (or group) clips the rest,
/// or the clipping mask is released.
fn clip_toggle(s: &mut Session, p: &Value) -> Result<Value> {
+12 -4
View File
@@ -31,9 +31,12 @@
//! Backspace) asks first when a layer or sublayer among them holds art ([`delete`]).
//! - The triangle opens or closes a row; Alt-click does the same to everything inside it.
//! - Double-clicking a name renames it; double-clicking elsewhere on a row opens its options.
//! - A target circle targets its layer, group or object (`layer.target`); dragging it onto another
//! row's circle moves the appearance there (Alt copies it, `appearance.transfer`) and dropping it
//! on the trash reduces it to basic appearance (`appearance.reduceToBasic`) without deleting it.
//! - A target circle targets its layer, group or object (`layer.target`). Its modifier keys
//! follow the names' rules: Ctrl/Cmd adds the item to the selection or takes it out, Shift
//! selects the art of every row from the last circle clicked to this one, and Shift+Ctrl/Cmd
//! adds that art (#8639). Dragging a circle onto another row's circle moves the appearance there
//! (Alt copies it, `appearance.transfer`) and dropping it on the trash reduces it to basic
//! appearance (`appearance.reduceToBasic`) without deleting it.
//! - Search All and the Filter button at its right (`ui.layersFilter`, lit while a filter is on)
//! narrow the rows, and every row that holds others shows open while they do. A row stays when
//! its name holds the text typed, it is one of the object kinds ticked under By Object and it is
@@ -74,7 +77,7 @@ pub use model::{Filter, ObjectKind, RowState};
#[cfg(test)]
use model::{Row, list_rows, painted_name};
use model::{isolated_root, push_rows, rows_of_doc};
use rows::{drag_ghost, key, rename_id, resolve_click, row};
use rows::{drag_ghost, key, rename_id, resolve_click, resolve_target_click, row};
#[cfg(test)]
use thumbs::THUMBS;
pub(crate) use thumbs::{ThumbSource, node_arc, real_thumb, retain_open_thumbs, show_thumbs_of, thumb_options};
@@ -184,6 +187,8 @@ struct Out {
actions: Vec<(String, Value)>,
/// A row clicked with these modifiers (resolved once every row is listed).
click: Option<(NodeId, egui::Modifiers)>,
/// A target circle clicked with these modifiers (resolved once every row is listed).
target_click: Option<(NodeId, egui::Modifiers)>,
/// The column drag after this frame (`Some(None)`: it ended).
column: Option<Option<ColumnDrag>>,
/// Rows to open or close, and whether to open them.
@@ -220,6 +225,8 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
ui.data_mut(|d| {
if before.is_some() {
d.remove::<(u64, String)>(rename_id());
// So is the target circles' Shift-click anchor: it could name another row here.
d.remove::<NodeId>(key("target-anchor"));
}
d.insert_temp(shown_doc, st.uid);
});
@@ -368,6 +375,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
});
let list_rect = scrolled.inner.inner_rect;
resolve_click(ui, &view, &list, &mut out);
resolve_target_click(ui, &view, &list, &mut out);
if let Some(st) = app.session.active_mut() {
for (id, open) in out.toggle.drain(..) {
st.layers_open.set(id, open);
+24 -1
View File
@@ -110,6 +110,29 @@ pub(super) fn resolve_click(ui: &Ui, view: &View, list: &[Row], out: &mut Out) {
});
}
/// Resolve the target circle clicked this frame by the rules of a row name click
/// ([`widgets::row_click`], #8639): plain targets it, Ctrl/Cmd adds it to the selection or takes
/// it out, Shift selects the art of every row from the last circle clicked (else the targeted row)
/// to it, and Shift+Ctrl/Cmd adds that art to the selection.
pub(super) fn resolve_target_click(ui: &Ui, view: &View, list: &[Row], out: &mut Out) {
let Some((id, m)) = out.target_click.take() else { return };
let anchor = ui.data(|d| d.get_temp::<NodeId>(key("target-anchor"))).or(view.target);
let order: Vec<NodeId> = list.iter().map(|r| r.node.id).collect();
// The circles have no highlighted rows of their own: a range starts only at the anchor.
let click = widgets::row_click(&order, &[], anchor, id, m);
if click.moves_anchor() {
ui.data_mut(|d| d.insert_temp(key("target-anchor"), id));
}
let ids = |rows: &[NodeId]| rows.iter().map(|r| r.0).collect::<Vec<_>>();
let params = match click {
widgets::RowClick::Only(id) => json!({"id": id.0}),
widgets::RowClick::Toggle(id) => json!({"id": id.0, "add": true}),
widgets::RowClick::Range(rows) => json!({"range": ids(&rows)}),
widgets::RowClick::AddRange(rows) => json!({"range": ids(&rows), "add": true}),
};
out.actions.push(("layer.target".into(), params));
}
/// Whether row `n` can take `drag` (the rows or objects `moving`) inside it. A group or an
/// Intertwine group takes objects; an Intertwine group, or a group in one, only objects that can
/// be intertwined.
@@ -515,7 +538,7 @@ pub(super) fn row(ui: &mut Ui, view: &View, item: &Row, out: &mut Out) {
let m = ui.input(|i| i.modifiers);
let on_name = ui.input(|i| i.pointer.interact_pos()).is_some_and(|p| p.x <= name_end.max(name_rect.left() + 20.0) && p.x >= name_rect.left());
if tresp.clicked() {
out.actions.push(("layer.target".into(), json!({"id": n.id.0, "add": m.shift})));
out.target_click = Some((n.id, m));
} else if sq_resp.clicked() {
out.actions.push(("layer.selectAll".into(), json!({"id": n.id.0, "add": m.shift})));
} else if resp.clicked() {
+65 -4
View File
@@ -400,15 +400,76 @@ fn clicking_a_target_circle_targets_the_layer() {
}
let st = app.session.active().unwrap();
assert_eq!((st.selection.target, st.selection.objects.clone()), (Some(a), vec![a]));
// Shift-clicking another object's circle adds it to the selection (#901), and again takes
// it out; nothing is targeted meanwhile.
click_with(&mut app, &ctx, c[1], egui::Modifiers::SHIFT);
// Ctrl/Cmd-clicking another object's circle adds it to the selection, as Ctrl/Cmd-clicking a
// name adds the row (#901, #8639), and again takes it out; nothing is targeted meanwhile.
click_with(&mut app, &ctx, c[1], egui::Modifiers::COMMAND);
let st = app.session.active().unwrap();
assert_eq!((st.selection.target, st.selection.objects.clone()), (None, vec![a, b]));
click_with(&mut app, &ctx, c[1], egui::Modifiers::SHIFT);
click_with(&mut app, &ctx, c[1], egui::Modifiers::COMMAND);
assert_eq!(app.session.active().unwrap().selection.objects, vec![a]);
}
/// Shift-clicking a target circle selects the art of every row from the last circle clicked to
/// it, as Shift-clicking a name highlights a range of rows (#8639); Shift+Ctrl/Cmd adds a range to
/// the selection. Nothing is targeted, and hidden art in the range is left out.
#[test]
fn shift_clicking_a_target_circle_selects_a_range_of_rows() {
let (mut app, _, [a, b]) = two_rects();
let run = |app: &mut VectorcraftApp, id: &str, p: serde_json::Value| app.session.execute(id, &p).unwrap();
let c3 = NodeId(run(&mut app, "shape.rectangle", json!({"x": 120, "y": 0, "width": 50, "height": 50}))["id"].as_u64().unwrap());
let d = NodeId(run(&mut app, "shape.rectangle", json!({"x": 0, "y": 60, "width": 50, "height": 50}))["id"].as_u64().unwrap());
run(&mut app, "select.none", json!({}));
let ctx = egui::Context::default();
// Rows top down: the layer, d, c3, b, a.
let (c, _) = frame(&mut app, &ctx, vec![], false);
assert_eq!(c.len(), 5);
let selected = |app: &VectorcraftApp| {
let st = app.session.active().unwrap();
let mut ids = st.selection.objects.clone();
ids.sort();
(st.selection.target, ids)
};
// From c3 down to a: b in between is selected too.
click_with(&mut app, &ctx, c[2], egui::Modifiers::NONE);
assert_eq!(selected(&app), (Some(c3), vec![c3]));
click_with(&mut app, &ctx, c[4], egui::Modifiers::SHIFT);
assert_eq!(selected(&app), (None, vec![a, b, c3]));
// A Shift range starts at the last circle clicked, not at the end of the last range.
click_with(&mut app, &ctx, c[3], egui::Modifiers::SHIFT);
assert_eq!(selected(&app), (None, vec![b, c3]));
// Shift+Ctrl/Cmd adds a range: from c3 up to d.
click_with(&mut app, &ctx, c[1], egui::Modifiers::SHIFT | egui::Modifiers::COMMAND);
assert_eq!(selected(&app), (None, vec![b, c3, d]));
// Hidden art in a range stays unselected.
run(&mut app, "select.set", json!({"ids": [b.0]}));
run(&mut app, "object.hide", json!({}));
click_with(&mut app, &ctx, c[2], egui::Modifiers::NONE);
click_with(&mut app, &ctx, c[4], egui::Modifiers::SHIFT);
assert_eq!(selected(&app), (None, vec![a, c3]));
}
/// The Shift-click anchor of the target circles belongs to the document it was clicked in: node
/// ids are per document, so in another document a Shift-click with no circle clicked there yet
/// targets only its own row, never a range from a row that has the old anchor's id.
#[test]
fn the_target_circle_anchor_does_not_carry_over_to_another_document() {
let (mut app, _, [a, _]) = two_rects();
let ctx = egui::Context::default();
let (c, _) = frame(&mut app, &ctx, vec![], false);
// Rows top down: the layer, b, a. The anchor is a.
click_with(&mut app, &ctx, c[2], egui::Modifiers::NONE);
let run = |app: &mut VectorcraftApp, id: &str, p: serde_json::Value| app.session.execute(id, &p).unwrap();
run(&mut app, "file.new", json!({"width": 200, "height": 200}));
let a2 = NodeId(run(&mut app, "shape.rectangle", json!({"x": 0, "y": 0, "width": 50, "height": 50}))["id"].as_u64().unwrap());
let b2 = NodeId(run(&mut app, "shape.rectangle", json!({"x": 60, "y": 0, "width": 50, "height": 50}))["id"].as_u64().unwrap());
run(&mut app, "select.none", json!({}));
assert_eq!(a2, a, "the new document reuses the old anchor's id, so a stale anchor would find a row");
let (c, _) = frame(&mut app, &ctx, vec![], false);
click_with(&mut app, &ctx, c[1], egui::Modifiers::SHIFT);
let st = app.session.active().unwrap();
assert_eq!((st.selection.target, st.selection.objects.clone()), (Some(b2), vec![b2]));
}
/// The rows whose target circle shows as targeted (its inner ring drawn), as indexes into the
/// circles [`frame`] returns.
fn targeted_rows(app: &mut VectorcraftApp, ctx: &egui::Context) -> Vec<usize> {
+2
View File
@@ -78,6 +78,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard
| Date | Change | Summary |
|---|---|---|
| 2026-11-20 | minor | G12: Actions panel item context menus for action sets (New Action…, New Set…, Duplicate Set, Delete Set, Set Options…) and actions (Play, Record, Duplicate, Delete, Action Options…, Batch…) with selection handling; clicking Duplicate on an action duplicates that action; headless tests in `crates/ui-egui/src/panels/actions.rs`; scores and estimates unchanged. |
| 2026-11-19 | minor | Layers: target circles take Ctrl/Cmd-click to add or remove an item and Shift-click to select a range of rows, as the row names do (#8639). Scores and estimates unchanged. |
| 2026-11-19 | minor | Layers: a target circle whose item is targeted and has an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the four looks (not targeted, targeted, with an appearance, both) differ (#8711). Scores and estimates unchanged. |
| 2026-11-19 | minor | G12: Brushes panel item right-click context menu offering Brush Options…, Duplicate Brush, and Delete Brush (disabled if the last remaining brush); right-clicking an unselected brush selects it first, and right-clicking within a multi-selection preserves it offering Duplicate Brushes / Delete Brushes; headless tests in `crates/ui-egui/src/panels/brushes/tests.rs`; scores and estimates unchanged. |
| 2026-11-19 | minor | G12: Character Styles and Paragraph Styles panels item context menus (Options…, Duplicate, Delete, Redefine, Clear Overrides); regression tests in crates/ui-egui/src/panels/text_styles/tests.rs; scores and estimates unchanged. |
@@ -760,6 +761,7 @@ since 2026-10-01.
- **Escape in Selection tool drags:** Escape during a Selection tool move or Alt-drag copy, a bounding-box scale or rotation, a marquee, or a corner widget, pie widget or bracket drag cancels it: the art returns to its state at the press, no copy is left, no undo step is added, the release does nothing, and the tool stays chosen. This is VectorCraft's own behavior. Regression tests: `escape_cancels_*` in `select/tests.rs` and `pie.rs`, and `escape_cancels_a_selection_tool_move_copy_scale_or_rotation` in `tests/selectescape.rs`.
- **Large Shift-marquee selections and Select › Inverse:** `select.toggle` and `select.add` with many ids (a Shift-drag marquee sends them together) go through the selection once instead of once per id, and Select › Inverse looks each object up in a set of the selected ones. The resulting selection, its order and the reply are the same as before. With 50,000 objects the selection step of toggling every object off took 528 to 655 ms before and 2.5 to 4.6 ms after in 7 runs, wall clock on a machine that was running other builds (`cargo run --release -p vectorcraft-engine --example selection_bench`). Regression tests: `add_all_does_what_adding_each_does` and `toggle_all_does_what_toggling_each_does` in `crates/doc/src/selection/tests.rs`, and `toggle_and_add_handle_each_listed_id_in_order` in `crates/engine/tests/it/selection_commands.rs`.
- **Shift-click in the Layers panel's selection column on a large layer:** `layer.selectAll {id, add: true}` checks whether the row's art is all selected with a set of the selected objects, and removes or adds that art in one pass instead of once per object. The resulting selection, its order, the reply and the highlighted rows are the same as before. On a layer of 50,000 objects the whole command took a median of 733 ms before and 6.9 ms after when all of the layer's art was selected, and 369 ms before and 24 ms after when every other object was, in 7 runs each, wall clock on Linux while other builds were running (`cargo run --release -p vectorcraft-engine --example layer_select_bench`). Regression test: `a_shift_click_in_the_selection_column_matches_adding_or_removing_each_id` in `crates/engine/src/tests/layers.rs`.
- **Ctrl/Cmd-click and Shift-click on Layers panel target circles (#8639):** the target circles follow the same modifier rules as the row names, as the help page describes for selecting objects in the Layers panel: Shift for adjacent objects, Ctrl or Command for non-adjacent ones ([Move objects to different layers](https://helpx.adobe.com/illustrator/desktop/manage-layers/create-and-organize-layers/move-objects-to-different-layers.html)). Ctrl/Cmd-click adds the item (a layer: its art) to the selection or takes it out, which Shift-click did before (#913); Shift-click selects the art of every row from the last circle clicked (else the targeted row) to this one, and Shift+Ctrl/Cmd-click adds it (`layer.target {range, add?}`). Hidden or locked art and art outside the isolated group in the range is left out, and nothing stays targeted. Regression tests: `clicking_a_target_circle_targets_the_layer` and `shift_clicking_a_target_circle_selects_a_range_of_rows` in `crates/ui-egui/src/panels/layers/tests.rs`.
- **Layers added to the selection from their target circles show as targeted (#8646):** with several items picked from their circles (nothing targeted), a layer or sublayer's circle shows its inner ring while all of its visible, unlocked art is selected, as an object's circle does while the object is selected. A layer is never selected itself, only its art, so its circle used to keep a single ring. Regression test: `a_layer_added_from_its_target_circle_shows_as_targeted` in `crates/ui-egui/src/panels/layers/tests.rs`.
- **A targeted item with an appearance of its own shows both marks (#8711):** its target circle keeps the inner ring of a targeted item, with the appearance dot drawn smaller inside it and a gap between them, so not targeted, targeted, with an appearance and both look different, as the target icons in [Appearance attributes](https://helpx.adobe.com/illustrator/using/appearance-attributes.html) do. The dot used to cover the ring. Regression test: `a_targeted_circle_with_an_appearance_shows_both_ring_and_dot` in `crates/ui-egui/src/panels/layers/tests.rs`.
- **Selection passes through raster effects:** clicks with the Selection, Direct Selection and Group Selection tools (Group Selection's repeated click included), the Selection tool's pointer and marquee, Direct Selection's marquee, pointer and anchor highlight, and Group Selection's marquee (E for enclosed objects included) leave out the area that a drop shadow, a glow, a blur or another raster effect paints beyond an object. A click on a shadow selects the object under it, or nothing over an empty canvas, a repeated Group Selection click there adds the groups of the object under it, and a press on the shadow of a selected object does not move it ([the help page](https://helpx.adobe.com/illustrator/using/selecting-objects.html)). Over a shadow, Direct Selection highlights only the anchors of the object under it, and Group Selection keeps its own pointer and highlights no anchor, as it does everywhere (VectorCraft's own rule). No setting changes this. This covers paths, groups, type, symbol instances and images. Regression tests: `crates/engine/src/tests/select_effects.rs`.