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 97438ec6b1..4785816809 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..53838c9bd7 100644 --- a/crates/engine/src/tests/newdoc.rs +++ b/crates/engine/src/tests/newdoc.rs @@ -532,6 +532,102 @@ 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, 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})); + 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]"), + (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}"); + 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/task_bar.rs b/crates/ui-egui/src/canvas/task_bar.rs index 5ec9e92382..b3917613b8 100644 --- a/crates/ui-egui/src/canvas/task_bar.rs +++ b/crates/ui-egui/src/canvas/task_bar.rs @@ -185,8 +185,8 @@ fn task_bar_shows_type(app: &VectorcraftApp) -> bool { /// What the Contextual Task Bar offers for the tool and selection in use, without the place it hangs at. The /// per-tool rules: -/// With the Artboard tool it offers Resize (Artboard Options), Duplicate, Rearrange All (with two or more -/// artboards) and Export (Export for Screens). +/// With the Artboard tool it offers Resize (Artboard 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 @@ -255,7 +255,7 @@ fn offer(app: &VectorcraftApp, images_memo: &mut Memo, smooth_memo: &mut Memo) - // 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"}))); @@ -552,10 +552,10 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpac // 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"})), @@ -697,17 +697,15 @@ pub(crate) fn chip_paints(app: &VectorcraftApp, ctx: &egui::Context) -> (vectorc (fill, stroke, fill_mixed, stroke_mixed) } -/// 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, 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) { // 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!({}))); } @@ -735,7 +733,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"; /// Whether the task bar shows the action `cmd` as its icon alone (its label names it and is its tooltip). diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 6116b95e91..a10e9e7003 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -4227,9 +4227,9 @@ fn task_bar_actions(app: &mut VectorcraftApp) -> Vec<&'static str> { } /// 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 -/// Export for Screens with the selected artboards checked, and Duplicate copies each selected -/// artboard in one undo step and selects the copies. +/// 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] fn the_artboard_tools_task_bar_buttons_act_on_the_selected_artboards() { let mut app = VectorcraftApp::new(Session::new(), Default::default()); @@ -4245,8 +4245,8 @@ fn the_artboard_tools_task_bar_buttons_act_on_the_selected_artboards() { } click(&mut app, "Resize"); assert_eq!(fields_then_cancel::(&mut app)["index"], json!(2), "Artboard Options"); - click(&mut app, "Rearrange All"); - fields_then_cancel::(&mut app); + click(&mut app, "Rearrange"); + assert_eq!(fields_then_cancel::(&mut app)["indices"], json!([0, 2]), "Rearrange"); click(&mut app, "Export"); assert_eq!(fields_then_cancel::(&mut app)["boards"], json!([true, false, true]), "Export for Screens"); diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index 9ea52ed030..d45ebae2da 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -183,6 +183,19 @@ impl<'a> SessionTool<'a> { tool_enter(&mut self.app(), mods, self.view) } + /// Enter places Rearrange waiting for its click: at the pointer over the canvas, else at the first selected + /// artboard's top-left → whether one was waiting. The Enter that confirmed its dialog is not taken. + fn place_rearrange(&self) -> bool { + use crate::dialogs::rearrange_artboards as rearrange; + let mut app = self.app(); + if !rearrange::refresh_placement(&mut app) || !rearrange::armed(&app) { + return false; + } + let at = app.hover_doc; + rearrange::place(&mut app, at); + true + } + /// A key the tool does not claim while its gesture runs: arrows and digits still reach it, with no modifier (a /// grid's rows and columns, the Perspective Selection tool's planes) → whether it took the key; other keys are /// [`Self::again`]'s. @@ -259,6 +272,13 @@ impl CanvasTool for SessionTool<'_> { app.canvas.last_drag = None; return ToolAction::Claimed; } + // Rearrange waiting for its click takes the press whole: the grid's top-left goes where it was pressed, and the + // tool gets no press, drag or release. + if crate::dialogs::rearrange_artboards::refresh_placement(&mut app) && !app.any_dialog_open() { + let at = pointer_event(PointerKind::Down, pointer, cx).pos; + crate::dialogs::rearrange_artboards::place(&mut app, Some(at)); + return ToolAction::Done; + } // Text typed into a panel's field (its preview) goes to the object it edits before the press can select another. if app.session.active().and_then(|st| st.interaction.as_ref()).is_some_and(|it| it.keep_on_switch) { if let Err(e) = app.session.commit_interaction() { @@ -458,6 +478,9 @@ impl CanvasTool for SessionTool<'_> { ToolKey::Submit => { // In Presentation Mode Enter opens no dialog: the tool takes none. let presenting = self.app().ui.screen_mode == 3; + if !presenting && self.place_rearrange() { + return true; + } !presenting && (self.send_key(EngineKey::Enter, held) || self.enter(held)) } ToolKey::Cancel => { @@ -465,6 +488,13 @@ impl CanvasTool for SessionTool<'_> { if self.app().ui.screen_mode == 3 { return false; } + // Escape drops Rearrange waiting for its click. + let mut app = self.app(); + if crate::dialogs::rearrange_artboards::refresh_placement(&mut app) { + crate::dialogs::rearrange_artboards::cancel_placement(&mut app); + return true; + } + drop(app); let ends = self.app().session.tool_ends_on_escape(self.view); if self.send_key(EngineKey::Escape, held) { return true; @@ -607,6 +637,10 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too (PressPhase::Idle, _) | (_, None) => None, (_, Some(view)) => ui.input(|i| i.pointer.hover_pos()).map(|p| view.to_doc(p)), }; + // Rearrange waiting for its click: dropped with its document or tool, and from the next pass Enter places it. + if crate::dialogs::rearrange_artboards::refresh_placement(app) { + crate::dialogs::rearrange_artboards::arm(app); + } show_overlays(app, ui, pass, view_info); response } @@ -636,6 +670,8 @@ fn show_overlays(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass, view_in } // Gap Options' Preview shows the gaps it finds. let mut extra = crate::dialogs::live_paint_gaps::overlays(app); + // Rearrange waiting for its click shows where its artboards go. + extra.extend(crate::dialogs::rearrange_artboards::placement_overlays(app)); if app.ui.view.edges && !revolve { if app.ui.view.text_threads { extra.extend(super::marks::thread_overlays(app, space.view.zoom)); diff --git a/crates/ui-egui/src/dialogs/rearrange_artboards.rs b/crates/ui-egui/src/dialogs/rearrange_artboards.rs index f5a52fd70e..e7f8571954 100644 --- a/crates/ui-egui/src/dialogs/rearrange_artboards.rs +++ b/crates/ui-egui/src/dialogs/rearrange_artboards.rs @@ -4,8 +4,18 @@ //! 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, and the Artboards panel +//! menu's Rearrange…) 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's outline 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 craft::ui::choice::Segmented; use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _}; @@ -19,15 +29,21 @@ use craft::ui::style::TypeRole; use craft::ui::text::NumberField; use serde_json::{Value, json}; use vectorcraft_doc::Unit; -use vectorcraft_engine::cmd::newdoc::ArtboardLayout; +use vectorcraft_engine::cmd::newdoc::{ArtboardLayout, rearrange_grid}; +use vectorcraft_geom::{BezPath, Point}; +use vectorcraft_tools::Overlay; use super::layer_options::check; use crate::VectorcraftApp; use crate::page_glyphs::LayoutGlyph; +use crate::state::RearrangePlacement; /// The command Rearrange All Artboards runs; the key of its dialog. pub(crate) 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)"; + static GRID_BY_ROW: LayoutGlyph = LayoutGlyph { tiles: &[(0, 0), (1, 0), (0, 1), (1, 1)] }; static GRID_BY_ROW_RTL: LayoutGlyph = LayoutGlyph { tiles: &[(1, 0), (0, 0), (1, 1), (0, 1)] }; static GRID_BY_COLUMN: LayoutGlyph = LayoutGlyph { tiles: &[(0, 0), (0, 1), (1, 0), (1, 1)] }; @@ -52,7 +68,8 @@ fn layout_glyph(l: ArtboardLayout, rtl: bool) -> (&'static str, &'static LayoutG } } -/// The settings the dialog edits. +/// The settings the dialog edits, and for Rearrange the artboards it lays out (`indices`, sorted +/// and once each), which the dialog does not edit. #[derive(Clone, Debug, PartialEq)] pub(crate) struct RearrangeValues { layout: ArtboardLayout, @@ -61,21 +78,26 @@ pub(crate) struct RearrangeValues { columns: f64, spacing: f64, move_artwork: bool, + indices: Option>, } impl Default for RearrangeValues { fn default() -> Self { - RearrangeValues { layout: ArtboardLayout::GridByRow, rtl: false, columns: 2.0, spacing: 20.0, move_artwork: true } + RearrangeValues { layout: ArtboardLayout::GridByRow, rtl: false, columns: 2.0, spacing: 20.0, move_artwork: true, indices: None } } } impl RearrangeValues { /// `artboard.rearrange` parameters. fn params(&self) -> Value { - json!({ + let mut p = json!({ "layout": self.layout.id(), "order": self.order(), "columns": self.columns, "spacing": self.spacing, "moveArtwork": self.move_artwork, - }) + }); + if let Some(indices) = &self.indices { + p["indices"] = json!(indices); + } + p } fn order(&self) -> &'static str { @@ -108,13 +130,36 @@ fn length_kind(unit: Unit) -> UnitKind { } } -/// `ui.menuDialog` for Rearrange All Artboards: opens the dialog on the spacing of its last OK. +/// `ui.menuDialog` for Rearrange All Artboards: opens the dialog on the spacing of its last OK. A +/// placement still waiting is dropped. pub(crate) fn open(app: &mut VectorcraftApp) -> Result { + cancel_placement(app); + open_with(app, None) +} + +/// 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(); + if let Err(e) = open_with(app, Some(indices)) { + app.status(e); + } +} + +/// Opens the dialog for `indices` (Rearrange), or for every artboard (Rearrange All Artboards). +fn open_with(app: &mut VectorcraftApp, indices: Option>) -> Result { let mut values = RearrangeValues::default(); if let Some(spacing) = app.ui.rearrange_artboards_spacing.as_f64() { values.spacing = spacing; } - let artboards = app.session.active().map_or(0, |doc| doc.doc.artboards.len()); + let artboards = indices.as_ref().map_or_else(|| app.session.active().map_or(0, |doc| doc.doc.artboards.len()), Vec::len); + values.indices = indices; let lengths = LengthUnits::new(UnitKind::Points, length_kind(app.session.general_unit()), 72.0); let lengths = crate::fields::bare_points(lengths, app.session.prefs.numbers_without_units_are_points); let dialogs = app.dialogs().ok_or("no window")?; @@ -122,18 +167,28 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result { Ok(Value::Null) } -/// The Rearrange All Artboards dialog; its answer is the settings OK confirmed, which [`pump`] runs. +/// 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 Rearrange All Artboards dialog, or Rearrange for the selected artboards; its answer is the +/// settings OK confirmed, which [`pump`] runs or leaves waiting for a click on the canvas. pub(crate) struct RearrangeArtboardsDialog { id: DialogId, open: bool, values: RearrangeValues, - /// The document's artboard count, which bounds Columns. + /// The artboards the dialog lays out (the document's, or the selected ones), which bounds Columns + /// and is the count it shows. artboards: usize, /// The lengths Spacing keeps and shows. lengths: LengthUnits, } -/// The rows of the dialog for a document of `artboards` artboards, Spacing shown in `unit`. +/// The rows of the dialog for `artboards` artboards, Spacing shown in `unit`. fn body(ui: &mut egui::Ui, v: &mut RearrangeValues, artboards: usize, lengths: LengthUnits) { Field::new(tl!("Layout:")).id_salt("layout").show(ui, |ui, _| { let entries: Vec> = ArtboardLayout::ALL @@ -176,7 +231,8 @@ fn body(ui: &mut egui::Ui, v: &mut RearrangeValues, artboards: usize, lengths: L v.move_artwork = on; } }); - Text::new(crate::i18n::fmt(tl!("Artboards: {n}"), &[("n", &artboards.to_string())])).role(TypeRole::Caption).show(ui); + let label = if v.indices.is_some() { tl!("Selected Artboards: {n}") } else { tl!("Artboards: {n}") }; + Text::new(crate::i18n::fmt(label, &[("n", &artboards.to_string())])).role(TypeRole::Caption).show(ui); } impl StackDialog for RearrangeArtboardsDialog { @@ -192,13 +248,11 @@ impl StackDialog for RearrangeArtboardsDialog { fn show(&mut self, ui: &mut egui::Ui, _: &DialogStack) -> Option> { let (artboards, lengths) = (self.artboards, self.lengths); - let shown = FormDialog::new(tl!("Rearrange All Artboards"), Bind::bound(&mut self.values)).opened(Bind::bound(&mut self.open)).show( - ui, - |ui, _, v| { - body(ui, v, artboards, lengths); - true - }, - ); + let title = if self.values.indices.is_some() { tl!("Rearrange") } else { tl!("Rearrange All Artboards") }; + let shown = FormDialog::new(title, Bind::bound(&mut self.values)).opened(Bind::bound(&mut self.open)).show(ui, |ui, _, v| { + body(ui, v, artboards, lengths); + true + }); match (shown.accepted, shown.closed) { (Some(value), _) => Some(DialogResult::Ok(value)), (None, Some(_)) => Some(DialogResult::Cancel), @@ -212,7 +266,12 @@ impl StackDialog for RearrangeArtboardsDialog { fn json_fields(&self) -> Option { let v = &self.values; - Some(json!({"layout": v.layout.id(), "order": v.order(), "columns": v.columns, "spacing": v.spacing, "moveArtwork": v.move_artwork})) + let mut fields = + json!({"layout": v.layout.id(), "order": v.order(), "columns": v.columns, "spacing": v.spacing, "moveArtwork": v.move_artwork}); + if let Some(indices) = &v.indices { + fields["indices"] = json!(indices); + } + Some(fields) } fn set_json_field(&mut self, _: &egui::Context, field: &str, value: Value) -> Result<(), String> { @@ -247,17 +306,128 @@ impl StackDialog for RearrangeArtboardsDialog { } } -/// Runs `artboard.rearrange` for the settings OK confirmed, and remembers the spacing of a successful one. +/// Runs `artboard.rearrange` for the settings OK confirmed, and remembers the spacing of a successful +/// one. Rearrange for the selected artboards runs nothing yet: it waits for its click on the canvas +/// ([`place`]). pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { let Some(dialogs) = app.dialogs() else { return }; let Some(DialogResult::Ok(values)) = dialogs.with(|host| host.take::()) else { return }; - match app.run(CMD, values.params()) { - Ok(_) => app.ui.rearrange_artboards_spacing = json!(values.spacing), - Err(e) => app.status(e), + match &values.indices { + None => match app.run(CMD, values.params()) { + Ok(_) => app.ui.rearrange_artboards_spacing = json!(values.spacing), + Err(e) => app.status(e), + }, + Some(listed) => match wait_for_click(app, listed, values.params()) { + Ok(()) => app.ui.rearrange_artboards_spacing = json!(values.spacing), + Err(e) => app.status(e), + }, } ctx.request_repaint(); } +/// Rearrange for artboards `listed` with `params`, confirmed: it waits for its click on the canvas, +/// for the active document and the tool in use. +fn wait_for_click(app: &mut VectorcraftApp, listed: &[usize], params: Value) -> Result<(), String> { + 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, ids, armed: false }); + app.status(PLACE_HINT); + Ok(()) +} + +/// 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 +} + +/// Whether a placement waits and has been seen by one canvas pass, so a key that arrives now is not +/// the Enter that confirmed its dialog. +pub(crate) fn armed(app: &VectorcraftApp) -> bool { + app.ui.rearrange_placement.as_ref().is_some_and(|pl| pl.armed) +} + +/// Marks a waiting placement as seen by the canvas (see [`armed`]). +pub(crate) fn arm(app: &mut VectorcraftApp) { + if let Some(pl) = app.ui.rearrange_placement.as_mut() { + pl.armed = true; + } +} + +/// Runs the waiting placement's `artboard.rearrange` with the grid's top-left at `at` (the pressed +/// point, or the pointer when Enter placed it); without `at` the grid starts at the first selected +/// artboard's top-left. When every selected artboard is locked, the status bar says so. +pub(crate) fn place(app: &mut VectorcraftApp, at: Option) { + let Some(mut pl) = app.ui.rearrange_placement.take() else { return }; + 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), + } +} + +/// The grid a waiting placement makes with its top-left at the pointer (`app.hover_doc`): the +/// outline of each artboard that moves, in the Artboard tool's color, 1 point wide on screen. +pub(crate) fn placement_overlays(app: &VectorcraftApp) -> Vec { + let Some(pl) = app.ui.rearrange_placement.as_ref().filter(|pl| app.session.tool_id() == pl.tool) else { return vec![] }; + let (Some(at), Some(st)) = (app.hover_doc, app.session.active().filter(|d| d.uid == pl.doc)) else { return vec![] }; + 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. + origins + .iter() + .zip(&sizes) + .zip(&boards) + .filter(|(_, a)| !a.locked) + .map(|((o, (w, h)), _)| { + let mut path = BezPath::new(); + path.move_to(*o); + path.line_to((o.x + w, o.y)); + path.line_to((o.x + w, o.y + h)); + path.line_to((o.x, o.y + h)); + path.close_path(); + Overlay::Path { path, color: vectorcraft_tools::xform::BLUE, width: 1.0, dashed: false } + }) + .collect() +} + #[cfg(test)] mod tests { use super::*; @@ -296,6 +466,11 @@ mod tests { crate::dialogs::host::pump(app, &ctx); } + /// The open dialog's fields. + fn fields(app: &VectorcraftApp) -> Value { + app.dialogs().unwrap().with(|host| host.open_dialogs().last().and_then(|d| d.fields.clone())).unwrap() + } + /// #681: the menu item opens the dialog; each setting reaches `artboard.rearrange`, as one undo step; a /// setting the layout makes meaningless is refused. #[test] @@ -337,7 +512,72 @@ mod tests { ok(&mut app); app.run("ui.menuDialog", json!({"command": CMD})).unwrap(); - let fields = app.dialogs().unwrap().with(|host| host.open_dialogs().last().and_then(|d| d.fields.clone())).unwrap(); - assert_eq!(fields["spacing"].as_f64(), Some(37.0)); + assert_eq!(fields(&app)["spacing"].as_f64(), Some(37.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 = app(3); + 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::Node::Item(item) if item.label == "Rearrange" => { + Some(crate::menus::click_target("Rearrange", &item.command.id, &item.command.params)) + } + _ => None, + }); + let (id, p) = target.expect("Rearrange in the canvas menu"); + crate::menus::invoke(&mut app, &id, p); + assert!(app.dialogs().unwrap().with(|host| host.get::().is_some()), "Rearrange opens"); + let shown = fields(&app); + assert_eq!(shown["indices"], json!([0, 2])); + let (title, count) = app.dialogs().unwrap().with(|host| { + let d = host.get::().unwrap(); + (d.values.indices.is_some(), d.artboards) + }); + assert_eq!((title, count), (true, 2), "Rearrange for the 2 selected artboards"); + set(&app, &[("layout", json!("row"))]).unwrap(); + let (before, undo) = (origins(&app), app.session.doc().unwrap().history.undo.len()); + ok(&mut app); + assert!(!app.any_dialog_open()); + 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(); + assert!(app.ui.rearrange_placement.is_none()); + assert!(fields(&app).get("indices").is_none()); + ok(&mut app); + assert_ne!(origins(&app), before); + assert_ne!(app.ui.status, PLACE_HINT); + } + + /// The outline of a waiting placement follows the pointer: the first selected artboard's cell + /// starts at the pointer, and a locked selected artboard has none. + #[test] + fn the_placement_outline_starts_at_the_pointer_and_leaves_locked_artboards_out() { + let mut app = app(3); + app.session.execute("artboard.setProps", &json!({"index": 2, "locked": true})).unwrap(); + app.select_tool("artboard"); + app.session.set_tool_option("selected", &json!([0, 1, 2])); + crate::panels::artboards::open_rearrange_selected(&mut app); + set(&app, &[("layout", json!("row")), ("spacing", json!(10))]).unwrap(); + ok(&mut app); + assert!(placement_overlays(&app).is_empty(), "no pointer over the canvas"); + app.hover_doc = Some(Point::new(500.0, 300.0)); + let starts: Vec = placement_overlays(&app) + .iter() + .map(|o| match o { + Overlay::Path { path, .. } => path.elements().first().and_then(|e| e.end_point()).unwrap(), + o => panic!("{o:?}"), + }) + .collect(); + assert_eq!(starts, [Point::new(500.0, 300.0), Point::new(610.0, 300.0)]); } } diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index a9cc777d11..aadaad7a2f 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -2977,6 +2977,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 d50867dbfb..0b51b17a69 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -344,6 +344,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 16bfdd8db6..0587af1106 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -3799,6 +3799,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 3f5a3d4364..64d1d831dc 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -351,6 +351,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 22b4627993..b84356a3da 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3100,6 +3100,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 7d28392760..0b9fad6332 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3045,6 +3045,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 265ea70c12..5b8fc6440f 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3947,6 +3947,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 d0a9a19f5e..fcef6ec435 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -3082,6 +3082,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 fd20e115ae..6f8851dde0 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -358,6 +358,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 c335b97504..b3569845e2 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3070,6 +3070,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 59d0eb788f..0f730e3027 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -3082,6 +3082,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 6159400c90..c458a3f31a 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -4397,6 +4397,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 f4a2b87047..c3fbad1328 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3647,6 +3647,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 db4091132b..9ca3faf5e8 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -975,6 +975,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 43f7516e48..81e650bbc4 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -3130,6 +3130,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 10645aba08..f3f2ee04f6 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -413,6 +413,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 991119f55f..e95cf55c1c 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -2496,6 +2496,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 eae44c6746..0a4a1b1c27 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -406,6 +406,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 5ba6b94a40..a4b6eb99ac 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -961,6 +961,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 fbab642caf..5b7169c111 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -311,6 +311,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 87cba9d49f..b6c9c6d1da 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2562,6 +2562,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 caec07d259..d29f9399e1 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3112,6 +3112,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 98a381d0de..d9e0ef34b2 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -3003,6 +3003,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 6ba9c5be5a..a079fdd4de 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -97,6 +97,7 @@ const UI_STRINGS: &[(&str, &[&str])] = &[ "Low-Latency Drawing", ], ), + ("rearrange selected artboards", &["Rearrange…", "Selected Artboards: {n}"]), ]; #[test] @@ -115,6 +116,7 @@ fn strings_the_ui_shows_are_in_every_complete_catalog() { const MESSAGES: &[(&str, &[&str], &str, &str)] = &[ ("Packaged 1 file in /out/card Folder", &[], "/out/card", "Packaged"), ("Packaged 3 files", &[], "", "Packaged"), + (crate::dialogs::rearrange_artboards::PLACE_HINT, &[], "", "Click on the canvas"), ("Packaged 1 file (fonts not copied: Mono) in /out/card (draft) v2", &[], "Mono", "Packaged"), ("command `object.group` is not available right now: nothing selected", &["es"], "`object.group`", "nothing selected"), ]; diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index c51b847b54..912137aa36 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2845,6 +2845,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 81c6c964a3..9a812c2cac 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3122,6 +3122,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 b14f9bc5c0..759b8ba3ac 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3439,6 +3439,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 77bbc38b7a..eec10ec83b 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2974,6 +2974,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 f3aedae902..d2bbf3bbd8 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -4420,6 +4420,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 9ff6f3c9c0..212cffd703 100644 --- a/crates/ui-egui/src/menus/context.rs +++ b/crates/ui-egui/src/menus/context.rs @@ -237,8 +237,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 + // (`menus::invoke`), 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 09195e00c3..0a3dc862b5 100644 --- a/crates/ui-egui/src/menus/invoke.rs +++ b/crates/ui-egui/src/menus/invoke.rs @@ -90,6 +90,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(opened) = open_menu_dialog(app, id) diff --git a/crates/ui-egui/src/panels/artboards.rs b/crates/ui-egui/src/panels/artboards.rs index e233f678cc..19ab69b734 100644 --- a/crates/ui-egui/src/panels/artboards.rs +++ b/crates/ui-egui/src/panels/artboards.rs @@ -175,6 +175,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() @@ -184,9 +194,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 @@ -608,6 +615,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); + } +} + /// The rows of the panel's menu. pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec { let command = |id: &'static str| PanelRow::Command(CommandRef::new(id)); @@ -621,6 +638,7 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec { command("artboard.convertToArtboards"), PanelRow::Command(CommandRef::with_params("tool.options", json!({"tool": "artboard"}))), PanelRow::Command(CommandRef::with_params("ui.menuDialog", json!({"command": "artboard.rearrange"}))), + command("ui.artboards.rearrange"), PanelRow::Separator, command("ui.artboards.fitToArt"), ] @@ -638,12 +656,14 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { set(CommandRef::new("artboard.convertToArtboards"), tl!("Convert to Artboards"), crate::menus::enabled(app, "artboard.convertToArtboards")); set(CommandRef::with_params("tool.options", json!({"tool": "artboard"})), tl!("Artboard Options…"), n > 0); set(CommandRef::with_params("ui.menuDialog", json!({"command": "artboard.rearrange"})), tl!("Rearrange All Artboards…"), n > 1); + set(CommandRef::new("ui.artboards.rearrange"), tl!("Rearrange…"), !tool_selection(app, n).is_empty()); set(CommandRef::new("ui.artboards.fitToArt"), tl!("Fit to Artwork Bounds"), n > 0); } /// Run the panel menu's own row `id` (`ui.artboards.`) → its result; None for any other id. Rename /// opens the name field on the active artboard's row when that artboard is selected, else on the first -/// selected row. +/// selected row. Rearrange… opens Rearrange for the artboards the Artboard tool has selected, and does +/// nothing when it has none. pub(crate) fn run(app: &mut VectorcraftApp, id: &str, _params: &Value) -> Option> { let n = app.session.active().map_or(0, |d| d.doc.artboards.len()); match id { @@ -658,6 +678,11 @@ pub(crate) fn run(app: &mut VectorcraftApp, id: &str, _params: &Value) -> Option } "ui.artboards.deleteEmpty" => return Some(delete_empty(app)), "ui.artboards.fitToArt" => return Some(app.run("artboard.fitToArt", json!({ "indices": picked(app, n) }))), + "ui.artboards.rearrange" => { + if !tool_selection(app, n).is_empty() { + open_rearrange_selected(app); + } + } _ => return None, } Some(Ok(Value::Null)) diff --git a/crates/ui-egui/src/panels/artboards/tests.rs b/crates/ui-egui/src/panels/artboards/tests.rs index 1595711f38..beaf1466e4 100644 --- a/crates/ui-egui/src/panels/artboards/tests.rs +++ b/crates/ui-egui/src/panels/artboards/tests.rs @@ -144,7 +144,7 @@ fn list_events_and_menu_rows_reach_their_commands() { assert!(run(&mut app, "ui.artboards.rename", &json!({})).is_some()); assert_eq!(app.ui.artboards_ui.rename, Some(2)); assert!(run(&mut app, "ui.artboards.nothing", &json!({})).is_none()); - assert_eq!(menu_rows(&app).len(), 11); + assert_eq!(menu_rows(&app).len(), 12); } /// #1006: Select › All on Active Artboard selects the art of the artboard made active here, @@ -913,16 +913,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"); @@ -1085,6 +1086,33 @@ fn the_artboard_tools_menu_deletes_empty_artboards_and_opens_dialogs() { assert_eq!(selected(&app, 1), 0); } +/// The panel menu's Rearrange… lays out the artboards the Artboard tool has selected, once each and +/// in document order; with another tool nothing is selected by it, so Rearrange… is off and opens +/// nothing, while the other entries still act on the active artboard. The list's Rearrange button +/// stays Rearrange All Artboards. +#[test] +fn the_panels_rearrange_lays_out_only_what_the_artboard_tool_selected() { + let mut app = menu_app(3); + let ctx = app.ui_ctx.clone().expect("a window"); + app.session.set_tool_option("selected", &json!([2, 0, 2])); + assert_eq!(tool_selection(&app, 3), [0, 2]); + assert!(enabled_state(&app, "ui.artboards.rearrange")); + run(&mut app, "ui.artboards.rearrange", &Value::Null).unwrap().unwrap(); + assert!(is_open::(&app)); + assert_eq!(dialog_fields(&app)["indices"], json!([0, 2])); + cancel_open(&mut app, &ctx); + apply(&mut app, vec![PageListEvent::Rearrange]); + assert!(is_open::(&app)); + assert!(dialog_fields(&app).get("indices").is_none(), "the list's button lays out every artboard"); + cancel_open(&mut app, &ctx); + app.select_tool("selection"); + select(&mut app, 1); + assert_eq!((tool_selection(&app, 3), picked(&app, 3)), (vec![], vec![1]), "another tool"); + assert!(!enabled_state(&app, "ui.artboards.rearrange")); + run(&mut app, "ui.artboards.rearrange", &Value::Null).unwrap().unwrap(); + assert!(!is_open::(&app)); +} + /// 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 84346b6d98..3a65476203 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -40,6 +40,21 @@ pub enum ViewMove { Jump, } +/// 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 { @@ -612,6 +627,10 @@ pub struct UiState { pub view: ViewFlags, #[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, /// A control request is being answered: its caller gets what fails as its reply, so no /// dialog says it too (`io::report_write_error`). #[serde(skip)] @@ -1400,6 +1419,7 @@ impl Default for UiState { help_bar: true, view: ViewFlags::default(), brush_key_color_pick: None, + rearrange_placement: None, answering_control: false, group_tool: vectorcraft_tools::TOOL_GROUPS.iter().map(|g| g[0].id.to_string()).collect(), touch_drawing_tool: None, diff --git a/crates/ui-egui/src/tests/taskbar.rs b/crates/ui-egui/src/tests/taskbar.rs index 35d569cb1c..1e0ce31c9a 100644 --- a/crates/ui-egui/src/tests/taskbar.rs +++ b/crates/ui-egui/src/tests/taskbar.rs @@ -849,7 +849,7 @@ fn tools_offer_their_bar_or_none() { let labels = |app: &mut VectorcraftApp| offer(app).map(|o| o.actions.iter().map(|a| a.0).collect::>()).unwrap_or_default(); app.select_tool("artboard"); crate::panels::artboards::select(&mut app, 1); - assert_eq!(labels(&mut app), ["Resize", "Duplicate", "Rearrange All", "Export"]); + assert_eq!(labels(&mut app), ["Resize", "Duplicate", "Rearrange", "Export"]); let b = app.session.active().unwrap().doc.artboards[1].rect; let o = offer(&mut app).unwrap(); assert!( @@ -860,9 +860,266 @@ fn tools_offer_their_bar_or_none() { app.select_tool("selection"); app.run("shape.rectangle", json!({"x": 20, "y": 20, "width": 40, "height": 40})).unwrap(); assert_eq!(labels(&mut app), ["Edit Path", "Offset Path", "Simplify", "Duplicate"]); + // One artboard, selected: Rearrange places it. app.run("file.new", json!({"width": 200, "height": 100})).unwrap(); app.select_tool("artboard"); - assert_eq!(labels(&mut app), ["Resize", "Duplicate", "Export"]); + assert_eq!(labels(&mut app), ["Resize", "Duplicate", "Rearrange", "Export"]); +} + +/// Three 200 by 100 pt artboards with the Artboard tool, `selected` selected. +fn rearrange_app(selected: serde_json::Value) -> VectorcraftApp { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 100, "artboards": 3})).unwrap(); + app.select_tool("artboard"); + app.session.set_tool_option("selected", &selected); + app +} + +fn artboard_rects(app: &VectorcraftApp) -> Vec { + app.session.active().unwrap().doc.artboards.iter().map(|a| a.rect).collect() +} + +fn undo_steps(app: &VectorcraftApp) -> usize { + app.session.active().unwrap().history.undo.len() +} + +/// Opens Rearrange for the selected artboards and presses OK with one row 10 pt apart, inside `rig`. +fn confirm_rearrange(rig: &mut Rig) { + use crate::dialogs::rearrange_artboards::{PLACE_HINT, RearrangeArtboardsDialog}; + rig.run_fired(); + let mut app = rig.app(); + crate::panels::artboards::open_rearrange_selected(&mut app); + let id = app.dialogs().and_then(|d| d.with(|h| h.open_dialogs().last().map(|o| o.id))).expect("Rearrange opens"); + assert!(app.dialogs().unwrap().with(|h| h.is_open::())); + crate::tests::picks::answer_dialog(&mut app, id, &[("layout", json!("row")), ("spacing", json!(10))], true); + assert!(app.ui.rearrange_placement.is_some() && app.ui.status == PLACE_HINT, "{}", app.ui.status); +} + +/// Rearrange for the selected artboards, 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 waiting 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, placement_overlays}; + let mut app = rearrange_app(json!([0, 2])); + let (before, steps) = (artboard_rects(&app), undo_steps(&app)); + on_canvas(&mut app, |rig| { + rig.fx.settle(); + let view = rig.app().canvas_view().expect("the canvas is laid out"); + let at = view.rect.center() + vec2(-150.0, -120.0); + let doc = view.to_doc(at); + + // Esc: nothing moves. + confirm_rearrange(rig); + rig.fx.frame(vec![egui::Event::PointerMoved(at)]); + rig.fx.key(Key::Escape, Modifiers::NONE); + rig.run_fired(); + assert!(rig.app().ui.rearrange_placement.is_none(), "Esc cancels"); + assert_ne!(rig.app().ui.status, PLACE_HINT); + // Another tool: nothing moves. + confirm_rearrange(rig); + rig.app().select_tool("selection"); + rig.fx.frame(vec![egui::Event::PointerMoved(at)]); + assert!(rig.app().ui.rearrange_placement.is_none(), "another tool cancels"); + { + let app = rig.app(); + assert_eq!((artboard_rects(&app), undo_steps(&app)), (before.clone(), steps)); + } + + rig.app().select_tool("artboard"); + rig.app().session.set_tool_option("selected", &json!([0, 2])); + confirm_rearrange(rig); + rig.fx.frame(vec![egui::Event::PointerMoved(at)]); + let outline = placement_overlays(&rig.app()); + assert_eq!(outline.len(), 2, "an outline for each selected artboard"); + rig.fx.click_at(at); + rig.run_fired(); + let app = rig.app(); + let after = artboard_rects(&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_steps(&app), steps + 1); + assert!(app.ui.rearrange_placement.is_none() && app.ui.status != PLACE_HINT); + }); +} + +/// A waiting Rearrange takes Enter from the keyboard: 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 = rearrange_app(json!([2, 0])); + let (before, steps) = (artboard_rects(&app), undo_steps(&app)); + on_canvas(&mut app, |rig| { + rig.fx.settle(); + confirm_rearrange(rig); + // Space held: the press pans. + let at = rig.app().canvas_view().expect("the canvas is laid out").rect.center(); + let origin = |rig: &Rig| rig.app().canvas_view().unwrap().to_screen(Point::ZERO); + let start = origin(rig); + let key = |key, pressed| egui::Event::Key { key, physical_key: None, pressed, repeat: false, modifiers: Modifiers::NONE }; + let button = |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE }; + let end = at + vec2(30.0, 20.0); + for ev in [ + key(Key::Space, true), + egui::Event::PointerMoved(at), + button(at, true), + egui::Event::PointerMoved(at.lerp(end, 0.5)), + egui::Event::PointerMoved(end), + button(end, false), + ] { + rig.fx.frame(vec![ev]); + } + rig.fx.frame(vec![key(Key::Space, false)]); + rig.run_fired(); + assert!(origin(rig) != start, "the Space-drag pans the view"); + { + let app = rig.app(); + assert!(app.ui.rearrange_placement.is_some(), "a Space-drag places nothing"); + assert_eq!((artboard_rects(&app), undo_steps(&app)), (before.clone(), steps)); + } + rig.fx.frame(vec![egui::Event::PointerGone]); + rig.fx.key(Key::Enter, Modifiers::NONE); + rig.run_fired(); + }); + let after = artboard_rects(&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_steps(&app), steps + 1); +} + +/// Once a pen has been seen, a finger press on the canvas navigates and does not place a waiting +/// Rearrange: the finger's drag pans the view while the artboards and the history stay as they +/// were. A mouse click 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 = rearrange_app(json!([1])); + let (before, steps) = (artboard_rects(&app), undo_steps(&app)); + let (touched, panned) = on_canvas(&mut app, |rig| { + rig.fx.settle(); + confirm_rearrange(rig); + let at = rig.app().canvas_view().expect("the canvas is laid out").rect.center() + vec2(40.0, 30.0); + let origin = |rig: &Rig| rig.app().canvas_view().unwrap().to_screen(Point::ZERO); + let start = origin(rig); + let button = |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE }; + let end = at + vec2(60.0, 40.0); + // The platform says a finger drives the pointer once a pen has been seen. + set_source(Source::Pen); + set_source(Source::Finger); + for ev in [ + egui::Event::PointerMoved(at), + button(at, true), + egui::Event::PointerMoved(at.lerp(end, 0.5)), + egui::Event::PointerMoved(end), + button(end, false), + ] { + rig.fx.frame(vec![ev]); + } + rig.run_fired(); + let touched = { + let app = rig.app(); + (app.ui.rearrange_placement.is_some(), artboard_rects(&app), undo_steps(&app)) + }; + let panned = origin(rig) != start; + // The mouse, with the pen still seen. + set_source(Source::Mouse); + rig.fx.click_at(at); + rig.run_fired(); + set_pen_seen(false); + (touched, panned) + }); + assert_eq!(touched, (true, before.clone(), steps), "the finger navigates"); + assert!(panned, "the finger pans the view"); + assert!(app.ui.rearrange_placement.is_none(), "the mouse places it"); + assert_ne!(artboard_rects(&app), before); + assert_eq!(undo_steps(&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 = rearrange_app(json!([0])); + on_canvas(&mut app, |rig| { + rig.fx.settle(); + confirm_rearrange(rig); + rig.app().run("artboard.reorder", json!({"index": 2, "to": 0})).unwrap(); + let before = artboard_rects(&rig.app()); + let at = rig.app().canvas_view().unwrap().rect.center(); + rig.fx.click_at(at); + rig.run_fired(); + let app = rig.app(); + assert!(app.ui.rearrange_placement.is_none() && app.ui.status != PLACE_HINT); + assert_eq!(artboard_rects(&app), 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": 10}); + app.run("file.new", json!({"width": 200, "height": 100, "artboards": 3, "artboardLayout": layout})).unwrap(); + app.run("artboard.setProps", json!({"index": 0, "locked": true})).unwrap(); + app.select_tool("artboard"); + for (selected, status) in [(json!([0, 1]), ""), (json!([0]), "the artboard is locked")] { + app.session.set_tool_option("selected", &selected); + // The status the placement leaves as the canvas takes Enter. + let placed = on_canvas(&mut app, |rig| { + rig.fx.settle(); + confirm_rearrange(rig); + rig.fx.frame(vec![egui::Event::PointerGone]); + rig.fx.key(Key::Enter, Modifiers::NONE); + let placed = rig.app().ui.status.clone(); + rig.run_fired(); + placed + }); + assert!(app.ui.rearrange_placement.is_none(), "{selected}"); + assert_eq!(placed, status, "{selected}"); + } +} + +/// Where [`rearrange_is_not_placed_by_a_press_on_a_panel_over_the_canvas`] floats its panel. +const PANEL_OVER_CANVAS: Rect = Rect::from_min_max(Pos2::new(300.0, 250.0), Pos2::new(420.0, 370.0)); + +/// A press on a panel floating 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 = rearrange_app(json!([0])); + let (before, steps) = (artboard_rects(&app), undo_steps(&app)); + let show = |app: &mut VectorcraftApp, ui: &mut Ui| { + canvas::show(app, ui); + egui::Area::new(egui::Id::unique("panel over the canvas")).fixed_pos(PANEL_OVER_CANVAS.min).show(ui.ctx(), |ui| { + ui.allocate_exact_size(PANEL_OVER_CANVAS.size(), egui::Sense::click_and_drag()); + }); + }; + let on_panel = driven(&mut app, CANVAS_ROOM, show, |rig| { + rig.fx.settle(); + confirm_rearrange(rig); + assert!(rig.app().canvas_view().expect("the canvas is laid out").rect.contains_rect(PANEL_OVER_CANVAS)); + rig.fx.click_at(PANEL_OVER_CANVAS.center()); + rig.run_fired(); + let on_panel = { + let app = rig.app(); + (app.ui.rearrange_placement.is_some(), artboard_rects(&app), undo_steps(&app)) + }; + rig.fx.click_at(PANEL_OVER_CANVAS.left_top() - vec2(40.0, 40.0)); + rig.run_fired(); + on_panel + }); + assert_eq!(on_panel, (true, before.clone(), steps), "the press is the panel's"); + assert!(app.ui.rearrange_placement.is_none(), "placed on the open canvas"); + assert_ne!(artboard_rects(&app), before); + assert_eq!(undo_steps(&app), steps + 1); } #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 2b6254f924..e0a252c0f0 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9573,22 +9573,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, 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…), 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. The panel's Rearrange +button stays 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 db1207ced3..1e7b74291d 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1108,7 +1108,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`. @@ -1670,6 +1670,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, and the Artboards panel menu's Rearrange… 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`, `tests::taskbar::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.