From 54e4b6e1f01e12d033da71b43537bf33362464be Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 21:55:23 -0800 Subject: [PATCH 1/2] =?UTF-8?q?Align:=20Object=20=E2=80=BA=20Align=20lists?= =?UTF-8?q?=20the=20Align=20To=20choices,=20and=20each=20can=20be=20given?= =?UTF-8?q?=20a=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Align to Selection, Align to Key Object and Align to Artboard follow the align items in Object › Align, with the choice the Align panel shows checked. Each is a UI command (align.toSelection, align.toKeyObject, align.toArtboard) that sets the choice as the panel's Align To button does, and Edit › Keyboard Shortcuts lists them under Align with no default key. align.toKeyObject fails with "no key object" when no object can be made the key. --- crates/mcp/src/tests.rs | 1 + crates/mcp/src/ui_catalog.rs | 18 +++++ crates/ui-egui/src/menus/run.rs | 1 + crates/ui-egui/src/menus/state.rs | 3 + crates/ui-egui/src/menus/tree.rs | 5 ++ crates/ui-egui/src/menus/ui_commands.rs | 18 +++++ crates/ui-egui/src/panels/align.rs | 31 ++++++++- crates/ui-egui/src/panels/align/tests.rs | 84 ++++++++++++++++++++++++ docs/mcp.md | 11 ++++ docs/target-app-parity.md | 1 + docs/ui-parity.md | 1 + 11 files changed, 172 insertions(+), 2 deletions(-) diff --git a/crates/mcp/src/tests.rs b/crates/mcp/src/tests.rs index 56b2f95944..bcee18074e 100644 --- a/crates/mcp/src/tests.rs +++ b/crates/mcp/src/tests.rs @@ -323,6 +323,7 @@ fn headless_command_list_includes_ui_commands() { "app.quit", "window.arrange.tile", "align.horizontalLeft", + "align.toKeyObject", "ui.action.play", ]; for (n, id) in want.iter().enumerate() { diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index b9b53059b4..8c3bcef98e 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -374,6 +374,24 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{} the Align panel's Horizontal Distribute Space button: object.distributeSpacing {axis: \"horizontal\"} with to: \"key\" while there is a key, else the Align To choice, and spacing: the Distribute Spacing value while there is a key; with the Artboard tool chosen, the artboard command of the same name (artboard.distribute, artboard.distributeSpacing) with the same direction on the artboards the tool has selected, to: \"artboard\" (the active artboard) and spacing: the Distribute Spacing value while Align to Artboard is chosen, else \"selection\"", ), + ( + "align.toSelection", + "Align to Selection", + "", + "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}", + ), + ( + "align.toKeyObject", + "Align to Key Object", + "", + "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, when the topmost selected object can't be the key (it is inside another selected object), or with the Artboard tool chosen", + ), + ( + "align.toArtboard", + "Align to Artboard", + "", + "{} the Align panel's Align to Artboard button: Align To becomes Artboard (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: \"artboard\"}; with the Artboard tool chosen the selected objects keep their key", + ), ( "type.bold", "Bold", diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs index ad85ed5bfa..aa4263112c 100644 --- a/crates/ui-egui/src/menus/run.rs +++ b/crates/ui-egui/src/menus/run.rs @@ -356,6 +356,7 @@ fn run_ui_part4(app: &mut VectorcraftApp, id: &str, _p: &Value) -> Option crate::panels::paragraph::convert_list_to_text(app), id if let Some(b) = crate::panels::align::button(id) => crate::panels::align::run_button(app, b), + id if let Some(v) = crate::panels::align::align_to_command(id) => crate::panels::align::run_align_to(app, v), "view.gradientAnnotator" => flag(&mut app.ui.view.gradient_annotator), "view.livePaintGaps" => flag(&mut app.ui.view.live_paint_gaps), "effect.last" => match app.last_effect.clone() { diff --git a/crates/ui-egui/src/menus/state.rs b/crates/ui-egui/src/menus/state.rs index 36dcdfc1d4..db1803c711 100644 --- a/crates/ui-egui/src/menus/state.rs +++ b/crates/ui-egui/src/menus/state.rs @@ -61,6 +61,8 @@ pub fn checked(app: &VectorcraftApp, id: &str, p: &Value) -> Option { // A View › Rotate View item is checked when the active view is turned to its angle; without // a document no item is checked. "view.rotate" => app.view().zip(p.get("angle").and_then(Value::as_f64)).is_some_and(|(view, a)| (view.rotation - a).abs() < 1e-9), + // Object › Align's Align To items: the choice the Align panel shows. + id if let Some(v) = crate::panels::align::align_to_command(id) => crate::panels::align::shown_align_to(app) == v, "window.control" => app.ui.control_bar, "window.helpBar" => app.ui.help_bar, "view.statusBarShow" => p.get("show").and_then(Value::as_str) == Some(app.ui.status_bar_show.param()), @@ -227,6 +229,7 @@ pub fn enabled(app: &VectorcraftApp, id: &str) -> bool { id if crate::panels::paragraph::ALIGN_COMMANDS.iter().any(|c| c.0 == id) => crate::panels::character::text_style(app).is_some(), "type.applyBullets" | "type.applyNumbers" | "type.convertListToText" => crate::panels::character::text_style(app).is_some(), id if let Some(b) = crate::panels::align::button(id) => enabled(app, b.command_now(app)), + id if let Some(v) = crate::panels::align::align_to_command(id) => crate::panels::align::can_choose(app, v), "file.reveal" => app.services.reveal.is_some() && app.session.active().is_some_and(|d| d.path.is_some()), "file.cancelExport" | "file.exportInBackground" => app.background.jobs.iter().any(|j| j.progress.is_some() && !j.cancelled()), "file.cancelOpen" => !app.opening.pending.is_empty(), diff --git a/crates/ui-egui/src/menus/tree.rs b/crates/ui-egui/src/menus/tree.rs index 137c3b5758..1f08bfa4a5 100644 --- a/crates/ui-egui/src/menus/tree.rs +++ b/crates/ui-egui/src/menus/tree.rs @@ -164,6 +164,11 @@ pub fn menu_tree_named(english_names: bool) -> Vec<(&'static str, Vec)> { cp("Vertical Align Top", "object.align", json!({"vertical": "top"})), cp("Vertical Align Center", "object.align", json!({"vertical": "center"})), cp("Vertical Align Bottom", "object.align", json!({"vertical": "bottom"})), + Sep, + // The Align panel's Align To choices, checked as the panel shows them. + c("Align to Selection", "align.toSelection"), + c("Align to Key Object", "align.toKeyObject"), + c("Align to Artboard", "align.toArtboard"), ], ), // The Align panel's Distribute Objects and Distribute Spacing buttons: each item runs diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index e2c40562f1..5c24ca9db9 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -375,6 +375,24 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{} the Align panel's Horizontal Distribute Space button: object.distributeSpacing {axis: \"horizontal\"} with to: \"key\" while there is a key, else the Align To choice, and spacing: the Distribute Spacing value while there is a key; with the Artboard tool chosen, the artboard command of the same name (artboard.distribute, artboard.distributeSpacing) with the same direction on the artboards the tool has selected, to: \"artboard\" (the active artboard) and spacing: the Distribute Spacing value while Align to Artboard is chosen, else \"selection\"", ), + ( + "align.toSelection", + "Align to Selection", + "", + "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}", + ), + ( + "align.toKeyObject", + "Align to Key Object", + "", + "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, when the topmost selected object can't be the key (it is inside another selected object), or with the Artboard tool chosen", + ), + ( + "align.toArtboard", + "Align to Artboard", + "", + "{} the Align panel's Align to Artboard button: Align To becomes Artboard (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: \"artboard\"}; with the Artboard tool chosen the selected objects keep their key", + ), ( "type.bold", "Bold", diff --git a/crates/ui-egui/src/panels/align.rs b/crates/ui-egui/src/panels/align.rs index e5cb5d07dc..b7de2bb612 100644 --- a/crates/ui-egui/src/panels/align.rs +++ b/crates/ui-egui/src/panels/align.rs @@ -329,7 +329,7 @@ fn key_is_anchor(app: &VectorcraftApp) -> bool { /// The Align To choice that the Align panel and the Control bar show chosen: Artboard while one /// object is selected (the buttons then align it to the artboard), else [`align_to`]. With the /// Artboard tool chosen, it is the stored choice, Selection or Artboard. -fn shown_align_to(app: &VectorcraftApp) -> AlignTo { +pub(crate) fn shown_align_to(app: &VectorcraftApp) -> AlignTo { if on_artboards(app) { return app.ui.align_to; } @@ -340,7 +340,7 @@ fn shown_align_to(app: &VectorcraftApp) -> AlignTo { /// guide, or something to make one of: two or more selected objects, or a guide selected with /// objects. With the Artboard tool chosen it is off: Align to Artboard keeps the active artboard /// in place. -fn can_choose(app: &VectorcraftApp, v: AlignTo) -> bool { +pub(crate) fn can_choose(app: &VectorcraftApp, v: AlignTo) -> bool { if on_artboards(app) { return v != AlignTo::Key; } @@ -377,6 +377,33 @@ pub(crate) fn choose_align_to(app: &mut VectorcraftApp, v: AlignTo) { } } +/// The Align To choices as UI commands ([`crate::menus::UI_COMMANDS`]): (command id, choice). Object +/// › Align lists them after its align items, checked as the Align panel shows its choice, and Edit › +/// Keyboard Shortcuts lists each under Align with no default shortcut. +pub const ALIGN_TO_COMMANDS: [(&str, AlignTo); 3] = + [("align.toSelection", AlignTo::Selection), ("align.toKeyObject", AlignTo::Key), ("align.toArtboard", AlignTo::Artboard)]; + +/// The Align To choice of UI command `id` ([`ALIGN_TO_COMMANDS`]). `None`: `id` is not one of them. +pub(crate) fn align_to_command(id: &str) -> Option { + ALIGN_TO_COMMANDS.iter().find(|c| c.0 == id).map(|c| c.1) +} + +/// Runs the UI command of Align To choice `v`: chooses it as the Align panel's Align To buttons do +/// ([`choose_align_to`]) → `{alignTo}`, the choice the Align panel then shows. An error when it +/// can't be chosen: Align to Key Object with no key object and nothing to make one of, with the +/// Artboard tool chosen, or when the topmost selected object can't be the key (it is inside +/// another selected object). +pub(crate) fn run_align_to(app: &mut VectorcraftApp, v: AlignTo) -> Result { + if !can_choose(app, v) { + return Err("no key object".into()); + } + choose_align_to(app, v); + if v == AlignTo::Key && !has_key(app) { + return Err("no key object".into()); + } + Ok(json!({"alignTo": shown_align_to(app).param()})) +} + /// The width of the Control bar's Align To menu ([`align_to_menu`]) for buttons `size` points /// square: the icon of the choice and the arrow after it. pub(crate) fn align_to_menu_width(size: f32) -> f32 { diff --git a/crates/ui-egui/src/panels/align/tests.rs b/crates/ui-egui/src/panels/align/tests.rs index 727498c61c..f2efcf6e35 100644 --- a/crates/ui-egui/src/panels/align/tests.rs +++ b/crates/ui-egui/src/panels/align/tests.rs @@ -627,6 +627,90 @@ fn object_align_follows_align_to() { assert_eq!((bounds(&app, &a).x1, bounds(&app, &b).x1), (boards[1].x1, boards[1].x1), "the active artboard's right edge"); } +/// The Align To choices of Object → Align ([`ALIGN_TO_COMMANDS`]), in their order: (command id, +/// label). +const ALIGN_TO_ENTRIES: [(&str, &str); 3] = + [("align.toSelection", "Align to Selection"), ("align.toKeyObject", "Align to Key Object"), ("align.toArtboard", "Align to Artboard")]; + +/// Which of Object → Align's Align To items are checked, in their order. +fn align_to_checks(app: &VectorcraftApp) -> Vec> { + ALIGN_TO_ENTRIES.iter().map(|(id, _)| crate::menus::checked(app, id, &json!({}))).collect() +} + +/// Object → Align lists the Align To choices after its align items, the one the Align panel shows +/// checked, and a click on one chooses it as the panel's button does. Edit › Keyboard Shortcuts +/// lists each under Align with no default shortcut, and a shortcut chooses it too. +#[test] +fn object_align_lists_the_align_to_choices() { + let (mut app, back, front) = back_and_front(); + let items: Vec<(String, Option)> = + crate::menus::menu_entries(&app).into_iter().filter(|e| e.path == ["Object", "Align"]).map(|e| (e.label, e.command)).skip(7).collect(); + let expected: Vec<(String, Option)> = ALIGN_TO_ENTRIES.iter().map(|(id, l)| (l.to_string(), Some(id.to_string()))).collect(); + assert_eq!(items, expected, "after the seven align items"); + assert_eq!(align_to_checks(&app), [Some(true), Some(false), Some(false)]); + object_align(&mut app, "Align to Artboard"); + assert_eq!(app.ui.align_to, AlignTo::Artboard); + assert_eq!(align_to_checks(&app), [Some(false), Some(false), Some(true)]); + let list = app.run("shortcuts.list", json!({})).unwrap(); + for (id, label) in ALIGN_TO_ENTRIES { + let e = list.as_array().unwrap().iter().find(|e| e["id"] == id).unwrap_or_else(|| panic!("{id} is not listed")); + assert_eq!((e["label"].as_str(), e["group"].as_str(), &e["default"]), (Some(label), Some("Align"), &Value::Null), "{id}"); + } + // Align to Key Object by a shortcut: the topmost selected object becomes the key, and the + // stored choice stays. + app.run("shortcuts.set", json!({"id": "align.toKeyObject", "shortcut": CHORD})).unwrap(); + press_chord(&mut app); + assert_eq!(app.session.active().unwrap().selection.key.map(|k| k.0), front.as_u64(), "{}", app.ui.status); + assert_eq!(align_to_checks(&app), [Some(false), Some(true), Some(false)]); + assert_eq!(app.ui.align_to, AlignTo::Artboard); + // Align to Selection lets the key go and stores Selection. + assert_eq!(app.run("align.toSelection", json!({})).unwrap(), json!({"alignTo": "selection"})); + assert!(!has_key(&app)); + assert_eq!(app.ui.align_to, AlignTo::Selection); + // One object: Align to Key Object is off and fails, and Align To shows Artboard checked. + app.run("select.set", json!({"ids": [back]})).unwrap(); + let key_item = crate::menus::menu_entries(&app).into_iter().find(|e| e.command.as_deref() == Some("align.toKeyObject")).unwrap(); + assert!(!key_item.enabled, "one object"); + assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "no key object"); + assert!(!has_key(&app)); + assert_eq!(align_to_checks(&app), [Some(false), Some(false), Some(true)]); + // Align to Selection with one object stores Selection and returns what the panel shows. + assert_eq!(app.run("align.toSelection", json!({})).unwrap(), json!({"alignTo": "artboard"})); + assert_eq!(app.ui.align_to, AlignTo::Selection); +} + +/// With the Artboard tool chosen, Align to Key Object is off and fails, and Align to Artboard and +/// Align to Selection store the choice while the selected objects keep their key. +#[test] +fn align_to_commands_with_the_artboard_tool() { + let (mut app, _, front) = back_and_front(); + app.run("align.toKeyObject", json!({})).unwrap(); + app.select_tool("artboard"); + assert!(has_key(&app), "choosing the Artboard tool keeps the key"); + let key_item = crate::menus::menu_entries(&app).into_iter().find(|e| e.command.as_deref() == Some("align.toKeyObject")).unwrap(); + assert!(!key_item.enabled, "the Artboard tool"); + assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "no key object"); + assert_eq!(app.run("align.toArtboard", json!({})).unwrap(), json!({"alignTo": "artboard"})); + assert_eq!(app.ui.align_to, AlignTo::Artboard); + assert_eq!(align_to_checks(&app), [Some(false), Some(false), Some(true)]); + assert_eq!(app.run("align.toSelection", json!({})).unwrap(), json!({"alignTo": "selection"})); + assert_eq!(app.ui.align_to, AlignTo::Selection); + assert_eq!(align_to_checks(&app), [Some(true), Some(false), Some(false)]); + assert_eq!(app.session.active().unwrap().selection.key.map(|k| k.0), front.as_u64(), "the key stays"); +} + +/// Align to Key Object fails when the topmost selected object can't be the key: a group selected +/// with an object inside it. +#[test] +fn align_to_key_object_fails_when_the_topmost_object_cannot_be_the_key() { + let (mut app, _, front) = back_and_front(); + let group = app.run("object.group", json!({})).unwrap()["id"].clone(); + app.run("select.set", json!({"ids": [group, front]})).unwrap(); + assert_eq!(app.session.active().unwrap().selection.objects.len(), 2, "the group and its member"); + assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "no key object"); + assert!(!has_key(&app)); +} + /// With anchor points selected, Object → Align sends its params unchanged: two anchor points of /// one path align to their own bounds with Align to Selection and with Align to Artboard chosen. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 2a71579399..70e64f9771 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6988,6 +6988,17 @@ the Align To choice, and while there is a key object or a key guide they send th `shortcuts.set {id, shortcut}` gives one a shortcut. The Object › Distribute menu lists the eight Distribute commands, and each item runs its command. +The Align panel's Align To choices are UI commands too, with no params: `align.toSelection`, `align.toKeyObject` and +`align.toArtboard`. Each chooses what a click on its Align To button chooses and returns `{alignTo}`, the choice the +panel then shows (`align.toSelection` returns `"artboard"` while one object is selected, which aligns to the artboard). +`align.toSelection` and `align.toArtboard` store the choice (`ui.inspect` › `ui.align_to`) and let the key go; with the +Artboard tool chosen they store it and the selected objects keep their key. With no key, `align.toKeyObject` makes the +topmost of two or more selected objects the key object, or a ruler guide selected with one object the key guide, and +keeps the stored choice. It fails with "no key object" when there is nothing to make the key, when the topmost selected +object is inside another selected object and can't be the key, and with the Artboard tool chosen. Object › Align lists +the three after its align items, with the choice the panel shows checked, and Edit › Keyboard Shortcuts lists them +under Align with no default shortcut. + With the Artboard tool chosen, the same buttons and UI commands, and the Control bar's Align and Distribute buttons, run `artboard.align`, `artboard.distribute` and `artboard.distributeSpacing` on the artboards the tool has selected. Align To then offers Align to Selection and Align to Artboard. Align to Artboard sends `to: "artboard"`, which keeps the diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index c767c1e6cc..3aa58f2427 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1268,6 +1268,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur The Control bar has an Align To menu after its Align buttons. The public documentation offers Align to Selection, Align to Key Object and Align to Artboard in the Control panel (VectorCraft's Control bar) as well as in the Align panel ([Move, align, and distribute objects](https://web.archive.org/web/20250115013546/https://helpx.adobe.com/illustrator/using/moving-aligning-distributing-objects.html)). The menu shows the icon of the choice the Align panel's Align To shows, and a pick sets the same choice as the Align panel's buttons do. Align to Key Object is off while no key object can be made. When the bar runs short of room, it drops the Distribute buttons first, then the Align To menu, then the Align buttons. Object › Align aligns objects as the align buttons do: it aligns one object to the active artboard whatever Align To is set to, and otherwise it aligns to the key object while there is one, else to the Align To choice, which is saved with the preferences (`ui.inspect` → `ui.align_to`). With direct-selected anchor points, Object › Align aligns the points to their own bounds. While one object is selected, Align To shows Artboard. Edit › Keyboard Shortcuts lists each of the Align panel's Align Objects, Distribute Objects and Distribute Spacing buttons under Align, with no default shortcut, as the reference app's [release notes](https://web.archive.org/web/20261006170350/https://helpx.adobe.com/illustrator/desktop/new-features/release-notes.html) describe for its Align and Distribute commands. A shortcut set there runs what a click on the button runs, with the Align To choice, the key object and the Distribute Spacing value (`align.horizontalLeft` and the other `align.*` UI commands). + Object › Align lists Align to Selection, Align to Key Object and Align to Artboard after its align items, with the choice the Align panel shows checked, and each sets that choice as the panel's Align To buttons do; Edit › Keyboard Shortcuts lists them under Align with no default shortcut. The public page has shortcuts for the Align commands set under Object › Align ([Align and distribute objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/align-and-distribute-objects.html)); placing the Align To choices there is VectorCraft's own (`align.toSelection`, `align.toKeyObject`, `align.toArtboard`; `panels::align::tests::object_align_lists_the_align_to_choices`). The command palette lists `select.key` as Cancel Key Object, and a pick cancels the key object (#541). Agent selection commands validate every object id before changing the selection and report the resulting count and ids (#784). Commands that act on `id` or else the selection, the highlighted layer row or a new object (`css.export`, `object.isolate`, `layer.locate`, `layer.releaseToLayers`, the graphic, character and paragraph style commands, `image.info`, the `links.*` and `shaper.*` commands that take an `id`, opacity mask editing and viewing, `symbol.edit`, the blend spine commands and `path.curvature`) refuse an `id` that is not an object id (`"abc"`, `"5"`, `true`) and change nothing; `effect.apply` with the effect given as `id` still applies it to the selection. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index e44a28165c..9bbe2d0d35 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -227,6 +227,7 @@ tools, never checked side by side) isn't captured row by row. | Align panel menu › Align to Glyph Bounds › Point Text and Area Text (checked while on): Align and Distribute measure point type or area type by the ink of its glyphs instead of its em box or frame | done | #4231; `alignGlyphBoundsPoint`, `alignGlyphBoundsArea` ([Align text](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/align-text.html)); `tests::glyphbounds`, `panels::align::tests::align_to_glyph_bounds_toggles_point_and_area_text`; the Character and Properties panels' Align to Glyph Bounds controls are not done | | Align and distribute artboards: with the Artboard tool chosen, the Align panel's Align Objects, Distribute Objects and Distribute Spacing buttons, and the Control bar's, move the selected artboards with the art inside them (Move Artwork with Artboard) | done | `artboard.align`, `artboard.distribute`, `artboard.distributeSpacing` ([Align and distribute artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/align-and-distribute-artboards.html)); VectorCraft's own rules: Align to Artboard keeps the active artboard in place and sends the Distribute Spacing value, Align to Key Object is off, a locked artboard stays where it is; `cmd::artboardalign::tests`, `panels::align::tests::the_align_buttons_align_the_selected_artboards` | | Object › Distribute, below Object › Align: Horizontal Distribute Left, Center and Right, Vertical Distribute Top, Center and Bottom, Horizontal Distribute Space and Vertical Distribute Space, each running what a click on its Align panel button runs (Align To, the key object, the Distribute Spacing value and, with the Artboard tool chosen, the selected artboards) | done | The `align.distribute*` commands; the public page names Object › Distribute beside Object › Align for the Align and Distribute commands ([Align and distribute objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/align-and-distribute-objects.html)); the items and their order are VectorCraft's own, taken from the Align panel; `menus::tests::object_distribute_runs_the_distribute_buttons` | +| Object › Align's Align to Selection, Align to Key Object and Align to Artboard, after the align items: each sets the Align panel's Align To choice as its button does, the choice the panel shows is checked, and Edit › Keyboard Shortcuts lists them under Align with no default key | done | `align.toSelection`, `align.toKeyObject`, `align.toArtboard`; the public page has shortcuts for the Align commands set under Object › Align ([Align and distribute objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/align-and-distribute-objects.html)); placing the Align To choices there is VectorCraft's own; `panels::align::tests::object_align_lists_the_align_to_choices` | | A marquee selects the objects whose paths it touches (anchors or segments): drawn inside a filled shape, over a background, it leaves that shape (Preview and Outline) | done | #1103 | | Click a segment independently of its endpoint anchors; only its direction handles show | done | #1278: hollow endpoint squares, selected edge emphasized; headless egui checked | | Drag a curved segment to bend it, a straight one to move its anchors | done | | From cf3e47d513795516f1f17c944cbe2e028501e8bb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 01:40:34 -0800 Subject: [PATCH 2/2] Align: Align to Key Object names the Artboard tool when that blocks it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - With the Artboard tool chosen, align.toKeyObject fails with "Align to Key Object isn't available with the Artboard tool" instead of "no key object": the selected objects can still have a key in that state. The message has a row in every catalog that has "no key object". - Align to Key Object is off in Object › Align and the Align panel when the topmost selected object is inside another selected object, the case where choosing it already failed. - The align.toSelection params text says the selected objects keep their key with the Artboard tool chosen; ui_catalog.rs regenerated. - A test pins Align to Key Object with a key anchor: checked, the menu name kept, and the key anchor kept. --- crates/mcp/src/ui_catalog.rs | 4 +-- crates/ui-egui/src/i18n/bg.tsv | 1 + crates/ui-egui/src/i18n/bs.tsv | 1 + crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/hi.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/vi.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + crates/ui-egui/src/menus/ui_commands.rs | 4 +-- crates/ui-egui/src/panels/align.rs | 45 +++++++++++++++--------- crates/ui-egui/src/panels/align/tests.rs | 26 ++++++++++++-- docs/mcp.md | 10 +++--- 32 files changed, 89 insertions(+), 27 deletions(-) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 8c3bcef98e..caa2104e76 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -378,13 +378,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "align.toSelection", "Align to Selection", "", - "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}", + "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}; with the Artboard tool chosen the selected objects keep their key", ), ( "align.toKeyObject", "Align to Key Object", "", - "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, when the topmost selected object can't be the key (it is inside another selected object), or with the Artboard tool chosen", + "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, which includes a topmost selected object inside another selected object; an error (\"Align to Key Object isn't available with the Artboard tool\") with the Artboard tool chosen", ), ( "align.toArtboard", diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 8d833f9cdb..4d76241b8d 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -4775,6 +4775,7 @@ axis Both И двете @msg no graphic style `{n}` няма графичен стил `{n}` @msg no interaction in progress няма текущо взаимодействие @msg no key object няма основен обект +@msg Align to Key Object isn't available with the Artboard tool „Подравняване спрямо ключов обект“ не е налично с инструмента „Работна област“ @msg no library `{key}` (see {list}) няма библиотека `{key}` (вижте {list}) @msg no native format няма нативен формат @msg no pages няма страници diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 280056bb88..c8c3993c65 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -5183,6 +5183,7 @@ imageTrace Outline Obris @msg no graphic style `{n}` nema grafičkog stila `{n}` @msg no interaction in progress nema interakcije u toku @msg no key object nema ključnog objekta +@msg Align to Key Object isn't available with the Artboard tool „Poravnaj s ključnim objektom“ nije dostupno s alatom radna ploča @msg no library `{key}` (see {list}) nema biblioteke `{key}` (vidi {list}) @msg no native format nema izvornog formata @msg no pages nema stranica diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 5d0db6ef1d..96f2aee5ee 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -6344,6 +6344,7 @@ liquify-list-end {0}, {1} {0} i {1} @msg no history state {v} no hi ha cap estat de l’historial {v} @msg no interaction in progress no hi ha cap interacció en curs @msg no key object no hi ha objecte clau +@msg Align to Key Object isn't available with the Artboard tool «Alinea a l’objecte clau» no està disponible amb l’eina de tauler @msg no library `{id}` no hi ha la biblioteca `{id}` @msg the library has another item of that kind named `{name}` la biblioteca ja té un altre element d’aquest tipus anomenat `{name}` @msg no library `{key}` (see {list}) no hi ha la biblioteca `{key}` (vegeu {list}) diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 3076fe7875..7ab54c355a 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5497,6 +5497,7 @@ liquify-list-end {0}, {1} {0} a {1} @msg no graphic style `{n}` grafický styl `{n}` neexistuje @msg no interaction in progress neprobíhá žádná interakce @msg no key object žádný klíčový objekt +@msg Align to Key Object isn't available with the Artboard tool „Zarovnat ke klíčovému objektu“ není s nástrojem Pracovní plocha k dispozici @msg no library `{key}` (see {list}) knihovna `{key}` neexistuje (viz {list}) @msg no native format chybí nativní formát @msg no pages žádné stránky diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index b610b9116d..a86d95d91e 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -7671,6 +7671,7 @@ imageTrace Outline Kontur @msg no graphic style `{n}` ingen grafisk stil `{n}` @msg no interaction in progress ingen interaktion i gang @msg no key object intet nøgleobjekt +@msg Align to Key Object isn't available with the Artboard tool Juster til nøgleobjekt er ikke tilgængelig med tegnebrætværktøjet @msg no library `{key}` (see {list}) intet bibliotek `{key}` (se {list}) @msg no native format intet indbygget format @msg no pages ingen sider diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 9f0b61afac..4af672551a 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5091,6 +5091,7 @@ liquify-list-end {0}, {1} {0} und {1} @msg no graphic style `{n}` kein Grafikstil `{n}` @msg no interaction in progress keine Interaktion im Gange @msg no key object kein Basisobjekt +@msg Align to Key Object isn't available with the Artboard tool „An Basisobjekt ausrichten“ ist mit dem Zeichenflächen-Werkzeug nicht verfügbar @msg no library `{key}` (see {list}) keine Bibliothek `{key}` (siehe {list}) @msg no native format kein natives Format @msg no pages keine Seiten diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index a15c2c555f..4c376a4f18 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -5154,6 +5154,7 @@ digits Malayalam Μαλαγιάλαμ @msg no graphic style `{n}` δεν υπάρχει στυλ γραφικών `{n}` @msg no interaction in progress δεν υπάρχει αλληλεπίδραση σε εξέλιξη @msg no key object δεν υπάρχει βασικό αντικείμενο +@msg Align to Key Object isn't available with the Artboard tool η «Στοίχιση ως προς το βασικό αντικείμενο» δεν είναι διαθέσιμη με το εργαλείο πίνακα σχεδίασης @msg no library `{key}` (see {list}) δεν υπάρχει βιβλιοθήκη `{key}` (δείτε {list}) @msg no native format δεν υπάρχει εγγενής μορφή @msg no pages δεν υπάρχουν σελίδες diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 5af6a75d82..a3730586df 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5204,6 +5204,7 @@ liquify-list-end {0}, {1} {0}, {1} @msg no graphic style `{n}` no existe el estilo gráfico `{n}` @msg no interaction in progress no hay ninguna interacción en curso @msg no key object no hay objeto clave +@msg Align to Key Object isn't available with the Artboard tool «Alinear con el objeto clave» no está disponible con la herramienta Mesa de trabajo @msg no library `{key}` (see {list}) no existe la biblioteca `{key}` (consulta {list}) @msg no native format no hay formato nativo @msg no pages no hay páginas diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 1a3f52e96d..f1e36c4d9f 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5420,6 +5420,7 @@ liquify-list-end {0}, {1} {0} ja {1} @msg no graphic style `{n}` ei grafiikkatyyliä `{n}` @msg no interaction in progress mikään vuorovaikutus ei ole käynnissä @msg no key object ei avainobjektia +@msg Align to Key Object isn't available with the Artboard tool ”Tasaa avainobjektiin” ei ole käytettävissä piirtoalustatyökalulla @msg no library `{key}` (see {list}) ei kirjastoa `{key}` (ks. {list}) @msg no native format ei omaa tiedostomuotoa @msg no pages ei sivuja diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index e2adbffc29..8b2c99741f 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5163,6 +5163,7 @@ liquify-list-end {0}, {1} {0} et {1} @msg no graphic style `{n}` aucun style graphique `{n}` @msg no interaction in progress aucune interaction en cours @msg no key object aucun objet clé +@msg Align to Key Object isn't available with the Artboard tool L’alignement sur l’objet clé n’est pas disponible avec l’outil Plan de travail @msg no library `{key}` (see {list}) aucune bibliothèque `{key}` (voir {list}) @msg no native format aucun format natif @msg no pages aucune page diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index e63af675f2..c009cb8cc7 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -7883,6 +7883,7 @@ liquify-list-end {0}, {1} {0} और {1} @msg no item at index {from} इंडेक्स {from} पर कोई आइटम नहीं @msg no item at one of the indices {idx} indices {idx} में से एक पर कोई आइटम नहीं @msg no key object कोई कुंजी ऑब्जेक्ट नहीं +@msg Align to Key Object isn't available with the Artboard tool आर्टबोर्ड टूल के साथ "मुख्य ऑब्जेक्ट पर संरेखित करें" उपलब्ध नहीं है @msg no layer कोई लेयर नहीं @msg no layer {id} (see layer.list) कोई लेयर {id} (layer.list देखें) @msg no layers to export निर्यात करने के लिए कोई लेयरें नहीं diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 68a8c82cf2..24f8ded896 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5869,6 +5869,7 @@ liquify-list-end {0}, {1} {0} és {1} @msg no graphic style `{n}` nincs ilyen grafikai stílus: `{n}` @msg no interaction in progress nincs folyamatban lévő művelet @msg no key object nincs kulcsobjektum +@msg Align to Key Object isn't available with the Artboard tool az „Igazítás a kulcsobjektumhoz” nem érhető el a Rajztábla eszközzel @msg no library `{id}` nincs ilyen könyvtár: `{id}` @msg the library has another item of that kind named `{name}` a könyvtárban már van egy másik ilyen fajta elem `{name}` néven @msg no library `{key}` (see {list}) nincs ilyen könyvtár: `{key}` (lásd: {list}) diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index b5ca49a56b..e6c3aaf72e 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -4882,6 +4882,7 @@ imageTrace Outline Kontur @msg no graphic style `{n}` tidak ada gaya grafis `{n}` @msg no interaction in progress tidak ada interaksi yang berlangsung @msg no key object tidak ada objek kunci +@msg Align to Key Object isn't available with the Artboard tool Ratakan ke objek kunci tidak tersedia dengan alat artboard @msg no library `{key}` (see {list}) tidak ada pustaka `{key}` (lihat {list}) @msg no native format tidak ada format asli @msg no pages tidak ada halaman diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index c09271ca2b..d8980a6a4f 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5228,6 +5228,7 @@ liquify-list-end {0}, {1} {0} e {1} @msg no graphic style `{n}` nessuno stile grafico `{n}` @msg no interaction in progress nessuna interazione in corso @msg no key object nessun oggetto chiave +@msg Align to Key Object isn't available with the Artboard tool «Allinea all'oggetto chiave» non è disponibile con lo strumento Tavola da disegno @msg no library `{key}` (see {list}) nessuna libreria `{key}` (vedi {list}) @msg no native format nessun formato nativo @msg no pages nessuna pagina diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index d3b9bef584..4b2a28a762 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -4959,6 +4959,7 @@ variable-list-end {0}, {1} {0}、{1} @msg no bounds 境界がありません @msg no current layer 現在のレイヤーがありません @msg no key object キーオブジェクトが設定されていません +@msg Align to Key Object isn't available with the Artboard tool アートボードツールでは「キーオブジェクトに整列」を使用できません @msg no previous transform 前回の変形がありません @msg nothing to align 整列するものがありません @msg select a clip group クリップグループを選択してください diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index cc03030df2..edeb02faeb 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -6960,6 +6960,7 @@ font-technology Variable ცვლადი @msg no graphic style `{n}` გრაფიკული სტილი `{n}` არ არის @msg no interaction in progress მიმდინარე ურთიერთქმედება არ არის @msg no key object საკვანძო ობიექტი არ არის +@msg Align to Key Object isn't available with the Artboard tool „საკვანძო ობიექტზე სწორება“ სამუშაო დაფის ხელსაწყოსთან მიუწვდომელია @msg no library `{key}` (see {list}) ბიბლიოთეკა `{key}` არ არის (იხ. {list}) @msg no native format საკუთარი ფორმატი არ არის @msg no pages გვერდები არ არის diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 4fa5ba90d8..7c805dd002 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -4886,6 +4886,7 @@ variable-list-end {0}, {1} {0} 및 {1} @msg no bounds 경계가 없습니다 @msg no current layer 현재 레이어가 없습니다 @msg no key object 키 개체가 없습니다 +@msg Align to Key Object isn't available with the Artboard tool 아트보드 도구에서는 키 개체에 정렬을 사용할 수 없습니다 @msg no previous transform 이전 변형이 없습니다 @msg nothing to align 정렬할 항목이 없습니다 @msg select a clip group 클립 그룹을 선택하세요 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index e726eae41b..237f4b978f 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5550,6 +5550,7 @@ imageTrace Outline Contour @msg no graphic style `{n}` geen grafische stijl `{n}` @msg no interaction in progress geen interactie gaande @msg no key object geen sleutelobject +@msg Align to Key Object isn't available with the Artboard tool Uitlijnen op sleutelobject is niet beschikbaar met het tekengebied-gereedschap @msg no library `{key}` (see {list}) geen bibliotheek `{key}` (zie {list}) @msg no native format geen eigen indeling @msg no pages geen pagina's diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 8cd18cdcb2..e996ff50d2 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5314,6 +5314,7 @@ liquify-list-end {0}, {1} {0} i {1} @msg no graphic style `{n}` brak stylu graficznego `{n}` @msg no interaction in progress brak trwającej interakcji @msg no key object brak obiektu kluczowego +@msg Align to Key Object isn't available with the Artboard tool „Wyrównaj do obiektu kluczowego” jest niedostępne z narzędziem Obszar kompozycji @msg no library `{key}` (see {list}) brak biblioteki `{key}` (patrz {list}) @msg no native format brak formatu natywnego @msg no pages brak stron diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index bba7ed642c..b302d733c9 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -4460,6 +4460,7 @@ axis Both Ambos @msg no graphic style `{n}` nenhum estilo gráfico `{n}` @msg no interaction in progress nenhuma interação em andamento @msg no key object nenhum objeto-chave +@msg Align to Key Object isn't available with the Artboard tool Alinhar ao Objeto-Chave não está disponível com a Ferramenta Mesa de Trabalho @msg no library `{key}` (see {list}) nenhuma biblioteca `{key}` (veja {list}) @msg no native format sem formato nativo @msg no pages sem páginas diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index e2ab3a9097..691c5ec468 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5225,6 +5225,7 @@ liquify-list-end {0}, {1} {0} и {1} @msg no graphic style `{n}` нет графического стиля `{n}` @msg no interaction in progress нет взаимодействия в процессе @msg no key object нет ключевого объекта +@msg Align to Key Object isn't available with the Artboard tool «Выровнять по ключевому объекту» недоступно с инструментом «Монтажная область» @msg no library `{key}` (see {list}) нет библиотеки `{key}` (см. {list}) @msg no native format нет собственного формата @msg no pages нет страниц diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 4893ecc8ce..db6fe3dd59 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -5094,6 +5094,7 @@ liquify-list-end {0}, {1} {0} och {1} @msg no graphic style `{n}` ingen grafisk stil `{n}` @msg no interaction in progress ingen interaktion pågår @msg no key object inget nyckelobjekt +@msg Align to Key Object isn't available with the Artboard tool Justera mot nyckelobjekt är inte tillgängligt med ritytsverktyget @msg no library `{key}` (see {list}) inget bibliotek `{key}` (se {list}) @msg no native format inget eget format @msg no pages inga sidor diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 3f6be1e0f9..12429053aa 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4916,6 +4916,7 @@ liquify-list-end {0}, {1} {0} ve {1} @msg no graphic style `{n}` grafik stili yok `{n}` @msg no interaction in progress herhangi bir etkileşim devam etmiyor @msg no key object anahtar nesne yok +@msg Align to Key Object isn't available with the Artboard tool Anahtar Nesneye Hizala, Çalışma Yüzeyi Aracı ile kullanılamaz @msg no library `{key}` (see {list}) `{key}` kitaplığı yok (bkz. {list}) @msg no native format yerel format yok @msg no pages sayfa yok diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 845010a40f..5cb7d71a6a 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5212,6 +5212,7 @@ liquify-list-end {0}, {1} {0} і {1} @msg no graphic style `{n}` немає графічного стилю `{n}` @msg no interaction in progress немає взаємодії у процесі @msg no key object немає ключового об’єкта +@msg Align to Key Object isn't available with the Artboard tool «Вирівняти за ключовим об’єктом» недоступно з інструментом «Монтажна область» @msg no library `{key}` (see {list}) немає бібліотеки `{key}` (див. {list}) @msg no native format немає власного формату @msg no pages немає сторінок diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index d501f87e17..7744045bef 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5560,6 +5560,7 @@ liquify-list-end {0}, {1} {0} và {1} @msg no graphic style `{n}` không có kiểu đồ họa `{n}` @msg no interaction in progress không có tương tác nào đang tiến hành @msg no key object không có đối tượng khóa +@msg Align to Key Object isn't available with the Artboard tool không thể dùng Căn theo đối tượng chính với Công cụ Bảng vẽ @msg no library `{id}` không có thư viện `{id}` @msg the library has another item of that kind named `{name}` thư viện đã có một mục khác cùng loại tên là `{name}` @msg no library `{key}` (see {list}) không có thư viện `{key}` (xem {list}) diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index a0ffedd15c..2b0693c357 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -4654,6 +4654,7 @@ imageTrace Outline 轮廓 @msg no bounds 没有边界 @msg no current layer 没有当前图层 @msg no key object 没有关键对象 +@msg Align to Key Object isn't available with the Artboard tool 使用画板工具时无法对齐关键对象 @msg no previous transform 没有上一次变换 @msg nothing to align 没有可对齐的内容 @msg select a clip group 请选择一个剪切组 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 86a856ddde..5a43976c8c 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2123,6 +2123,7 @@ file-filter Templates 範本 @msg no bounds 沒有邊界 @msg no current layer 沒有目前圖層 @msg no key object 沒有關鍵物件 +@msg Align to Key Object isn't available with the Artboard tool 使用工作區域工具時無法對齊關鍵物件 @msg no previous transform 沒有上一次的變形 @msg nothing to align 沒有可對齊的內容 @msg select a clip group 請選取剪裁群組 diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 5c24ca9db9..316f740872 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -379,13 +379,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "align.toSelection", "Align to Selection", "", - "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}", + "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}; with the Artboard tool chosen the selected objects keep their key", ), ( "align.toKeyObject", "Align to Key Object", "", - "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, when the topmost selected object can't be the key (it is inside another selected object), or with the Artboard tool chosen", + "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, which includes a topmost selected object inside another selected object; an error (\"Align to Key Object isn't available with the Artboard tool\") with the Artboard tool chosen", ), ( "align.toArtboard", diff --git a/crates/ui-egui/src/panels/align.rs b/crates/ui-egui/src/panels/align.rs index b7de2bb612..ca838c03b9 100644 --- a/crates/ui-egui/src/panels/align.rs +++ b/crates/ui-egui/src/panels/align.rs @@ -336,20 +336,32 @@ pub(crate) fn shown_align_to(app: &VectorcraftApp) -> AlignTo { aligns_to(align_to(app), objects_aligned(app)) } -/// Whether Align To choice `v` can be chosen. Align to Key Object needs a key object or a key -/// guide, or something to make one of: two or more selected objects, or a guide selected with -/// objects. With the Artboard tool chosen it is off: Align to Artboard keeps the active artboard -/// in place. +/// What Align to Key Object makes the key while there is none, as `select.key` params: the topmost +/// of two or more selected objects when no other selected object holds it, or with one object, a +/// ruler guide selected with it. `None`: nothing can be made the key. +fn key_pick(app: &VectorcraftApp) -> Option { + if selection_len(app) < 2 { + return guide_for_key(app).map(|g| json!({"guide": g})); + } + let id = topmost(app)?; + let st = app.session.active()?; + let inside = st.doc.ancestry(id).unwrap_or_default().into_iter().any(|a| a != id && st.selection.contains(a)); + if inside { None } else { Some(json!({"id": id.0})) } +} + +/// Whether Align To choice `v` can be chosen. Align to Key Object needs a key object, a key guide +/// or a key anchor, or something to make the key ([`key_pick`]). With the Artboard tool chosen it +/// is off: Align to Artboard keeps the active artboard in place. pub(crate) fn can_choose(app: &VectorcraftApp, v: AlignTo) -> bool { if on_artboards(app) { return v != AlignTo::Key; } - v != AlignTo::Key || selection_len(app) >= 2 || has_key(app) || guide_for_key(app).is_some() + v != AlignTo::Key || has_key(app) || key_pick(app).is_some() } /// Chooses Align To `v`, as the Align panel's Align To buttons and the Control bar's Align To menu -/// do. Align to Key Object makes the topmost selected object the key object, unless there is one -/// already; with one object, a guide selected with it becomes the key. The stored choice stays as +/// do. Align to Key Object makes the key what [`key_pick`] gives, unless there is a key already: +/// the topmost selected object, or with one object, a guide selected with it. The stored choice stays as /// it was, and Align To shows it again once the key is cleared. Align to Selection and Align to /// Artboard store the choice and let go of the key object. With the Artboard tool chosen, the /// choice is stored and the selected objects keep their key. @@ -362,12 +374,10 @@ pub(crate) fn choose_align_to(app: &mut VectorcraftApp, v: AlignTo) { return; } if v == AlignTo::Key { - if !has_key(app) { - match (topmost(app).filter(|_| selection_len(app) >= 2), guide_for_key(app)) { - (Some(id), _) => app.run("select.key", json!({"id": id.0})).ok(), - (None, Some(g)) => app.run("select.key", json!({"guide": g})).ok(), - (None, None) => None, - }; + if !has_key(app) + && let Some(p) = key_pick(app) + { + app.run("select.key", p).ok(); } } else { app.ui.align_to = v; @@ -390,10 +400,13 @@ pub(crate) fn align_to_command(id: &str) -> Option { /// Runs the UI command of Align To choice `v`: chooses it as the Align panel's Align To buttons do /// ([`choose_align_to`]) → `{alignTo}`, the choice the Align panel then shows. An error when it -/// can't be chosen: Align to Key Object with no key object and nothing to make one of, with the -/// Artboard tool chosen, or when the topmost selected object can't be the key (it is inside -/// another selected object). +/// can't be chosen: Align to Key Object with the Artboard tool chosen, or with no key and nothing +/// to make the key ([`key_pick`]), which includes a topmost selected object inside another +/// selected object. pub(crate) fn run_align_to(app: &mut VectorcraftApp, v: AlignTo) -> Result { + if v == AlignTo::Key && on_artboards(app) { + return Err("Align to Key Object isn't available with the Artboard tool".into()); + } if !can_choose(app, v) { return Err("no key object".into()); } diff --git a/crates/ui-egui/src/panels/align/tests.rs b/crates/ui-egui/src/panels/align/tests.rs index f2efcf6e35..ffdc0b10a3 100644 --- a/crates/ui-egui/src/panels/align/tests.rs +++ b/crates/ui-egui/src/panels/align/tests.rs @@ -689,7 +689,7 @@ fn align_to_commands_with_the_artboard_tool() { assert!(has_key(&app), "choosing the Artboard tool keeps the key"); let key_item = crate::menus::menu_entries(&app).into_iter().find(|e| e.command.as_deref() == Some("align.toKeyObject")).unwrap(); assert!(!key_item.enabled, "the Artboard tool"); - assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "no key object"); + assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "Align to Key Object isn't available with the Artboard tool"); assert_eq!(app.run("align.toArtboard", json!({})).unwrap(), json!({"alignTo": "artboard"})); assert_eq!(app.ui.align_to, AlignTo::Artboard); assert_eq!(align_to_checks(&app), [Some(false), Some(false), Some(true)]); @@ -699,18 +699,38 @@ fn align_to_commands_with_the_artboard_tool() { assert_eq!(app.session.active().unwrap().selection.key.map(|k| k.0), front.as_u64(), "the key stays"); } -/// Align to Key Object fails when the topmost selected object can't be the key: a group selected -/// with an object inside it. +/// Align to Key Object is off and fails when the topmost selected object can't be the key: a group +/// selected with an object inside it. #[test] fn align_to_key_object_fails_when_the_topmost_object_cannot_be_the_key() { let (mut app, _, front) = back_and_front(); let group = app.run("object.group", json!({})).unwrap()["id"].clone(); app.run("select.set", json!({"ids": [group, front]})).unwrap(); assert_eq!(app.session.active().unwrap().selection.objects.len(), 2, "the group and its member"); + let key_item = crate::menus::menu_entries(&app).into_iter().find(|e| e.command.as_deref() == Some("align.toKeyObject")).unwrap(); + assert!(!key_item.enabled, "the topmost object is inside the group"); + assert!(!can_choose(&app, AlignTo::Key), "the panel's button is off too"); assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "no key object"); assert!(!has_key(&app)); } +/// With a key anchor, Object → Align shows Align to Key Object checked under its menu name, and +/// the command keeps the key anchor → `{alignTo: "key"}`. +#[test] +fn align_to_key_object_with_a_key_anchor() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let id = app.run("path.create", json!({"d": "M100 40 L200 60 L150 160 Z"})).unwrap()["id"].as_u64().unwrap(); + app.run("select.anchors", json!({"id": id, "anchors": [[0, 0], [0, 2]], "mode": "set"})).unwrap(); + app.run("select.key", json!({"id": id, "anchor": [0, 2]})).unwrap(); + assert_eq!(align_to_checks(&app), [Some(false), Some(true), Some(false)]); + let key_item = crate::menus::menu_entries(&app).into_iter().find(|e| e.command.as_deref() == Some("align.toKeyObject")).unwrap(); + assert_eq!((key_item.label.as_str(), key_item.enabled), ("Align to Key Object", true)); + assert_eq!(app.run("align.toKeyObject", json!({})).unwrap(), json!({"alignTo": "key"})); + let key_anchor = app.session.active().unwrap().selection.key_anchor.map(|(k, a)| (k.0, a)); + assert_eq!(key_anchor, Some((id, (0, 2))), "the key anchor stays"); +} + /// With anchor points selected, Object → Align sends its params unchanged: two anchor points of /// one path align to their own bounds with Align to Selection and with Align to Artboard chosen. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 70e64f9771..4d8e141427 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6994,10 +6994,12 @@ panel then shows (`align.toSelection` returns `"artboard"` while one object is s `align.toSelection` and `align.toArtboard` store the choice (`ui.inspect` › `ui.align_to`) and let the key go; with the Artboard tool chosen they store it and the selected objects keep their key. With no key, `align.toKeyObject` makes the topmost of two or more selected objects the key object, or a ruler guide selected with one object the key guide, and -keeps the stored choice. It fails with "no key object" when there is nothing to make the key, when the topmost selected -object is inside another selected object and can't be the key, and with the Artboard tool chosen. Object › Align lists -the three after its align items, with the choice the panel shows checked, and Edit › Keyboard Shortcuts lists them -under Align with no default shortcut. +keeps the stored choice. It fails with "no key object" when there is nothing to make the key, which includes a topmost +selected object inside another selected object, and with "Align to Key Object isn't available with the Artboard tool" +while the Artboard tool is chosen; its menu item and the panel's button are off in both cases. Object › Align lists the +three after its align items, with the choice the panel shows checked, and Edit › Keyboard Shortcuts lists them under +Align with no default shortcut. While the key is a key anchor, the panel names its choice Align to Key Anchor and the +menu item keeps the name Align to Key Object. With the Artboard tool chosen, the same buttons and UI commands, and the Control bar's Align and Distribute buttons, run `artboard.align`, `artboard.distribute` and `artboard.distributeSpacing` on the artboards the tool has selected.