diff --git a/crates/engine/src/cmd/menucmds.rs b/crates/engine/src/cmd/menucmds.rs index 2a073ab62a..defc405514 100644 --- a/crates/engine/src/cmd/menucmds.rs +++ b/crates/engine/src/cmd/menucmds.rs @@ -1,6 +1,6 @@ //! Object menu long tail: Lock/Hide All Artwork Above & Other Layers, Transform Each, Reset -//! Bounding Box, Rasterize, Crop Image, Mask (an image), Create Trim Marks, Convert to Shape and -//! Artboards → Convert / Rearrange. (Live blends are in `live.rs`.) +//! Bounding Box, Rotate Bounding Box, Rasterize, Crop Image, Mask (an image), Create Trim Marks, +//! Convert to Shape and Artboards → Convert / Rearrange. (Live blends are in `live.rs`.) use std::collections::{BTreeMap, BTreeSet, HashSet}; use std::sync::Arc; @@ -15,8 +15,8 @@ use vectorcraft_render::encode::{RasterExportOptions, RasterFormat}; use super::edit::{duplicate_in, selected_roots, selected_roots_to_transform}; use super::{ - CommandSpec, EngineError, Result, Session, bad, check_numbers, check_switches, cmd, f64_or, fileio, find_command, has_doc, has_selected_member, - has_selection, switch_or, + CommandSpec, EngineError, Result, Session, bad, check_numbers, check_switches, cmd, f64_or, f64_req, fileio, find_command, has_doc, + has_selected_member, has_selection, switch_or, }; /// Session-level (not saved) state owned by the menu commands. @@ -110,6 +110,15 @@ pub fn specs() -> Vec { has_selection, reset_bounding_box ), + cmd!( + "object.rotateBoundingBox", + "Rotate Bounding Box…", + ["Object", "Transform"], + None, + "{angle: degrees (counter-clockwise), absolute?: bool (true: turn the box to angle; default false: turn it by angle from the angle the selected objects share, 0 when theirs differ)} turn the bounding box of the selected objects to one angle without moving their art; the objects inside them (the children of groups, compound paths, clip groups, blends, envelopes, repeats and intertwines, and the art of linked opacity masks) turn with them and keep their angle relative to them; a path of a compound path selected on its own turns only its own box; one undo step, none when every box is already at the angle; object.resetBoundingBox squares the boxes again; a missing or non-numeric angle is an error → {angle: the new angle of the boxes, in (-180, 180], changed: objects whose box turned, the objects inside the selected ones included}", + has_selection, + rotate_bounding_box + ), cmd!( "object.rasterize", "Rasterize…", @@ -225,9 +234,10 @@ pub(crate) fn squash(s: &mut Session, from: usize, label: &str) { // ---------- Reset Bounding Box ---------- /// Squares each selected object and every object inside it: the children of groups, compound paths, -/// clip groups, blends, envelopes, repeats and intertwines, and the art of linked opacity masks. +/// clip groups, blends, envelopes, repeats and intertwines, and the art of linked opacity masks. A +/// path of a compound path selected on its own is squared alone, as the transforms move it alone. fn reset_bounding_box(s: &mut Session, _: &Value) -> Result { - let ids = selected_roots(s)?; + let ids = selected_roots_to_transform(s)?; let d = &s.doc()?.doc; let mut changed = 0; let squared: Vec<(NodeId, Node)> = ids @@ -251,6 +261,69 @@ fn reset_bounding_box(s: &mut Session, _: &Value) -> Result { Ok(json!({ "changed": changed })) } +// ---------- Rotate Bounding Box ---------- + +/// Turns the bounding box of the selected objects to one angle without moving their art: by `angle` +/// from the angle they share (0 when it differs), or to `angle` with `absolute`. Each object's box +/// turns by what takes it there, and so do the boxes of the objects inside it (the children of +/// groups and the art of linked opacity masks), which keep their angle relative to it. +fn rotate_bounding_box(s: &mut Session, p: &Value) -> Result { + const C: &str = "object.rotateBoundingBox"; + // A JSON number is always finite. + let angle = f64_req(p, "angle", C)?; + let absolute = switch_or(p, "absolute", false, C)?; + // The same objects the transforms move: a path of a compound path selected on its own turns + // its own box. Layers are left out, as they have no box. + let owners = selected_roots_to_transform(s)?; + let d = &s.doc()?.doc; + let start = if absolute { 0.0 } else { d.bbox_angle(&owners) }; + // An angle within the tolerance of 0 is stored as 0, as `Node::turn_boxes` stores it. + let target = match vectorcraft_geom::normalize_deg(start + angle) { + a if a.abs() <= BOX_EPS_DEG => 0.0, + a => a, + }; + let mut changed = 0; + let turned: Vec<(NodeId, Node)> = owners + .iter() + .filter_map(|id| { + let n = d.node(*id)?; + let by = vectorcraft_geom::normalize_deg(target - n.bbox_angle); + (by.abs() > BOX_EPS_DEG).then(|| { + let mut c = n.clone(); + c.turn_boxes(by); + // The selected object's box is set to the target itself, so repeated turns add no + // rounding error to it. + c.bbox_angle = target; + changed += boxes(&c); + (*id, c) + }) + }) + .collect(); + if !turned.is_empty() { + s.edit("Rotate Bounding Box", |d, _| { + for (id, n) in turned { + if let Some(slot) = d.node_mut(id) { + *slot = n; + } + } + Ok(()) + })?; + } + Ok(json!({ "angle": target, "changed": changed })) +} + +/// Angles closer than this (degrees) are the same, as `vectorcraft_doc::orient` compares them. +const BOX_EPS_DEG: f64 = 1e-6; + +/// The number of objects in `n`'s subtree whose box [`Node::turn_boxes`] turns: `n`, its children +/// and the art of a linked opacity mask, layers left out. +fn boxes(n: &Node) -> usize { + let own = usize::from(!n.is_layer()); + let children: usize = n.children().into_iter().flatten().map(|c| boxes(c)).sum(); + let mask = n.extras().mask.as_ref().filter(|m| m.linked).map_or(0, |m| boxes(&m.art)); + own + children + mask +} + /// A copy of `n` with the angle of every object in its subtree set to 0, or `None` when no box in /// it stands at an angle, and the number of objects squared. The subtree takes in children and the /// art of linked opacity masks (an unlinked mask's art turns on its own); layers have no box. Only diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index 6a0caf4cd6..abe1ae4362 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -366,6 +366,7 @@ pub(super) const ALLOWED: &[&str] = &[ "object.repeat.release", "object.resetBoundingBox", "object.rotate", + "object.rotateBoundingBox", "object.scale", "object.setBounds", "object.setLiveShape", diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index e6c622963a..a16f01cfa0 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -2809,6 +2809,26 @@ fn an_isolated_compound_paths_member_moves_alone() { assert_eq!((x0(&s, outer), x0(&s, hole)), (5.0, 55.0), "the compound path selected: the whole ring"); } +/// Rotate Bounding Box and Reset Bounding Box take the same objects as the transforms: a path of +/// a compound path selected alone turns or squares its own box, and the compound path selected +/// turns its box and its paths'. +#[test] +fn rotate_bounding_box_of_a_compound_paths_member_turns_only_that_path() { + let angle = |s: &Session, id: NodeId| s.doc().unwrap().doc.node(id).unwrap().bbox_angle; + let mut s = session(); + let (c, outer, hole) = isolated_ring(&mut s); + s.execute("object.exitIsolation", &json!({})).unwrap(); + s.execute("select.set", &json!({"ids": [hole.0]})).unwrap(); + s.execute("object.rotateBoundingBox", &json!({"angle": 30})).unwrap(); + assert_eq!((angle(&s, c), angle(&s, outer), angle(&s, hole)), (0.0, 0.0, 30.0), "only the hole's box turned"); + s.execute("select.set", &json!({"ids": [c.0]})).unwrap(); + s.execute("object.rotateBoundingBox", &json!({"angle": 10})).unwrap(); + assert_eq!((angle(&s, c), angle(&s, outer), angle(&s, hole)), (10.0, 10.0, 40.0), "the compound path and its paths"); + s.execute("select.set", &json!({"ids": [hole.0]})).unwrap(); + assert_eq!(s.execute("object.resetBoundingBox", &json!({})).unwrap()["changed"], 1); + assert_eq!((angle(&s, c), angle(&s, outer), angle(&s, hole)), (10.0, 10.0, 0.0), "Reset squared only the hole's box"); +} + /// The X, Y, W and H of the Properties and Transform panels run `object.setBounds`, which takes the /// same objects as the other transforms: a path of a compound path selected alone sets its own /// box and leaves the ring around it (#4046). The hole is off-centre, and a plain rectangle diff --git a/crates/engine/src/tests/bboxrotate.rs b/crates/engine/src/tests/bboxrotate.rs index db09eba280..eec4ee191a 100644 --- a/crates/engine/src/tests/bboxrotate.rs +++ b/crates/engine/src/tests/bboxrotate.rs @@ -579,6 +579,157 @@ fn reset_bounding_box_squares_the_turned_members_of_a_square_group() { assert_eq!(selection_box(&s).angle, 0.0); } +#[test] +fn rotate_bounding_box_turns_the_box_and_leaves_the_art() { + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 100.0, 50.0); + sel(&mut s, &[a]); + let art = anchors(&s, a); + let n = undo_len(&s); + let r = s.execute("object.rotateBoundingBox", &json!({"angle": 90})).unwrap(); + assert_eq!((r["changed"].as_u64(), r["angle"].as_f64()), (Some(1), Some(90.0))); + assert_eq!(undo_len(&s), n + 1); + assert_eq!(anchors(&s, a), art, "the art stays where it is"); + // The box is at 90°, so its width runs along the rectangle's 50 pt side. + let b = selection_box(&s); + assert!(near(b.angle, 90.0)); + assert!(near(b.rect.width(), 50.0) && near(b.rect.height(), 100.0), "{b:?}"); + // By an angle from the box's angle; absolute sets it; the result wraps to (-180, 180]. + s.execute("object.rotateBoundingBox", &json!({"angle": 20})).unwrap(); + assert!(near(angle(&s, a), 110.0)); + let r = s.execute("object.rotateBoundingBox", &json!({"angle": 200, "absolute": true})).unwrap(); + assert!(near(r["angle"].as_f64().unwrap(), -160.0) && near(angle(&s, a), -160.0)); + // A box already at the angle changes nothing and adds no step. + let n = undo_len(&s); + let r = s.execute("object.rotateBoundingBox", &json!({"angle": -160, "absolute": true})).unwrap(); + assert_eq!(r["changed"], 0); + let r = s.execute("object.rotateBoundingBox", &json!({"angle": 360})).unwrap(); + assert_eq!(r["changed"], 0); + assert_eq!(undo_len(&s), n); + // Undo turns the box back; Reset Bounding Box squares it. + s.execute("edit.undo", &json!({})).unwrap(); + assert!(near(angle(&s, a), 110.0)); + assert_eq!(s.execute("object.resetBoundingBox", &json!({})).unwrap()["changed"], 1); + assert_eq!(anchors(&s, a), art); +} + +/// Turns that add up to 0 within the tolerance leave the box at exactly 0, so the box measures +/// square to the page and Reset Bounding Box has nothing to square. +#[test] +fn rotate_bounding_box_back_to_zero_stores_zero() { + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 100.0, 50.0); + sel(&mut s, &[a]); + for by in [0.3, -0.1] { + s.execute("object.rotateBoundingBox", &json!({"angle": by})).unwrap(); + } + let r = s.execute("object.rotateBoundingBox", &json!({"angle": -0.2})).unwrap(); + assert_eq!((r["angle"].as_f64(), angle(&s, a)), (Some(0.0), 0.0), "{r}"); + assert_eq!(selection_box(&s).angle, 0.0); + let n = undo_len(&s); + assert_eq!(s.execute("object.resetBoundingBox", &json!({})).unwrap()["changed"], 0); + assert_eq!(undo_len(&s), n); + // A negative zero is reported and stored as 0. + let r = s.execute("object.rotateBoundingBox", &json!({"angle": -0.0, "absolute": true})).unwrap(); + let got = r["angle"].as_f64().unwrap(); + assert!(got == 0.0 && got.is_sign_positive(), "{r}"); + assert_eq!(r["changed"], 0); +} + +#[test] +fn rotate_bounding_box_gives_a_mixed_selection_one_angle() { + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 100.0, 50.0); + let b = turned_rect(&mut s); + sel(&mut s, &[a, b]); + // The objects share no angle, so the box is square to the page and turns from 0. + assert_eq!(selection_box(&s).angle, 0.0); + let n = undo_len(&s); + assert_eq!(s.execute("object.rotateBoundingBox", &json!({"angle": 10})).unwrap()["changed"], 2); + assert_eq!(undo_len(&s), n + 1, "one step for both"); + assert!(near(angle(&s, a), 10.0) && near(angle(&s, b), 10.0)); + assert!(near(selection_box(&s).angle, 10.0)); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(near(angle(&s, a), 0.0) && near(angle(&s, b), 45.0)); + s.execute("edit.redo", &json!({})).unwrap(); + assert!(near(angle(&s, a), 10.0) && near(angle(&s, b), 10.0)); +} + +#[test] +fn rotate_bounding_box_turns_the_objects_inside_a_group_with_it() { + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 100.0, 50.0); + let b = rect(&mut s, 300.0, 100.0, 100.0, 50.0); + sel(&mut s, &[a, b]); + s.execute("object.rotate", &json!({"angle": 20})).unwrap(); + let g = id_of(&s.execute("object.group", &json!({})).unwrap()); + let art = (anchors(&s, a), anchors(&s, b)); + // The group and both members, as Reset Bounding Box counts them. + assert_eq!(s.execute("object.rotateBoundingBox", &json!({"angle": 30})).unwrap()["changed"], 3); + // The members keep their 20° relative to the group's box. + assert!(near(angle(&s, g), 30.0) && near(angle(&s, a), 50.0) && near(angle(&s, b), 50.0)); + assert_eq!((anchors(&s, a), anchors(&s, b)), art); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(near(angle(&s, g), 0.0) && near(angle(&s, a), 20.0) && near(angle(&s, b), 20.0)); + s.execute("edit.redo", &json!({})).unwrap(); + assert!(near(angle(&s, g), 30.0) && near(angle(&s, a), 50.0) && near(angle(&s, b), 50.0)); + // After Ungroup the members still share a turned box. + s.execute("object.ungroup", &json!({})).unwrap(); + assert!(near(selection_box(&s).angle, 50.0)); +} + +/// The art of a linked opacity mask turns with its object; an unlinked mask's art keeps its angle. +#[test] +fn rotate_bounding_box_turns_a_linked_masks_art_only() { + let mask_angle = |s: &Session, a: NodeId| s.doc().unwrap().doc.node(a).unwrap().extras().mask.as_ref().unwrap().art.bbox_angle; + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 100.0, 50.0); + let b = rect(&mut s, 150.0, 120.0, 100.0, 50.0); + sel(&mut s, &[a, b]); + s.execute("transparency.makeOpacityMask", &json!({})).unwrap(); + assert_eq!(s.execute("object.rotateBoundingBox", &json!({"angle": 30})).unwrap()["changed"], 2); + assert!(near(angle(&s, a), 30.0) && near(mask_angle(&s, a), 30.0)); + s.execute("transparency.unlinkOpacityMask", &json!({})).unwrap(); + assert_eq!(s.execute("object.rotateBoundingBox", &json!({"angle": 10})).unwrap()["changed"], 1); + assert!(near(angle(&s, a), 40.0) && near(mask_angle(&s, a), 30.0)); +} + +/// Rotate Bounding Box and Reset Bounding Box act on the same boxes: after a turn of a group that +/// holds an object with a linked opacity mask, Reset squares every box it turned. +#[test] +fn reset_bounding_box_squares_every_box_rotate_bounding_box_turned() { + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 100.0, 50.0); + let b = rect(&mut s, 150.0, 120.0, 100.0, 50.0); + sel(&mut s, &[a, b]); + s.execute("transparency.makeOpacityMask", &json!({})).unwrap(); + let c = rect(&mut s, 300.0, 100.0, 100.0, 50.0); + sel(&mut s, &[a, c]); + s.execute("object.group", &json!({})).unwrap(); + let art = (anchors(&s, a), anchors(&s, c)); + // The group, the masked object, its mask's art and the other rectangle. + assert_eq!(s.execute("object.rotateBoundingBox", &json!({"angle": 25})).unwrap()["changed"], 4); + assert!(object_angles(&s).iter().all(|x| near(*x, 25.0)), "{:?}", object_angles(&s)); + assert_eq!(s.execute("object.resetBoundingBox", &json!({})).unwrap()["changed"], 4); + assert!(object_angles(&s).iter().all(|x| *x == 0.0), "{:?}", object_angles(&s)); + assert_eq!((anchors(&s, a), anchors(&s, c)), art); +} + +#[test] +fn rotate_bounding_box_refuses_bad_params() { + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 100.0, 50.0); + sel(&mut s, &[a]); + let n = undo_len(&s); + for p in [json!({}), json!({"angle": null}), json!({"angle": "30"}), json!({"angle": 30, "absolute": "yes"})] { + assert!(s.execute("object.rotateBoundingBox", &p).is_err(), "{p}"); + } + assert_eq!((angle(&s, a), undo_len(&s)), (0.0, n)); + // Nothing selected: the command is not enabled. + s.execute("select.none", &json!({})).unwrap(); + assert!(s.execute("object.rotateBoundingBox", &json!({"angle": 30})).is_err()); +} + /// Two rectangles turned 20°, put in a container by `make`, turned 10° with it and reset, then /// released by `release`: nothing stands at an angle before or after the release. fn reset_then_release(make: &str, release: &str) -> Session { diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 4ef39146e7..f32292995a 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -2955,6 +2955,8 @@ digits Malayalam Малаялам Reselect Избиране отново Reset Нулиране Reset Bounding Box Нулиране на ограничителната рамка + Rotate Bounding Box Завъртане на ограничителната рамка + Rotate Bounding Box… Завъртане на ограничителната рамка… Reset Envelope Mesh Нулиране на мрежата на обвивката Reset Envelope Shape Нулиране на формата на обвивката Reset Essentials Нулиране на основните diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 39f95d5b2f..c4411862be 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -169,6 +169,8 @@ Shear… Smicanje… Transform Each… Transformiši svaki… Reset Bounding Box Vrati granični okvir na početno + Rotate Bounding Box Rotiraj granični okvir + Rotate Bounding Box… Rotiraj granični okvir… Arrange Rasporedi Bring to Front Postavi na vrh Bring Forward Pomakni naprijed diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index e2b9bc2d95..f3d7390fa8 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -3764,6 +3764,8 @@ digits Malayalam Malaiàlam Reset Automation Restableix Automation Reset Bar Position Restableix la posició de la barra Reset Bounding Box Restableix el quadre delimitador + Rotate Bounding Box Gira el quadre delimitador + Rotate Bounding Box… Gira el quadre delimitador… Reset Envelope Mesh Restableix la malla de l’embolcall Reset Envelope Shape Restableix la forma de l’embolcall Reset Essentials Restableix Essentials diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index f6c2502219..7eb2b24ee9 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -173,6 +173,8 @@ Shear… Zkosit… Transform Each… Transformovat jednotlivě… Reset Bounding Box Obnovit ohraničovací rámeček + Rotate Bounding Box Otočit ohraničovací rámeček + Rotate Bounding Box… Otočit ohraničovací rámeček… Arrange Uspořádat Bring to Front Přenést do popředí Bring Forward Přenést blíž diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index bcf3386fc7..5c16934d99 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -871,6 +871,8 @@ liquify-list-end {0}, {1} {0} og {1} Shear… Skæv… Transform Each… Transformér hver for sig… Reset Bounding Box Nulstil afgrænsningsramme + Rotate Bounding Box Rotér afgrænsningsramme + Rotate Bounding Box… Rotér afgrænsningsramme… Arrange Arrangér Bring to Front Anbring forrest Bring Forward Flyt fremad diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index d1d705bb54..cfa7b2bc3c 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3004,6 +3004,8 @@ digits Malayalam Malayalam Reselect Erneut auswählen Reset Zurücksetzen Reset Bounding Box Begrenzungsrahmen zurücksetzen + Rotate Bounding Box Begrenzungsrahmen drehen + Rotate Bounding Box… Begrenzungsrahmen drehen… Reset Envelope Mesh Hüllengitter zurücksetzen Reset Envelope Shape Hüllenform zurücksetzen Reset Essentials Essentials zurücksetzen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 62c1e87f89..4afaad7c49 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3839,6 +3839,8 @@ digits Malayalam Μαλαγιάλαμ Replaces the saved preset of that name. Αντικαθιστά την αποθηκευμένη προεπιλογή με αυτό το όνομα. Require a password to open the document Απαίτηση κωδικού για το άνοιγμα εγγράφου Reset Bounding Box Επαναφορά πλαισίου οριοθέτησης + Rotate Bounding Box Περιστροφή πλαισίου οριοθέτησης + Rotate Bounding Box… Περιστροφή πλαισίου οριοθέτησης… Reset Envelope Mesh Επαναφορά πλέγματος περιβλήματος Reset Envelope Shape Επαναφορά σχήματος περιβλήματος Reset Essentials Επαναφορά χώρου εργασίας Essentials diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 0b48d67835..6c7a0283ca 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -3043,6 +3043,8 @@ digits Malayalam Malayálam Reselect Volver a seleccionar Reset Restablecer Reset Bounding Box Restablecer cuadro delimitador + Rotate Bounding Box Rotar cuadro delimitador + Rotate Bounding Box… Rotar cuadro delimitador… Reset Envelope Mesh Restablecer malla de envolvente Reset Envelope Shape Restablecer forma de envolvente Reset Essentials Restablecer Essentials diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 6177d7de5f..6d1450044a 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -180,6 +180,8 @@ Shear… Vinouta… Transform Each… Muunna kutakin… Reset Bounding Box Palauta rajausruutu + Rotate Bounding Box Kierrä rajausruutua + Rotate Bounding Box… Kierrä rajausruutua… Arrange Järjestä Bring to Front Tuo eteen Bring Forward Tuo eteenpäin diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 004e6b534b..3b22234ace 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3031,6 +3031,8 @@ digits Malayalam Malayalam Reselect Resélectionner Reset Réinitialiser Reset Bounding Box Réinitialiser le cadre de sélection + Rotate Bounding Box Faire pivoter le cadre de sélection + Rotate Bounding Box… Faire pivoter le cadre de sélection… Reset Envelope Mesh Réinitialiser le filet de l’enveloppe Reset Envelope Shape Réinitialiser la forme de l’enveloppe Reset Essentials Réinitialiser Essentials diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 622b32e479..85e5b89667 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -3116,6 +3116,8 @@ Reset રીસેટ કરો Reset Bar Position બાર સ્થિતિ રીસેટ કરો Reset Bounding Box બાઉન્ડિંગ બોક્સ રીસેટ કરો + Rotate Bounding Box બાઉન્ડિંગ બોક્સ ફેરવો + Rotate Bounding Box… બાઉન્ડિંગ બોક્સ ફેરવો… Reset Envelope Mesh એન્વેલપ મેશ રીસેટ કરો Reset Envelope Shape એન્વેલપ આકાર રીસેટ કરો Reset Essentials એસેન્શિયલ્સ રીસેટ કરો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 70ef7a840f..df7dcda0fa 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -4129,6 +4129,8 @@ antiAlias Sharp शार्प Reset Automation स्वचालन रीसेट करें Reset Bar Position बार स्थिति रीसेट करें Reset Bounding Box बाउंडिंग बॉक्स रीसेट करें + Rotate Bounding Box बाउंडिंग बॉक्स घुमाएँ + Rotate Bounding Box… बाउंडिंग बॉक्स घुमाएँ… Reset Envelope Mesh एन्वेलप मेश रीसेट करें Reset Envelope Shape एन्वेलप शेप रीसेट करें Reset Essentials एसेंशियल्स रीसेट करें diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index d2c87616d4..465658bf39 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3606,6 +3606,8 @@ mark-style Japanese Japán Reset Automation Automation visszaállítása Reset Bar Position Sáv helyének visszaállítása Reset Bounding Box Befoglaló keret visszaállítása + Rotate Bounding Box Befoglaló keret elforgatása + Rotate Bounding Box… Befoglaló keret elforgatása… Reset Envelope Mesh Burkolóháló visszaállítása Reset Envelope Shape Burkoló alakjának visszaállítása Reset Essentials Essentials visszaállítása diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 23ae30fb11..5264351971 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -162,6 +162,8 @@ Shear… Miringkan… Transform Each… Transformasi masing-masing… Reset Bounding Box Atur ulang kotak pembatas + Rotate Bounding Box Putar kotak pembatas + Rotate Bounding Box… Putar kotak pembatas… Arrange Susun Bring to Front Bawa ke depan Bring Forward Majukan diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index baf7565bb9..99bb0a8874 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -3085,6 +3085,8 @@ digits Malayalam Malayalam Reselect Riseleziona Reset Reimposta Reset Bounding Box Reimposta riquadro di delimitazione + Rotate Bounding Box Ruota riquadro di delimitazione + Rotate Bounding Box… Ruota riquadro di delimitazione… Reset Envelope Mesh Reimposta trama involucro Reset Envelope Shape Reimposta forma involucro Reset Essentials Reimposta Essentials diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 753b282d99..9f961b780f 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -217,6 +217,8 @@ digits Malayalam マラヤーラム数字 Shear… シアー… Transform Each… 個別に変形… Reset Bounding Box バウンディングボックスのリセット + Rotate Bounding Box バウンディングボックスの回転 + Rotate Bounding Box… バウンディングボックスの回転… Arrange 重ね順 Bring to Front 最前面へ Bring Forward 前面へ diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 6d2ac51735..aed17243fe 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -2334,6 +2334,8 @@ Shear… დახრა… Transform Each… თითოეულის გარდაქმნა… Reset Bounding Box შემომსაზღვრელი ჩარჩოს ჩამოყრა + Rotate Bounding Box შემომსაზღვრელი ჩარჩოს შემობრუნება + Rotate Bounding Box… შემომსაზღვრელი ჩარჩოს შემობრუნება… Arrange დალაგება Bring to Front წინა პლანზე გადმოტანა Bring Forward წინ გადმოტანა diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index d220bf0203..8ac14a4fa0 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -210,6 +210,8 @@ digits Malayalam 말라얄람어 Shear… 기울이기… Transform Each… 각각 변형… Reset Bounding Box 경계 상자 재설정 + Rotate Bounding Box 경계 상자 회전 + Rotate Bounding Box… 경계 상자 회전… Arrange 정렬 순서 Bring to Front 맨 앞으로 가져오기 Bring Forward 앞으로 가져오기 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 55eb3fad74..f036a57add 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -735,6 +735,8 @@ liquify-list-end {0}, {1} {0} en {1} Shear… Schuin zetten… Transform Each… Elk afzonderlijk transformeren… Reset Bounding Box Begrenzingskader herstellen + Rotate Bounding Box Begrenzingskader roteren + Rotate Bounding Box… Begrenzingskader roteren… Arrange Schikken Bring to Front Naar de voorgrond brengen Bring Forward Naar voren brengen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index b238d25053..ef6f99c45b 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -137,6 +137,8 @@ Shear… Pochyl… Transform Each… Przekształć każdy… Reset Bounding Box Resetuj obwiednię + Rotate Bounding Box Obróć obwiednię + Rotate Bounding Box… Obróć obwiednię… Arrange Ułóż Bring to Front Przenieś na wierzch Bring Forward Przesuń do przodu diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 7d4a3d4552..4f421bcbd1 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2536,6 +2536,8 @@ digits Malayalam Malaiala Reselect Resselecionar Reset Redefinir Reset Bounding Box Redefinir Caixa Delimitadora + Rotate Bounding Box Girar Caixa Delimitadora + Rotate Bounding Box… Girar Caixa Delimitadora… Reset Envelope Mesh Redefinir Malha do Envelope Reset Envelope Shape Redefinir Forma do Envelope Reset Essentials Redefinir Essentials diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index da918b1c0a..5e4e0fc825 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3072,6 +3072,8 @@ digits Malayalam Малаялам Reselect Выделить снова Reset Сбросить Reset Bounding Box Сбросить ограничительную рамку + Rotate Bounding Box Повернуть ограничительную рамку + Rotate Bounding Box… Повернуть ограничительную рамку… Reset Envelope Mesh Сбросить сетку оболочки Reset Envelope Shape Сбросить форму оболочки Reset Essentials Сбросить «Основные» diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index e166dc80ce..cb1ddf3641 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -2973,6 +2973,8 @@ digits Malayalam Malayalam Reselect Markera igen Reset Återställ Reset Bounding Box Återställ begränsningsram + Rotate Bounding Box Rotera begränsningsram + Rotate Bounding Box… Rotera begränsningsram… Reset Envelope Mesh Återställ kuvertnät Reset Envelope Shape Återställ kuvertform Reset Essentials Återställ Grundläggande diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index eaa30130ae..48c9a8c19d 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2810,6 +2810,8 @@ digits Malayalam Malayalam Reselect Yeniden seç Reset Sıfırla Reset Bounding Box Sınırlayıcı Kutuyu Sıfırla + Rotate Bounding Box Sınırlayıcı Kutuyu Döndür + Rotate Bounding Box… Sınırlayıcı Kutuyu Döndür… Reset Envelope Mesh Zarf Ağını Sıfırla Reset Envelope Shape Zarf Şeklini Sıfırla Reset Essentials Essentials'ı sıfırla diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 1840fa13b2..954dc4b7d1 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3077,6 +3077,8 @@ digits Malayalam Малаялам Reselect Виділити знову Reset Скинути Reset Bounding Box Скинути обмежувальну рамку + Rotate Bounding Box Повернути обмежувальну рамку + Rotate Bounding Box… Повернути обмежувальну рамку… Reset Envelope Mesh Скинути сітку оболонки Reset Envelope Shape Скинути форму оболонки Reset Essentials Скинути «Основні» diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 2567b8e485..65bb9e00cb 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3381,6 +3381,8 @@ mark-style Japanese Kiểu Nhật Reset all Revolve settings to their defaults. Đặt lại tất cả cài đặt Revolve về mặc định. Reset Bar Position Đặt lại vị trí thanh Reset Bounding Box Đặt lại hộp bao + Rotate Bounding Box Xoay hộp bao + Rotate Bounding Box… Xoay hộp bao… Reset Envelope Mesh Đặt lại lưới Envelope Reset Envelope Shape Đặt lại hình dạng Envelope Reset Essentials Đặt lại Essentials diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index f28919c7e3..94a62a6a6b 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2937,6 +2937,8 @@ digits Malayalam 马拉雅拉姆数字 Reselect 重新选择 Reset 重置 Reset Bounding Box 重置定界框 + Rotate Bounding Box 旋转定界框 + Rotate Bounding Box… 旋转定界框… Reset Envelope Mesh 重置封套网格 Reset Envelope Shape 重置封套形状 Reset Essentials 重置基本功能 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 613c8031b7..6017ea3259 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -4226,6 +4226,8 @@ digits Malayalam 馬來亞拉姆數字 Reselect 重新選取 Reset 重設 Reset Bounding Box 重設邊框 + Rotate Bounding Box 旋轉邊框 + Rotate Bounding Box… 旋轉邊框… Reset Envelope Mesh 重設封套網格 Reset Envelope Shape 重設封套形狀 Reset Essentials 重設基本功能 diff --git a/crates/ui-egui/src/menus/tree.rs b/crates/ui-egui/src/menus/tree.rs index 617d0d403e..4b1e9df1bd 100644 --- a/crates/ui-egui/src/menus/tree.rs +++ b/crates/ui-egui/src/menus/tree.rs @@ -770,6 +770,7 @@ pub(super) fn transform_items() -> Vec { c("Transform Each…", "object.transformEach"), Sep, c("Reset Bounding Box", "object.resetBoundingBox"), + cp("Rotate Bounding Box…", "object.rotateBoundingBox", json!({"angle": 0})), ] } diff --git a/crates/ui-egui/src/panels/transform/tests.rs b/crates/ui-egui/src/panels/transform/tests.rs index 3dff8e6a4b..a798fc75ce 100644 --- a/crates/ui-egui/src/panels/transform/tests.rs +++ b/crates/ui-egui/src/panels/transform/tests.rs @@ -82,6 +82,35 @@ fn rotation_field_shows_the_angle_the_box_keeps() { assert!(shown.iter().any(|t| t == "0°") && !shown.iter().any(|t| t == "100 pt"), "{shown:?}"); } +/// Object › Transform › Rotate Bounding Box… asks for an angle and turns the box, not the art, in +/// one undo step: the panel then shows the box's angle. +#[test] +fn rotate_bounding_box_menu_item_turns_the_box_by_the_dialog_angle() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 100, "height": 50})).unwrap(); + let entry = crate::menus::menu_entries(&app) + .into_iter() + .find(|e| e.path == ["Object", "Transform"] && e.label == "Rotate Bounding Box…") + .expect("menu item"); + let (id, p) = crate::menus::click_target(&entry.label, entry.command.as_deref().unwrap(), &entry.params); + crate::menus::invoke(&mut app, &id, p); + let d = app.ui.dialog.as_mut().expect("a dialog opens"); + assert_eq!(d.str("__command"), "object.rotateBoundingBox"); + d.fields.insert("angle".into(), json!(90)); + let bounds = |app: &VectorcraftApp| { + let st = app.session.doc().unwrap(); + st.doc.bounds_of(&st.selection.objects, false) + }; + let art = bounds(&app); + let undo = app.session.doc().unwrap().history.undo.len(); + crate::dialogs::confirm(&mut app).unwrap(); + assert_eq!(app.session.doc().unwrap().history.undo.len(), undo + 1); + assert_eq!(bounds(&app), art, "the art stays where it is"); + let shown = texts(&mut app, show); + assert!(shown.iter().any(|t| t == "90°"), "{shown:?}"); +} + /// #812: a selected live polygon shows its Polygon Properties in the Transform panel and the /// Properties panel's Transform section, and Make Sides Equal evens it out after a stretch. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 77c9dfed12..3a4b8c1511 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9627,7 +9627,11 @@ stay square to it, as in the reference app. `object.distort` turns it as the war (see Free Distort on a turned bounding box). `object.rotate {angle, absolute: true}` turns the selection to an angle (the Transform and Properties panels' Rotate field), and `object.setBounds` measures width, height and the reference point along the turned box (x, y stay page coordinates). Objects turned together share the box. A new group starts -square to the page. `object.resetBoundingBox` squares the box again without moving the art. It also squares every +square to the page. `object.rotateBoundingBox {angle}` turns the selection's box by `angle` without moving the art +(`absolute: true` turns it to `angle`; the menu's Rotate Bounding Box… asks for the angle). Selected objects with +different angles get one shared angle, and the objects inside them keep their angle relative to them. A path of a +compound path selected on its own turns or squares only its own box. A box already at the angle adds no undo step. +`object.resetBoundingBox` squares the box again without moving the art. It also squares every object inside the selected ones: the children of groups, compound paths, clip groups, blends, envelopes, repeats and intertwines, and the art of linked opacity masks (an unlinked mask's art keeps its angle). Ungroup, Release Clipping Mask, Release Compound Path, Blend Expand, Release Envelope, Release Repeat, Release Intertwine and Release Opacity Mask diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index c0ae7eee77..0de8068d4b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1055,6 +1055,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The Transform panel works out its Align to Pixel Grid checkbox once for each document revision and reuses it on later frames, and lists the selected objects' ids only when the box is clicked. The box shows the same state. With Select All of 99,500 objects (100,000 paths, 1,000 of them in 500 compound paths), working the state out on every frame took a median 33.5 ms of thread CPU time per frame in a release build on a loaded machine; the first frame after a change now takes 31.5 ms and later frames take about 1 ns (`panels::transform::tests::align_to_pixel_grid_kept_state_equals_a_full_measure`, `align_to_pixel_grid_state_is_measured_once_per_revision`, `pixel_aligned_state_timing`). - Break Link to Symbol and Object › Expand give a symbol instance's art the instance's own bounding box: after Reset Bounding Box the art stands square to the page, an object turned inside the symbol keeps its angle relative to the instance's box, a group added for the instance's opacity takes the instance's box, and the clip groups of 9-slice art take the angle of their cell. Compound shapes and Pathfinder receive an instance's art with the same angles (VectorCraft's own behavior; `bboxrotate::reset_bounding_box_then_expand_symbol_instance`, `reset_bounding_box_then_expand_keeps_the_angles_inside_the_symbol`, `expanding_a_faded_symbol_instance_gives_its_group_the_instance_box`, `expanding_a_reflected_symbol_instance_keeps_its_box`, `symbol_nine_slice::break_link_turns_the_cells_of_a_sliced_instance_with_its_box`, effects `outline_object_turns_an_instances_art_with_its_box`). - Object › Transform › Reset Bounding Box squares the box of every object inside the selected ones as well: the children of groups, compound paths, clip groups, blends, envelopes, repeats and intertwines, and the art of linked opacity masks. Ungroup and the release commands then bring back boxes square to the page (VectorCraft's own behavior; `bboxrotate::reset_bounding_box_squares_the_objects_inside_a_group`, `reset_bounding_box_squares_the_turned_members_of_a_square_group`, `reset_bounding_box_then_release_clipping_mask` and the other `reset_bounding_box_then_*` tests, `reset_bounding_box_leaves_the_art_of_an_unlinked_opacity_mask`). + - Object › Transform › Rotate Bounding Box… turns the selection's bounding box by the angle typed in its dialog without moving the art (`object.rotateBoundingBox`, `absolute: true` to set the angle). Objects with different angles get one shared angle, and the objects inside a group and the art of a linked opacity mask turn with it. A path of a compound path selected on its own turns only its own box, and Reset Bounding Box squares only that path's box too (VectorCraft's own behavior; `bboxrotate::rotate_bounding_box_turns_the_box_and_leaves_the_art`, `rotate_bounding_box_back_to_zero_stores_zero`, `rotate_bounding_box_gives_a_mixed_selection_one_angle`, `rotate_bounding_box_turns_the_objects_inside_a_group_with_it`, `rotate_bounding_box_turns_a_linked_masks_art_only`, `reset_bounding_box_squares_every_box_rotate_bounding_box_turned`, `rotate_bounding_box_refuses_bad_params`, `tests::rotate_bounding_box_of_a_compound_paths_member_turns_only_that_path`, ui-egui `panels::transform::tests::rotate_bounding_box_menu_item_turns_the_box_by_the_dialog_angle`). - After a rotation the Free Transform tool shows and drags the same turned bounding box as the Selection tool: its handles, their cursors and its rotate zone sit on the selection's own sides, a handle scales along those sides from the opposite handle ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/scale-objects.html)), Cmd/Ctrl on a side handle shears along that side, and Perspective Distort and Free Distort start from the turned box's corners (`object.distort` takes `angle` with `from`) (`bboxrotate::free_transform_handles_turn_with_the_object_and_scale_along_its_axes`, `free_transform_shears_along_the_turned_side`, `free_transform_distort_starts_from_the_turned_box`, `xform::distort_reads_from_in_a_turned_frame_and_rejects_a_bad_angle`, tools `xform::free::tests::the_box_and_its_handles_turn_with_the_selection`). - After a rotation the Scale and Reflect tools, the Scale and Reflect dialogs, `object.scale`, `object.reflect` with a named axis and the Transform and Properties panels' flips act along the selection's turned bounding box until Reset Bounding Box: the horizontal and vertical scale stretch along its own width and height, and the vertical and horizontal reflection axes are its own. The Reflect tool's default axis and its Shift steps start from the box's axes, and an axis drawn with the tool is the line drawn on the page. `basis: "page"` keeps the page's axes (VectorCraft's own rules; `bboxrotate::scale_and_reflect_follow_the_turned_box`, tools `xform::transform::tests::scale_and_reflect_drags_follow_a_turned_bounding_box`). - Perspective Distort and Free Distort (`object.distort`) turn each warped object's bounding box as the warp turns the object at its own center, the objects inside groups, compound paths and clip groups and the art of linked opacity masks included, so the next Selection or Free Transform drag uses the tilted box; Object › Transform › Reset Bounding Box squares it again, and corners left where they are add no undo step (VectorCraft's own rule; `bboxrotate::distort_turns_an_upright_box_with_the_warp_at_its_center`, `distort_turns_each_member_and_linked_mask_by_its_own_warp`, `mirrored_and_collapsing_distorts_keep_valid_angles`, `distort_angles_undo_redo_and_reopen_together`, `xform::unchanged_distort_records_no_history`).