From 9693ce96aac2a7ec6caed6fdb4d89e82b14ee621 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 13:33:21 -0800 Subject: [PATCH 1/7] Arrange Tools: Group by Row puts each row of the selection in its own group Object > Plug-ins > Arrange Tools > Group by Row... (addon.arrange.groupRows) groups the selected top-level objects by the rows their visual bounds share: an object joins a row when its bounds overlap the row from top to bottom, and Group By Columns does the same from left to right. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard share a row; an object alone in its row stays as it is. Each new group takes its frontmost member's place in the stacking order, and the groups and the objects left alone stay selected. One undo step, none when no row holds two objects; an unknown direction is refused. At most 20000 objects, sorted once along the axis. Group Overlapping Objects and Group by Row share the step that builds the groups. The dialog has Group By (Rows or Columns) with Preview. Docs: docs/mcp.md, docs/ui-parity.md, docs/target-app-parity.md, ROADMAP. --- ROADMAP.md | 1 + crates/engine/src/cmd/addons/arrange.rs | 77 ++++++++- crates/engine/src/cmd/addons/arrange/tests.rs | 154 ++++++++++++++++++ crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/engine/tests/command_sweep.rs | 2 + crates/ui-egui/src/addons/arrange.rs | 19 ++- crates/ui-egui/src/addons/arrange/tests.rs | 58 +++++++ docs/mcp.md | 5 +- docs/target-app-parity.md | 4 + docs/ui-parity.md | 1 + 10 files changed, 317 insertions(+), 5 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index c743448b07..4a869f1d36 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -164,6 +164,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap - 2026-11-01: Randomize Opacity joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): each selected object gets its own opacity at random between a minimum and a maximum percent, with a seed that repeats the result, as one undo step (`addon.arrange.randomizeOpacity`, #4925). - 2026-11-01: Sort Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects are sorted by width, height, area, position, opacity or stacking order (small to large, large to small or at random) and take another of those in that order, trading their values or stepping them evenly, as one undo step (`addon.arrange.sort`, #4917). - 2026-11-29: Offset Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects are chained one after another in a row or a column with a set gap (negative to overlap them), in stacking order or by position, either way; the first stays in place and the others move only along the row or column, as one undo step (`addon.arrange.offset`). A VectorCraft addition: headline numbers unchanged. +- 2026-11-29: Group by Row joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects whose visual bounds overlap from top to bottom go into one group for each row (or, by column, from left to right), within their own layer or group and artboard, at the stacking place of their frontmost member; an object alone in its row stays as it is. One undo step, with a previewed dialog (`addon.arrange.groupRows`). A VectorCraft addition: headline numbers unchanged. - 2026-11-15: Tangent Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the circles that touch two selected paths or compound paths at a set radius, or three of them (up to eight for three circles), touching each outline without crossing it; circles, rotated ellipses and other paths alike. A dialog that previews every circle or one picked by number, the current paint, one undo step (`addon.pathtools.tangentCircle`). A VectorCraft addition: headline numbers unchanged. - 2026-11-17: Add Bounding Rectangle and Add Bounding Circle join the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): a live rectangle on the selection's geometric bounding box, or the smallest live circle that holds its outlines, around the whole selection or around each object, with the current paint and one undo step; the menu items open a dialog with Offset, One per Object and Preview (`addon.pathtools.boundingRectangle`, `addon.pathtools.boundingCircle`, #6966). A VectorCraft addition: headline numbers unchanged. - 2026-11-22: Add Inscribed Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the largest live circle inside each selected closed path or compound path, in the area it fills under its fill rule, with the current paint and one undo step (`addon.pathtools.inscribedCircle`, #6966). A VectorCraft addition: headline numbers unchanged. diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index a25f341d1c..4274932141 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -4,7 +4,8 @@ //! Replace with Top Object puts a copy of the topmost selected object in place of each of the //! others; and Set Size of Each gives every selected object an exact width and height. Places and //! sizes are measured and set as `object.setBounds` does. Group Overlapping Objects groups the -//! objects whose visual bounds overlap, Randomize Opacity gives each selected object a random +//! objects whose visual bounds overlap, Group by Row groups them by the rows (or columns) their +//! visual bounds share, Randomize Opacity gives each selected object a random //! opacity, and Sort Objects sorts the selected objects by one attribute and gives them another in //! that order. Its submenu (Object › Plug-ins › Arrange Tools), its dialogs and Zoom to Selection //! (a view command) are the UI's. @@ -98,6 +99,15 @@ pub fn specs() -> Vec { has_multi, group_overlapping ), + cmd!( + "addon.arrange.groupRows", + "Group by Row", + ["Object", "Plug-ins", "Arrange Tools"], + None, + "{direction?: \"row\" (objects whose vertical extents overlap) | \"column\" (objects whose horizontal extents overlap) (\"row\")} group the selected objects (the top-level ones, at most 20000) into one group for each row (column), as one undo step. An object joins a row when its visual bounds (strokes and effects as drawn; a clipping group by its mask) overlap the row's extent across it; extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row, an object alone in its row stays as it is, and each new group goes where its frontmost member was in the stacking order; the new groups (top to bottom, or left to right) and the objects left alone stay selected. A run with no row of two or more objects makes no step → {groups: [id…], grouped (how many objects went into groups)}", + has_multi, + group_rows + ), cmd!( "addon.arrange.randomizeOpacity", "Randomize Opacity", @@ -407,11 +417,74 @@ fn group_overlapping(s: &mut Session, _: &Value) -> Result { roots.iter().filter_map(|id| Some((*id, (d.parent_of(*id), effects::preview::bounds_of(d, &[*id], true)?)))).collect(); let keyed: Vec<(Option, Rect)> = items.iter().map(|(_, k)| *k).collect(); let sets: Vec> = overlapping(&keyed).into_iter().map(|set| set.iter().filter_map(|i| Some(items.get(*i)?.0)).collect()).collect(); + group_each(s, "Group Overlapping Objects", &roots, sets) +} + +/// The rows of `items` (each a key and an extent `(start, end)` along the axis across the rows): the sets of +/// two or more (each in the order given) among items of the same key whose extents overlap, chains included. +/// Extents that only touch stay apart. Sorted by start, then by end, each item joins its key's open row when it +/// starts before that row ends, so the rows come out in order along the axis, and an extent with no length at +/// another's start stays apart from it whatever their order. +fn rows_of(items: &[(K, (f64, f64))]) -> Vec> { + let mut order: Vec = (0..items.len()).collect(); + order.sort_by(|a, b| items[*a].1.0.total_cmp(&items[*b].1.0).then(items[*a].1.1.total_cmp(&items[*b].1.1))); + let mut rows: Vec> = vec![]; + // Each key's open row: its index in `rows` and where it ends. + let mut open: HashMap = HashMap::new(); + for i in order { + let (key, (start, end)) = items[i]; + match open.get_mut(&key) { + Some((row, until)) if start < *until => { + if let Some(r) = rows.get_mut(*row) { + r.push(i); + } + *until = until.max(end); + } + _ => { + open.insert(key, (rows.len(), end)); + rows.push(vec![i]); + } + } + } + rows.retain(|r| r.len() > 1); + for r in &mut rows { + r.sort_unstable(); + } + rows +} + +fn group_rows(s: &mut Session, p: &Value) -> Result { + const C: &str = "addon.arrange.groupRows"; + let rows = choice(p, C, "direction", &["row", "column"])?.unwrap_or("row") == "row"; + let roots = selected_roots(s)?; + if roots.len() > MAX_OBJECTS { + return Err(bad(C, "too many objects selected (at most 20000)")); + } + let d = &s.doc()?.doc; + // Each object's row key (its parent and its artboard) and its extent across the rows. + type Keyed = ((Option, Option), (f64, f64)); + let items: Vec<(NodeId, Keyed)> = roots + .iter() + .filter_map(|id| { + let b = effects::preview::bounds_of(d, &[*id], true)?; + let extent = if rows { (b.y0, b.y1) } else { (b.x0, b.x1) }; + Some((*id, ((d.parent_of(*id), d.artboard_for_bounds(b)), extent))) + }) + .collect(); + let keyed: Vec<_> = items.iter().map(|(_, k)| *k).collect(); + let sets: Vec> = rows_of(&keyed).into_iter().map(|set| set.iter().filter_map(|i| Some(items.get(*i)?.0)).collect()).collect(); + group_each(s, if rows { "Group by Row" } else { "Group by Column" }, &roots, sets) +} + +/// Put each of `sets` (two or more of the selected top-level objects `roots`, each in stacking order) into a +/// new group of its own at its frontmost member's place, as undo step `label`, and select the new groups and +/// the objects of `roots` left alone. No step when `sets` is empty. +fn group_each(s: &mut Session, label: &str, roots: &[NodeId], sets: Vec>) -> Result { if sets.is_empty() { return Ok(json!({ "groups": [], "grouped": 0 })); } let grouped: std::collections::HashSet = sets.iter().flatten().copied().collect(); - let groups = s.edit("Group Overlapping Objects", |d, sel| { + let groups = s.edit(label, |d, sel| { // Every group at once: the members behind each front one go, then each front one is // replaced by its group (one pass over the tree each, however many groups). let (mut places, mut behind, mut groups) = (vec![], vec![], vec![]); diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index 498a927898..94e43a78d2 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -390,6 +390,7 @@ fn off_without_a_selection() { "addon.arrange.replace", "addon.arrange.size", "addon.arrange.groupOverlapping", + "addon.arrange.groupRows", "addon.arrange.randomizeOpacity", "addon.arrange.sort", ] { @@ -473,6 +474,159 @@ fn group_overlapping_is_off_with_one_object_and_scales_to_many() { assert!(sets.iter().all(|s| s.len() == 2 && s[1] == s[0] + 1)); } +fn layer_children(s: &Session) -> Vec { + s.doc().unwrap().doc.layers[0].children().unwrap().iter().map(|n| n.id).collect() +} + +#[test] +fn group_rows_groups_each_row_and_leaves_loners() { + let mut s = session(); + // Row one: a and b (y 0 to 12). c only touches it (from y 12), alone in its row. Row two: d and e. + let a = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + let d = rect(&mut s, 0.0, 40.0, 10.0, 10.0); + let b = rect(&mut s, 20.0, 2.0, 10.0, 10.0); + let c = rect(&mut s, 40.0, 12.0, 10.0, 10.0); + let e = rect(&mut s, 20.0, 45.0, 10.0, 10.0); + select(&mut s, &[a, b, c, d, e]); + let n = steps(&s); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + assert_eq!(steps(&s), n + 1, "one undo step"); + assert_eq!(r["grouped"], json!(4)); + let groups = ids_of(&r["groups"]); + assert_eq!(groups.len(), 2); + assert_eq!(children(&s, groups[0]), [a, b], "the top row first, its members in stacking order"); + assert_eq!(children(&s, groups[1]), [d, e]); + // Each group where its frontmost member was: a d b c e → group(ab) at b, c, group(de) at e. + assert_eq!(layer_children(&s), [groups[0], c, groups[1]]); + let sel = &s.doc().unwrap().selection.objects; + assert!(sel.contains(&groups[0]) && sel.contains(&groups[1]) && sel.contains(&c) && sel.len() == 3, "{sel:?}"); + assert_eq!(s.doc().unwrap().history.undo.last().map(|step| step.label.as_str()), Some("Group by Row")); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(layer_children(&s), [a, d, b, c, e]); +} + +#[test] +fn group_rows_makes_columns_and_joins_rows_an_object_spans() { + let mut s = session(); + // Columns: a and b share x 0 to 15, c stands apart. + let a = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + let b = rect(&mut s, 5.0, 50.0, 10.0, 10.0); + let c = rect(&mut s, 30.0, 0.0, 10.0, 10.0); + select(&mut s, &[a, b, c]); + let r = s.execute("addon.arrange.groupRows", &json!({"direction": "column"})).unwrap(); + let groups = ids_of(&r["groups"]); + assert_eq!(groups.len(), 1); + assert_eq!(children(&s, groups[0]), [a, b]); + assert_eq!(s.doc().unwrap().history.undo.last().map(|step| step.label.as_str()), Some("Group by Column")); + // By row, p and q lie in two rows until r, reaching from one to the other, joins them. + let mut s = session(); + let p = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + let q = rect(&mut s, 50.0, 20.0, 10.0, 10.0); + select(&mut s, &[p, q]); + let n = steps(&s); + let r = s.execute("addon.arrange.groupRows", &json!({"direction": "row"})).unwrap(); + assert_eq!((r["grouped"].clone(), steps(&s)), (json!(0), n), "two rows of one: no groups, no step"); + let bridge = rect(&mut s, 100.0, 5.0, 10.0, 20.0); + select(&mut s, &[p, q, bridge]); + let r = s.execute("addon.arrange.groupRows", &json!({"direction": "row"})).unwrap(); + let groups = ids_of(&r["groups"]); + assert_eq!(groups.len(), 1); + assert_eq!(children(&s, groups[0]), [p, q, bridge]); +} + +#[test] +fn group_rows_keeps_layers_and_artboards_apart_and_measures_visual_bounds() { + let mut s = session(); + s.execute("artboard.new", &json!({"x": 500, "y": 0, "width": 200, "height": 300})).unwrap(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + // Touching a's bottom edge: a row of its own until strokes reach over the edge. + let below = rect(&mut s, 50.0, 20.0, 20.0, 20.0); + let far = rect(&mut s, 550.0, 0.0, 20.0, 20.0); + s.execute("layer.new", &json!({})).unwrap(); + let other = rect(&mut s, 100.0, 0.0, 20.0, 20.0); + select(&mut s, &[a, below, far, other]); + let n = steps(&s); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + assert_eq!((r["grouped"].clone(), steps(&s)), (json!(0), n), "another artboard, another layer, a touching edge: no groups"); + select(&mut s, &[a, below]); + s.execute("paint.setStroke", &json!({"color": "#000000"})).unwrap(); + s.execute("stroke.set", &json!({"weight": 4})).unwrap(); + select(&mut s, &[a, below, far, other]); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + let groups = ids_of(&r["groups"]); + assert_eq!(groups.len(), 1); + assert_eq!(children(&s, groups[0]), [a, below], "the strokes overlap"); + let doc = &s.doc().unwrap().doc; + assert_ne!(doc.parent_of(far), Some(groups[0]), "left on its own artboard"); + assert_ne!(doc.layer_of(other), doc.layer_of(a), "left in its own layer"); +} + +#[test] +fn group_rows_measures_clipping_groups_by_their_mask() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + // A 200 tall object clipped to a 30 tall mask at y 100. + let clipped = rect(&mut s, 50.0, 0.0, 10.0, 200.0); + let mask = rect(&mut s, 40.0, 100.0, 30.0, 30.0); + select(&mut s, &[clipped, mask]); + s.execute("object.clippingMask.make", &json!({})).unwrap(); + let group = s.doc().unwrap().selection.objects[0]; + let b = rect(&mut s, 100.0, 110.0, 10.0, 10.0); + select(&mut s, &[a, group, b]); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + let groups = ids_of(&r["groups"]); + assert_eq!(groups.len(), 1); + assert_eq!(children(&s, groups[0]), [group, b], "the mask's row, not the clipped art's"); +} + +#[test] +fn group_rows_is_off_with_one_object_skips_locked_ones_and_refuses_bad_params() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + select(&mut s, &[a]); + assert!(!enabled(&s, "addon.arrange.groupRows")); + let b = rect(&mut s, 30.0, 0.0, 20.0, 20.0); + let c = rect(&mut s, 60.0, 0.0, 20.0, 20.0); + select(&mut s, &[a, b, c]); + assert!(enabled(&s, "addon.arrange.groupRows")); + refuses(&mut s, "addon.arrange.groupRows", &[json!({"direction": "diagonal"}), json!({"direction": 3}), json!({"direction": true})]); + select(&mut s, &[b]); + s.execute("object.lock", &json!({})).unwrap(); + s.execute("select.all", &json!({})).unwrap(); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + let groups = ids_of(&r["groups"]); + assert_eq!(groups.len(), 1); + assert_eq!(children(&s, groups[0]), [a, c], "the locked object stays out"); + assert_eq!(s.doc().unwrap().doc.parent_of(b), Some(s.doc().unwrap().doc.layers[0].id)); +} + +#[test] +fn group_rows_sorts_many_objects_into_rows() { + // 20000 objects in pairs up the page, the front one of each pair starting higher: each pair overlaps, + // neighboring pairs only touch. + let items: Vec<(u8, (f64, f64))> = (0..20_000) + .map(|i| { + let top = (10_000 - i / 2) as f64 * 10.0; + (0, (if i % 2 == 0 { top + 1.0 } else { top }, top + 10.0)) + }) + .collect(); + let rows = super::rows_of(&items); + assert_eq!(rows.len(), 10_000); + assert!(rows.iter().all(|r| r.len() == 2 && r[1] == r[0] + 1), "pairs, in the order given"); + assert_eq!(rows.first(), Some(&vec![19_998, 19_999]), "the top row first"); +} + +#[test] +fn group_rows_keeps_a_flat_object_on_a_row_edge_apart_in_either_order() { + // An extent with no height at the top edge of another only touches it, whichever is in front. + let flat_behind: Vec<(u8, (f64, f64))> = vec![(0, (0.0, 0.0)), (0, (0.0, 10.0))]; + let flat_in_front: Vec<(u8, (f64, f64))> = vec![(0, (0.0, 10.0)), (0, (0.0, 0.0))]; + assert!(super::rows_of(&flat_behind).is_empty()); + assert!(super::rows_of(&flat_in_front).is_empty(), "{:?}", super::rows_of(&flat_in_front)); + // Inside the row, it joins. + assert_eq!(super::rows_of(&[(0u8, (0.0, 10.0)), (0, (5.0, 5.0))]), vec![vec![0, 1]]); +} + fn opacity(s: &Session, id: NodeId) -> f32 { s.doc().unwrap().doc.node(id).unwrap().opacity } diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index 75074c6c3c..a0bd0d94b2 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -6,6 +6,7 @@ pub(super) const ALLOWED: &[&str] = &[ "addon.arrange.grid", "addon.arrange.groupOverlapping", + "addon.arrange.groupRows", "addon.arrange.offset", "addon.arrange.randomizeOpacity", "addon.arrange.replace", diff --git a/crates/engine/tests/command_sweep.rs b/crates/engine/tests/command_sweep.rs index c98cd9278e..bc72152b5c 100644 --- a/crates/engine/tests/command_sweep.rs +++ b/crates/engine/tests/command_sweep.rs @@ -1003,6 +1003,8 @@ fn structured_junk() { ("addon.arrange.size", json!({"width": 1e6, "height": 0.001, "reference": 8, "scaleStrokes": true})), ("addon.arrange.size", json!({"width": 0.001, "proportional": true, "reference": u64::MAX})), ("addon.arrange.groupOverlapping", json!({"ids": "x", "junk": f64::MAX})), + ("addon.arrange.groupRows", json!({"direction": "column"})), + ("addon.arrange.groupRows", json!({"direction": "diagonal", "junk": f64::MAX})), ("addon.arrange.randomizeOpacity", json!({"min": 0, "max": 100, "seed": u64::MAX})), ("addon.arrange.randomizeOpacity", json!({"min": f64::MAX, "max": -1e308, "seed": -1, "ids": [u64::MAX]})), ("addon.arrange.randomizeOpacity", json!({"min": 100, "max": 0, "seed": 1e308, "ids": []})), diff --git a/crates/ui-egui/src/addons/arrange.rs b/crates/ui-egui/src/addons/arrange.rs index ccd32bd7aa..44eb168b3b 100644 --- a/crates/ui-egui/src/addons/arrange.rs +++ b/crates/ui-egui/src/addons/arrange.rs @@ -1,5 +1,5 @@ //! Arrange Tools in the interface: its submenu (Object › Plug-ins › Arrange Tools); the dialogs of -//! Arrange in Grid, Offset Objects, Replace with Top Object, Set Size of Each, Randomize Opacity and Sort Objects, +//! Arrange in Grid, Offset Objects, Replace with Top Object, Set Size of Each, Group by Row, Randomize Opacity and Sort Objects, //! which preview on the canvas and run their `addon.arrange.*` command on OK; Group Overlapping //! Objects; and Zoom to Selection ([`ZOOM`]), which fits the active view to the selection. @@ -25,14 +25,16 @@ const GRID: &str = "addon.arrange.grid"; const OFFSET: &str = "addon.arrange.offset"; const REPLACE: &str = "addon.arrange.replace"; const SIZE: &str = "addon.arrange.size"; +const ROWS: &str = "addon.arrange.groupRows"; const OPACITY: &str = "addon.arrange.randomizeOpacity"; const SORT: &str = "addon.arrange.sort"; /// Each dialog's command and heading. -const DIALOGS: [(&str, &str); 6] = [ +const DIALOGS: [(&str, &str); 7] = [ (GRID, "Arrange in Grid"), (OFFSET, "Offset Objects"), (REPLACE, "Replace with Top Object"), (SIZE, "Set Size of Each"), + (ROWS, "Group by Row"), (OPACITY, "Randomize Opacity"), (SORT, "Sort Objects"), ]; @@ -64,6 +66,7 @@ pub fn menu() -> Vec { c("Replace with Top Object…", REPLACE), c("Set Size of Each…", SIZE), cp("Group Overlapping Objects", "addon.arrange.groupOverlapping", json!({})), + c("Group by Row…", ROWS), c("Randomize Opacity…", OPACITY), c("Sort Objects…", SORT), Sep, @@ -75,6 +78,7 @@ static GRID_SPEC: Spec = Spec { command: GRID, params: grid_params, found: None static OFFSET_SPEC: Spec = Spec { command: OFFSET, params: offset_params, found: None }; static REPLACE_SPEC: Spec = Spec { command: REPLACE, params: replace_params, found: None }; static SIZE_SPEC: Spec = Spec { command: SIZE, params: size_params, found: None }; +static ROWS_SPEC: Spec = Spec { command: ROWS, params: group_rows_params, found: None }; static OPACITY_SPEC: Spec = Spec { command: OPACITY, params: opacity_params, found: None }; static SORT_SPEC: Spec = Spec { command: SORT, params: sort_params, found: None }; @@ -149,6 +153,11 @@ fn size_rows(lengths: LengthUnits) -> Vec { ] } +fn group_rows_rows() -> Vec { + let directions = [("row", "Rows"), ("column", "Columns")]; + vec![choice("direction", "Group By:", &directions, "row")] +} + fn opacity_rows() -> Vec { vec![percent("min", "Minimum:", 30.0), percent("max", "Maximum:", 100.0), seed()] } @@ -192,6 +201,10 @@ fn size_params(fields: &DialogFields) -> Value { Value::Object(params) } +fn group_rows_params(fields: &DialogFields) -> Value { + Value::Object(form::json_of(&group_rows_rows(), fields)) +} + fn opacity_params(fields: &DialogFields) -> Value { Value::Object(form::json_of(&opacity_rows(), fields)) } @@ -217,6 +230,7 @@ pub(crate) fn open(app: &mut VectorcraftApp, id: &str) -> Option (offset_rows(lengths), json!({ "direction": "row", "gap": 10, "order": "stacking", "reverse": false })), REPLACE => (replace_rows(), json!({ "fit": "keep", "keep": false, "scaleStrokes": strokes })), + ROWS => (group_rows_rows(), json!({ "direction": "row" })), // A new seed each time the document has changed, so running it again varies the result. OPACITY => (opacity_rows(), json!({ "min": 30, "max": 100, "seed": st.revision % SEEDS })), // The random order's seed (not shown): new whenever the document has changed, so each run @@ -245,6 +259,7 @@ pub(crate) fn open(app: &mut VectorcraftApp, id: &str) -> Option super::dialogs::open(app, &GRID_SPEC, fields, move |fields| dialog(GRID, grid_rows(lengths)).values(Bind::bound(fields))), OFFSET => super::dialogs::open(app, &OFFSET_SPEC, fields, move |fields| dialog(OFFSET, offset_rows(lengths)).values(Bind::bound(fields))), REPLACE => super::dialogs::open(app, &REPLACE_SPEC, fields, |fields| dialog(REPLACE, replace_rows()).values(Bind::bound(fields))), + ROWS => super::dialogs::open(app, &ROWS_SPEC, fields, |fields| dialog(ROWS, group_rows_rows()).values(Bind::bound(fields))), OPACITY => super::dialogs::open(app, &OPACITY_SPEC, fields, |fields| { let (min, max) = (fields.number("min").unwrap_or(0.0), fields.number("max").unwrap_or(100.0)); dialog(OPACITY, opacity_rows()).ok_enabled(min <= max).values(Bind::bound(fields)) diff --git a/crates/ui-egui/src/addons/arrange/tests.rs b/crates/ui-egui/src/addons/arrange/tests.rs index 016391d661..41686a4bd1 100644 --- a/crates/ui-egui/src/addons/arrange/tests.rs +++ b/crates/ui-egui/src/addons/arrange/tests.rs @@ -169,6 +169,64 @@ fn stacking(panel: &Harness) -> Vec { panel.app().session.doc().unwrap().doc.layers[0].children().unwrap().iter().map(|n| n.id).collect() } +/// [`app`] with a third rectangle, c, in b's row and a's column; all three selected. +fn rows_app() -> (VectorcraftApp, NodeId, NodeId, NodeId) { + let (mut app, a, b) = app(); + let c = NodeId(app.run("shape.rectangle", json!({"x": 10, "y": 100, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + app.run("select.all", json!({})).unwrap(); + (app, a, b, c) +} + +fn parent(panel: &Harness, id: NodeId) -> Option { + panel.app().session.doc().unwrap().doc.parent_of(id) +} + +#[test] +fn real_group_by_row_keyboard_choice_reaches_the_preview_and_ok_groups_as_one_step() { + let (app, a, b, c) = rows_app(); + let n = steps(&app); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + click(&mut panel.app(), "Group by Row…"); + panel.frame(); + let layer = panel.app().session.doc().unwrap().doc.layers[0].id; + // Rows: b and c share one, a is alone in its own. + assert_eq!(parent(&panel, b), parent(&panel, c), "the preview groups b's row"); + assert_ne!(parent(&panel, b), Some(layer)); + assert_eq!(parent(&panel, a), Some(layer)); + panel.click_role("Group By", Role::COMBO_BOX); + panel.key(egui::Key::ArrowDown, egui::Modifiers::NONE); + panel.key(egui::Key::Enter, egui::Modifiers::NONE); + panel.frame(); + let id = host::dialog_id(&panel.app()); + assert_eq!(host::read(&panel.app(), id, |f| f.text("direction").map(str::to_owned)), Some("column".to_owned())); + // Columns: a and c share one, b is alone in its own. + assert_eq!(parent(&panel, a), parent(&panel, c), "the preview follows the keyboard choice"); + assert_ne!(parent(&panel, a), Some(layer)); + assert_eq!(parent(&panel, b), Some(layer)); + panel.click("OK"); + panel.frame(); + let group = parent(&panel, a).unwrap(); + assert_eq!(stacking(&panel), vec![b, group], "the group takes c's place, in front of b"); + assert_eq!(parent(&panel, c), Some(group)); + assert_eq!(steps(&panel.app()), n + 1, "one undo step"); + assert!(!panel.app().any_dialog_open()); +} + +#[test] +fn real_group_by_row_cancel_leaves_the_objects_ungrouped() { + let (app, a, b, c) = rows_app(); + let n = steps(&app); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + click(&mut panel.app(), "Group by Row…"); + panel.frame(); + assert_eq!(stacking(&panel).len(), 2, "the preview groups b and c"); + panel.click("Cancel"); + panel.frame(); + assert_eq!(stacking(&panel), vec![a, b, c]); + assert_eq!(steps(&panel.app()), n); + assert!(!panel.app().any_dialog_open()); +} + #[test] fn real_replace_edits_reach_the_preview_and_confirmed_copies() { let (app, a, b) = app(); diff --git a/docs/mcp.md b/docs/mcp.md index d984e7b92d..1582662613 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17582,6 +17582,7 @@ as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid | `addon.arrange.replace` | `fit`: `keep`, `bounds` (the replaced object's width and height), `proportional` (fits inside them) (`keep`); `scaleStrokes`; `keep` (false) | Puts a copy of the topmost selected object centred on each of the other selected objects, in that object's place in the stacking order; the replaced objects are deleted unless `keep` (the copy then goes right above each). Needs two objects or more; the copies are selected. → `{ids}` | | `addon.arrange.size` | `width`, `height` pt, 0.001…1000000 (at least one); `proportional` (false: a side not given stays; true: it follows the given one in proportion); `reference` 0…8 (4, the centre); `scaleStrokes` | Gives every selected object that width and height, keeping its reference point in place (the 9-point grid row by row from the top-left). | | `addon.arrange.groupOverlapping` | none | Groups the selected objects (at most 20000) wherever their visual bounds overlap or touch, chains included: when A overlaps B and B overlaps C, all three go in one group. Only objects in the same layer or group are grouped together; objects that overlap nothing stay as they are. Each new group goes where its frontmost member was in the stacking order, and the groups and the objects left alone stay selected; with nothing overlapping it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | +| `addon.arrange.groupRows` | `direction`: `row` (vertical extents), `column` (horizontal extents) (`row`) | Groups the selected objects (at most 20000) into one group for each row (column): an object joins a row when its visual bounds, a clipping group's by its mask, overlap the row's extent from top to bottom (left to right). Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row; an object alone in its row stays as it is. Each new group goes where its frontmost member was in the stacking order, and the groups (top to bottom, or left to right) and the objects left alone stay selected; with no row of two objects or more it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | | `addon.arrange.randomizeOpacity` | `min`, `max` % 0…100 (30, 100; `min` not more than `max`); `seed` whole number (0); `ids` (the selection) | Gives each selected object its own opacity (the object opacity the Transparency panel sets), picked at random and evenly from `min` to `max`; the same seed, objects and range give the same opacities. Groups take one opacity of their own; the objects inside keep theirs. A run that changes no opacity, such as `min` and `max` both at the opacity every object has, records no undo step. → `{count}` | | `addon.arrange.sort` | `by`, `apply`: `width`, `height`, `area` (width × height), `x` (left edge), `y` (top edge), `opacity` (%), `stacking` (stacking order from the back) (`area`, `stacking`); `order`: `ascending` (small to large), `descending` (large to small), `random` (`ascending`); `distribute` (false); `seed` whole number (0, for `random`); `scaleStrokes`; `ids` (the selection) | Sorts the selected objects (at most 20000) by `by` and gives them the values of `apply` in that order: the first gets the smallest value. Without `distribute` the objects trade the values they have; with it the values step evenly from the smallest to the largest. A width, height or area changes about each object's centre (an area in proportion), a place moves the top-left corner. Stacking order always trades places, and only among objects in the same layer or group. Needs two objects or more. → `{count}` | @@ -17591,11 +17592,13 @@ and fails with nothing selected. Arrange in Grid…, Replace with Top Object…, (`ui.menuDialog {command}`, dialog kinds `arrangeGrid`, `arrangeReplace`, `arrangeSize`, `arrangeOpacity` and `arrangeSort`) whose fields are the command's parameters, with Preview (Randomize Opacity's seed, and Sort Objects' `seed`, which is not shown, start new whenever the document has changed); Set Size of Each's `__width` and `__height` say which sizes OK applies. Offset Objects… opens one the same way (`ui.menuDialog {command: "addon.arrange.offset"}`), with Direction, Gap, Order -and Reverse Order. +and Reverse Order. Group by Row… opens one too (`ui.menuDialog {command: "addon.arrange.groupRows"}`), with Group By +(Rows or Columns). ```json {"name":"run_command","arguments":{"command":"addon.arrange.grid","params":{"columns":4,"gapX":12,"gapY":12}}} {"name":"run_command","arguments":{"command":"addon.arrange.offset","params":{"direction":"column","gap":6,"order":"position"}}} +{"name":"run_command","arguments":{"command":"addon.arrange.groupRows","params":{"direction":"row"}}} {"name":"run_command","arguments":{"command":"addon.arrange.replace","params":{"fit":"proportional"}}} {"name":"run_command","arguments":{"command":"addon.arrange.size","params":{"width":72,"proportional":true}}} ``` diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index ee49042298..ef8382bb36 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3162,6 +3162,10 @@ A VectorCraft addition, not a feature of the reference app, so no area score mov A VectorCraft addition, so no area score moves. Object › Plug-ins › Arrange Tools › Offset Objects… chains the top-level selected objects one after another in a row (left to right) or a column (top to bottom) with a gap of −1000000 to 1000000 pt (10 by default; a negative gap overlaps them). The order is the stacking order from the back, or the position (left edges in a row, top edges in a column), and Reverse Order runs it the other way. The first object stays where it is; each later one moves only along the row or column so that it starts the gap past the end of the one before it, and keeps its place across it. Objects are measured by their visual bounds, a clipping group by its mask. One undo step; no step when nothing moves. Tests: `offset_*` in `cmd::addons::arrange::tests` in `vectorcraft-engine` (row and column, both orders and reversed, a negative gap, strokes and clipping groups, no step, locked objects left out, bad params), `real_offset_*` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. +## Arrange Tools add-on: Group by Row (2026-11-29) + +A VectorCraft addition, so no area score moves. Object › Plug-ins › Arrange Tools › Group by Row… puts the top-level selected objects (at most 20000) into one group for each row: an object joins a row when its visual bounds, a clipping group's by its mask, overlap the row from top to bottom. Group By Columns does the same from left to right. Extents that only touch stay apart, an object that overlaps two rows joins them, and only objects in the same layer or group and on the same artboard share a row; an object alone in its row stays as it is. Each new group takes its frontmost member's place in the stacking order, and the groups and the objects left alone stay selected. One undo step; no step when no row holds two objects. Tests: `group_rows_*` in `cmd::addons::arrange::tests` in `vectorcraft-engine` (rows and loners, columns, an object spanning two rows, layers and artboards kept apart, strokes and clipping groups, locked objects left out, bad params, 20000 objects), `real_group_by_row_*` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. + ## Type Tools add-on: Text Tweaker (2026-11-03) A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Type Tools › Text Tweaker… gives one character attribute (size, baseline shift, character rotation, horizontal or vertical scale, tracking, leading or stroke weight) to the selected characters letter by letter, from a start value to an end value along a straight ramp, an ease in and out, a bow, a spike or at random with a seed, while the text stays live and editable (#4924). With Block enabled, a leading ramp sets Line Gap from the first changed character instead of varying leading across the text. Values are set as the Character panel sets them, in its units and ranges, so scaled type takes the sizes shown; spaces and line breaks are skipped unless asked for, each type object gets its own ramp, the range is the Type tool's selection or all the text of the selected type objects, and the run is one undo step from a dialog with Preview. Tests: `cmd::addons::typetools::tests` in `vectorcraft-engine` (each shape, each attribute, skipped spaces, ranges, one ramp per object, seeded random values, scaled type, one undo step, bad params refused), `addons::typetools::tests` in `vectorcraft-ui-egui` (the submenu, the dialog, Preview and Cancel, OK) and `command_sweep`. Commands: `docs/mcp.md` › Type Tools add-on. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index ac20453f86..795af5c60c 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -568,6 +568,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Randomize Opacity… gives each selected object its own opacity at random between Minimum and Maximum (%), with a Seed that repeats it and Preview, one undo step | done | #4925; `addon.arrange.randomizeOpacity`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; not a feature of the reference app, so it is not scored | | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Sort Objects… sorts the selected objects by Sort By (width, height, area, X or Y position, opacity, stacking order) in an Order (Small to Large, Large to Small, Random) and gives them Apply To in that order, trading the values or with Distribute Evenly; Scale Strokes & Effects; Preview; one undo step | done | #4917; `addon.arrange.sort`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; not a feature of the reference app, so it is not scored | | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Offset Objects… chains the selected objects one after another in a Direction (Row (Left to Right) or Column (Top to Bottom)) with a Gap (negative overlaps), in an Order (Stacking Order or Position) with Reverse Order; the first stays in place and the others move only along the row or column; Preview; one undo step | done | `addon.arrange.offset`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; a VectorCraft addition, so it is not scored | +| Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Group by Row… groups the selected objects whose visual bounds overlap from top to bottom into one group for each row, or with Group By Columns from left to right (within one layer or group and one artboard), each group at its frontmost member's stacking place; Preview; one undo step | done | `addon.arrange.groupRows`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; a VectorCraft addition, so it is not scored | | Document Tools add-on (VectorCraft addition): Object › Plug-ins › Document Tools › Save a Timestamped Copy writes `_YYYY-MM-DD_HH-MM.` next to the document (a folder picked for one never saved), which keeps its path, title and modified state; off on the web | done | #4926; `addon.document.saveTimestampedCopy`, `crates/engine/src/cmd/addons/document.rs`, `crates/ui-egui/src/addons/document.rs` and their tests; not a feature of the reference app, so it is not scored | | Document Tools add-on (VectorCraft addition): Export All Open Documents as PDF / as SVG (#4920) | done | asks for a folder, writes a copy of every open document named after it (taken names numbered, nothing replaced), documents and active tab unchanged; failures named in the status bar | | Document Tools add-on (VectorCraft addition): Object › Plug-ins › Document Tools › Batch Trace Folder asks for a folder of images, then a destination folder, traces each image with a preset (optionally expanded) and saves it there as `.vectorcraft`, `.svg`, `.pdf`, `.ai` or `.eps` under its own name (taken names numbered, nothing replaced), closing each image again; the status bar counts the images traced and those that couldn't be; off on the web | done | #4921; `addon.document.batchTraceFolder`, `crates/engine/src/cmd/addons/document/batch_trace.rs`, `crates/ui-egui/src/addons/document.rs` and their tests; not a feature of the reference app | From 1f9238190c5e39d0112e0459384780184def951f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 15:16:10 -0800 Subject: [PATCH 2/7] Arrange Tools: Group by Row treats a -0.0 edge as 0.0 rows_of sorted extents with total_cmp, which puts -0.0 before 0.0, so an extent starting at -0.0 opened its row before a flat extent at 0.0 and the flat one joined a row it only touches. Both ends of each extent now go through + 0.0 first, with a test for a -0.0 start beside a flat 0.0 extent. --- crates/engine/src/cmd/addons/arrange.rs | 4 +++- crates/engine/src/cmd/addons/arrange/tests.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index 4274932141..9c64df9c1d 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -424,8 +424,10 @@ fn group_overlapping(s: &mut Session, _: &Value) -> Result { /// two or more (each in the order given) among items of the same key whose extents overlap, chains included. /// Extents that only touch stay apart. Sorted by start, then by end, each item joins its key's open row when it /// starts before that row ends, so the rows come out in order along the axis, and an extent with no length at -/// another's start stays apart from it whatever their order. +/// another's start stays apart from it whatever their order. Adding 0.0 turns -0.0 into 0.0, which +/// `total_cmp` would otherwise order first. fn rows_of(items: &[(K, (f64, f64))]) -> Vec> { + let items: Vec<(K, (f64, f64))> = items.iter().map(|(k, (start, end))| (*k, (start + 0.0, end + 0.0))).collect(); let mut order: Vec = (0..items.len()).collect(); order.sort_by(|a, b| items[*a].1.0.total_cmp(&items[*b].1.0).then(items[*a].1.1.total_cmp(&items[*b].1.1))); let mut rows: Vec> = vec![]; diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index 94e43a78d2..2a586763b6 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -625,6 +625,9 @@ fn group_rows_keeps_a_flat_object_on_a_row_edge_apart_in_either_order() { assert!(super::rows_of(&flat_in_front).is_empty(), "{:?}", super::rows_of(&flat_in_front)); // Inside the row, it joins. assert_eq!(super::rows_of(&[(0u8, (0.0, 10.0)), (0, (5.0, 5.0))]), vec![vec![0, 1]]); + // A start of -0.0 is the same edge as 0.0, so the flat extent there still only touches. + let negative_zero: Vec<(u8, (f64, f64))> = vec![(0, (0.0, 0.0)), (0, (-0.0, 10.0))]; + assert!(super::rows_of(&negative_zero).is_empty(), "{:?}", super::rows_of(&negative_zero)); } fn opacity(s: &Session, id: NodeId) -> f32 { From aa7962ec9514a0718a5c6b3a330fe20d44704dda Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:11:19 -0800 Subject: [PATCH 3/7] Arrange Tools: Group by Row leaves masks, locked objects and blend keys alone Clipping masks, locked or hidden objects and objects outside every artboard stay in place; a selection inside a live blend and a direction of null are rejected. The docs say raster effects do not count toward row bounds. --- crates/engine/src/cmd/addons/arrange.rs | 29 ++++- crates/engine/src/cmd/addons/arrange/tests.rs | 119 +++++++++++++++++- docs/mcp.md | 2 +- 3 files changed, 143 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index 9c64df9c1d..d33bcfcee5 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use serde_json::{Value, json}; use vectorcraft_color::recolor::Rng; -use vectorcraft_doc::{Node, NodeId, OrientedBox}; +use vectorcraft_doc::{Node, NodeId, NodeKind, OrientedBox}; use vectorcraft_geom::{Affine, Point, Rect, Vec2}; use vectorcraft_render::effects; @@ -104,7 +104,7 @@ pub fn specs() -> Vec { "Group by Row", ["Object", "Plug-ins", "Arrange Tools"], None, - "{direction?: \"row\" (objects whose vertical extents overlap) | \"column\" (objects whose horizontal extents overlap) (\"row\")} group the selected objects (the top-level ones, at most 20000) into one group for each row (column), as one undo step. An object joins a row when its visual bounds (strokes and effects as drawn; a clipping group by its mask) overlap the row's extent across it; extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row, an object alone in its row stays as it is, and each new group goes where its frontmost member was in the stacking order; the new groups (top to bottom, or left to right) and the objects left alone stay selected. A run with no row of two or more objects makes no step → {groups: [id…], grouped (how many objects went into groups)}", + "{direction?: \"row\" (objects whose vertical extents overlap) | \"column\" (objects whose horizontal extents overlap) (\"row\" when omitted; null is invalid)} group the selected objects (the top-level ones, at most 20000) into one group for each row (column), as one undo step. An object joins a row when its visual bounds overlap the row's extent across it. Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, and clipping masks stay in place. The command rejects selections of editable objects whose parent is neither a layer nor a group, including live blend keys. An object alone in its row stays as it is, and each new group goes where its frontmost member was in the stacking order; the new groups (top to bottom, or left to right) and the objects left alone stay selected. A run with no row of two or more objects makes no step → {groups: [id…], grouped (how many objects went into groups)}", has_multi, group_rows ), @@ -457,20 +457,39 @@ fn rows_of(items: &[(K, (f64, f64))]) -> Vec Result { const C: &str = "addon.arrange.groupRows"; + if p.get("direction").is_some_and(Value::is_null) { + return Err(bad(C, "`direction` must be row or column")); + } let rows = choice(p, C, "direction", &["row", "column"])?.unwrap_or("row") == "row"; let roots = selected_roots(s)?; if roots.len() > MAX_OBJECTS { return Err(bad(C, "too many objects selected (at most 20000)")); } let d = &s.doc()?.doc; + let editable_roots: Vec<_> = { + let editable = d.editable(); + roots.iter().copied().filter(|id| editable(*id)).collect() + }; + for id in &editable_roots { + if d.parent_of(*id).and_then(|parent| d.node(parent)).is_some_and(|n| !matches!(n.kind, NodeKind::Layer { .. } | NodeKind::Group { .. })) { + return Err(bad(C, "selected objects must be in a layer or group")); + } + } // Each object's row key (its parent and its artboard) and its extent across the rows. - type Keyed = ((Option, Option), (f64, f64)); - let items: Vec<(NodeId, Keyed)> = roots + type Keyed = ((Option, usize), (f64, f64)); + let items: Vec<(NodeId, Keyed)> = editable_roots .iter() .filter_map(|id| { + let parent = d.parent_of(*id); + if parent + .and_then(|parent| d.node(parent)) + .is_some_and(|n| n.clips() && n.children().and_then(|c| c.first()).is_some_and(|c| c.id == *id)) + { + return None; + } let b = effects::preview::bounds_of(d, &[*id], true)?; let extent = if rows { (b.y0, b.y1) } else { (b.x0, b.x1) }; - Some((*id, ((d.parent_of(*id), d.artboard_for_bounds(b)), extent))) + Some((*id, ((parent, d.artboard_for_bounds(b)?), extent))) }) .collect(); let keyed: Vec<_> = items.iter().map(|(_, k)| *k).collect(); diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index 2a586763b6..e382c2a440 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -579,6 +579,119 @@ fn group_rows_measures_clipping_groups_by_their_mask() { assert_eq!(children(&s, groups[0]), [group, b], "the mask's row, not the clipped art's"); } +#[test] +fn group_rows_keeps_clipping_masks_first_in_groups_and_layers() { + for clipping_layer in [false, true] { + let mut s = session(); + let mask = rect(&mut s, 0.0, 0.0, 100.0, 100.0); + let a = rect(&mut s, 10.0, 10.0, 20.0, 20.0); + let b = rect(&mut s, 40.0, 10.0, 20.0, 20.0); + select(&mut s, &[mask, a, b]); + let parent = if clipping_layer { + s.doc().unwrap().doc.layers[0].id + } else { + s.execute("object.group", &json!({})).unwrap(); + s.doc().unwrap().selection.objects[0] + }; + s.edit("Set clipping", |d, _| { + d.node_mut(parent).unwrap().set_clips(true); + Ok(()) + }) + .unwrap(); + select(&mut s, &[mask, a]); + let n = steps(&s); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + assert_eq!((r["grouped"].clone(), steps(&s)), (json!(0), n)); + assert_eq!(children(&s, parent), [mask, a, b]); + select(&mut s, &[mask, a, b]); + let before = s.doc().unwrap().doc.clone(); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + let groups = ids_of(&r["groups"]); + assert_eq!(r["grouped"], json!(2)); + assert_eq!(children(&s, parent), [mask, groups[0]]); + assert_eq!(children(&s, groups[0]), [a, b]); + assert!(s.doc().unwrap().selection.objects.contains(&mask)); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(*s.doc().unwrap().doc == *before); + } +} + +#[test] +fn group_rows_refuses_explicitly_selected_live_blend_keys() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + let b = rect(&mut s, 30.0, 0.0, 20.0, 20.0); + select(&mut s, &[a, b]); + s.execute("object.blend.make", &json!({})).unwrap(); + let blend = s.doc().unwrap().selection.objects[0]; + let c = rect(&mut s, 60.0, 0.0, 20.0, 20.0); + let d = rect(&mut s, 90.0, 0.0, 20.0, 20.0); + select(&mut s, &[a, b]); + refuses(&mut s, "addon.arrange.groupRows", &[json!({})]); + select(&mut s, &[a, b, c, d]); + refuses(&mut s, "addon.arrange.groupRows", &[json!({})]); + assert_eq!(children(&s, blend), [a, b]); +} + +#[test] +fn group_rows_skips_explicitly_selected_locked_and_hidden_objects() { + for command in ["object.lock", "object.hide"] { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + let b = rect(&mut s, 30.0, 0.0, 20.0, 20.0); + let c = rect(&mut s, 60.0, 0.0, 20.0, 20.0); + select(&mut s, &[b]); + s.execute(command, &json!({})).unwrap(); + select(&mut s, &[a, b, c]); + assert!(s.doc().unwrap().selection.objects.contains(&b)); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + let groups = ids_of(&r["groups"]); + assert_eq!(r["grouped"], json!(2)); + assert_eq!(children(&s, groups[0]), [a, c]); + assert_eq!(s.doc().unwrap().doc.parent_of(b), Some(s.doc().unwrap().doc.layers[0].id)); + } +} + +#[test] +fn group_rows_leaves_objects_outside_all_artboards_ungrouped() { + for direction in ["row", "column"] { + let mut s = session(); + let a = rect(&mut s, 500.0, 500.0, 20.0, 20.0); + let b = rect(&mut s, 505.0, 505.0, 20.0, 20.0); + select(&mut s, &[a, b]); + let (before, n) = (s.doc().unwrap().doc.clone(), steps(&s)); + let r = s.execute("addon.arrange.groupRows", &json!({"direction": direction})).unwrap(); + assert_eq!((r["grouped"].clone(), steps(&s)), (json!(0), n)); + assert!(*s.doc().unwrap().doc == *before); + let c = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + let d = rect(&mut s, 5.0, 5.0, 20.0, 20.0); + select(&mut s, &[a, b, c, d]); + let r = s.execute("addon.arrange.groupRows", &json!({"direction": direction})).unwrap(); + let groups = ids_of(&r["groups"]); + assert_eq!(r["grouped"], json!(2)); + assert_eq!(children(&s, groups[0]), [c, d]); + assert_eq!(layer_children(&s), [a, b, groups[0]]); + let sel = &s.doc().unwrap().selection.objects; + assert!(sel.contains(&a) && sel.contains(&b)); + } +} + +#[test] +fn group_rows_documents_and_excludes_raster_effects_from_bounds() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + select(&mut s, &[a]); + s.execute("effect.apply", &json!({"effect": "stylize.dropShadow", "params": {"x": 0, "y": 5, "blur": 0}})).unwrap(); + let b = rect(&mut s, 0.0, 21.0, 20.0, 20.0); + select(&mut s, &[a, b]); + let n = steps(&s); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + assert_eq!((r["grouped"].clone(), steps(&s)), (json!(0), n)); + assert_eq!(layer_children(&s), [a, b]); + let spec = super::specs().into_iter().find(|c| c.id == "addon.arrange.groupRows").unwrap(); + assert!(spec.params.contains("excludes raster effects")); +} + #[test] fn group_rows_is_off_with_one_object_skips_locked_ones_and_refuses_bad_params() { let mut s = session(); @@ -589,7 +702,11 @@ fn group_rows_is_off_with_one_object_skips_locked_ones_and_refuses_bad_params() let c = rect(&mut s, 60.0, 0.0, 20.0, 20.0); select(&mut s, &[a, b, c]); assert!(enabled(&s, "addon.arrange.groupRows")); - refuses(&mut s, "addon.arrange.groupRows", &[json!({"direction": "diagonal"}), json!({"direction": 3}), json!({"direction": true})]); + refuses( + &mut s, + "addon.arrange.groupRows", + &[json!({"direction": "diagonal"}), json!({"direction": 3}), json!({"direction": true}), json!({"direction": null})], + ); select(&mut s, &[b]); s.execute("object.lock", &json!({})).unwrap(); s.execute("select.all", &json!({})).unwrap(); diff --git a/docs/mcp.md b/docs/mcp.md index 1582662613..e01104769b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17582,7 +17582,7 @@ as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid | `addon.arrange.replace` | `fit`: `keep`, `bounds` (the replaced object's width and height), `proportional` (fits inside them) (`keep`); `scaleStrokes`; `keep` (false) | Puts a copy of the topmost selected object centred on each of the other selected objects, in that object's place in the stacking order; the replaced objects are deleted unless `keep` (the copy then goes right above each). Needs two objects or more; the copies are selected. → `{ids}` | | `addon.arrange.size` | `width`, `height` pt, 0.001…1000000 (at least one); `proportional` (false: a side not given stays; true: it follows the given one in proportion); `reference` 0…8 (4, the centre); `scaleStrokes` | Gives every selected object that width and height, keeping its reference point in place (the 9-point grid row by row from the top-left). | | `addon.arrange.groupOverlapping` | none | Groups the selected objects (at most 20000) wherever their visual bounds overlap or touch, chains included: when A overlaps B and B overlaps C, all three go in one group. Only objects in the same layer or group are grouped together; objects that overlap nothing stay as they are. Each new group goes where its frontmost member was in the stacking order, and the groups and the objects left alone stay selected; with nothing overlapping it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | -| `addon.arrange.groupRows` | `direction`: `row` (vertical extents), `column` (horizontal extents) (`row`) | Groups the selected objects (at most 20000) into one group for each row (column): an object joins a row when its visual bounds, a clipping group's by its mask, overlap the row's extent from top to bottom (left to right). Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row; an object alone in its row stays as it is. Each new group goes where its frontmost member was in the stacking order, and the groups (top to bottom, or left to right) and the objects left alone stay selected; with no row of two objects or more it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | +| `addon.arrange.groupRows` | `direction`: `row` (vertical extents), `column` (horizontal extents) (`row` when omitted; `null` is invalid) | Groups the selected objects (at most 20000) into one group for each row (column): an object joins a row when its visual bounds overlap the row's extent from top to bottom (left to right). Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, and clipping masks stay in place. The command rejects selections of editable objects whose parent is neither a layer nor a group, including live blend keys. An object alone in its row stays as it is. Each new group goes where its frontmost member was in the stacking order, and the groups (top to bottom, or left to right) and the objects left alone stay selected; with no row of two objects or more it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | | `addon.arrange.randomizeOpacity` | `min`, `max` % 0…100 (30, 100; `min` not more than `max`); `seed` whole number (0); `ids` (the selection) | Gives each selected object its own opacity (the object opacity the Transparency panel sets), picked at random and evenly from `min` to `max`; the same seed, objects and range give the same opacities. Groups take one opacity of their own; the objects inside keep theirs. A run that changes no opacity, such as `min` and `max` both at the opacity every object has, records no undo step. → `{count}` | | `addon.arrange.sort` | `by`, `apply`: `width`, `height`, `area` (width × height), `x` (left edge), `y` (top edge), `opacity` (%), `stacking` (stacking order from the back) (`area`, `stacking`); `order`: `ascending` (small to large), `descending` (large to small), `random` (`ascending`); `distribute` (false); `seed` whole number (0, for `random`); `scaleStrokes`; `ids` (the selection) | Sorts the selected objects (at most 20000) by `by` and gives them the values of `apply` in that order: the first gets the smallest value. Without `distribute` the objects trade the values they have; with it the values step evenly from the smallest to the largest. A width, height or area changes about each object's centre (an area in proportion), a place moves the top-left corner. Stacking order always trades places, and only among objects in the same layer or group. Needs two objects or more. → `{count}` | From 6532abda434ceed8e59919e3305c490750518510 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 17:19:26 -0800 Subject: [PATCH 4/7] Arrange Tools: Group by Row refuses Shaper and compound shape children and non-object params Group by Row now refuses objects whose parent is a Shaper group or a live compound shape, since regrouping them breaks the Shaper group or changes the Boolean result, and refuses parameters that are not an object. Row measurements share one symbol name index instead of indexing every symbol for each instance. --- crates/engine/src/cmd/addons/arrange.rs | 14 ++- crates/engine/src/cmd/addons/arrange/tests.rs | 95 +++++++++++++++++++ docs/mcp.md | 2 +- 3 files changed, 106 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index d33bcfcee5..1d6d57b0cc 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -104,7 +104,7 @@ pub fn specs() -> Vec { "Group by Row", ["Object", "Plug-ins", "Arrange Tools"], None, - "{direction?: \"row\" (objects whose vertical extents overlap) | \"column\" (objects whose horizontal extents overlap) (\"row\" when omitted; null is invalid)} group the selected objects (the top-level ones, at most 20000) into one group for each row (column), as one undo step. An object joins a row when its visual bounds overlap the row's extent across it. Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, and clipping masks stay in place. The command rejects selections of editable objects whose parent is neither a layer nor a group, including live blend keys. An object alone in its row stays as it is, and each new group goes where its frontmost member was in the stacking order; the new groups (top to bottom, or left to right) and the objects left alone stay selected. A run with no row of two or more objects makes no step → {groups: [id…], grouped (how many objects went into groups)}", + "{direction?: \"row\" (objects whose vertical extents overlap) | \"column\" (objects whose horizontal extents overlap) (\"row\" when omitted; null is invalid)} group the selected objects (the top-level ones, at most 20000) into one group for each row (column), as one undo step. Parameters must be an object. An object joins a row when its visual bounds overlap the row's extent across it. Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, and clipping masks stay in place. The command rejects selections of editable objects whose parent is neither a layer nor a group, including live blend keys, and direct children of Shaper groups or live compound shapes. An object alone in its row stays as it is, and each new group goes where its frontmost member was in the stacking order; the new groups (top to bottom, or left to right) and the objects left alone stay selected. A run with no row of two or more objects makes no step → {groups: [id…], grouped (how many objects went into groups)}", has_multi, group_rows ), @@ -457,6 +457,9 @@ fn rows_of(items: &[(K, (f64, f64))]) -> Vec Result { const C: &str = "addon.arrange.groupRows"; + if !p.is_object() { + return Err(bad(C, "parameters must be an object")); + } if p.get("direction").is_some_and(Value::is_null) { return Err(bad(C, "`direction` must be row or column")); } @@ -471,12 +474,15 @@ fn group_rows(s: &mut Session, p: &Value) -> Result { roots.iter().copied().filter(|id| editable(*id)).collect() }; for id in &editable_roots { - if d.parent_of(*id).and_then(|parent| d.node(parent)).is_some_and(|n| !matches!(n.kind, NodeKind::Layer { .. } | NodeKind::Group { .. })) { - return Err(bad(C, "selected objects must be in a layer or group")); + if d.parent_of(*id).and_then(|parent| d.node(parent)).is_some_and(|n| { + !matches!(n.kind, NodeKind::Layer { .. } | NodeKind::Group { .. }) || n.is_compound_shape() || n.extras().shaper.is_some() + }) { + return Err(bad(C, "selected objects must be in a layer or group without live structural roles")); } } // Each object's row key (its parent and its artboard) and its extent across the rows. type Keyed = ((Option, usize), (f64, f64)); + let symbols = d.symbol_boxes(); let items: Vec<(NodeId, Keyed)> = editable_roots .iter() .filter_map(|id| { @@ -487,7 +493,7 @@ fn group_rows(s: &mut Session, p: &Value) -> Result { { return None; } - let b = effects::preview::bounds_of(d, &[*id], true)?; + let b = effects::preview::visual_bounds(&symbols.unmeasured(), d.node(*id)?)?; let extent = if rows { (b.y0, b.y1) } else { (b.x0, b.x1) }; Some((*id, ((parent, d.artboard_for_bounds(b)?), extent))) }) diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index e382c2a440..5416687473 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -633,6 +633,58 @@ fn group_rows_refuses_explicitly_selected_live_blend_keys() { assert_eq!(children(&s, blend), [a, b]); } +#[test] +fn group_rows_refuses_explicitly_selected_shaper_children() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 100.0, 100.0); + let b = rect(&mut s, 50.0, 0.0, 100.0, 100.0); + select(&mut s, &[a, b]); + let shaper = NodeId(s.execute("shaper.scribble", &json!({"points": [[25, 25], [125, 25]]})).unwrap()["id"].as_u64().unwrap()); + let members = children(&s, shaper); + assert!(members.len() >= 2); + let sources = members[0]; + let face = s + .doc() + .unwrap() + .doc + .node(shaper) + .unwrap() + .children() + .unwrap() + .iter() + .find(|n| n.name.as_deref().is_some_and(|name| name.starts_with(vectorcraft_doc::shaper::FILL_PREFIX))) + .unwrap() + .id; + let c = rect(&mut s, 200.0, 0.0, 20.0, 20.0); + let d = rect(&mut s, 230.0, 0.0, 20.0, 20.0); + for direction in ["row", "column"] { + select(&mut s, &[sources, face]); + refuses(&mut s, "addon.arrange.groupRows", &[json!({"direction": direction})]); + select(&mut s, &[sources, face, c, d]); + refuses(&mut s, "addon.arrange.groupRows", &[json!({"direction": direction})]); + assert_eq!(children(&s, shaper), members); + } +} + +#[test] +fn group_rows_refuses_explicitly_selected_live_compound_shape_operands() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 30.0, 30.0); + let b = rect(&mut s, 10.0, 0.0, 30.0, 30.0); + select(&mut s, &[a, b]); + s.execute("object.compoundShape.make", &json!({"mode": "subtract"})).unwrap(); + let shape = s.doc().unwrap().selection.objects[0]; + let c = rect(&mut s, 200.0, 0.0, 20.0, 20.0); + let d = rect(&mut s, 230.0, 0.0, 20.0, 20.0); + for direction in ["row", "column"] { + select(&mut s, &[a, b]); + refuses(&mut s, "addon.arrange.groupRows", &[json!({"direction": direction})]); + select(&mut s, &[a, b, c, d]); + refuses(&mut s, "addon.arrange.groupRows", &[json!({"direction": direction})]); + assert_eq!(children(&s, shape), [a, b]); + } +} + #[test] fn group_rows_skips_explicitly_selected_locked_and_hidden_objects() { for command in ["object.lock", "object.hide"] { @@ -717,6 +769,49 @@ fn group_rows_is_off_with_one_object_skips_locked_ones_and_refuses_bad_params() assert_eq!(s.doc().unwrap().doc.parent_of(b), Some(s.doc().unwrap().doc.layers[0].id)); } +#[test] +fn group_rows_refuses_non_object_params_without_an_edit() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + let b = rect(&mut s, 30.0, 0.0, 20.0, 20.0); + select(&mut s, &[a, b]); + let selection = s.doc().unwrap().selection.objects.clone(); + refuses(&mut s, "addon.arrange.groupRows", &[json!([]), json!(["row"]), json!("row"), json!(true), json!(3)]); + assert_eq!(s.doc().unwrap().selection.objects, selection); +} + +#[test] +fn group_rows_reads_the_symbol_index_once_for_all_members() { + use std::sync::Arc; + use vectorcraft_doc::{Appearance, Document, Node, NodeKind, Symbol}; + use vectorcraft_geom::Affine; + + let mut d = Document::new(400.0, 300.0); + for i in 0..200 { + let art = Node::path(d.alloc_id(), vectorcraft_geom::shapes::rectangle(Rect::new(0.0, 0.0, 10.0, 10.0)), Appearance::default_art()); + d.symbols.push(Symbol { dynamic: false, name: format!("Mark {i}"), art: Arc::new(art) }); + } + let layer = d.layers[0].id; + let ids: Vec<_> = (0..8) + .map(|i| { + let xf = Affine::translate((0.0, f64::from(i) * 20.0)); + let n = Node::new(d.alloc_id(), NodeKind::SymbolInstance { symbol: format!("Mark {i}"), xf }); + d.insert(Some(layer), usize::MAX, n).unwrap() + }) + .collect(); + let symbol_count = d.symbols.len(); + let mut s = Session::new(); + s.add_document(d, None); + select(&mut s, &ids); + let n = steps(&s); + let before = vectorcraft_doc::symbols_read(); + let r = s.execute("addon.arrange.groupRows", &json!({})).unwrap(); + let read = vectorcraft_doc::symbols_read() - before; + assert!(read <= symbol_count, "{read} symbols read, {symbol_count} in the document"); + assert_eq!((r["grouped"].clone(), steps(&s)), (json!(0), n)); + assert_eq!(layer_children(&s), ids); +} + #[test] fn group_rows_sorts_many_objects_into_rows() { // 20000 objects in pairs up the page, the front one of each pair starting higher: each pair overlaps, diff --git a/docs/mcp.md b/docs/mcp.md index e01104769b..3543a70ff2 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17582,7 +17582,7 @@ as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid | `addon.arrange.replace` | `fit`: `keep`, `bounds` (the replaced object's width and height), `proportional` (fits inside them) (`keep`); `scaleStrokes`; `keep` (false) | Puts a copy of the topmost selected object centred on each of the other selected objects, in that object's place in the stacking order; the replaced objects are deleted unless `keep` (the copy then goes right above each). Needs two objects or more; the copies are selected. → `{ids}` | | `addon.arrange.size` | `width`, `height` pt, 0.001…1000000 (at least one); `proportional` (false: a side not given stays; true: it follows the given one in proportion); `reference` 0…8 (4, the centre); `scaleStrokes` | Gives every selected object that width and height, keeping its reference point in place (the 9-point grid row by row from the top-left). | | `addon.arrange.groupOverlapping` | none | Groups the selected objects (at most 20000) wherever their visual bounds overlap or touch, chains included: when A overlaps B and B overlaps C, all three go in one group. Only objects in the same layer or group are grouped together; objects that overlap nothing stay as they are. Each new group goes where its frontmost member was in the stacking order, and the groups and the objects left alone stay selected; with nothing overlapping it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | -| `addon.arrange.groupRows` | `direction`: `row` (vertical extents), `column` (horizontal extents) (`row` when omitted; `null` is invalid) | Groups the selected objects (at most 20000) into one group for each row (column): an object joins a row when its visual bounds overlap the row's extent from top to bottom (left to right). Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, and clipping masks stay in place. The command rejects selections of editable objects whose parent is neither a layer nor a group, including live blend keys. An object alone in its row stays as it is. Each new group goes where its frontmost member was in the stacking order, and the groups (top to bottom, or left to right) and the objects left alone stay selected; with no row of two objects or more it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | +| `addon.arrange.groupRows` | `direction`: `row` (vertical extents), `column` (horizontal extents) (`row` when omitted; `null` is invalid). Parameters must be an object. | Groups the selected objects (at most 20000) into one group for each row (column): an object joins a row when its visual bounds overlap the row's extent from top to bottom (left to right). Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, and clipping masks stay in place. The command rejects selections of editable objects whose parent is neither a layer nor a group, including live blend keys, and direct children of Shaper groups or live compound shapes. An object alone in its row stays as it is. Each new group goes where its frontmost member was in the stacking order, and the groups (top to bottom, or left to right) and the objects left alone stay selected; with no row of two objects or more it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | | `addon.arrange.randomizeOpacity` | `min`, `max` % 0…100 (30, 100; `min` not more than `max`); `seed` whole number (0); `ids` (the selection) | Gives each selected object its own opacity (the object opacity the Transparency panel sets), picked at random and evenly from `min` to `max`; the same seed, objects and range give the same opacities. Groups take one opacity of their own; the objects inside keep theirs. A run that changes no opacity, such as `min` and `max` both at the opacity every object has, records no undo step. → `{count}` | | `addon.arrange.sort` | `by`, `apply`: `width`, `height`, `area` (width × height), `x` (left edge), `y` (top edge), `opacity` (%), `stacking` (stacking order from the back) (`area`, `stacking`); `order`: `ascending` (small to large), `descending` (large to small), `random` (`ascending`); `distribute` (false); `seed` whole number (0, for `random`); `scaleStrokes`; `ids` (the selection) | Sorts the selected objects (at most 20000) by `by` and gives them the values of `apply` in that order: the first gets the smallest value. Without `distribute` the objects trade the values they have; with it the values step evenly from the smallest to the largest. A width, height or area changes about each object's centre (an area in proportion), a place moves the top-left corner. Stacking order always trades places, and only among objects in the same layer or group. Needs two objects or more. → `{count}` | From 094f59566c024a363abfead0916650e99843f0c4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:05:25 -0800 Subject: [PATCH 5/7] Arrange Tools: Group by Row refuses parts of live groups and graphs and leaves layers alone Group by Row now also refuses direct children of Objects on Path and Live Paint groups and objects inside a live graph, while a whole live group or graph can still be grouped with other art. Selected layers and sublayers stay selected and are not grouped. --- crates/engine/src/cmd/addons/arrange.rs | 33 +++-- crates/engine/src/cmd/addons/arrange/tests.rs | 129 ++++++++++++++++++ docs/mcp.md | 2 +- 3 files changed, 151 insertions(+), 13 deletions(-) diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index 1d6d57b0cc..7768b4f62e 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -104,7 +104,7 @@ pub fn specs() -> Vec { "Group by Row", ["Object", "Plug-ins", "Arrange Tools"], None, - "{direction?: \"row\" (objects whose vertical extents overlap) | \"column\" (objects whose horizontal extents overlap) (\"row\" when omitted; null is invalid)} group the selected objects (the top-level ones, at most 20000) into one group for each row (column), as one undo step. Parameters must be an object. An object joins a row when its visual bounds overlap the row's extent across it. Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, and clipping masks stay in place. The command rejects selections of editable objects whose parent is neither a layer nor a group, including live blend keys, and direct children of Shaper groups or live compound shapes. An object alone in its row stays as it is, and each new group goes where its frontmost member was in the stacking order; the new groups (top to bottom, or left to right) and the objects left alone stay selected. A run with no row of two or more objects makes no step → {groups: [id…], grouped (how many objects went into groups)}", + "{direction?: \"row\" (objects whose vertical extents overlap) | \"column\" (objects whose horizontal extents overlap) (\"row\" when omitted; null is invalid)} group the selected objects (the top-level ones, at most 20000) into one group for each row (column), as one undo step. Parameters must be an object. An object joins a row when its visual bounds overlap the row's extent across it. Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, clipping masks, layers, and sublayers stay in place. Every grouping candidate must have a parent that is a layer or group. The command rejects selections containing editable live blend keys, direct children of Shaper groups, live compound shapes, Objects on Path groups, or Live Paint groups, and any descendants of live graphs. Complete live groups and graphs can be grouped with other artwork. An object alone in its row stays as it is, and each new group goes where its frontmost member was in the stacking order; the new groups (top to bottom, or left to right) and the objects left alone stay selected. A run with no row of two or more objects makes no step → {groups: [id…], grouped (how many objects went into groups)}", has_multi, group_rows ), @@ -471,26 +471,33 @@ fn group_rows(s: &mut Session, p: &Value) -> Result { let d = &s.doc()?.doc; let editable_roots: Vec<_> = { let editable = d.editable(); - roots.iter().copied().filter(|id| editable(*id)).collect() + roots.iter().copied().filter(|id| editable(*id) && d.node(*id).is_some_and(|n| !n.is_layer())).collect() }; for id in &editable_roots { - if d.parent_of(*id).and_then(|parent| d.node(parent)).is_some_and(|n| { - !matches!(n.kind, NodeKind::Layer { .. } | NodeKind::Group { .. }) || n.is_compound_shape() || n.extras().shaper.is_some() - }) { + let parent = d.parent_of(*id); + let valid_parent = parent.and_then(|parent| d.node(parent)).is_some_and(|n| { + matches!(n.kind, NodeKind::Layer { .. } | NodeKind::Group { .. }) + && !n.is_compound_shape() + && n.extras().shaper.is_none() + && n.extras().objects_on_path.is_none() + && !vectorcraft_tools::builder::is_live_paint(n) + }); + let in_graph = parent + .and_then(|parent| d.ancestry(parent)) + .is_some_and(|ancestors| ancestors.iter().any(|ancestor| d.node(*ancestor).is_some_and(|n| n.extras().graph.is_some()))); + if !valid_parent || in_graph { return Err(bad(C, "selected objects must be in a layer or group without live structural roles")); } } // Each object's row key (its parent and its artboard) and its extent across the rows. - type Keyed = ((Option, usize), (f64, f64)); + type Keyed = ((NodeId, usize), (f64, f64)); let symbols = d.symbol_boxes(); let items: Vec<(NodeId, Keyed)> = editable_roots .iter() .filter_map(|id| { - let parent = d.parent_of(*id); - if parent - .and_then(|parent| d.node(parent)) - .is_some_and(|n| n.clips() && n.children().and_then(|c| c.first()).is_some_and(|c| c.id == *id)) - { + let parent = d.parent_of(*id)?; + let container = d.node(parent)?; + if container.clips() && container.children().and_then(|c| c.first()).is_some_and(|c| c.id == *id) { return None; } let b = effects::preview::visual_bounds(&symbols.unmeasured(), d.node(*id)?)?; @@ -500,7 +507,9 @@ fn group_rows(s: &mut Session, p: &Value) -> Result { .collect(); let keyed: Vec<_> = items.iter().map(|(_, k)| *k).collect(); let sets: Vec> = rows_of(&keyed).into_iter().map(|set| set.iter().filter_map(|i| Some(items.get(*i)?.0)).collect()).collect(); - group_each(s, if rows { "Group by Row" } else { "Group by Column" }, &roots, sets) + let mut selection = roots; + selection.extend(s.doc()?.selection.objects.iter().copied().filter(|id| d.node(*id).is_some_and(|n| n.is_layer()))); + group_each(s, if rows { "Group by Row" } else { "Group by Column" }, &selection, sets) } /// Put each of `sets` (two or more of the selected top-level objects `roots`, each in stacking order) into a diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index 5416687473..6f50164c0c 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -616,6 +616,135 @@ fn group_rows_keeps_clipping_masks_first_in_groups_and_layers() { } } +#[test] +fn group_rows_leaves_selected_layers_and_sublayers_in_place() { + for sublayers in [false, true] { + let mut s = session(); + let parent = s.doc().unwrap().doc.layers[0].id; + let mut layers = vec![]; + for _ in 0..2 { + let command = if sublayers { "layer.newSublayer" } else { "layer.new" }; + let params = if sublayers { json!({"parent": parent.0}) } else { json!({"top": true}) }; + let layer = NodeId(s.execute(command, ¶ms).unwrap()["id"].as_u64().unwrap()); + rect(&mut s, 10.0, 10.0, 20.0, 20.0); + layers.push(layer); + } + s.execute("layer.setCurrent", &json!({"id": parent.0})).unwrap(); + let a = rect(&mut s, 10.0, 10.0, 20.0, 20.0); + let b = rect(&mut s, 15.0, 15.0, 20.0, 20.0); + for direction in ["row", "column"] { + select(&mut s, &layers); + let before = s.doc().unwrap().doc.clone(); + let n = steps(&s); + let r = s.execute("addon.arrange.groupRows", &json!({"direction": direction})).unwrap(); + assert_eq!(r["grouped"], json!(0), "layers must not become ordinary group members"); + assert_eq!(steps(&s), n); + assert!(*s.doc().unwrap().doc == *before); + select(&mut s, &[layers[0], layers[1], a, b]); + let r = s.execute("addon.arrange.groupRows", &json!({"direction": direction})).unwrap(); + assert_eq!(r["grouped"], json!(2)); + let groups = ids_of(&r["groups"]); + assert_eq!(children(&s, groups[0]), [a, b]); + for layer in &layers { + assert_eq!(s.doc().unwrap().doc.parent_of(*layer), sublayers.then_some(parent)); + assert!(s.doc().unwrap().selection.objects.contains(layer)); + } + s.execute("edit.undo", &json!({})).unwrap(); + assert!(*s.doc().unwrap().doc == *before); + } + } +} + +#[test] +fn group_rows_refuses_objects_without_a_parent() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0, 20.0, 20.0); + let b = rect(&mut s, 15.0, 15.0, 20.0, 20.0); + s.edit("Set root objects", |d, _| { + for id in [a, b] { + let node = d.remove(id)?; + d.layers.push(node); + } + Ok(()) + }) + .unwrap(); + select(&mut s, &[a, b]); + refuses(&mut s, "addon.arrange.groupRows", &[json!({"direction": "row"}), json!({"direction": "column"})]); +} + +fn refuse_row_parts_and_group_whole(s: &mut Session, group: NodeId, parts: &[Vec]) { + let center = bounds(s, group).center(); + let a = rect(s, center.x - 10.0, center.y - 10.0, 20.0, 20.0); + let b = rect(s, center.x - 5.0, center.y - 5.0, 20.0, 20.0); + let members = children(s, group); + for direction in ["row", "column"] { + for selected in parts { + select(s, selected); + let selection = s.doc().unwrap().selection.clone(); + refuses(s, "addon.arrange.groupRows", &[json!({"direction": direction})]); + assert_eq!(s.doc().unwrap().selection, selection); + let mut mixed = selected.clone(); + mixed.extend([a, b]); + select(s, &mixed); + refuses(s, "addon.arrange.groupRows", &[json!({"direction": direction})]); + assert_eq!(children(s, group), members); + } + select(s, &[group, a, b]); + let before = s.doc().unwrap().doc.clone(); + let n = steps(s); + let r = s.execute("addon.arrange.groupRows", &json!({"direction": direction})).unwrap(); + assert_eq!(r["grouped"], json!(3)); + let groups = ids_of(&r["groups"]); + assert_eq!(children(s, groups[0]), [group, a, b]); + assert_eq!(children(s, group), members); + assert_eq!(steps(s), n + 1); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(*s.doc().unwrap().doc == *before); + } +} + +#[test] +fn group_rows_refuses_objects_on_path_children_but_groups_the_whole_group() { + let mut s = session(); + let path = rect(&mut s, 20.0, 20.0, 100.0, 100.0); + let member = rect(&mut s, 30.0, 30.0, 20.0, 20.0); + let group = NodeId(s.execute("object.objectsOnPath.attach", &json!({"path": path.0, "ids": [member.0]})).unwrap()["id"].as_u64().unwrap()); + refuse_row_parts_and_group_whole(&mut s, group, &[vec![path, member]]); + assert!(s.doc().unwrap().doc.node(group).unwrap().extras().objects_on_path.is_some()); +} + +#[test] +fn group_rows_refuses_live_paint_faces_and_edges_but_groups_the_whole_group() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 100.0, 100.0); + let b = rect(&mut s, 50.0, 0.0, 100.0, 100.0); + select(&mut s, &[a, b]); + let group = NodeId(s.execute("livePaint.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + let node = s.doc().unwrap().doc.node(group).unwrap(); + let faces: Vec<_> = vectorcraft_tools::builder::faces(node).iter().map(|n| n.id).collect(); + let edges: Vec<_> = vectorcraft_tools::builder::edges(node).iter().map(|n| n.id).collect(); + assert!(faces.len() >= 2); + assert!(edges.len() >= 2); + refuse_row_parts_and_group_whole(&mut s, group, &[faces.clone(), edges.clone()]); + let node = s.doc().unwrap().doc.node(group).unwrap(); + assert_eq!(vectorcraft_tools::builder::faces(node).iter().map(|n| n.id).collect::>(), faces); + assert_eq!(vectorcraft_tools::builder::edges(node).iter().map(|n| n.id).collect::>(), edges); +} + +#[test] +fn group_rows_refuses_live_graph_descendants_but_groups_the_whole_graph() { + let mut s = session(); + let params = json!({"type": "column", "x": 20, "y": 20, "width": 200, "height": 200, "csv": ",Series\nA,3\nB,5"}); + let graph = NodeId(s.execute("graph.create", ¶ms).unwrap()["id"].as_u64().unwrap()); + let node = s.doc().unwrap().doc.node(graph).unwrap(); + let series = node.children().unwrap().iter().find(|n| n.extras().series_index == Some(0)).unwrap(); + let marks: Vec<_> = series.children().unwrap().iter().take(2).map(|n| n.id).collect(); + assert_eq!(marks.len(), 2); + let direct = children(&s, graph); + refuse_row_parts_and_group_whole(&mut s, graph, &[marks, direct]); + assert!(s.doc().unwrap().doc.node(graph).unwrap().extras().graph.is_some()); +} + #[test] fn group_rows_refuses_explicitly_selected_live_blend_keys() { let mut s = session(); diff --git a/docs/mcp.md b/docs/mcp.md index 3543a70ff2..dfaf15c8b0 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17582,7 +17582,7 @@ as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid | `addon.arrange.replace` | `fit`: `keep`, `bounds` (the replaced object's width and height), `proportional` (fits inside them) (`keep`); `scaleStrokes`; `keep` (false) | Puts a copy of the topmost selected object centred on each of the other selected objects, in that object's place in the stacking order; the replaced objects are deleted unless `keep` (the copy then goes right above each). Needs two objects or more; the copies are selected. → `{ids}` | | `addon.arrange.size` | `width`, `height` pt, 0.001…1000000 (at least one); `proportional` (false: a side not given stays; true: it follows the given one in proportion); `reference` 0…8 (4, the centre); `scaleStrokes` | Gives every selected object that width and height, keeping its reference point in place (the 9-point grid row by row from the top-left). | | `addon.arrange.groupOverlapping` | none | Groups the selected objects (at most 20000) wherever their visual bounds overlap or touch, chains included: when A overlaps B and B overlaps C, all three go in one group. Only objects in the same layer or group are grouped together; objects that overlap nothing stay as they are. Each new group goes where its frontmost member was in the stacking order, and the groups and the objects left alone stay selected; with nothing overlapping it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | -| `addon.arrange.groupRows` | `direction`: `row` (vertical extents), `column` (horizontal extents) (`row` when omitted; `null` is invalid). Parameters must be an object. | Groups the selected objects (at most 20000) into one group for each row (column): an object joins a row when its visual bounds overlap the row's extent from top to bottom (left to right). Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, and clipping masks stay in place. The command rejects selections of editable objects whose parent is neither a layer nor a group, including live blend keys, and direct children of Shaper groups or live compound shapes. An object alone in its row stays as it is. Each new group goes where its frontmost member was in the stacking order, and the groups (top to bottom, or left to right) and the objects left alone stay selected; with no row of two objects or more it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | +| `addon.arrange.groupRows` | `direction`: `row` (vertical extents), `column` (horizontal extents) (`row` when omitted; `null` is invalid). Parameters must be an object. | Groups the selected objects (at most 20000) into one group for each row (column): an object joins a row when its visual bounds overlap the row's extent from top to bottom (left to right). Measurement includes strokes and vector effects, measures a clipping group by its mask, and excludes raster effects such as shadows, glows, and blurs. Extents that only touch stay apart, and an object that overlaps two rows joins them into one. Only objects in the same layer or group and on the same artboard (the one holding the object's center, else the one it overlaps most) share a row. Objects outside all artboards, locked or hidden objects, clipping masks, layers, and sublayers stay in place. Every grouping candidate must have a parent that is a layer or group. The command rejects selections containing editable live blend keys, direct children of Shaper groups, live compound shapes, Objects on Path groups, or Live Paint groups, and any descendants of live graphs. Complete live groups and graphs can be grouped with other artwork. An object alone in its row stays as it is. Each new group goes where its frontmost member was in the stacking order, and the groups (top to bottom, or left to right) and the objects left alone stay selected; with no row of two objects or more it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | | `addon.arrange.randomizeOpacity` | `min`, `max` % 0…100 (30, 100; `min` not more than `max`); `seed` whole number (0); `ids` (the selection) | Gives each selected object its own opacity (the object opacity the Transparency panel sets), picked at random and evenly from `min` to `max`; the same seed, objects and range give the same opacities. Groups take one opacity of their own; the objects inside keep theirs. A run that changes no opacity, such as `min` and `max` both at the opacity every object has, records no undo step. → `{count}` | | `addon.arrange.sort` | `by`, `apply`: `width`, `height`, `area` (width × height), `x` (left edge), `y` (top edge), `opacity` (%), `stacking` (stacking order from the back) (`area`, `stacking`); `order`: `ascending` (small to large), `descending` (large to small), `random` (`ascending`); `distribute` (false); `seed` whole number (0, for `random`); `scaleStrokes`; `ids` (the selection) | Sorts the selected objects (at most 20000) by `by` and gives them the values of `apply` in that order: the first gets the smallest value. Without `distribute` the objects trade the values they have; with it the values step evenly from the smallest to the largest. A width, height or area changes about each object's centre (an area in proportion), a place moves the top-left corner. Stacking order always trades places, and only among objects in the same layer or group. Needs two objects or more. → `{count}` | From cd1c3e8c9f9936c94dec8e723a05eb18c9904da3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 20:16:33 -0800 Subject: [PATCH 6/7] Docs: name Group by Row among the Arrange Tools visual-bounds exceptions The Arrange Tools overview said every command except Arrange in Grid and Offset Objects measures as object.setBounds does. Group by Row always uses visual bounds, with strokes and vector effects included and raster effects left out, so the overview now names it and points to its row. --- docs/mcp.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/mcp.md b/docs/mcp.md index 17d78bcf03..d0521ef3a2 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17572,7 +17572,8 @@ images and patterns keep their colours. → `{changed, swatches: [the document s Arrange Tools is a built-in add-on that lays out, swaps, replaces and sizes selected objects: its commands are `addon.arrange.*`, and in the desktop app it lives in Object › Plug-ins › Arrange Tools. Each command acts on the top-level selected objects and is one undo step; a run that moves nothing makes no step. Places and sizes are measured -as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid and Offset Objects, which use visual bounds. +as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid and Offset Objects, which use visual bounds, and Group by Row, which always uses visual bounds +with strokes and vector effects included and raster effects left out (see its row). | Command | Parameters (default) | Does | |---|---|---| From 78eb2f4afb6adc0bb844c07ad59ccbce1522322d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 1 Dec 2026 02:09:48 -0800 Subject: [PATCH 7/7] Arrange Tools: list Group by Row among the dialogs ui.menuDialog opens ui.menuDialog opens the Group by Row dialog, so its params text and the MCP UI catalog name addon.arrange.groupRows with the other Arrange Tools dialogs. --- crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/menus/ui_commands.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 2c8f54eb6e..ca3e348b7c 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -1531,7 +1531,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.menuDialog", "Menu Dialog", "", - "{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|object.stepAndRepeat|artboard.rearrange|artboard.rename|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options|addon.arrange.grid|addon.arrange.offset|addon.arrange.replace|addon.arrange.size|addon.arrange.match|addon.packaging.setFoldAngle|addon.pathtools.cornerSet|addon.pathtools.divideDashes|addon.pathtools.bridge|addon.pathtools.tangentCircle|addon.type.textTweaker|addon.color.swatchLegend|addon.arrange.randomizeOpacity|addon.arrange.sort|addon.color.applyNearestSwatch|addon.select.byArtboards|addon.select.editPointsOnly|type.smartPunctuation|variable.define|variable.rename|variable.bind|dataset.new|dataset.set|dataset.rename|dataset.select} open the dialog that command's menu item opens (its `key` in ui.inspect is the command id, except `transformEach` for object.transformEach, `envelopeWarp` for object.envelope.makeWithWarp and object.envelope.resetWithWarp, `envelopeMesh` for object.envelope.makeWithMesh and object.envelope.resetWithMesh, `variables` for variable.define and variable.rename and variable.bind and dataset.new and dataset.set and dataset.rename and dataset.select, `envelopeOptions` for object.envelope.options, `smoothSlider` for object.path.smooth, and `simplifySlider` for object.path.simplify; the dialogs of addon.color.applyNearestSwatch and addon.select.byArtboards have no `key`; smoothSlider and simplifySlider are the sliders over the canvas, with field `level`, and object.path.simplify opens its dialog `object.path.simplify` instead once OK in that dialog keeps the settings (`retain`); Set Fold Angle's `angle` is the selected fold lines' angle, and it is refused while the selection has no fold line it can change; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected; variable.rename opens only while the document has a variable, and dataset.set and dataset.rename only while it has a data set, and otherwise the status bar says why; ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel take the dialog's `id` from ui.inspect, or `top`, not its `key`)", + "{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|object.stepAndRepeat|artboard.rearrange|artboard.rename|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options|addon.arrange.grid|addon.arrange.offset|addon.arrange.replace|addon.arrange.size|addon.arrange.match|addon.arrange.groupRows|addon.packaging.setFoldAngle|addon.pathtools.cornerSet|addon.pathtools.divideDashes|addon.pathtools.bridge|addon.pathtools.tangentCircle|addon.type.textTweaker|addon.color.swatchLegend|addon.arrange.randomizeOpacity|addon.arrange.sort|addon.color.applyNearestSwatch|addon.select.byArtboards|addon.select.editPointsOnly|type.smartPunctuation|variable.define|variable.rename|variable.bind|dataset.new|dataset.set|dataset.rename|dataset.select} open the dialog that command's menu item opens (its `key` in ui.inspect is the command id, except `transformEach` for object.transformEach, `envelopeWarp` for object.envelope.makeWithWarp and object.envelope.resetWithWarp, `envelopeMesh` for object.envelope.makeWithMesh and object.envelope.resetWithMesh, `variables` for variable.define and variable.rename and variable.bind and dataset.new and dataset.set and dataset.rename and dataset.select, `envelopeOptions` for object.envelope.options, `smoothSlider` for object.path.smooth, and `simplifySlider` for object.path.simplify; the dialogs of addon.color.applyNearestSwatch and addon.select.byArtboards have no `key`; smoothSlider and simplifySlider are the sliders over the canvas, with field `level`, and object.path.simplify opens its dialog `object.path.simplify` instead once OK in that dialog keeps the settings (`retain`); Set Fold Angle's `angle` is the selected fold lines' angle, and it is refused while the selection has no fold line it can change; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected; variable.rename opens only while the document has a variable, and dataset.set and dataset.rename only while it has a data set, and otherwise the status bar says why; ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel take the dialog's `id` from ui.inspect, or `top`, not its `key`)", ), ( "ui.widthPointEdit", diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 5681df62bf..67dabfc392 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -1532,7 +1532,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.menuDialog", "Menu Dialog", "", - "{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|object.stepAndRepeat|artboard.rearrange|artboard.rename|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options|addon.arrange.grid|addon.arrange.offset|addon.arrange.replace|addon.arrange.size|addon.arrange.match|addon.packaging.setFoldAngle|addon.pathtools.cornerSet|addon.pathtools.divideDashes|addon.pathtools.bridge|addon.pathtools.tangentCircle|addon.type.textTweaker|addon.color.swatchLegend|addon.arrange.randomizeOpacity|addon.arrange.sort|addon.color.applyNearestSwatch|addon.select.byArtboards|addon.select.editPointsOnly|type.smartPunctuation|variable.define|variable.rename|variable.bind|dataset.new|dataset.set|dataset.rename|dataset.select} open the dialog that command's menu item opens (its `key` in ui.inspect is the command id, except `transformEach` for object.transformEach, `envelopeWarp` for object.envelope.makeWithWarp and object.envelope.resetWithWarp, `envelopeMesh` for object.envelope.makeWithMesh and object.envelope.resetWithMesh, `variables` for variable.define and variable.rename and variable.bind and dataset.new and dataset.set and dataset.rename and dataset.select, `envelopeOptions` for object.envelope.options, `smoothSlider` for object.path.smooth, and `simplifySlider` for object.path.simplify; the dialogs of addon.color.applyNearestSwatch and addon.select.byArtboards have no `key`; smoothSlider and simplifySlider are the sliders over the canvas, with field `level`, and object.path.simplify opens its dialog `object.path.simplify` instead once OK in that dialog keeps the settings (`retain`); Set Fold Angle's `angle` is the selected fold lines' angle, and it is refused while the selection has no fold line it can change; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected; variable.rename opens only while the document has a variable, and dataset.set and dataset.rename only while it has a data set, and otherwise the status bar says why; ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel take the dialog's `id` from ui.inspect, or `top`, not its `key`)", + "{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|object.stepAndRepeat|artboard.rearrange|artboard.rename|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options|addon.arrange.grid|addon.arrange.offset|addon.arrange.replace|addon.arrange.size|addon.arrange.match|addon.arrange.groupRows|addon.packaging.setFoldAngle|addon.pathtools.cornerSet|addon.pathtools.divideDashes|addon.pathtools.bridge|addon.pathtools.tangentCircle|addon.type.textTweaker|addon.color.swatchLegend|addon.arrange.randomizeOpacity|addon.arrange.sort|addon.color.applyNearestSwatch|addon.select.byArtboards|addon.select.editPointsOnly|type.smartPunctuation|variable.define|variable.rename|variable.bind|dataset.new|dataset.set|dataset.rename|dataset.select} open the dialog that command's menu item opens (its `key` in ui.inspect is the command id, except `transformEach` for object.transformEach, `envelopeWarp` for object.envelope.makeWithWarp and object.envelope.resetWithWarp, `envelopeMesh` for object.envelope.makeWithMesh and object.envelope.resetWithMesh, `variables` for variable.define and variable.rename and variable.bind and dataset.new and dataset.set and dataset.rename and dataset.select, `envelopeOptions` for object.envelope.options, `smoothSlider` for object.path.smooth, and `simplifySlider` for object.path.simplify; the dialogs of addon.color.applyNearestSwatch and addon.select.byArtboards have no `key`; smoothSlider and simplifySlider are the sliders over the canvas, with field `level`, and object.path.simplify opens its dialog `object.path.simplify` instead once OK in that dialog keeps the settings (`retain`); Set Fold Angle's `angle` is the selected fold lines' angle, and it is refused while the selection has no fold line it can change; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected; variable.rename opens only while the document has a variable, and dataset.set and dataset.rename only while it has a data set, and otherwise the status bar says why; ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel take the dialog's `id` from ui.inspect, or `top`, not its `key`)", ), ( "ui.widthPointEdit",