From 5caea7ad329bd1332fd1ebadb2b7b182db6f116b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 20 Nov 2026 22:16:00 -0800 Subject: [PATCH 1/4] Artboards: Rearrange works on the selected artboards only artboard.rearrange takes indices (the artboards to lay out, in document order) and at (the grid's top-left). The other artboards, their art and their guides stay where they are, and a listed locked artboard keeps its place and its cell. Without indices the command lays out every artboard as before. With indices the reply adds indices and moved, and no undo step is recorded when nothing moved. With the Artboard tool, the canvas menu's Rearrange, the Contextual Task Bar's Rearrange, the Artboards panel menu's new Rearrange... and the panel's Rearrange button open the Rearrange dialog for the selected artboards, with their count. After OK the grid's outline follows the pointer, and a click on the canvas places its top-left there in one undo step. Enter places it from the keyboard when no other control has the focus, a Space-drag pans, and Esc, another tool, another document or a change to the listed artboards cancels it. Rearrange All Artboards is unchanged. The help page describes the selected-artboard arrangement and the click that places it: https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/rearrange-artboards.html The top-left reference point, the outline, the fallback to the first selected artboard's corner and the rules for locked artboards and for art on other artboards are VectorCraft's own. Docs: docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/cmd/menucmds.rs | 52 ++-- crates/engine/src/cmd/newdoc.rs | 24 ++ crates/engine/src/tests/newdoc.rs | 93 +++++++ crates/engine/tests/command_sweep.rs | 7 +- crates/ui-egui/src/canvas.rs | 1 + crates/ui-egui/src/canvas/input.rs | 4 + crates/ui-egui/src/canvas/task_bar.rs | 20 +- crates/ui-egui/src/canvas/tests.rs | 216 +++++++++++++++- .../src/dialogs/rearrange_artboards.rs | 231 +++++++++++++++++- crates/ui-egui/src/i18n/bg.tsv | 3 + crates/ui-egui/src/i18n/bs.tsv | 3 + crates/ui-egui/src/i18n/ca.tsv | 3 + crates/ui-egui/src/i18n/cs.tsv | 3 + crates/ui-egui/src/i18n/da.tsv | 3 + crates/ui-egui/src/i18n/de.tsv | 3 + crates/ui-egui/src/i18n/el.tsv | 3 + crates/ui-egui/src/i18n/es.tsv | 3 + crates/ui-egui/src/i18n/fi.tsv | 3 + crates/ui-egui/src/i18n/fr.tsv | 3 + crates/ui-egui/src/i18n/gu.tsv | 3 + crates/ui-egui/src/i18n/hi.tsv | 3 + crates/ui-egui/src/i18n/hu.tsv | 3 + crates/ui-egui/src/i18n/id.tsv | 3 + crates/ui-egui/src/i18n/it.tsv | 3 + crates/ui-egui/src/i18n/ja.tsv | 3 + crates/ui-egui/src/i18n/ka.tsv | 3 + crates/ui-egui/src/i18n/ko.tsv | 3 + crates/ui-egui/src/i18n/nl.tsv | 3 + crates/ui-egui/src/i18n/pl.tsv | 3 + crates/ui-egui/src/i18n/pt-br.tsv | 3 + crates/ui-egui/src/i18n/ru.tsv | 3 + crates/ui-egui/src/i18n/sv.tsv | 3 + crates/ui-egui/src/i18n/tests.rs | 16 ++ crates/ui-egui/src/i18n/tr.tsv | 3 + crates/ui-egui/src/i18n/uk.tsv | 3 + crates/ui-egui/src/i18n/vi.tsv | 3 + crates/ui-egui/src/i18n/zh-hans.tsv | 3 + crates/ui-egui/src/i18n/zh-hant.tsv | 3 + crates/ui-egui/src/menus/context.rs | 6 +- crates/ui-egui/src/menus/invoke.rs | 8 + crates/ui-egui/src/panels/artboards.rs | 33 ++- crates/ui-egui/src/panels/artboards/tests.rs | 26 +- crates/ui-egui/src/state.rs | 20 ++ docs/mcp.md | 49 +++- docs/target-app-parity.md | 3 +- 45 files changed, 824 insertions(+), 69 deletions(-) diff --git a/crates/engine/src/cmd/menucmds.rs b/crates/engine/src/cmd/menucmds.rs index aa330e11ea..96365e6553 100644 --- a/crates/engine/src/cmd/menucmds.rs +++ b/crates/engine/src/cmd/menucmds.rs @@ -187,7 +187,7 @@ pub fn specs() -> Vec { "Rearrange All Artboards…", ["Object", "Artboards"], None, - "{layout?: gridByRow|gridByColumn|row|column (gridByRow; byColumn?: true is gridByColumn), order?: leftToRight|rightToLeft (leftToRight: right-to-left mirrors the order along the rows), columns?: n (2; the rows for gridByColumn; row and column ignore it), spacing?: pt (20), moveArtwork?: true (each object of a layer or sublayer moves with the artboard its center is on; locked and hidden art, and art on a locked artboard, only with lockedAndHidden), patterns?: bool (Transform Patterns: pattern fills and strokes transform with the art; default: prefs transformPatternTiles), lockedAndHidden?: bool (default: prefs moveLockedWithArtboard), byColumn?: bool (an older way to ask for layout gridByColumn)} lay the artboards out in their order, the grid's top-left at the first artboard's; a locked artboard stays where it is → {artboards, rows, columns}", + "{layout?: gridByRow|gridByColumn|row|column (gridByRow; byColumn?: true is gridByColumn), order?: leftToRight|rightToLeft (leftToRight: right-to-left mirrors the order along the rows), columns?: n (2; the rows for gridByColumn; row and column ignore it), spacing?: pt (20), moveArtwork?: true (each object of a layer or sublayer moves with the artboard its center is on; locked and hidden art, and art on a locked artboard, only with lockedAndHidden), patterns?: bool (Transform Patterns: pattern fills and strokes transform with the art; default: prefs transformPatternTiles), lockedAndHidden?: bool (default: prefs moveLockedWithArtboard), byColumn?: bool (an older way to ask for layout gridByColumn), indices?: [n] (lay out only these artboards, in document order; the others and their art and guides stay where they are), at?: [x, y] (the grid's top-left)} lay the artboards out in their order, the grid's top-left at `at`, else at the first artboard's laid out; a locked artboard stays where it is and keeps its place in the grid → {artboards, rows, columns; with indices also indices and moved, the count of artboards that moved}", has_doc, rearrange_artboards ), @@ -1718,32 +1718,48 @@ fn rearrange_artboards(s: &mut Session, p: &Value) -> Result { Some(_) => return Err(bad(CMD, "order must be leftToRight or rightToLeft")), }; let count = s.doc()?.doc.artboards.len(); - let n_ab = count.max(1); - // Columns of a grid by row, rows of a grid by column. - let lines = whole_or(p, "columns", 2, CMD)?.clamp(1, n_ab as u64) as usize; - let (rows, cols) = match layout { - L::GridByRow => (n_ab.div_ceil(lines), lines), - L::GridByColumn => (lines, n_ab.div_ceil(lines)), - L::Row => (1, n_ab), - L::Column => (n_ab, 1), + // `indices` lays out only those artboards, in document order; left out, every artboard. + let picked: Option> = match p.get("indices") { + Some(v) => Some(super::panelcmds::listed_artboards(&s.doc()?.doc, v, "indices", CMD)?), + None => None, }; + let at = match p.get("at") { + Some(v) => Some(super::finite_numbers::<2>(v).map(|[x, y]| Point::new(x, y)).ok_or_else(|| bad(CMD, "`at` must be [x, y]"))?), + None => None, + }; + // Columns of a grid by row, rows of a grid by column. + let lines = whole_or(p, "columns", 2, CMD)?; check_numbers(p, &["spacing"], CMD)?; let spacing = f64_or(p, "spacing", 20.0).clamp(-1.0e5, 1.0e5); let move_art = switch_or(p, "moveArtwork", true, CMD)?; check_switches(p, &["patterns"], CMD)?; let locked_and_hidden = super::panelcmds::locked_and_hidden(s, p, move_art, CMD)?; let d = &s.doc()?.doc; - let rects: Vec = d.artboards.iter().map(|a| a.rect).collect(); + let laid: Vec = picked.clone().unwrap_or_else(|| (0..count).collect()); + let rects: Vec = laid.iter().filter_map(|i| d.artboards.get(*i)).map(|a| a.rect).collect(); let sizes: Vec<(f64, f64)> = rects.iter().map(|r| (r.width(), r.height())).collect(); - let first = rects.first().map_or(Point::ZERO, |r| r.origin()); - let origins = super::newdoc::grid_origins_rc(&sizes, first, (rows, cols), spacing, layout == L::GridByColumn, rtl); - // A locked artboard stays where it is, and keeps its place in the grid. - let deltas: Vec = - rects.iter().zip(origins).zip(&d.artboards).map(|((r, o), a)| if a.locked { Vec2::ZERO } else { o - r.origin() }).collect(); + // The grid's top-left: `at`, else the first artboard laid out's. + let origin = at.unwrap_or_else(|| rects.first().map_or(Point::ZERO, |r| r.origin())); + let (origins, rows, cols) = super::newdoc::rearrange_grid(&sizes, origin, layout, lines, spacing, rtl); + // A locked artboard stays where it is, and keeps its place in the grid; an artboard not laid + // out stays where it is. + let mut deltas = vec![Vec2::ZERO; count]; + for ((i, r), o) in laid.iter().zip(&rects).zip(origins) { + if let Some(dl) = deltas.get_mut(*i) + && !d.artboards.get(*i).is_some_and(|a| a.locked) + { + *dl = o - r.origin(); + } + } + let moved = deltas.iter().filter(|dl| dl.x.abs() > 1e-9 || dl.y.abs() > 1e-9).count(); + let result = match &picked { + Some(indices) => json!({ "artboards": count, "indices": indices, "moved": moved, "rows": rows, "columns": cols }), + None => json!({ "artboards": count, "rows": rows, "columns": cols }), + }; // When no artboard moves more than 1e-9 pt on either axis, or there is none, the document and // its undo history stay as they are. - if deltas.iter().all(|dl| dl.x.abs() <= 1e-9 && dl.y.abs() <= 1e-9) { - return Ok(json!({ "artboards": count, "rows": rows, "columns": cols })); + if moved == 0 { + return Ok(result); } // With moveArtwork, each top-level object (a child of a layer or sublayer) moves with the // artboard its center is on, with symbol instances measured by their art as @@ -1791,5 +1807,5 @@ fn rearrange_artboards(s: &mut Session, p: &Value) -> Result { } Ok(()) })?; - Ok(json!({ "artboards": count, "rows": rows, "columns": cols })) + Ok(result) } diff --git a/crates/engine/src/cmd/newdoc.rs b/crates/engine/src/cmd/newdoc.rs index e74a570a5b..89f67594a1 100644 --- a/crates/engine/src/cmd/newdoc.rs +++ b/crates/engine/src/cmd/newdoc.rs @@ -601,6 +601,30 @@ pub(crate) fn grid_origins_rc( .collect() } +/// Rearrange Artboards' grid for artboards of `sizes`, in their order, its top-left at `origin`: +/// `lines` is the column count of a grid by row and the row count of a grid by column (kept to 1 +/// to the artboard count), and `rtl` puts the first column at the right. Returns each artboard's +/// top-left corner and the grid's rows and columns. +pub fn rearrange_grid( + sizes: &[(f64, f64)], + origin: Point, + layout: ArtboardLayout, + lines: u64, + spacing: f64, + rtl: bool, +) -> (Vec, usize, usize) { + let n = sizes.len().max(1); + let lines = usize::try_from(lines).unwrap_or(usize::MAX).clamp(1, n); + let (rows, cols) = match layout { + ArtboardLayout::GridByRow => (n.div_ceil(lines), lines), + ArtboardLayout::GridByColumn => (lines, n.div_ceil(lines)), + ArtboardLayout::Row => (1, n), + ArtboardLayout::Column => (n, 1), + }; + let origins = grid_origins_rc(sizes, origin, (rows, cols), spacing, layout == ArtboardLayout::GridByColumn, rtl); + (origins, rows, cols) +} + /// The built-in presets: (category, presets as (name, width, height, units)), with the category's /// colour mode and raster effects resolution. Sizes in `units` (converted to points on use). type Category = (&'static str, ColorMode, f64, &'static [(&'static str, f64, f64, Unit)]); diff --git a/crates/engine/src/tests/newdoc.rs b/crates/engine/src/tests/newdoc.rs index c6699190b6..b60f40f023 100644 --- a/crates/engine/src/tests/newdoc.rs +++ b/crates/engine/src/tests/newdoc.rs @@ -532,6 +532,99 @@ fn rearrange_that_moves_no_artboard_records_no_undo_step() { assert_eq!(history(&s), before); } +/// Rearrange with `indices` lays out only those artboards, in document order whatever order they +/// are listed in, with the grid's top-left at `at`: their art and guides go along, and the other +/// artboards, their art and their guides stay where they are, all in one undo step. +#[test] +fn rearrange_lays_out_only_the_listed_artboards() { + let mut s = new_doc(json!({"width": 100, "height": 50, "artboards": 4})); + let before = boards(&s); + let art: Vec = before + .iter() + .map(|r| { + NodeId( + s.execute("shape.rectangle", &json!({"x": r.x0 + 10.0, "y": r.y0 + 10.0, "width": 10, "height": 10})).unwrap()["id"] + .as_u64() + .unwrap(), + ) + }) + .collect(); + for i in [0, 1] { + s.execute("guide.add", &json!({"vertical": true, "pos": before[i].x0 + 5.0, "artboard": i})).unwrap(); + } + let undo = s.doc().unwrap().history.undo.len(); + let p = json!({"indices": [3, 1], "layout": "row", "spacing": 10, "at": [500, 400]}); + let r = s.execute("artboard.rearrange", &p).unwrap(); + assert_eq!(r, json!({"artboards": 4, "indices": [1, 3], "moved": 2, "rows": 1, "columns": 2})); + let after = boards(&s); + assert_eq!((after[0], after[2]), (before[0], before[2]), "the artboards not listed stay"); + assert_eq!((after[1], after[3]), (Rect::new(500.0, 400.0, 600.0, 450.0), Rect::new(610.0, 400.0, 710.0, 450.0))); + let d = &s.doc().unwrap().doc; + for (id, r) in art.iter().zip(&after) { + let b = d.node(*id).unwrap().geometric_bounds().unwrap(); + assert_eq!((b.x0, b.y0), (r.x0 + 10.0, r.y0 + 10.0), "the art is on its artboard"); + } + let guides: Vec = d.ruler_guides().iter().map(|g| g.pos).collect(); + assert_eq!(guides, [before[0].x0 + 5.0, 505.0]); + assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1, "one undo step"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(boards(&s), before); +} + +/// Without `at`, the grid of the listed artboards starts at the first one's top-left; one listed +/// artboard is laid out alone; a listed locked artboard stays and keeps its cell; when every listed +/// artboard is locked, nothing moves, no undo step is recorded and `moved` is 0. +#[test] +fn rearrange_of_listed_artboards_starts_at_the_first_and_keeps_locked_ones() { + let mut s = new_doc(json!({"width": 100, "height": 50, "artboards": 4, "artboardLayout": {"layout": "row", "spacing": 20}})); + let before = boards(&s); + // Artboards 1 and 3 in one column, from artboard 1's corner. + let r = s.execute("artboard.rearrange", &json!({"indices": [1, 3], "layout": "column", "spacing": 10})).unwrap(); + assert_eq!(r["moved"], 1); + let after = boards(&s); + assert_eq!(after[1], before[1]); + assert_eq!(after[3], Rect::new(before[1].x0, before[1].y1 + 10.0, before[1].x1, before[1].y1 + 60.0)); + // One artboard goes to `at`. + s.execute("artboard.rearrange", &json!({"indices": [2], "at": [-300, -200]})).unwrap(); + assert_eq!(boards(&s)[2], Rect::new(-300.0, -200.0, -200.0, -150.0)); + // Artboard 0 locked keeps its place and its cell: artboard 2 goes to the second cell from 0's. + s.execute("artboard.setProps", &json!({"index": 0, "locked": true})).unwrap(); + let r = s.execute("artboard.rearrange", &json!({"indices": [0, 2], "layout": "row", "spacing": 5, "at": [1000, 0]})).unwrap(); + assert_eq!(r["moved"], 1); + assert_eq!((boards(&s)[0], boards(&s)[2]), (before[0], Rect::new(1105.0, 0.0, 1205.0, 50.0))); + // Every listed artboard locked: nothing moves. + let placed = boards(&s); + let undo = s.doc().unwrap().history.undo.len(); + let r = s.execute("artboard.rearrange", &json!({"indices": [0], "at": [3000, 3000]})).unwrap(); + assert_eq!(r, json!({"artboards": 4, "indices": [0], "moved": 0, "rows": 1, "columns": 1})); + assert_eq!((boards(&s), s.doc().unwrap().history.undo.len()), (placed, undo)); +} + +/// Rearrange refuses `indices` that are not a non-empty list of artboards, and an `at` that is not +/// [x, y], before anything moves; a listed index given twice counts once. +#[test] +fn rearrange_refuses_bad_indices_and_at() { + let mut s = new_doc(json!({"width": 100, "height": 50, "artboards": 3})); + let before = (boards(&s), s.doc().unwrap().history.undo.len()); + for (p, msg) in [ + (json!({"indices": []}), "invalid parameters for `artboard.rearrange`: `indices` must be a non-empty list of artboard indices"), + (json!({"indices": 1}), "invalid parameters for `artboard.rearrange`: `indices` must be a list of artboard indices"), + (json!({"indices": [1.5]}), "invalid parameters for `artboard.rearrange`: `indices` must contain whole numbers"), + (json!({"indices": [-1]}), "invalid parameters for `artboard.rearrange`: `indices` must contain whole numbers"), + (json!({"indices": ["1"]}), "invalid parameters for `artboard.rearrange`: `indices` must contain whole numbers"), + (json!({"indices": [0, 3]}), "no such artboard"), + (json!({"indices": [0, 1], "at": [1]}), "invalid parameters for `artboard.rearrange`: `at` must be [x, y]"), + (json!({"indices": [0, 1], "at": "0,0"}), "invalid parameters for `artboard.rearrange`: `at` must be [x, y]"), + (json!({"at": [0, "1"]}), "invalid parameters for `artboard.rearrange`: `at` must be [x, y]"), + ] { + let err = s.execute("artboard.rearrange", &p).unwrap_err().to_string(); + assert_eq!(err, msg, "{p}"); + assert_eq!((boards(&s), s.doc().unwrap().history.undo.len()), before, "{p}"); + } + let r = s.execute("artboard.rearrange", &json!({"indices": [2, 2], "at": [0, 500]})).unwrap(); + assert_eq!((r["indices"].clone(), boards(&s)[2]), (json!([2]), Rect::new(0.0, 500.0, 100.0, 550.0))); +} + /// A session whose New Document profiles are in a fresh folder for test `name` (not made yet). fn with_profiles(name: &str) -> (Session, std::path::PathBuf) { let dir = std::env::temp_dir().join(format!("vc-newdoc-profiles-{name}-{}", std::process::id())); diff --git a/crates/engine/tests/command_sweep.rs b/crates/engine/tests/command_sweep.rs index 1413bb17bb..6664828398 100644 --- a/crates/engine/tests/command_sweep.rs +++ b/crates/engine/tests/command_sweep.rs @@ -93,7 +93,7 @@ fn every_command_without_a_document() { } /// Regression: huge column counts used to panic with `capacity overflow`; in every layout and -/// order (#681), with huge and negative spacing too. +/// order (#681), with huge and negative spacing too, and with `indices` and `at`. #[test] fn artboard_rearrange_huge_columns() { for fx in Fixture::ALL { @@ -106,6 +106,11 @@ fn artboard_rearrange_huge_columns() { } } } + // Listed artboards, out of range, and the grid's top-left at the far ends of the plane. + for (indices, at) in [(json!([0]), json!([1e308, -1e308])), (json!([0, u64::MAX]), json!([0, 0])), (json!([]), json!([-1e308, 1e308]))] { + let p = json!({ "indices": indices, "at": at, "columns": u64::MAX, "spacing": 1e308 }); + assert_eq!(probe(fx, "artboard.rearrange", &p), None); + } } } diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 8b366665d4..d690ea5dd0 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -430,6 +430,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { print_tiling_overlay(app, &painter, &xf); } original_path_overlay(app, &painter, &xf); + crate::dialogs::rearrange_artboards::paint_placement(app, &painter, &xf, t.selection); let overlays = selection_visuals(app, &painter, &xf, (hidden_chars, selection_marks, hover_still), revolve_edit, view_info); draw_overlays(&painter, &xf, &overlays, &t, HandleLook::of(&app.session.prefs), &mut shared_paths); diff --git a/crates/ui-egui/src/canvas/input.rs b/crates/ui-egui/src/canvas/input.rs index a6a0509de5..d7de78ec2a 100644 --- a/crates/ui-egui/src/canvas/input.rs +++ b/crates/ui-egui/src/canvas/input.rs @@ -22,6 +22,10 @@ pub(super) fn handle_input(app: &mut VectorcraftApp, ui: &Ui, resp: &egui::Respo if (cancelled && pointer.primary_pressed()) || crate::dialogs::brush_key_color_input(app, ui, resp, rect) { return; } + // Rearrange's placement takes the press or Enter that places the artboards, and Esc. + if crate::dialogs::rearrange_artboards::placement_input(app, ui, resp, rect, modal, space) { + return; + } let v = *app.view().unwrap_or(&View::default()); let xf = Xf::at(rect, &v, app.canvas_ui_zoom); // A lifted pen or finger takes the pointer away in the frame it lifts (egui's `PointerGone`), diff --git a/crates/ui-egui/src/canvas/task_bar.rs b/crates/ui-egui/src/canvas/task_bar.rs index 03ced4f7c6..253b916079 100644 --- a/crates/ui-egui/src/canvas/task_bar.rs +++ b/crates/ui-egui/src/canvas/task_bar.rs @@ -175,7 +175,7 @@ pub(crate) fn task_bar_shows_type(app: &VectorcraftApp) -> bool { /// The Contextual Task Bar: a floating pill under the selection with the most likely next actions. /// With the Artboard tool it sits under the selected artboards and offers Resize (Artboard -/// Options), Duplicate, Rearrange All (with two or more artboards) and Export (Export for Screens). +/// Options), Duplicate, Rearrange (the selected artboards) and Export (Export for Screens). /// A basic shape selected with the Selection tool shows a Shape Properties button in place of Lock. /// While a basic shape tool (Rectangle, Rounded Rectangle, Ellipse, Polygon or Star) has one closed /// path selected, as after it draws one, the bar offers Edit Path, Fill and Stroke, and Shape @@ -252,7 +252,7 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { // Edit Path: the Direct Selection tool, to edit the path's anchors. let edit_path = || (tl!("Edit Path"), "dc-direct", "tool.select", json!({"tool": "directSelection"})); if on_artboards { - artboard_items(&mut items, st.doc.artboards.len()); + artboard_items(&mut items); } else if blank { // Draw (Pencil) switches to the Pencil tool; Place Image picks files for the Place dialog. items.push((tl!("Draw (Pencil)"), "pencil", "tool.select", json!({"tool": "pencil"}))); @@ -576,10 +576,10 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { // Properties or the Control bar, it leaves the Image Trace panel as it was. Some((TASK_BAR_IMAGE_TRACE, _)) => crate::menus::invoke(app, "imageTrace.make", json!({"preset": "Default"})), // The Artboard tool's buttons: Artboard Options for the active artboard, as Properties' - // icon opens it; Duplicate for every selected artboard; Rearrange All Artboards. + // icon opens it; Duplicate and Rearrange for every selected artboard. Some((TASK_BAR_ARTBOARD_OPTIONS, _)) => crate::menus::invoke(app, "tool.options", json!({"tool": "artboard"})), Some((TASK_BAR_DUPLICATE_ARTBOARDS, _)) => crate::panels::artboards::duplicate_picked(app), - Some((TASK_BAR_REARRANGE_ARTBOARDS, _)) => crate::panels::artboards::open_rearrange(app), + Some((TASK_BAR_REARRANGE_ARTBOARDS, _)) => crate::panels::artboards::open_rearrange_selected(app), // The convert buttons convert the direct-selected anchors, as the Control bar's buttons do. Some((TASK_BAR_TO_CORNER, _)) => crate::menus::invoke(app, "path.convertAnchors", json!({"to": "corner"})), Some((TASK_BAR_TO_SMOOTH, _)) => crate::menus::invoke(app, "path.convertAnchors", json!({"to": "smooth"})), @@ -980,17 +980,15 @@ fn paint_chip(ui: &mut Ui, t: &Tokens, paint: &vectorcraft_color::Paint, mixed: resp.on_hover_text(tip).clicked() } -/// The Contextual Task Bar's items with the Artboard tool in a document of `artboards` artboards: -/// Resize, Duplicate, Rearrange All (with two or more) and Export. -fn artboard_items(items: &mut Vec<(&'static str, &'static str, &'static str, serde_json::Value)>, artboards: usize) { +/// The Contextual Task Bar's items with the Artboard tool: Resize, Duplicate, Rearrange (the +/// selected artboards) and Export. +fn artboard_items(items: &mut Vec<(&'static str, &'static str, &'static str, serde_json::Value)>) { // As in the reference app, the Artboard tool offers to resize, duplicate and export the // artboards (), // and to rearrange them (). items.push((tl!("Resize"), "move-diagonal-2", TASK_BAR_ARTBOARD_OPTIONS, json!({}))); items.push((tl!("Duplicate"), "copy", TASK_BAR_DUPLICATE_ARTBOARDS, json!({}))); - if artboards > 1 { - items.push((tl!("Rearrange All"), "dc-rearrange", TASK_BAR_REARRANGE_ARTBOARDS, json!({}))); - } + items.push((tl!("Rearrange"), "dc-rearrange", TASK_BAR_REARRANGE_ARTBOARDS, json!({}))); items.push((tl!("Export"), "share-2", "file.exportForScreens", json!({}))); } @@ -1018,7 +1016,7 @@ const TASK_BAR_ARTBOARD_OPTIONS: &str = "taskBar.artboardOptions"; /// The Contextual Task Bar's Duplicate button with the Artboard tool. const TASK_BAR_DUPLICATE_ARTBOARDS: &str = "taskBar.duplicateArtboards"; -/// The Contextual Task Bar's Rearrange All button with the Artboard tool. +/// The Contextual Task Bar's Rearrange button with the Artboard tool. const TASK_BAR_REARRANGE_ARTBOARDS: &str = "taskBar.rearrangeArtboards"; /// The Contextual Task Bar's Convert Selected Anchor Points to Corner button, for direct-selected diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index d5244aa234..8e56795605 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -12504,7 +12504,7 @@ fn task_bar_labels(app: &mut VectorcraftApp, ctx: &egui::Context) -> Vec<(String } /// With the Artboard tool, the Contextual Task Bar sits under the selected artboards and offers -/// Resize, Duplicate, Rearrange All (with two or more artboards) and Export instead of the +/// Resize, Duplicate, Rearrange (the selected artboards, one included) and Export instead of the /// selected objects' actions. With the Selection tool it offers the objects' actions again, and /// with nothing in the document the blank canvas actions. #[test] @@ -12522,7 +12522,7 @@ fn the_task_bar_offers_the_artboard_tools_actions() { let b = app.session.active().unwrap().doc.artboards[1].rect; let view = app.view_mut().unwrap(); (view.center, view.zoom) = (b.center(), 1.0); - assert_eq!(names(&mut app), ["Resize", "Duplicate", "Rearrange All", "Export"]); + assert_eq!(names(&mut app), ["Resize", "Duplicate", "Rearrange", "Export"]); // Under artboard 2. let xf = Xf::new(app.canvas_rect.unwrap(), app.view().unwrap()); let bar = task_bar_rect(&ctx).unwrap(); @@ -12534,10 +12534,212 @@ fn the_task_bar_offers_the_artboard_tools_actions() { app.session.execute("shape.rectangle", &json!({"x": 20, "y": 20, "width": 40, "height": 40})).unwrap(); assert_eq!(names(&mut app), ["Edit Path", "Offset Path", "Simplify", "Duplicate"]); - // One artboard: nothing to rearrange. + // One artboard, selected: Rearrange places it. app.session.execute("file.new", &json!({"width": 200, "height": 100})).unwrap(); app.select_tool("artboard"); - assert_eq!(names(&mut app), ["Resize", "Duplicate", "Export"]); + assert_eq!(names(&mut app), ["Resize", "Duplicate", "Rearrange", "Export"]); +} + +/// The task bar's Rearrange, confirmed, waits for a click: the grid's outline follows the pointer, +/// and a press on the canvas puts the selected artboards' grid there with its top-left at the press, +/// as one undo step, leaving the other artboards and giving the tool no press. Esc cancels a second +/// one, and so does another tool, with nothing moved. +#[test] +fn rearrange_places_the_selected_artboards_where_the_canvas_is_clicked() { + use crate::dialogs::rearrange_artboards::PLACE_HINT; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 3})).unwrap(); + app.select_tool("artboard"); + app.session.set_tool_option("selected", &json!([0, 2])); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let boards = |app: &VectorcraftApp| app.session.active().unwrap().doc.artboards.iter().map(|a| a.rect).collect::>(); + let undo = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len(); + let wait = |app: &mut VectorcraftApp| { + crate::panels::artboards::open_rearrange_selected(app); + let d = app.ui.dialog.as_mut().expect("Rearrange opens"); + d.fields.insert("layout".into(), json!("row")); + d.fields.insert("spacing".into(), json!(10)); + crate::dialogs::confirm(app).unwrap(); + assert!(app.ui.rearrange_placement.is_some() && app.ui.status == PLACE_HINT); + }; + let (before, steps) = (boards(&app), undo(&app)); + let canvas = app.canvas_rect.unwrap(); + let at = canvas.center() + vec2(-150.0, -120.0); + let xf = Xf::at(canvas, app.view().unwrap(), app.canvas_ui_zoom); + let doc = xf.to_doc(at); + let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + + // Esc: nothing moves. + wait(&mut app); + frame( + &mut app, + &ctx, + vec![egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }], + ); + assert!(app.ui.rearrange_placement.is_none()); + // Another tool: nothing moves. + wait(&mut app); + app.select_tool("selection"); + frame(&mut app, &ctx, vec![]); + assert!(app.ui.rearrange_placement.is_none()); + assert_eq!((boards(&app), undo(&app)), (before.clone(), steps)); + + app.select_tool("artboard"); + app.session.set_tool_option("selected", &json!([0, 2])); + wait(&mut app); + // The grid's outline: artboard 0's top-left at the pointer. + let outlines = |app: &mut VectorcraftApp| { + let raw = egui::RawInput { + screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), + events: vec![egui::Event::PointerMoved(at)], + ..Default::default() + }; + let out = ctx.run_ui(raw, |ui| show(app, ui)); + out.shapes.iter().any(|s| match &s.shape { + egui::Shape::Path(p) => p.closed && p.points.first().is_some_and(|q| (*q - at).length() < 0.5), + _ => false, + }) + }; + outlines(&mut app); + assert!(outlines(&mut app), "the grid's outline starts at the pointer"); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), button(true)]); + frame(&mut app, &ctx, vec![button(false)]); + let after = boards(&app); + assert_eq!(after.len(), 3, "the Artboard tool made no artboard"); + assert_eq!(after[1], before[1], "artboard 2 is not selected"); + let near = |a: f64, b: f64| (a - b).abs() < 1e-3; + assert!(near(after[0].x0, doc.x) && near(after[0].y0, doc.y), "{:?} at {doc:?}", after[0]); + assert!(near(after[2].x0, doc.x + 210.0) && near(after[2].y0, doc.y), "{:?}", after[2]); + assert_eq!(undo(&app), steps + 1); + assert!(app.ui.rearrange_placement.is_none() && app.ui.status != PLACE_HINT); +} + +/// A waiting Rearrange takes Enter from the keyboard, but not in the frame it was confirmed in (the +/// dialog's own Enter): with the pointer off the canvas, the grid starts at the first selected +/// artboard's top-left, in one undo step. A press with Space held pans and places nothing. +#[test] +fn rearrange_places_the_selected_artboards_with_enter_and_lets_space_pan() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 3})).unwrap(); + app.select_tool("artboard"); + app.session.set_tool_option("selected", &json!([2, 0])); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let boards = |app: &VectorcraftApp| app.session.active().unwrap().doc.artboards.iter().map(|a| a.rect).collect::>(); + let undo = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len(); + let (before, steps) = (boards(&app), undo(&app)); + crate::panels::artboards::open_rearrange_selected(&mut app); + let d = app.ui.dialog.as_mut().expect("Rearrange opens"); + d.fields.insert("layout".into(), json!("row")); + d.fields.insert("spacing".into(), json!(10)); + crate::dialogs::confirm(&mut app).unwrap(); + let key = |key, pressed| egui::Event::Key { key, physical_key: None, pressed, repeat: false, modifiers: Default::default() }; + // The Enter that confirmed the dialog places nothing. + frame(&mut app, &ctx, vec![key(egui::Key::Enter, true)]); + assert!(app.ui.rearrange_placement.is_some()); + // Space held: the press pans. + let at = app.canvas_rect.unwrap().center(); + let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + frame(&mut app, &ctx, vec![key(egui::Key::Space, true), egui::Event::PointerMoved(at), button(true)]); + frame(&mut app, &ctx, vec![button(false), key(egui::Key::Space, false)]); + assert!(app.ui.rearrange_placement.is_some()); + assert_eq!((boards(&app), undo(&app)), (before.clone(), steps)); + // Enter while another control has the keyboard focus is that control's. + ctx.memory_mut(|m| m.request_focus(egui::Id::unique("another control"))); + frame(&mut app, &ctx, vec![key(egui::Key::Enter, true)]); + assert!(app.ui.rearrange_placement.is_some(), "Enter in another control places nothing"); + assert_eq!((boards(&app), undo(&app)), (before.clone(), steps)); + ctx.memory_mut(|m| m.surrender_focus(egui::Id::unique("another control"))); + // Enter with the pointer off the canvas: from artboard 1's corner, artboard 3 next to it. + frame(&mut app, &ctx, vec![egui::Event::PointerGone, key(egui::Key::Enter, true)]); + let after = boards(&app); + assert!(app.ui.rearrange_placement.is_none()); + assert_eq!((after[0], after[1]), (before[0], before[1])); + assert_eq!((after[2].x0, after[2].y0), (before[0].x0 + 210.0, before[0].y0)); + assert_eq!(undo(&app), steps + 1); +} + +/// A waiting Rearrange is dropped when its artboards change places in the list before the click, +/// so the click moves no artboard the tool did not select. +#[test] +fn rearrange_waiting_for_a_click_is_dropped_when_its_artboards_are_reordered() { + use crate::dialogs::rearrange_artboards::PLACE_HINT; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 3})).unwrap(); + app.select_tool("artboard"); + app.session.set_tool_option("selected", &json!([0])); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + crate::panels::artboards::open_rearrange_selected(&mut app); + crate::dialogs::confirm(&mut app).unwrap(); + assert!(app.ui.rearrange_placement.is_some()); + app.run("artboard.reorder", json!({"index": 2, "to": 0})).unwrap(); + let before: Vec<_> = app.session.active().unwrap().doc.artboards.iter().map(|a| a.rect).collect(); + let at = app.canvas_rect.unwrap().center(); + let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), button(true)]); + frame(&mut app, &ctx, vec![button(false)]); + assert!(app.ui.rearrange_placement.is_none() && app.ui.status != PLACE_HINT); + let after: Vec<_> = app.session.active().unwrap().doc.artboards.iter().map(|a| a.rect).collect(); + assert_eq!(after, before); +} + +/// A Rearrange placement that moves nothing says the artboard is locked only when every selected +/// artboard is locked; a locked artboard beside one already in its cell leaves no such message. +#[test] +fn rearrange_says_locked_only_when_every_selected_artboard_is_locked() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + let layout = json!({"layout": "row", "spacing": 20}); + app.session.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 3, "artboardLayout": layout})).unwrap(); + app.session.execute("artboard.setProps", &json!({"index": 0, "locked": true})).unwrap(); + app.select_tool("artboard"); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let enter = egui::Event::Key { key: egui::Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }; + for (selected, status) in [(json!([0, 1]), ""), (json!([0]), "the artboard is locked")] { + app.session.set_tool_option("selected", &selected); + crate::panels::artboards::open_rearrange_selected(&mut app); + let d = app.ui.dialog.as_mut().expect("Rearrange opens"); + d.fields.insert("layout".into(), json!("row")); + d.fields.insert("spacing".into(), json!(20)); + crate::dialogs::confirm(&mut app).unwrap(); + frame(&mut app, &ctx, vec![]); + frame(&mut app, &ctx, vec![egui::Event::PointerGone, enter.clone()]); + assert!(app.ui.rearrange_placement.is_none(), "{selected}"); + assert_eq!(app.ui.status, status, "{selected}"); + } +} + +/// A press on a floating panel over the canvas does not place a waiting Rearrange; a press on the +/// open canvas does. +#[test] +fn rearrange_is_not_placed_by_a_press_on_a_panel_over_the_canvas() { + let (mut app, ctx, _, over, _) = distance_scene(false); + app.select_tool("artboard"); + app.session.set_tool_option("selected", &json!([0])); + crate::panels::artboards::open_rearrange_selected(&mut app); + crate::dialogs::confirm(&mut app).unwrap(); + let board = |app: &VectorcraftApp| app.session.active().unwrap().doc.artboards[0].rect; + let before = board(&app); + let cover = Some(Cover::Panel(egui::Rect::from_center_size(over, vec2(120.0, 120.0)))); + let run = |app: &mut VectorcraftApp, events, cover| distance_frame_covered(app, &ctx, events, cover); + // A new window takes a sizing pass before it covers anything. + for _ in 0..3 { + run(&mut app, vec![egui::Event::PointerMoved(over)], cover); + } + let button = |pressed| egui::Event::PointerButton { pos: over, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + run(&mut app, vec![button(true)], cover); + run(&mut app, vec![button(false)], cover); + assert!(app.ui.rearrange_placement.is_some(), "the press is the panel's"); + assert_eq!(board(&app), before); + for _ in 0..3 { + run(&mut app, vec![egui::Event::PointerMoved(over)], None); + } + run(&mut app, vec![button(true)], None); + run(&mut app, vec![button(false)], None); + assert!(app.ui.rearrange_placement.is_none(), "placed on the open canvas"); + assert_ne!(board(&app), before); } /// Screen readers name the Contextual Task Bar's text buttons by their labels. @@ -12581,7 +12783,7 @@ fn the_task_bar_leaves_isolate_out_while_an_opacity_mask_is_edited() { } /// The Artboard tool's Contextual Task Bar buttons act on its selected artboards: Resize opens -/// Artboard Options for the active one, Rearrange All opens Rearrange All Artboards, Export opens +/// Artboard Options for the active one, Rearrange opens Rearrange for the selected artboards, Export opens /// Export for Screens with the selected artboards checked, and Duplicate copies each selected /// artboard in one undo step and selects the copies. #[test] @@ -12603,8 +12805,8 @@ fn the_artboard_tools_task_bar_buttons_act_on_the_selected_artboards() { }; let d = press(&mut app, "Resize").expect("Artboard Options"); assert_eq!((d.kind.as_str(), d.f64("index", 9.0)), ("artboardOptions", 2.0)); - let d = press(&mut app, "Rearrange All").expect("Rearrange All Artboards"); - assert_eq!(d.kind, crate::dialogs::rearrange_artboards::KIND); + let d = press(&mut app, "Rearrange").expect("Rearrange"); + assert_eq!((d.kind.as_str(), &d.fields["indices"]), (crate::dialogs::rearrange_artboards::KIND, &json!([0, 2]))); let d = press(&mut app, "Export").expect("Export for Screens"); assert_eq!((d.kind.as_str(), &d.fields["boards"]), (crate::dialogs::EXPORT_FOR_SCREENS, &json!([true, false, true]))); diff --git a/crates/ui-egui/src/dialogs/rearrange_artboards.rs b/crates/ui-egui/src/dialogs/rearrange_artboards.rs index 6fa90910a4..42c31efa7e 100644 --- a/crates/ui-egui/src/dialogs/rearrange_artboards.rs +++ b/crates/ui-egui/src/dialogs/rearrange_artboards.rs @@ -4,14 +4,26 @@ //! Spacing and Move Artwork with Artboard, with the document's artboard count. OK runs //! `artboard.rearrange` as one undo step (#681). //! +//! Rearrange (the Artboard tool's canvas menu and Contextual Task Bar, the Artboards panel's +//! Rearrange… and its button while the Artboard tool is in use) is the same dialog for the +//! selected artboards (field `indices`), with their count. Its OK waits for a click on the canvas, +//! which places the grid's top-left there: the grid follows the pointer until then, Enter places it +//! at the pointer (or, off the canvas, at the first selected artboard's top-left), a Space-drag +//! still pans, and Esc, another tool or another document cancels it. The click or Enter runs +//! `artboard.rearrange` with `indices` and `at` as one undo step +//! (https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/rearrange-artboards.html). +//! //! Fields: `layout` (`gridByRow` | `gridByColumn` | `row` | `column`), `order` (`leftToRight` | -//! `rightToLeft`), `columns` (the rows of a grid by column), `spacing` (pt) and `moveArtwork`. +//! `rightToLeft`), `columns` (the rows of a grid by column), `spacing` (pt), `moveArtwork` and, for +//! Rearrange, `indices`. use serde_json::{Value, json}; -use vectorcraft_engine::cmd::newdoc::ArtboardLayout; +use vectorcraft_engine::cmd::newdoc::{ArtboardLayout, rearrange_grid}; +use vectorcraft_geom::Rect; use super::{DialogSpec, form, run_and_close}; -use crate::state::Dialog; +use crate::canvas::Xf; +use crate::state::{Dialog, RearrangePlacement, View}; use crate::{VectorcraftApp, widgets}; /// The dialog kind of Rearrange All Artboards. @@ -19,11 +31,17 @@ pub const KIND: &str = "rearrangeArtboards"; const CMD: &str = "artboard.rearrange"; +/// The status bar's message while a Rearrange waits for its click. +pub(crate) const PLACE_HINT: &str = "Click on the canvas to place the artboards (Esc cancels)"; + /// Width of the label column. const LABEL_W: f32 = 96.0; -pub(super) const SPEC: DialogSpec = - DialogSpec { heading: |_| tl!("Rearrange All Artboards").into(), body, confirm, min_width: 320.0, ..DialogSpec::FORM }; +pub(super) const SPEC: DialogSpec = DialogSpec { heading, body, confirm, min_width: 320.0, ..DialogSpec::FORM }; + +fn heading(d: &Dialog) -> String { + if indices(d).is_some() { tl!("Rearrange") } else { tl!("Rearrange All Artboards") }.into() +} /// The fields a fresh dialog starts with. pub fn fields() -> Value { @@ -39,6 +57,133 @@ pub fn open_fields(app: &VectorcraftApp) -> Value { fields } +/// Open Rearrange for artboards `indices`, kept sorted and once each; none opens nothing. A +/// placement still waiting is dropped. +pub(crate) fn open_selected(app: &mut VectorcraftApp, indices: &[usize]) { + cancel_placement(app); + if indices.is_empty() { + return; + } + let mut indices = indices.to_vec(); + indices.sort_unstable(); + indices.dedup(); + let mut fields = open_fields(app); + fields["indices"] = json!(indices); + app.ui.dialog = Some(Dialog::new(KIND, fields)); +} + +/// The artboards of a menu item's params that list nothing but `indices` (the Artboard tool's +/// Rearrange), as whole numbers. +pub(crate) fn menu_indices(p: &Value) -> Option> { + let o = p.as_object().filter(|o| o.len() == 1)?; + let list = o.get("indices")?.as_array()?; + list.iter().map(|i| i.as_u64().and_then(|i| usize::try_from(i).ok())).collect() +} + +/// The artboards a Rearrange dialog lays out; `None` for Rearrange All Artboards. +fn indices(d: &Dialog) -> Option> { + d.fields.get("indices").and_then(Value::as_array).map(|a| a.iter().filter_map(Value::as_u64).filter_map(|i| usize::try_from(i).ok()).collect()) +} + +/// The artboards a waiting placement lays out. +fn placed(pl: &RearrangePlacement) -> Vec { + pl.params["indices"].as_array().into_iter().flatten().filter_map(Value::as_u64).filter_map(|i| usize::try_from(i).ok()).collect() +} + +/// Drop the placement waiting for its click, and its message in the status bar. +pub(crate) fn cancel_placement(app: &mut VectorcraftApp) { + if app.ui.rearrange_placement.take().is_some() && app.ui.status == PLACE_HINT { + app.status(""); + } +} + +/// Whether a placement waits for its click: one whose document is no longer the active one, whose +/// tool is no longer the tool in use, or whose listed places no longer hold the artboards it was +/// confirmed for (removed or moved in the list) is dropped. +pub(crate) fn refresh_placement(app: &mut VectorcraftApp) -> bool { + let Some(pl) = app.ui.rearrange_placement.as_ref() else { return false }; + let same = app.session.active().filter(|d| d.uid == pl.doc).is_some_and(|d| { + let listed = placed(pl); + listed.len() == pl.ids.len() && listed.iter().zip(&pl.ids).all(|(i, id)| d.doc.artboards.get(*i).is_some_and(|a| a.id == *id)) + }); + if same && app.session.tool_id() == pl.tool { + return true; + } + cancel_placement(app); + false +} + +/// The canvas's input while a placement waits and no modal dialog is open (`modal`): Esc cancels +/// it, a press on the canvas runs `artboard.rearrange` with the grid's top-left (`at`) at the +/// pressed point, and Enter, when no other control has the keyboard focus, runs it with `at` at the +/// pointer over the canvas, else with the grid at the first selected artboard's top-left. While +/// Space lends the view tools (`space`), presses pan or zoom as usual. Returns true when the +/// placement takes the frame's input, so no tool gets it. +pub(crate) fn placement_input(app: &mut VectorcraftApp, ui: &egui::Ui, resp: &egui::Response, rect: egui::Rect, modal: bool, space: bool) -> bool { + if !refresh_placement(app) || modal { + return false; + } + if ui.input(|i| i.key_pressed(egui::Key::Escape)) { + cancel_placement(app); + return true; + } + let armed = app.ui.rearrange_placement.as_ref().is_some_and(|pl| pl.armed); + if let Some(pl) = app.ui.rearrange_placement.as_mut() { + pl.armed = true; + } + if space { + return false; + } + let pointer = ui.input(|i| i.pointer.clone()); + // The grid follows the pointer. + if pointer.is_moving() { + ui.ctx().request_repaint(); + } + let xf = Xf::at(rect, app.view().unwrap_or(&View::default()), app.canvas_ui_zoom); + let pressed = pointer.interact_pos().filter(|p| pointer.primary_pressed() && resp.hovered() && rect.contains(*p)); + // Enter belongs to the control that has the keyboard focus, when another one has it. + let free_keys = ui.memory(|m| m.focused().is_none_or(|id| id == resp.id)); + let entered = armed && free_keys && ui.input(|i| i.key_pressed(egui::Key::Enter)); + let at = match (pressed, entered) { + (Some(p), _) => Some(xf.to_doc(p)), + (None, true) => pointer.hover_pos().filter(|p| resp.hovered() && rect.contains(*p)).map(|p| xf.to_doc(p)), + (None, false) => return false, + }; + let Some(mut pl) = app.ui.rearrange_placement.take() else { return false }; + let listed = placed(&pl); + let locked = app.session.active().is_some_and(|d| listed.iter().all(|i| d.doc.artboards.get(*i).is_some_and(|a| a.locked))); + if let Some(at) = at { + pl.params["at"] = json!([at.x, at.y]); + } + match app.run(CMD, pl.params) { + // Every selected artboard locked: nothing could move. + Ok(r) if r["moved"] == 0 && locked => app.status("the artboard is locked"), + Ok(_) => app.status(""), + Err(e) => app.status(e), + } + true +} + +/// The grid a waiting placement makes with its top-left at the pointer: the outline of each +/// artboard that moves, in `color`, 1 point wide on screen. +pub(crate) fn paint_placement(app: &VectorcraftApp, painter: &egui::Painter, xf: &Xf, color: egui::Color32) { + let Some(pl) = app.ui.rearrange_placement.as_ref().filter(|pl| app.session.tool_id() == pl.tool) else { return }; + let (Some(at), Some(st)) = (app.hover_doc, app.session.active().filter(|d| d.uid == pl.doc)) else { return }; + let boards: Vec<&vectorcraft_doc::Artboard> = placed(pl).into_iter().filter_map(|i| st.doc.artboards.get(i)).collect(); + let sizes: Vec<(f64, f64)> = boards.iter().map(|a| (a.rect.width(), a.rect.height())).collect(); + let p = &pl.params; + let layout = p["layout"].as_str().and_then(ArtboardLayout::parse).unwrap_or_default(); + let lines = p["columns"].as_f64().filter(|c| c.is_finite()).map_or(2, |c| c.round().max(1.0) as u64); + let spacing = p["spacing"].as_f64().filter(|s| s.is_finite()).unwrap_or(20.0).clamp(-1.0e5, 1.0e5); + let (origins, ..) = rearrange_grid(&sizes, at, layout, lines, spacing, p["order"] == "rightToLeft"); + // A locked artboard keeps its cell but stays where it is. + for ((o, (w, h)), a) in origins.iter().zip(&sizes).zip(&boards) { + if !a.locked { + painter.add(egui::Shape::closed_line(xf.quad(Rect::new(o.x, o.y, o.x + w, o.y + h)), egui::Stroke::new(1.0, color))); + } + } +} + /// A layout's toggle: its tooltip and its artboards' cells (column, row) in their order, left to /// right. fn layout_glyph(l: ArtboardLayout) -> (&'static str, &'static [(u8, u8)]) { @@ -58,15 +203,20 @@ fn mirrored(cells: &[(u8, u8)], rtl: bool) -> Vec<(u8, u8)> { /// `artboard.rearrange` parameters from the fields. fn params(d: &Dialog) -> Value { - json!({ + let mut p = json!({ "layout": d.str("layout"), "order": d.str("order"), "columns": d.f64("columns", 2.0), "spacing": d.f64("spacing", 20.0), "moveArtwork": d.bool("moveArtwork"), - }) + }); + if let Some(indices) = indices(d) { + p["indices"] = json!(indices); + } + p } fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { let unit = app.session.general_unit(); - let n = app.session.active().map_or(0, |doc| doc.doc.artboards.len()); + let selected = indices(d); + let n = selected.as_ref().map_or_else(|| app.session.active().map_or(0, |doc| doc.doc.artboards.len()), Vec::len); let layout = ArtboardLayout::parse(&d.str("layout")).unwrap_or_default(); let rtl = d.str("order") == "rightToLeft"; widgets::label_row(ui, tl!("Layout:"), LABEL_W, |ui| { @@ -114,12 +264,32 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { form::check(ui, d, "moveArtwork", tl!("Move Artwork with Artboard")); }); ui.add_space(8.0); - widgets::dim_label(ui, &crate::i18n::fmt(tl!("Artboards: {n}"), &[("n", &n.to_string())])); + let count = if selected.is_some() { tl!("Selected Artboards: {n}") } else { tl!("Artboards: {n}") }; + widgets::dim_label(ui, &crate::i18n::fmt(count, &[("n", &n.to_string())])); false } +/// Rearrange All Artboards runs at once. Rearrange closes and waits for its click on the canvas +/// ([`placement_input`]). fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result { - let result = run_and_close(app, CMD, params(d))?; + let result = match indices(d) { + None => { + cancel_placement(app); + run_and_close(app, CMD, params(d))? + } + Some(listed) => { + let st = app.session.active().ok_or_else(|| "no document".to_string())?; + let ids: Vec = listed.iter().filter_map(|i| st.doc.artboards.get(*i)).map(|a| a.id).collect(); + if ids.len() != listed.len() { + return Err("no such artboard".into()); + } + let (doc, tool) = (st.uid, app.session.tool_id().to_string()); + app.ui.rearrange_placement = Some(RearrangePlacement { doc, tool, params: params(d), ids, armed: false }); + app.ui.dialog = None; + app.status(PLACE_HINT); + Value::Null + } + }; app.ui.rearrange_artboards_spacing = json!(d.f64("spacing", 20.0)); Ok(result) } @@ -229,4 +399,45 @@ mod tests { // Two rows (Columns 2 reads Rows for a grid by column), the first column at the right. assert_eq!(origins(&app), [(120.0, 0.0), (120.0, 70.0), (0.0, 0.0), (0.0, 70.0)]); } + + /// The Artboard tool's canvas menu opens Rearrange for the artboards the tool has selected, + /// with their count; OK moves nothing and waits for a click on the canvas with those artboards + /// and the dialog's fields. Rearrange All Artboards still lays out every artboard at once. + #[test] + fn rearrange_from_the_canvas_menu_waits_for_a_click_with_the_selected_artboards() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 100, "height": 50, "artboards": 3})).unwrap(); + app.select_tool("artboard"); + app.session.set_tool_option("selected", &json!([0, 2])); + let items = crate::menus::context_items(&app); + let target = items.iter().find_map(|i| match i { + crate::menus::Item::Cmd("Rearrange", id, p) => Some(crate::menus::click_target("Rearrange", id, p)), + _ => None, + }); + let (id, p) = target.expect("Rearrange in the canvas menu"); + crate::menus::invoke(&mut app, &id, p); + assert_eq!(app.ui.dialog.as_ref().map(|d| d.kind.as_str()), Some(KIND)); + let ctx = context(); + frame(&mut app, &ctx, vec![]); + let texts = frame(&mut app, &ctx, vec![]); + for want in ["Rearrange", "Layout:", "Move Artwork with Artboard", "Selected Artboards: 2"] { + assert!(texts.iter().any(|t| t == want), "{want:?} in {texts:?}"); + } + assert!(!texts.iter().any(|t| t == "Rearrange All Artboards" || t == "Artboards: 3"), "{texts:?}"); + app.ui.dialog.as_mut().unwrap().fields.insert("layout".into(), json!("row")); + let (before, undo) = (origins(&app), app.session.doc().unwrap().history.undo.len()); + crate::dialogs::confirm(&mut app).unwrap(); + assert!(app.ui.dialog.is_none()); + assert_eq!((origins(&app), app.session.doc().unwrap().history.undo.len()), (before.clone(), undo)); + let waiting = app.ui.rearrange_placement.as_ref().expect("waits for a click"); + assert_eq!((waiting.params["indices"].clone(), waiting.params["layout"].clone()), (json!([0, 2]), json!("row"))); + assert_eq!(app.ui.status, PLACE_HINT); + + // Rearrange All Artboards drops it and runs at once. + app.run("ui.menuDialog", json!({"command": CMD})).unwrap(); + crate::dialogs::confirm(&mut app).unwrap(); + assert_ne!(origins(&app), before); + assert!(app.ui.rearrange_placement.is_none()); + assert_ne!(app.ui.status, PLACE_HINT); + } } diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 167737554d..dce0f2c36e 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -2969,6 +2969,9 @@ digits Malayalam Малаялам Scale Artwork with Artboard Мащабиране на графиката заедно с работната област Artboards: {n} Работни области: {n} Rearrange All Artboards… Пренареждане на всички работни области… + Rearrange… Пренареждане… + Selected Artboards: {n} Избрани работни области: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Кликнете върху платното, за да поставите работните области (Esc отменя) Recall Selection Възстановяване на селекцията RECENT СКОРОШНИ Recent Скорошни diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index a9d6e35ed8..0ede519045 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -343,6 +343,9 @@ Artboards Radne ploče Convert to Artboards Pretvori u radne ploče Rearrange All Artboards… Preuredi sve radne ploče… + Rearrange… Preuredi… + Selected Artboards: {n} Odabrane radne ploče: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Kliknite na platno da postavite radne ploče (Esc otkazuje) Fit to Artwork Bounds Uklopi u granice crteža Fit to Selected Art Uklopi u odabrani crtež Graph Grafikon diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index e4271f7926..ee851070ea 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -3791,6 +3791,9 @@ digits Malayalam Malaiàlam Rearrange All Reorganitza-ho tot Rearrange All Artboards Reorganitza tots els taulers Rearrange All Artboards… Reorganitza tots els taulers… + Rearrange… Reorganitza… + Selected Artboards: {n} Taulers seleccionats: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Fes clic al llenç per col·locar els taulers (Esc cancel·la) Rearrange Artboards Reorganitza els taulers Recall Selection Recupera la selecció RECENT RECENTS diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 488df173c3..62d89ff1c0 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -350,6 +350,9 @@ Artboards Pracovní plochy Convert to Artboards Převést na pracovní plochy Rearrange All Artboards… Přeuspořádat všechny pracovní plochy… + Rearrange… Přeuspořádat… + Selected Artboards: {n} Vybrané pracovní plochy: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Kliknutím na plátno umístíte pracovní plochy (Esc zruší) Fit to Artwork Bounds Přizpůsobit hranicím kresby Fit to Selected Art Přizpůsobit vybrané kresbě Graph Graf diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 302ab6aa69..c15122b46a 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3081,6 +3081,9 @@ liquify-list-end {0}, {1} {0} og {1} Artboards Tegneflader Convert to Artboards Konvertér til tegneflader Rearrange All Artboards… Omarrangér alle tegneflader… + Rearrange… Omarrangér… + Selected Artboards: {n} Markerede tegneflader: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Klik på lærredet for at placere tegnefladerne (Esc annullerer) Fit to Artwork Bounds Tilpas til grafikkens grænser Fit to Selected Art Tilpas til valgt grafik Graph Diagram diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 9482345f18..31b26f673c 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3037,6 +3037,9 @@ digits Malayalam Malayalam Scale Artwork with Artboard Grafik mit Zeichenfläche skalieren Artboards: {n} Zeichenflächen: {n} Rearrange All Artboards… Alle Zeichenflächen neu anordnen… + Rearrange… Neu anordnen… + Selected Artboards: {n} Ausgewählte Zeichenflächen: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Klicken Sie auf die Arbeitsfläche, um die Zeichenflächen zu platzieren (Esc bricht ab) Recall Selection Auswahl abrufen RECENT ZULETZT VERWENDET Recent Zuletzt verwendet diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 434d0cc0b8..5aac0384ed 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3939,6 +3939,9 @@ digits Malayalam Μαλαγιάλαμ Scale Artwork with Artboard Κλιμάκωση σχεδίου μαζί με τον πίνακα σχεδίασης Artboards: {n} Πίνακες σχεδίασης: {n} Rearrange All Artboards… Αναδιάταξη όλων των πινάκων σχεδίασης… + Rearrange… Αναδιάταξη… + Selected Artboards: {n} Επιλεγμένοι πίνακες σχεδίασης: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Κάντε κλικ στον καμβά για να τοποθετήσετε τους πίνακες σχεδίασης (Esc για ακύρωση) Recall Selection Ανάκληση επιλογής RECENT ΠΡΟΣΦΑΤΑ Recent Colors Πρόσφατα χρώματα diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 3f83e928e4..688ba57a94 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -3074,6 +3074,9 @@ digits Malayalam Malayálam Scale Artwork with Artboard Escalar la ilustración con la mesa de trabajo Artboards: {n} Mesas de trabajo: {n} Rearrange All Artboards… Reorganizar todas las mesas de trabajo… + Rearrange… Reorganizar… + Selected Artboards: {n} Mesas de trabajo seleccionadas: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Haz clic en el lienzo para colocar las mesas de trabajo (Esc cancela) Recall Selection Recuperar selección RECENT RECIENTES Recent Recientes diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index a4d85b23e8..e1f8d0cc89 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -357,6 +357,9 @@ Artboards Piirtoalustat Convert to Artboards Muunna piirtoalustoiksi Rearrange All Artboards… Järjestä kaikki piirtoalustat uudelleen… + Rearrange… Järjestä uudelleen… + Selected Artboards: {n} Valitut piirtoalustat: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Sijoita piirtoalustat napsauttamalla kangasta (Esc peruuttaa) Fit to Artwork Bounds Sovita kuvituksen rajoihin Fit to Selected Art Sovita valittuun kuvitukseen Graph Kaavio diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8f56486157..7d8839460e 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3062,6 +3062,9 @@ digits Malayalam Malayalam Scale Artwork with Artboard Mettre à l’échelle l’illustration avec le plan de travail Artboards: {n} Plans de travail : {n} Rearrange All Artboards… Réorganiser tous les plans de travail… + Rearrange… Réorganiser… + Selected Artboards: {n} Plans de travail sélectionnés ({n}) +@msg Click on the canvas to place the artboards (Esc cancels) Cliquez sur la zone de travail pour placer les plans de travail (Échap pour annuler) Recall Selection Rappeler la sélection RECENT RÉCENTS Recent Récents diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 0bb7c9b71f..3cf704bff4 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -3080,6 +3080,9 @@ Rearrange All બધું ફરીથી ગોઠવો Rearrange All Artboards બધા આર્ટબોર્ડ ફરીથી ગોઠવો Rearrange All Artboards… બધા આર્ટબોર્ડ ફરીથી ગોઠવો… + Rearrange… ફરીથી ગોઠવો… + Selected Artboards: {n} પસંદ કરેલા આર્ટબોર્ડ: {n} +@msg Click on the canvas to place the artboards (Esc cancels) આર્ટબોર્ડ મૂકવા કેનવાસ પર ક્લિક કરો (Esc રદ કરે છે) Rearrange Artboards આર્ટબોર્ડ ફરીથી ગોઠવો Recall Selection પસંદગી યાદ કરો Recent Colors તાજેતરના રંગો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index e9509d9202..a4e94e2dd7 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -4389,6 +4389,9 @@ arrowhead Feather पंख Rearrange All सभी को फिर से व्यवस्थित करें Rearrange All Artboards सभी आर्टबोर्ड को फिर से व्यवस्थित करें Rearrange All Artboards… सभी आर्टबोर्ड को पुनर्व्यवस्थित करें… + Rearrange… फिर से व्यवस्थित करें… + Selected Artboards: {n} चुने गए आर्टबोर्ड: {n} +@msg Click on the canvas to place the artboards (Esc cancels) आर्टबोर्ड प्लेस करने के लिए कैनवास पर क्लिक करें (Esc से कैंसल करें) Rearrange Artboards रीरेंज आर्टबोर्ड Recall Selection सिलेक्शन वापस लाएँ Recent हाल के diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 87f050ef0d..5090c8611e 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3639,6 +3639,9 @@ mark-style Japanese Japán Rearrange All Összes átrendezése Rearrange All Artboards Összes rajztábla átrendezése Rearrange All Artboards… Összes rajztábla átrendezése… + Rearrange… Átrendezés… + Selected Artboards: {n} Kijelölt rajztáblák: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Kattints a vászonra a rajztáblák elhelyezéséhez (Esc: mégse) Recall Selection Kijelölés visszahívása Recent Legutóbbi RECENT LEGUTÓBBI diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 924d3d80b5..2d6cb32cd4 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -958,6 +958,9 @@ Artboards Artboard Convert to Artboards Konversi ke artboard Rearrange All Artboards… Atur ulang semua artboard… + Rearrange… Atur ulang… + Selected Artboards: {n} Artboard terpilih: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Klik kanvas untuk menempatkan artboard (Esc membatalkan) Fit to Artwork Bounds Sesuaikan ke batas karya seni Fit to Selected Art Sesuaikan ke karya seni terseleksi Graph Grafik diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 5f47e3f117..f4815b087e 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -3122,6 +3122,9 @@ digits Malayalam Malayalam Scale Artwork with Artboard Scala la grafica con la tavola da disegno Artboards: {n} Tavole da disegno: {n} Rearrange All Artboards… Ridisponi tutte le tavole da disegno… + Rearrange… Ridisponi… + Selected Artboards: {n} Tavole da disegno selezionate: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Fai clic sull'area di lavoro per posizionare le tavole da disegno (Esc annulla) Recall Selection Richiama selezione RECENT RECENTI Recent Recenti diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 9a1b5f6354..9ac7433248 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -412,6 +412,9 @@ digits Malayalam マラヤーラム数字 Artboards アートボード Convert to Artboards アートボードに変換 Rearrange All Artboards… すべてのアートボードを再配置… + Rearrange… 再配置… + Selected Artboards: {n} 選択したアートボード: {n} +@msg Click on the canvas to place the artboards (Esc cancels) キャンバスをクリックしてアートボードを配置します (Esc でキャンセル) Fit to Artwork Bounds アートワーク境界に合わせる Fit to Selected Art 選択オブジェクトに合わせる Graph グラフ diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 8eeacee621..8da0dd59d7 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -2493,6 +2493,9 @@ Artboards სამუშაო დაფები Convert to Artboards სამუშაო დაფებად გარდაქმნა Rearrange All Artboards… ყველა სამუშაო დაფის გადალაგება… + Rearrange… გადალაგება… + Selected Artboards: {n} მონიშნული სამუშაო დაფები: {n} +@msg Click on the canvas to place the artboards (Esc cancels) დაწკაპეთ ტილოზე სამუშაო დაფების განსათავსებლად (Esc აუქმებს) Fit to Artwork Bounds ნახატის საზღვრებზე მორგება Fit to Selected Art მონიშნულ ნახატზე მორგება Graph დიაგრამა diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 57e0b8be10..8bba69752a 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -405,6 +405,9 @@ digits Malayalam 말라얄람어 Artboards 아트보드 Convert to Artboards 아트보드로 변환 Rearrange All Artboards… 모든 아트보드 재정렬… + Rearrange… 재정렬… + Selected Artboards: {n} 선택한 아트보드: {n} +@msg Click on the canvas to place the artboards (Esc cancels) 캔버스를 클릭하여 아트보드를 배치하세요(Esc로 취소) Fit to Artwork Bounds 아트워크 경계에 맞추기 Fit to Selected Art 선택한 아트에 맞추기 Graph 그래프 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 5ed5cdc3e0..2e2bbc801f 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -945,6 +945,9 @@ liquify-list-end {0}, {1} {0} en {1} Artboards Tekengebieden Convert to Artboards Converteren naar tekengebieden Rearrange All Artboards… Alle tekengebieden herschikken… + Rearrange… Herschikken… + Selected Artboards: {n} Geselecteerde tekengebieden: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Klik op het canvas om de tekengebieden te plaatsen (Esc annuleert) Fit to Artwork Bounds Op artworkgrenzen passend maken Fit to Selected Art Op geselecteerd artwork passend maken Graph Grafiek diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 74029133dc..7dec21b241 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -310,6 +310,9 @@ Artboards Obszary kompozycji Convert to Artboards Konwertuj na obszary kompozycji Rearrange All Artboards… Przestaw wszystkie obszary kompozycji… + Rearrange… Przestaw… + Selected Artboards: {n} Zaznaczone obszary kompozycji: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Kliknij obszar roboczy, aby umieścić obszary kompozycji (Esc anuluje) Fit to Artwork Bounds Dopasuj do granic kompozycji Fit to Selected Art Dopasuj do zaznaczonej kompozycji Graph Wykres diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index a1747af0b2..5e9251d5bb 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2554,6 +2554,9 @@ digits Malayalam Malaiala Scale Artwork with Artboard Dimensionar Arte com a Mesa de Trabalho Artboards: {n} Mesas de Trabalho: {n} Rearrange All Artboards… Reorganizar Todas as Mesas de Trabalho… + Rearrange… Reorganizar… + Selected Artboards: {n} Mesas de Trabalho Selecionadas: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Clique na tela para posicionar as mesas de trabalho (Esc cancela) Recall Selection Relembrar Seleção Recent Colors Cores Recentes Recent Files Arquivos Recentes diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index ca0c8d5145..3a3a301a38 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3104,6 +3104,9 @@ digits Malayalam Малаялам Scale Artwork with Artboard Масштабировать иллюстрацию вместе с монтажной областью Artboards: {n} Монтажные области: {n} Rearrange All Artboards… Переставить все монтажные области… + Rearrange… Переставить… + Selected Artboards: {n} Выбранные монтажные области: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Щёлкните холст, чтобы разместить монтажные области (Esc отменяет) Recall Selection Восстановить выделение RECENT ПОСЛЕДНИЕ Recent Последние diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index c26474cf93..4692322465 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -2995,6 +2995,9 @@ digits Malayalam Malayalam Scale Artwork with Artboard Skala grafik med rityta Artboards: {n} Ritytor: {n} Rearrange All Artboards… Ordna om alla ritytor… + Rearrange… Ordna om… + Selected Artboards: {n} Markerade ritytor: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Klicka på arbetsytan för att placera ritytorna (Esc avbryter) Recall Selection Hämta markering RECENT SENASTE Recent Senaste diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 2ca2c76e03..aaeaeb33d1 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -517,6 +517,22 @@ fn attributes_panel_options_strings_are_in_complete_catalogs() { } } +/// Rearrange for selected artboards: the Artboards panel menu's Rearrange…, its dialog's count and +/// the message while it waits for its click on the canvas. +#[test] +fn rearrange_selected_artboards_strings_are_in_complete_catalogs() { + for lang in LANGUAGES.iter().filter(|lang| lang.complete_menus) { + for label in ["Rearrange…", "Selected Artboards: {n}"] { + assert!(lang.catalog().plain(label).is_some(), "{} is missing {label}", lang.code); + } + } + let hint = crate::dialogs::rearrange_artboards::PLACE_HINT; + for code in COMPLETE_MESSAGES { + let lang = Lang::from_code(code).expect("registered"); + assert_ne!(message(lang, hint), hint, "{code}"); + } +} + /// Area Type Options › First Baseline's choices (the dropdown reads them in the "effect" context, /// falling back to the plain row). #[test] diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 82186ebcdd..170a8da290 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2843,6 +2843,9 @@ digits Malayalam Malayalam Scale Artwork with Artboard Çalışma Yüzeyi ile Resmi Ölçeklendirin Artboards: {n} Çalışma yüzeyleri: {n} Rearrange All Artboards… Tüm Çalışma Yüzeylerini Yeniden Düzenleme… + Rearrange… Yeniden Düzenle… + Selected Artboards: {n} Seçili çalışma yüzeyleri: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Çalışma yüzeylerini yerleştirmek için tuvale tıklayın (Esc iptal eder) Recall Selection Seçimi Geri Çağır RECENT SON Recent Son diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index de3329ef10..d44e2fc353 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3114,6 +3114,9 @@ digits Malayalam Малаялам Scale Artwork with Artboard Масштабувати ілюстрацію разом із монтажною областю Artboards: {n} Монтажні області: {n} Rearrange All Artboards… Переставити всі монтажні області… + Rearrange… Переставити… + Selected Artboards: {n} Вибрані монтажні області: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Клацніть полотно, щоб розмістити монтажні області (Esc скасовує) Recall Selection Відновити виділення RECENT ОСТАННІ Recent Останні diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 675143a8d6..b047b0382e 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3431,6 +3431,9 @@ mark-style Japanese Kiểu Nhật Rearrange All Sắp xếp lại tất cả Rearrange All Artboards Sắp xếp lại tất cả bảng vẽ Rearrange All Artboards… Sắp xếp lại tất cả bảng vẽ… + Rearrange… Sắp xếp lại… + Selected Artboards: {n} Bảng vẽ đã chọn: {n} +@msg Click on the canvas to place the artboards (Esc cancels) Bấm vào khung vẽ để đặt các bảng vẽ (Esc để hủy) Recall Selection Khôi phục vùng chọn RECENT GẦN ĐÂY Recent Gần đây diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 57f6a4403b..feea46f4a0 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2966,6 +2966,9 @@ digits Malayalam 马拉雅拉姆数字 Scale Artwork with Artboard 随画板缩放图稿 Artboards: {n} 画板:{n} Rearrange All Artboards… 重新排列所有画板… + Rearrange… 重新排列… + Selected Artboards: {n} 选定的画板:{n} +@msg Click on the canvas to place the artboards (Esc cancels) 单击画布以放置画板 (Esc 取消) Recall Selection 召回选区 RECENT 最近使用 Recent 最近使用 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 9834c17ea6..35e3165ad7 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -4412,6 +4412,9 @@ digits Malayalam 馬來亞拉姆數字 Scale Artwork with Artboard 隨工作區域縮放圖稿 Artboards: {n} 工作區域:{n} Rearrange All Artboards… 重新排列所有工作區域… + Rearrange… 重新排列… + Selected Artboards: {n} 選取的工作區域:{n} +@msg Click on the canvas to place the artboards (Esc cancels) 按一下畫布以放置工作區域 (Esc 取消) Recall Selection 叫出選取範圍 RECENT 最近使用 Recent 最近使用 diff --git a/crates/ui-egui/src/menus/context.rs b/crates/ui-egui/src/menus/context.rs index d80b69038b..d310e84c78 100644 --- a/crates/ui-egui/src/menus/context.rs +++ b/crates/ui-egui/src/menus/context.rs @@ -236,8 +236,10 @@ fn artboard_items(app: &VectorcraftApp) -> Vec { } } v.push(Sep); - if n > 1 { - v.push(c("Rearrange", "artboard.rearrange")); + // Rearrange lays out the selected artboards: a click on the item opens its dialog + // (`canvas::context`), whose OK waits for a click on the canvas. + if !sel.is_empty() { + v.push(cp("Rearrange", "artboard.rearrange", json!({ "indices": sel }))); } if facts.map_or_else(|| boards::fit_has_art(app, &free), |f| f.any_art) { v.push(c("Fit to Artwork Bounds", "artboard.fitToArt")); diff --git a/crates/ui-egui/src/menus/invoke.rs b/crates/ui-egui/src/menus/invoke.rs index 7186f0707d..e4ed40b2fb 100644 --- a/crates/ui-egui/src/menus/invoke.rs +++ b/crates/ui-egui/src/menus/invoke.rs @@ -186,6 +186,14 @@ pub fn invoke(app: &mut VectorcraftApp, id: &str, p: Value) { { return; } + // The Artboard tool's Rearrange (its canvas menu) opens Rearrange for the artboards it lists, + // whose OK waits for a click on the canvas. + if id == "artboard.rearrange" + && let Some(indices) = crate::dialogs::rearrange_artboards::menu_indices(&p) + { + crate::dialogs::rearrange_artboards::open_selected(app, &indices); + return; + } // Params first: some dialogs' fields take a look through the session (Move's last move). if p.as_object().is_none_or(|o| o.is_empty()) && let Some((kind, fields)) = menu_dialog(app, id) diff --git a/crates/ui-egui/src/panels/artboards.rs b/crates/ui-egui/src/panels/artboards.rs index 94560b9f76..2f4a4715a2 100644 --- a/crates/ui-egui/src/panels/artboards.rs +++ b/crates/ui-egui/src/panels/artboards.rs @@ -221,6 +221,16 @@ pub(crate) fn selected(app: &VectorcraftApp, n: usize) -> usize { /// The selected artboards (of `n`): while the Artboard tool is in use, those it has selected /// (Shift-click, #1139), else the active one. pub(crate) fn picked(app: &VectorcraftApp, n: usize) -> Vec { + let mut all = tool_selection(app, n); + if all.is_empty() { + all.push(selected(app, n)); + } + all +} + +/// The artboards (of `n`) the Artboard tool has selected while it is in use, sorted and once +/// each; empty with another tool or with none selected. +pub(crate) fn tool_selection(app: &VectorcraftApp, n: usize) -> Vec { let tool = (app.session.tool_id() == "artboard").then(|| app.session.tool_options()["selected"].clone()); let mut all: Vec = tool .iter() @@ -230,9 +240,6 @@ pub(crate) fn picked(app: &VectorcraftApp, n: usize) -> Vec { .filter_map(|i| usize::try_from(i).ok()) .filter(|i| *i < n) .collect(); - if all.is_empty() { - all.push(selected(app, n)); - } all.sort_unstable(); all.dedup(); all @@ -721,7 +728,12 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { set_pstate(ui.ctx(), "ab-keys", keys.then_some(app.frame_iteration())); let n = abs.len(); widgets::bottom_bar(ui, |ui| { - if widgets::icon_button_enabled(ui, "dc-rearrange", tl!("Rearrange All Artboards"), false, n > 1, 24.0).clicked() { + // With artboards selected by the Artboard tool, Rearrange for those. + if !tool_selection(app, n).is_empty() { + if widgets::icon_button_enabled(ui, "dc-rearrange", tl!("Rearrange"), false, true, 24.0).clicked() { + open_rearrange_selected(app); + } + } else if widgets::icon_button_enabled(ui, "dc-rearrange", tl!("Rearrange All Artboards"), false, n > 1, 24.0).clicked() { open_rearrange(app); } ui.add_space((ui.available_width() - 4.0 * 28.0).max(0.0)); @@ -766,6 +778,16 @@ pub(crate) fn open_rearrange(app: &mut VectorcraftApp) { app.run("ui.menuDialog", json!({ "command": "artboard.rearrange" })).ok(); } +/// Open Rearrange for the selected artboards ([`picked`]), whose OK waits for a click on the +/// canvas. +pub(crate) fn open_rearrange_selected(app: &mut VectorcraftApp) { + let n = app.session.active().map_or(0, |d| d.doc.artboards.len()); + if n > 0 { + let indices = picked(app, n); + crate::dialogs::rearrange_artboards::open_selected(app, &indices); + } +} + pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) { let n = app.session.active().map(|d| d.doc.artboards.len()).unwrap_or(0); let sel = selected(app, n); @@ -797,6 +819,9 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) { if menu_item(ui, tl!("Rearrange All Artboards…"), n > 1, false) { open_rearrange(app); } + if menu_item(ui, tl!("Rearrange…"), !tool_selection(app, n).is_empty(), false) { + open_rearrange_selected(app); + } ui.separator(); if menu_item(ui, tl!("Fit to Artwork Bounds"), n > 0, false) { app.run("artboard.fitToArt", json!({ "indices": picked(app, n) })).ok(); diff --git a/crates/ui-egui/src/panels/artboards/tests.rs b/crates/ui-egui/src/panels/artboards/tests.rs index b52d1da682..ba7a01eee2 100644 --- a/crates/ui-egui/src/panels/artboards/tests.rs +++ b/crates/ui-egui/src/panels/artboards/tests.rs @@ -1601,16 +1601,17 @@ fn the_artboard_tools_menu_lists_the_pages_entries_in_order() { } /// An entry whose command can't run is left out: Cut with every artboard selected, or a locked one; -/// Delete Artboards in a document of one; Select All Artboards with all selected; Rearrange with one; -/// Fit to Artwork Bounds without art; Switch Orientation on a square artboard. +/// Delete Artboards in a document of one; Select All Artboards with all selected; Fit to Artwork +/// Bounds without art; Switch Orientation on a square artboard. Rearrange lays out the one selected +/// artboard. #[test] fn the_artboard_tools_menu_leaves_out_what_cannot_run() { let shown = |app: &VectorcraftApp, label: &str| menu_labels(&crate::menus::context_items(app)).contains(&label); let mut app = menu_app(1); - for label in ["Cut", "Delete Artboards", "Delete Empty Artboards", "Select All Artboards", "Rearrange", "Fit to Artwork Bounds"] { + for label in ["Cut", "Delete Artboards", "Delete Empty Artboards", "Select All Artboards", "Fit to Artwork Bounds"] { assert!(!shown(&app, label), "{label} with one empty artboard"); } - assert!(shown(&app, "Copy") && shown(&app, "Switch Orientation")); + assert!(shown(&app, "Copy") && shown(&app, "Switch Orientation") && shown(&app, "Rearrange")); app.session.execute("artboard.setProps", &json!({"index": 0, "width": 50})).unwrap(); assert!(!shown(&app, "Switch Orientation"), "a square artboard"); @@ -1782,6 +1783,23 @@ fn the_artboard_tools_menu_deletes_empty_artboards_and_opens_dialogs() { assert_eq!(selected(&app, 1), 0); } +/// The panel's Rearrange button and Rearrange… lay out the artboards the Artboard tool has +/// selected, once each and in document order; with another tool nothing is selected by it, so the +/// button is Rearrange All Artboards and Rearrange… is off, while the other entries still act on +/// the active artboard. +#[test] +fn the_panels_rearrange_lays_out_only_what_the_artboard_tool_selected() { + let mut app = menu_app(3); + app.session.set_tool_option("selected", &json!([2, 0, 2])); + assert_eq!(tool_selection(&app, 3), [0, 2]); + open_rearrange_selected(&mut app); + let d = app.ui.dialog.take().unwrap(); + assert_eq!((d.kind.as_str(), d.fields["indices"].clone()), (crate::dialogs::rearrange_artboards::KIND, json!([0, 2]))); + app.select_tool("selection"); + select(&mut app, 1); + assert_eq!((tool_selection(&app, 3), picked(&app, 3)), (vec![], vec![1]), "another tool"); +} + /// A lock entry lists only the artboards it changes and is left out when it has none, so it never /// records an undo step that changes nothing. #[test] diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index f8bce4e088..46d3c389bf 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -23,6 +23,21 @@ pub struct BrushKeyColorPick { pub press: Option, } +/// Rearrange for selected artboards, confirmed and waiting for the click on the canvas that places +/// the grid's top-left: the document (`DocState::uid`) and the tool it was confirmed in, and the +/// `artboard.rearrange` parameters, `indices` included, with the `Artboard::id` of each listed +/// artboard (`ids`), so a placement whose artboards moved in the list or were removed is dropped. +/// `armed` is false until the canvas has seen one frame of it, so the Enter that confirmed the +/// dialog does not also place the artboards. +#[derive(Clone, Debug)] +pub struct RearrangePlacement { + pub doc: u64, + pub tool: String, + pub params: Value, + pub ids: Vec, + pub armed: bool, +} + /// Per-document view (camera). #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct View { @@ -636,6 +651,10 @@ pub struct UiState { pub dialog: Option, #[serde(skip)] pub brush_key_color_pick: Option, + /// Rearrange for selected artboards waiting for its click on the canvas + /// (`dialogs::rearrange_artboards`). + #[serde(skip)] + pub rearrange_placement: Option, /// Messages to show in a dialog once the open one is closed (`dialogs::confirm::tell`), in /// the order they came. #[serde(skip)] @@ -1359,6 +1378,7 @@ impl Default for UiState { view: ViewFlags::default(), dialog: None, brush_key_color_pick: None, + rearrange_placement: None, told: vec![], answering_control: false, flyout: None, diff --git a/docs/mcp.md b/docs/mcp.md index 5032690fc6..345b743a49 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9326,22 +9326,49 @@ page in the page's order, and no entries for objects or the view: Cut (`artboard (`edit.paste`), Undo, Redo, New Artboard (`artboard.new`), Duplicate Artboards (`artboard.duplicate`), Rename (`artboard.rename`), Delete Artboards (`artboard.delete` with `indices`), Delete Empty Artboards (`artboard.deleteEmpty`), Select All Artboards (`artboard.selectAll`), Lock Artboards and Unlock Artboards -(`artboard.setProps` with `locked`), Rearrange (`artboard.rearrange`), Fit to Artwork Bounds (`artboard.fitToArt`), -Switch Orientation (`artboard.switchOrientation`), Artboard Options (`tool.options {tool: "artboard"}`) and Export -(`file.exportForScreens`). Exit Isolation Mode and the Unlock submenu for locked objects under the pointer follow them. -Cut, Copy, Duplicate Artboards, Rename, Delete Artboards, Lock Selected, Unlock Selected, Fit to Artwork Bounds, Switch -Orientation and Export act on the artboards the tool has selected, else the active one. Artboard Options opens on the -active artboard. New Artboard, Paste, Undo, Redo, Delete Empty Artboards, Select All Artboards and Rearrange do not act on -the selected artboards. Lock All and Unlock All act on every artboard, and Lock All Except Selected acts on the artboards -that are not selected. A right-click on an artboard that is not selected first selects it alone. An entry that cannot -run is left out: Cut with a locked artboard or every artboard selected, Delete Artboards with no artboard to delete, Select All Artboards with every artboard selected, Rearrange with -one artboard, Fit to Artwork Bounds with no art on a selected unlocked artboard, Switch Orientation with no selected -artboard to change, and a lock entry with no artboard to change. The menu measures the art for Delete Empty Artboards and +(`artboard.setProps` with `locked`), Rearrange (`artboard.rearrange` with `indices`), Fit to Artwork Bounds +(`artboard.fitToArt`), Switch Orientation (`artboard.switchOrientation`), Artboard Options +(`tool.options {tool: "artboard"}`) and Export (`file.exportForScreens`). Exit Isolation Mode and the Unlock submenu +for locked objects under the pointer follow them. Cut, Copy, Duplicate Artboards, Rename, Delete Artboards, Lock +Selected, Unlock Selected, Rearrange, Fit to Artwork Bounds, Switch Orientation and Export act on the artboards the tool +has selected, else the active one. Artboard Options opens on the active artboard. New Artboard, Paste, Undo, Redo, +Delete Empty Artboards and Select All Artboards do not act on the selected artboards. Lock All and Unlock All act on +every artboard, and Lock All Except Selected acts on the artboards that are not selected. A right-click on an artboard +that is not selected first selects it alone. An entry that cannot run is left out: Cut with a locked artboard or every +artboard selected, Delete Artboards with no artboard to delete, Select All Artboards with every artboard selected, Fit +to Artwork Bounds with no art on a selected unlocked artboard, Switch Orientation with no selected artboard to change, +and a lock entry with no artboard to change. The menu measures the art for Delete Empty Artboards and Fit to Artwork Bounds once, at the right-click. Paste centers copied artboards on the right-click's point (`edit.paste {artboardsAt: [x, y]}`) and centers copied objects there too (`center`). Chosen from a menu or the command palette with the tool in use, `artboard.new` makes the new artboard active, `artboard.duplicate` selects the copies, and `artboard.delete` and `artboard.deleteEmpty` make a remaining artboard active. +Rearrange for selected artboards: the +[Rearrange artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/rearrange-artboards.html) +help page describes rearranging only the artboards picked with the Artboard tool, with the same layout, order, count, +spacing and move-artwork choices as for all artboards, and a click on the canvas that puts the arrangement in place. +`artboard.rearrange {indices: [n…]}` lays out only those artboards (zero-based, sorted, an index given twice counts once), +in document order, and leaves every other artboard, its art and its guides where they are; `at: [x, y]` puts the +grid's top-left there, else at the first listed artboard's top-left. A listed locked artboard stays where it is and +keeps its cell. With `moveArtwork`, an object moves with the listed artboard its center is on; an object whose center +is on another artboard stays. `indices` that is not a list, an empty list, an entry that is not a whole number and an +`at` that is not [x, y] are refused before anything moves, and an index past the last artboard is `no such artboard`. +The reply adds `indices` and `moved`, the number of artboards that moved; with none moved (every listed artboard +locked, or already in place) no undo step is recorded. Without `indices` the command lays out every artboard as +before, and its reply is `{artboards, rows, columns}`. In the desktop app, the Artboard tool's canvas menu and +Contextual Task Bar (Rearrange), and while the Artboard tool is in use the Artboards panel's menu (Rearrange…) and its +Rearrange button, open the Rearrange dialog (kind `rearrangeArtboards` with field `indices`) for the artboards the tool +has selected, showing their count. With another tool Rearrange… is off and the panel's button is Rearrange All +Artboards. Its OK changes nothing yet: the grid's outline follows the pointer, and the +next press on the canvas runs `artboard.rearrange` with `indices` and `at` at the press, as one undo step. Enter, when +no other control has the keyboard focus, runs it with `at` at the pointer over the canvas, else without `at` (the grid at the first selected artboard's top-left). +A press with Space held pans or zooms as usual and places nothing. Esc, another tool or another document cancels it +without an edit. The status bar reads "Click on the canvas to place the +artboards (Esc cancels)" meanwhile. The top-left reference point, the outline, the fallback to the first artboard's +corner and the rules for locked artboards and art on other artboards are VectorCraft's own. Object › Artboards › +Rearrange All Artboards…, the Artboards panel's Rearrange All Artboards… and the Properties panel's Rearrange All still +lay out every artboard at once. + Locked artboards: `artboard.setProps {index, locked: true}` locks an artboard and `{index, locked: false}` unlocks it, each in one undo step. The Artboards panel's lock column, left of a row's options icon, shows a lock on a locked artboard, and a click there runs this command. A locked artboard keeps its place and size. `artboard.setProps` with a diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f8a3dc84a0..50a9451aa2 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1093,7 +1093,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The contextual task bar's handle drags it anywhere on the canvas (kept whole on it as the window resizes); unpinned it keeps that offset as it follows the selection, and its More Options menu hides it, pins its position across selection changes (`window.taskBar.pin`), resets it under the selection (`window.taskBar.reset`) and shows the Properties panel. As in Illustrator the position isn't kept across launches. Not done: the bar's variants for other tools (only the selection tools, the Type tools, the basic shape tools, the Smooth tool and the Artboard tool show it). - A click on another object moves the contextual task bar under it without hiding it for the press; it gives way only to a drag (#4681). - With one image selected, the contextual task bar offers Image Trace, which traces the image at once with the Default preset (the Image Trace panel is left as it was), and Crop Image; with an Image Trace object it offers Expand, which keeps only the traced paths. This follows Illustrator's bar: for a selected image it includes Image Trace, Retype and Crop Image, and traced artwork can be expanded from it ([Contextual Task Bar announcement](https://community.adobe.com/announcements-651/contextual-task-bar-in-illustrator-2025-quick-actions-when-you-need-them-1546580)). Offset Path and Simplify, which don't apply to an image, aren't offered for one. Not done: Retype, which the app doesn't have. - - With the Artboard tool, the contextual task bar sits under the selected artboards and offers Resize (Artboard Options for the active artboard), Duplicate (each selected artboard, in one undo step, the copies then selected), Rearrange All (with two or more artboards) and Export (Export for Screens with the selected artboards checked). This follows Illustrator's bar: while the Artboard tool is in use, it has options for resizing, duplicating and exporting artboards (the [Contextual Task Bar announcement](https://community.adobe.com/questions-652/contextual-task-bar-in-illustrator-2025-quick-actions-when-you-need-them-1546580); Rearrange and Export on the bar: [Managing Artboards in Illustrator](https://creativepro.com/managing-artboards-in-illustrator/)). + - With the Artboard tool, the contextual task bar sits under the selected artboards and offers Resize (Artboard Options for the active artboard), Duplicate (each selected artboard, in one undo step, the copies then selected), Rearrange (the selected artboards, placed with a click on the canvas) and Export (Export for Screens with the selected artboards checked). This follows Illustrator's bar: while the Artboard tool is in use, it has options for resizing, duplicating and exporting artboards (the [Contextual Task Bar announcement](https://community.adobe.com/questions-652/contextual-task-bar-in-illustrator-2025-quick-actions-when-you-need-them-1546580); Rearrange and Export on the bar: [Managing Artboards in Illustrator](https://creativepro.com/managing-artboards-in-illustrator/)). - On a blank canvas the contextual task bar offers Draw (Pencil), which switches to the Pencil tool, and Place Image, which picks files for the Place dialog, as the help page lists for a new document (). VectorCraft's own rules: the bar shows them while a selection tool is in use in a document with no artwork (layers and guides only), sits under the active artboard (under the canvas's center when the artboard is out of view), and leaves out the Fill, Stroke, Recolor Artwork and Lock controls. Not done: Generate Vectors. Evidence: `a_blank_canvas_offers_draw_and_place_image`, `the_blank_canvas_bar_draws_with_the_pencil_and_places_an_image` and `the_blank_canvas_bar_wraps_on_a_narrow_canvas` in `crates/ui-egui/src/tests/taskbar.rs`. - The contextual task bar offers more next steps by selection (): an open path Join and Edit Path (the Direct Selection tool), a closed path Edit Path, a compound path Edit Path and Release Compound Path, a clipping group Edit Clipping Path and Release Clipping Mask instead of Ungroup and Isolate, an image selected with vector art Make Clipping Mask instead of Unite, point or area type Convert To Area Type or Convert To Point Type beside Create Outlines, and type on a path, for which the overview names an item to add an effect and rearrange the text, Type on a Path Options (`type.pathOptions`; its options: ) beside Create Outlines. Evidence: `crates/ui-egui/src/tests/taskbar.rs`. - While a Type tool (Type, Area Type, Type on a Path and their vertical versions) adds or edits type, the contextual task bar shows the font family menu, the font style menu, the Font Size combo and the Fill chip (); the Touch Type tool shows no bar, as the same page describes. Type selected with a selection tool shows the same three font controls beside its Create Outlines, conversion and Type on a Path items (). The controls act as the Character panel's do: on the characters a Type tool selects, else on every selected type object, with the size left blank where the sizes differ. VectorCraft's own rules: a Type tool's bar leaves out the object actions, the Stroke chip, Recolor Artwork and Lock; a Type tool shows no bar before it adds type or with other art selected; type selected with other art shows no font controls; the font controls go on a second row when one row would be wider than the canvas, and narrow to fit a canvas narrower than they are; while a Type tool edits type, the Fill chip shows the edited characters' fill ("?" where it differs). Evidence: `the_type_tools_show_font_and_fill_controls`, `the_type_tools_show_no_bar_without_type`, `selected_type_shows_font_controls_beside_its_actions`, `the_task_bars_font_size_sets_what_the_character_panel_would`, `the_type_tools_fill_chip_activates_the_fill`, `the_type_tools_bar_is_named_and_stays_on_the_canvas`, `selected_types_font_controls_take_a_second_row_on_a_narrow_canvas` and `the_type_tools_fill_chip_shows_the_edited_characters_fill` in `crates/ui-egui/src/tests/taskbar.rs`. @@ -1648,6 +1648,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur With the Artboard tool selecting several artboards, Paste in Place, Paste in Front and Paste in Back put a copy of the copied art on each, where it was on the artboard it was copied from, in one undo step, as the public [Cut, copy, and paste artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/cut-copy-and-paste-artboards.html) page describes (`artboards` on the three commands). Art copied from no artboard keeps its place on the first selected artboard and its offset to it on the others, and an `artboard` or `artboards` index the document does not have is an error; these rules are VectorCraft's own. The three commands used to paste one copy, on the active artboard, and an `artboard` index the document did not have pasted the art where it was. A replay of the journal repeats a Cut or Copy made with the Artboard tool on the artboards it took (`edit.cut` and `edit.copy` record `selectedArtboards` and `art`), whichever tool is chosen in the new session and whatever is selected there. A recorded action follows the tool chosen when it plays. The replay used to act on the objects selected then, or stop with nothing selected. This rule is VectorCraft's own. With the Artboard tool, the canvas context menu lists the entries of the public [Use the artboard context menu](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/use-artboard-context-menu.html) page in its order: Cut, Copy, Paste at the pointer, Undo, Redo, New Artboard, Duplicate Artboards, Rename (`artboard.rename`), Delete Artboards, Delete Empty Artboards, Select All Artboards (`artboard.selectAll`), Lock Artboards and Unlock Artboards, Rearrange, Fit to Artwork Bounds, Switch Orientation (`artboard.switchOrientation`), Artboard Options and Export. A right-click on an artboard that is not selected selects it first. + Rearrange lays out only the artboards the Artboard tool has selected, as the [Rearrange artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/rearrange-artboards.html) help page describes for a selection: the canvas context menu's Rearrange, the Contextual Task Bar's Rearrange, the Artboards panel menu's Rearrange… and the panel's Rearrange button with the Artboard tool open the Rearrange dialog for them, and after OK the grid's outline follows the pointer until a click on the canvas places its top-left there, in one undo step (`artboard.rearrange {indices, at}`); Enter places it from the keyboard, a Space-drag still pans, and Esc or another tool cancels it. The other artboards, their art and their guides stay where they are, and a selected locked artboard keeps its place and its cell. The top-left reference point and the handling of locked artboards and of art on unselected artboards are VectorCraft's own. Evidence: `tests::newdoc::{rearrange_lays_out_only_the_listed_artboards, rearrange_of_listed_artboards_starts_at_the_first_and_keeps_locked_ones, rearrange_refuses_bad_indices_and_at}` in `crates/engine`, `canvas::tests::rearrange_places_the_selected_artboards_where_the_canvas_is_clicked` and `dialogs::rearrange_artboards::tests::rearrange_from_the_canvas_menu_waits_for_a_click_with_the_selected_artboards` in `crates/ui-egui`. The Artboards panel menu's New Artboard adds the artboard in one undo step and makes it the active one, as the panel's button, the Control bar and Properties do; with the Artboard tool it is then the only one selected. This is VectorCraft's own rule. The menu item used to leave the active artboard where it was. With the Artboard tool, Paste and Paste in Place make the first pasted artboard the active one (the navigator's and the Artboards panel's), and Cut makes the artboard before the first cut one active (the new first artboard when artboard 1 was cut). A command that chooses another document (`document.activate`) starts the tool on that document's active artboard, as choosing its tab does, and File › Revert keeps the active artboard and starts the tool on it. Paste used to leave the active artboard where it was while the tool had the pasted artboard active, and Cut left the active artboard on the artboard after the cut one while the tool had the one before it. With the Artboard tool, an action that reverts the document or switches to another document and back (`command.batch`), and the Actions panel menu's Batch… over a folder whose files it closes or over data sets with a Revert step (`action.batch`), keep the active artboard and start the tool on it, as File › Revert does. They used to make artboard 1 the active one. From 6b123376fd8c572dbac71bab1f6b34ca9ad1328f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 20 Nov 2026 23:51:45 -0800 Subject: [PATCH 2/4] Docs: artboard.rearrange with at and no indices places the whole grid Without indices the command lays out every artboard; at still sets the grid's top-left there. The mcp.md paragraph now says so. --- docs/mcp.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/mcp.md b/docs/mcp.md index 345b743a49..410b1ac04a 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9354,12 +9354,12 @@ keeps its cell. With `moveArtwork`, an object moves with the listed artboard its is on another artboard stays. `indices` that is not a list, an empty list, an entry that is not a whole number and an `at` that is not [x, y] are refused before anything moves, and an index past the last artboard is `no such artboard`. The reply adds `indices` and `moved`, the number of artboards that moved; with none moved (every listed artboard -locked, or already in place) no undo step is recorded. Without `indices` the command lays out every artboard as -before, and its reply is `{artboards, rows, columns}`. In the desktop app, the Artboard tool's canvas menu and -Contextual Task Bar (Rearrange), and while the Artboard tool is in use the Artboards panel's menu (Rearrange…) and its -Rearrange button, open the Rearrange dialog (kind `rearrangeArtboards` with field `indices`) for the artboards the tool -has selected, showing their count. With another tool Rearrange… is off and the panel's button is Rearrange All -Artboards. Its OK changes nothing yet: the grid's outline follows the pointer, and the +locked, or already in place) no undo step is recorded. Without `indices` the command lays out every artboard, and its +reply is `{artboards, rows, columns}`; `at` there puts the grid's top-left at `at` too. In the desktop app, the +Artboard tool's canvas menu and Contextual Task Bar (Rearrange), and while the Artboard tool is in use the Artboards +panel's menu (Rearrange…) and its Rearrange button, open the Rearrange dialog (kind `rearrangeArtboards` with field +`indices`) for the artboards the tool has selected, showing their count. With another tool Rearrange… is off and the +panel's button is Rearrange All Artboards. Its OK changes nothing yet: the grid's outline follows the pointer, and the next press on the canvas runs `artboard.rearrange` with `indices` and `at` at the press, as one undo step. Enter, when no other control has the keyboard focus, runs it with `at` at the pointer over the canvas, else without `at` (the grid at the first selected artboard's top-left). A press with Space held pans or zooms as usual and places nothing. Esc, another tool or another document cancels it From 8a878f0ebebbf6aa87d2e9597bab6d215294e494 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 00:41:10 -0800 Subject: [PATCH 3/4] Artboards: a finger press that only navigates does not place Rearrange's waiting artboards Once a pen has been seen, a finger press on the canvas navigates the view. Rearrange's waiting placement took that press as its click and moved the artboards. The placement now skips it, and the press pans as before. --- crates/ui-egui/src/canvas/tests.rs | 35 +++++++++++++++++++ .../src/dialogs/rearrange_artboards.rs | 4 ++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 8e56795605..fae39555f3 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -12660,6 +12660,41 @@ fn rearrange_places_the_selected_artboards_with_enter_and_lets_space_pan() { assert_eq!(undo(&app), steps + 1); } +/// Once a pen has been seen, a finger press on the canvas navigates and does not place a waiting +/// Rearrange; a mouse press then places it. +#[test] +fn rearrange_is_not_placed_by_a_finger_once_a_pen_was_seen() { + use crate::touch::{Source, set_pen_seen, set_source}; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 2})).unwrap(); + app.select_tool("artboard"); + app.session.set_tool_option("selected", &json!([1])); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let boards = |app: &VectorcraftApp| app.session.active().unwrap().doc.artboards.iter().map(|a| a.rect).collect::>(); + let undo = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len(); + let (before, steps) = (boards(&app), undo(&app)); + crate::panels::artboards::open_rearrange_selected(&mut app); + crate::dialogs::confirm(&mut app).unwrap(); + frame(&mut app, &ctx, vec![]); + assert!(app.ui.rearrange_placement.is_some()); + let at = app.canvas_rect.unwrap().center() + vec2(40.0, 30.0); + let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + set_source(Source::Pen); + set_source(Source::Finger); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), button(true)]); + frame(&mut app, &ctx, vec![button(false)]); + let finger = (app.ui.rearrange_placement.is_some(), boards(&app), undo(&app)); + set_source(Source::Mouse); + set_pen_seen(false); + assert_eq!(finger, (true, before.clone(), steps), "the finger navigates"); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), button(true)]); + frame(&mut app, &ctx, vec![button(false)]); + assert!(app.ui.rearrange_placement.is_none(), "the mouse places it"); + assert_ne!(boards(&app), before); + assert_eq!(undo(&app), steps + 1); +} + /// A waiting Rearrange is dropped when its artboards change places in the list before the click, /// so the click moves no artboard the tool did not select. #[test] diff --git a/crates/ui-egui/src/dialogs/rearrange_artboards.rs b/crates/ui-egui/src/dialogs/rearrange_artboards.rs index 42c31efa7e..c8ef10df6d 100644 --- a/crates/ui-egui/src/dialogs/rearrange_artboards.rs +++ b/crates/ui-egui/src/dialogs/rearrange_artboards.rs @@ -140,7 +140,9 @@ pub(crate) fn placement_input(app: &mut VectorcraftApp, ui: &egui::Ui, resp: &eg ui.ctx().request_repaint(); } let xf = Xf::at(rect, app.view().unwrap_or(&View::default()), app.canvas_ui_zoom); - let pressed = pointer.interact_pos().filter(|p| pointer.primary_pressed() && resp.hovered() && rect.contains(*p)); + // A finger press once a pen has been seen navigates the view and places nothing. + let navigates = crate::touch::finger_navigates_only(); + let pressed = pointer.interact_pos().filter(|p| pointer.primary_pressed() && !navigates && resp.hovered() && rect.contains(*p)); // Enter belongs to the control that has the keyboard focus, when another one has it. let free_keys = ui.memory(|m| m.focused().is_none_or(|id| id == resp.id)); let entered = armed && free_keys && ui.input(|i| i.key_pressed(egui::Key::Enter)); From 2efe8814da093334841b14fd4dd8b79cbaa6c163 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 01:31:53 -0800 Subject: [PATCH 4/4] Tests: drive the finger Rearrange check with touch events and check the view pans The finger case of rearrange_is_not_placed_by_a_finger_once_a_pen_was_seen now sends touch Start, Move and End events with the first finger pressing as the pointer, adds a second finger and drags both, and checks that the view pans while the waiting placement, the artboards and the history stay as they were. The mouse placement check is unchanged. rearrange_refuses_bad_indices_and_at also checks that an `at` that would put an artboard past the canvas is refused and leaves the artboards and the history as they were. --- crates/engine/src/tests/newdoc.rs | 5 ++++- crates/ui-egui/src/canvas/tests.rs | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/tests/newdoc.rs b/crates/engine/src/tests/newdoc.rs index b60f40f023..53838c9bd7 100644 --- a/crates/engine/src/tests/newdoc.rs +++ b/crates/engine/src/tests/newdoc.rs @@ -601,7 +601,8 @@ fn rearrange_of_listed_artboards_starts_at_the_first_and_keeps_locked_ones() { } /// Rearrange refuses `indices` that are not a non-empty list of artboards, and an `at` that is not -/// [x, y], before anything moves; a listed index given twice counts once. +/// [x, y], before anything moves, and leaves the document as it was when `at` would put an +/// artboard past the canvas; a listed index given twice counts once. #[test] fn rearrange_refuses_bad_indices_and_at() { let mut s = new_doc(json!({"width": 100, "height": 50, "artboards": 3})); @@ -616,6 +617,8 @@ fn rearrange_refuses_bad_indices_and_at() { (json!({"indices": [0, 1], "at": [1]}), "invalid parameters for `artboard.rearrange`: `at` must be [x, y]"), (json!({"indices": [0, 1], "at": "0,0"}), "invalid parameters for `artboard.rearrange`: `at` must be [x, y]"), (json!({"at": [0, "1"]}), "invalid parameters for `artboard.rearrange`: `at` must be [x, y]"), + (json!({"indices": [0], "at": [1e20, 0]}), "result would exceed the canvas (coordinates out of range)"), + (json!({"at": [0, -4.000001e6]}), "result would exceed the canvas (coordinates out of range)"), ] { let err = s.execute("artboard.rearrange", &p).unwrap_err().to_string(); assert_eq!(err, msg, "{p}"); diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index fae39555f3..736f00632c 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -12661,10 +12661,12 @@ fn rearrange_places_the_selected_artboards_with_enter_and_lets_space_pan() { } /// Once a pen has been seen, a finger press on the canvas navigates and does not place a waiting -/// Rearrange; a mouse press then places it. +/// Rearrange: the first finger presses as the pointer, a second lands and both drag, and the view +/// pans while the artboards and the history stay as they were. A mouse press then places it. #[test] fn rearrange_is_not_placed_by_a_finger_once_a_pen_was_seen() { use crate::touch::{Source, set_pen_seen, set_source}; + use egui::TouchPhase::{End, Move, Start}; let mut app = VectorcraftApp::new(Session::new(), Default::default()); app.session.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 2})).unwrap(); app.select_tool("artboard"); @@ -12680,14 +12682,28 @@ fn rearrange_is_not_placed_by_a_finger_once_a_pen_was_seen() { assert!(app.ui.rearrange_placement.is_some()); let at = app.canvas_rect.unwrap().center() + vec2(40.0, 30.0); let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + let center = |app: &VectorcraftApp| app.view().unwrap().center; + let view_before = center(&app); + // The platform says a finger drives the pointer once a pen has been seen, and egui makes the + // first finger the pointer too. set_source(Source::Pen); set_source(Source::Finger); - frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), button(true)]); - frame(&mut app, &ctx, vec![button(false)]); - let finger = (app.ui.rearrange_placement.is_some(), boards(&app), undo(&app)); + let second = at + vec2(80.0, 0.0); + frame(&mut app, &ctx, vec![finger(0, Start, at), egui::Event::PointerMoved(at), button(true)]); + let pressed = app.ui.rearrange_placement.is_some(); + frame(&mut app, &ctx, vec![finger(1, Start, second)]); + for k in 1..=3 { + let d = vec2(0.0, 20.0 * k as f32); + frame(&mut app, &ctx, vec![finger(0, Move, at + d), finger(1, Move, second + d), egui::Event::PointerMoved(at + d)]); + } + let d = vec2(0.0, 60.0); + frame(&mut app, &ctx, vec![finger(0, End, at + d), finger(1, End, second + d), finger_button(at + d, false), egui::Event::PointerGone]); + let touched = (pressed, app.ui.rearrange_placement.is_some(), boards(&app), undo(&app)); + let panned = center(&app) != view_before; set_source(Source::Mouse); set_pen_seen(false); - assert_eq!(finger, (true, before.clone(), steps), "the finger navigates"); + assert_eq!(touched, (true, true, before.clone(), steps), "the finger navigates"); + assert!(panned, "two fingers pan the view"); frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), button(true)]); frame(&mut app, &ctx, vec![button(false)]); assert!(app.ui.rearrange_placement.is_none(), "the mouse places it");