Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge #550: Transform values act on a selected placed graphic, not its frame

aiongg4dbd73a6fde7
diff --cc ROADMAP.md
index d03828228,20bafb6fa..350479121
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -128,59 -129,12 +128,60 @@@ list) · [roadmap.md](docs/roadmap.md)
Newest first.
+ - **2026-10-12** · With a placed graphic selected (Direct Selection), the Transform values act on the graphic inside its frame, as in InDesign: a tilted frame's image can be straightened to 0°. No readiness percentage change.
+- **2026-10-11** · Font menu laid out like InDesign's: filters (classification, favourites,
+ recently added), families opening to their styles, the selected text as the sample in three
+ sizes, Recently Used fonts, Show Similar Fonts and each font's format.
+- **2026-10-12** · The Effects panel shows the level its settings apply to ("Group: Color Dodge 100%") and, as in InDesign, Isolate Blending and Knockout Group for a selected group. No readiness percentage change.
+- **2026-10-12** · Edit › Step and Repeat has its InDesign dialog: Repeat (Count, or Rows and Columns with Create as a grid), Offset (Vertical, Horizontal, in ruler units) and Preview, which shows the copies while the dialog is open; Cancel takes them away and OK makes them as one undo step. No readiness percentage change.
+- **2026-10-12** · Load Styles: the Paragraph Styles and Character Styles panels load styles from another DesignCraft document or an IDML file, with the styles, swatches and lists they name; a dialog picks the styles and what happens to one the document defines differently (`style.load`). No readiness percentage change.
+- **2026-10-12** · On screen, blend modes blend with the objects below and not with the paper, as in InDesign and in PDF export: a Color Dodge or Screen object over blank paper shows as it is. No readiness percentage change.
+- **2026-10-12** · Text threads by hand: click a selected text frame's in or out port to load
+ the text cursor, then click a frame to thread it, click empty space for a column-wide frame or
+ drag one (it snaps like frame drawing); Shift-click autoflows, Alt-click stays loaded on the
+ frame just added; click the linked frame or double-click a port to break the thread.
+ `text.thread`, `text.unthread`, `text.removeFromThread` with undo; locked frames and layers
+ refuse threads. The alpha gate now waits only on the Primary Text Frame page fixes (#165). No
+ readiness percentage change.
+- **2026-10-12** · Properties › Transform shows rotation, shear and X/Y scale, and Rotate 90° and Flip Horizontal/Vertical buttons, as InDesign's does. No readiness percentage change.
+- **2026-10-12** · Underlines and strikethroughs are drawn as one bar per stretch of text on screen, as in PDF export: a bar per letter left faint seams between the letters. No readiness percentage change.
+- **2026-10-12** · The section marker character shows its section's marker text on document pages (nothing when the section has none) instead of the word "Section", which stays on parent pages; editing the marker recomposes (#556). No readiness percentage change.
+- **2026-10-12** · IDML import keeps a font family name exactly as written, trailing spaces included, and font lookup falls back to the name without surrounding spaces; `FontStyle="Nothing"` leaves the style to the paragraph (#558). No readiness percentage change.
+- **2026-10-12** · Clipping paths saved with images in IDML (Detect Edges, Alpha Channel, Photoshop Path, User-Modified Path, inverted or not) clip the image on screen and in PDF and survive IDML export; `object.clippingPathOptions` reports, inverts or removes one (#450). No readiness percentage change.
+- **2026-10-12** · Anchored objects with text wrap push text aside: other stories' text under them and the lines of their own story after the anchor's line (#557). No readiness percentage change.
- **2026-10-12** · Words in capitals hyphenate like capitalized words (FERRUM COM-MODI), as in InDesign; Hyphenate Capitalized Words off keeps them whole. No readiness percentage change.
+- **2026-10-12** · Load Swatches refuses an `.ase` file with more than 100,000 colors, and `swatch.load` merges a file of 100,000 colors in under 0.1 s (it took 9.6 s of CPU in a test build). No readiness percentage change.
+- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.
+- **2026-10-11** · The View menu follows InDesign's: proofing first, then zoom, Rotate Spread, Screen Mode, Display Performance, rulers, Extras, Grids & Guides and Structure; the view items that sat at the end of the Type menu moved there. No readiness percentage change.
+- **2026-10-11** · Properties › Appearance's Fill and Stroke menus gain InDesign's Tint field and, for a text frame, Apply To: Frame / Text. No readiness percentage change.
+- **2026-10-11** · `story.replaceRange`, `story.setText`, notes, footnotes, endnotes, type on a path and table cells read `\r` and `\r\n` as paragraph returns, as `frame.create` and `text.insert` already did. No readiness percentage change.
+- **2026-10-11** · Corner Options keep curved sides curved and round every corner point, including where an arc meets a line (a Pathfinder quarter circle with rounded corners stayed a triangle). No readiness percentage change.
+- **2026-10-11:** Type › Justification… (Cmd+Alt+Shift+J, also in the Paragraph panel menu) sets word and letter spacing, glyph scaling and the composer on the selected paragraphs, sharing the Paragraph Style Options section (#531). No readiness percentage change.
+- **2026-10-11** · Properties gains InDesign's Pathfinder section (Add, Subtract, Intersect, Exclude Overlap, Minus Back) with several objects selected; section titles and icon buttons have accessible names. No readiness percentage change.
- **2026-10-11** · `transform.move {copy}`, Edit › Duplicate and Step and Repeat return the copies' ids, so a script can go on with them. No readiness percentage change.
- **2026-10-11** · `object.fill` and `object.stroke` refuse a swatch name the document doesn't have (it painted nothing) and suggest the name meant (`Paper` → `[Paper]`). No readiness percentage change.
-- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.
-
+- **2026-10-11** · Japanese captions now cover print ranges, imported style handling and table
+ row/column movement, including row-height distribution. Existing translation and RTL helpers
+ handle the display; command IDs, stored option values and user-defined style names are unchanged.
+- **2026-10-11** · Moving a sheared and rotated text frame no longer leaves trails of text behind: canvas repaints cover the frame's whole text box, not just its outline. No readiness percentage change.
+- **2026-10-11** · Live corners: the yellow widget on a selected rectangle frame shows corner
+ diamonds; dragging one rounds the corners, Alt-click steps the corner shape (#186).
+- **2026-10-11** · Optical kerning (#181): pairs are spaced from their outlines (ink gap per band,
+ pulled towards the font's stem gap, bounded) instead of silently using the font's kern pairs.
+- **2026-10-11** · New Document laid out like InDesign's (#325): Recent, Saved, Print, Web and
+ Mobile preset tabs beside the preset's details; saved document presets live in the engine
+ (`file.savePreset`, `file.deletePreset`, `file.new {preset}`); `file.new` takes intent, units,
+ start page and per-edge bleed and slug.
+- **2026-10-11** · macOS: fonts that font services and managers activate (Adobe Fonts,
+ RightFont) are listed, read from the files CoreText has available (#261, #327).
+- **2026-10-11:** Document pages take their parent page's margins and columns (left or right parent page by side) and follow its changes unless they have their own; parent ruler guides draw and snap on the pages based on it. IDML import marks a page margin preference that differs from its parent as the page's own. No readiness percentage change.
+- **2026-10-11** · Document Setup laid out like InDesign's: Page Size, Margins (new: every
+ page's, `layout.documentSetup {margins}`), Bleed and Slug with links, Adjust Layout.
+- **2026-10-11** · IDML reads and writes a spread's view rotation (Rotate Spread) as the
+ rotation part of the spread transform (#484).
+- **2026-10-11** · The document grid is drawn (View ▸ Grids & Guides ▸ Show/Hide Document Grid,
+ ⌘'), on the lines Snap to Document Grid uses, behind or in front of page items (#530).
+- **2026-10-12** · Double-clicking the Fill or Stroke box in the Tools panel opens the Color Picker with the selection's colour, as in InDesign (it opened the Swatches panel). No readiness percentage change.
- **2026-10-10 (UI.4–UI.5):** Panel tabs can move into other groups, split the dock, float, resize and return to their saved locations through shared docking transactions. Layouts persist in custom workspaces; UI and control commands share the same validated action path. Shared pane geometry and widget-state theme application retain all five palettes and local fonts. Split panes send keyboard input only to the focused canvas and scope contextual toolbar IDs per pane. No readiness percentage change.
- **2026-10-10** · Version 0.6.0; releases add a Linux riscv64 tar.gz (cross-compiled, CLI
smoke-tested under QEMU).
diff --cc crates/engine/src/cmd/object.rs
index cc25b3d09,dbe378e2d..2d7be8d44
--- a/crates/engine/src/cmd/object.rs
+++ b/crates/engine/src/cmd/object.rs
@@@ -135,7 -134,7 +135,7 @@@ pub fn specs() -> Vec<CommandSpec>
"Transform Panel",
[],
None,
- "{x?, y? (measured from the rulers' zero point, view.zeroPoint), width?, height?, scaleX? (%), scaleY? (%), rotation? (°), shear? (°), ref?: 0..8, ids?} — reference-point based geometry; rotation and shear are absolute (Transformations are Totals decides whether nested objects measure them on the pasteboard)",
- "{x?, y?, width?, height?, scaleX? (%), scaleY? (%), rotation? (°), shear? (°), ref?: 0..8, ids?, content?: bool (the placed graphic inside each frame; the frame stays. Default: whether the selection is content, when no ids are given)} — reference-point based geometry; rotation and shear are absolute (Transformations are Totals decides whether nested objects measure them on the pasteboard)",
++ "{x?, y? (measured from the rulers' zero point, view.zeroPoint), width?, height?, scaleX? (%), scaleY? (%), rotation? (°), shear? (°), ref?: 0..8, ids?, content?: bool (the placed graphic inside each frame; the frame stays. Default: whether the selection is content, when no ids are given)} — reference-point based geometry; rotation and shear are absolute (Transformations are Totals decides whether nested objects measure them on the pasteboard)",
has_selection,
transform_set
),
@@@ -3540,60 -2917,82 +3643,140 @@@ mod swatch_name_tests
}
}
+#[cfg(test)]
+mod copy_ids_tests {
+ use serde_json::json;
+
+ #[test]
+ fn copies_report_their_ids() {
+ let mut s = crate::Session::new();
+ s.execute("file.new", &json!({})).unwrap();
+ let a = s.execute("frame.create", &json!({"rect": [0, 0, 50, 50]})).unwrap()["id"].as_u64().unwrap();
+ let ids = |r: &serde_json::Value| r["ids"].as_array().unwrap().iter().map(|v| v.as_u64().unwrap()).collect::<Vec<_>>();
+ let selected = |s: &crate::Session| s.doc().unwrap().selection.items.iter().map(|i| i.0).collect::<Vec<_>>();
+ // Moving reports what moved; copying reports the copies, which are selected.
+ assert_eq!(ids(&s.execute("transform.move", &json!({"dx": 5, "dy": 0, "ids": [a]})).unwrap()), [a]);
+ assert_eq!(ids(&s.execute("transform.move", &json!({"dx": 5, "dy": 0, "ids": [a], "content": true})).unwrap()), [a]);
+ let r = s.execute("transform.move", &json!({"dx": 100, "dy": 0, "copy": true, "ids": [a]})).unwrap();
+ let copy = ids(&r);
+ assert!(copy.len() == 1 && copy[0] != a && s.doc().unwrap().doc.item(designcraft_doc::ItemId(copy[0])).is_some(), "{r}");
+ assert_eq!(selected(&s), copy);
+ // Edit › Duplicate.
+ let r = s.execute("edit.duplicate", &json!({})).unwrap();
+ let dup = ids(&r);
+ assert!(dup.len() == 1 && dup[0] != copy[0], "{r}");
+ assert_eq!(selected(&s), dup);
+ // Step and Repeat: every copy.
+ let r = s.execute("edit.stepAndRepeat", &json!({"count": 3, "dx": 0, "dy": 60, "ids": [a]})).unwrap();
+ assert_eq!((r["created"].as_u64(), ids(&r).len()), (Some(3), 3), "{r}");
+ assert!(ids(&r).iter().all(|i| s.doc().unwrap().doc.item(designcraft_doc::ItemId(*i)).is_some()));
+ }
+}
+
+#[cfg(test)]
+mod tint_alone_tests {
+ use serde_json::json;
+
+ #[test]
+ fn a_tint_alone_keeps_each_swatch_and_leaves_no_stroke_alone() {
+ let mut s = crate::Session::new();
+ s.execute("file.new", &json!({})).unwrap();
+ let a = s.execute("frame.create", &json!({"rect": [0, 0, 50, 50]})).unwrap()["id"].as_u64().unwrap();
+ let b = s.execute("frame.create", &json!({"rect": [60, 0, 110, 50]})).unwrap()["id"].as_u64().unwrap();
+ s.execute("object.fill", &json!({"swatch": "[Black]", "ids": [a]})).unwrap();
+ s.execute("object.fill", &json!({"swatch": "C=100 M=0 Y=0 K=0", "ids": [b]})).unwrap();
+ s.execute("object.stroke", &json!({"swatch": "[None]", "ids": [a, b]})).unwrap();
+ // Fill tint on both: each keeps its swatch.
+ s.execute("object.fill", &json!({"tint": 0.25, "ids": [a, b]})).unwrap();
+ let item = |s: &crate::Session, id: u64| s.doc().unwrap().doc.item(designcraft_doc::ItemId(id)).unwrap().clone();
+ assert_eq!((item(&s, a).fill.swatch.as_str(), item(&s, a).fill.tint), ("[Black]", 0.25));
+ assert_eq!((item(&s, b).fill.swatch.as_str(), item(&s, b).fill.tint), ("C=100 M=0 Y=0 K=0", 0.25));
+ // A swatch alone is 100%.
+ s.execute("object.fill", &json!({"swatch": "[Paper]", "ids": [a]})).unwrap();
+ assert_eq!(item(&s, a).fill.tint, 1.0);
+ // A stroke tint on no stroke: still no stroke.
+ s.execute("object.stroke", &json!({"tint": 0.5, "ids": [a]})).unwrap();
+ assert!(item(&s, a).stroke.is_none(), "{:?}", item(&s, a).stroke);
+ assert!(s.execute("object.fill", &json!({"ids": [a]})).is_err(), "neither swatch nor tint");
+ }
+}
++
+ #[cfg(test)]
+ mod content_transform_tests {
+ use serde_json::json;
+
+ use crate::Session;
+
+ /// A rotated graphic frame holding a 200 x 100 image, its content selected.
+ fn rotated_frame_with_image() -> (Session, u64) {
+ let mut s = Session::new();
+ s.execute("file.new", &json!({})).unwrap();
+ let f = s.execute("frame.create", &json!({"rect": [100, 100, 300, 300], "content": "graphic"})).unwrap()["id"].as_u64().unwrap();
+ let png = designcraft_render::Rendered { width: 200, height: 100, pixels: vec![200u8; 200 * 100 * 4] }.to_png();
+ s.execute("file.place", &json!({"base64": crate::cmd::file::base64_encode(&png), "name": "a.png", "frame": f})).unwrap();
+ s.execute("transform.rotate", &json!({"ids": [f], "angle": -45})).unwrap();
+ s.execute("selection.set", &json!({"ids": [f], "content": true})).unwrap();
+ (s, f)
+ }
+
+ #[test]
+ fn rotating_the_content_leaves_the_frame_as_it_is() {
+ let (mut s, f) = rotated_frame_with_image();
+ let before = s.execute("transform.info", &json!({"ids": [f]})).unwrap();
+ assert!((before["rotation"].as_f64().unwrap() + 45.0).abs() < 1e-6 && (before["content"]["rotation"].as_f64().unwrap() + 45.0).abs() < 1e-6);
+ // The tutorial's step: the image straightened inside its tilted frame.
+ s.execute("transform.set", &json!({"rotation": 0})).unwrap();
+ let after = s.execute("transform.info", &json!({"ids": [f]})).unwrap();
+ assert!((after["rotation"].as_f64().unwrap() + 45.0).abs() < 1e-6, "the frame stays at -45: {after}");
+ assert!(after["content"]["rotation"].as_f64().unwrap().abs() < 1e-6, "the image is upright: {after}");
+ // Scale and position act on the image too.
+ s.execute("transform.set", &json!({"scaleX": 50, "scaleY": 50})).unwrap();
+ let info = s.execute("transform.info", &json!({"ids": [f]})).unwrap();
+ assert!((info["content"]["scaleX"].as_f64().unwrap() - 50.0).abs() < 1e-6, "{info}");
+ assert!((info["rotation"].as_f64().unwrap() + 45.0).abs() < 1e-6);
+ // One undo step each.
+ s.execute("edit.undo", &json!({})).unwrap();
+ s.execute("edit.undo", &json!({})).unwrap();
+ let undone = s.execute("transform.info", &json!({"ids": [f]})).unwrap();
+ assert!((undone["content"]["rotation"].as_f64().unwrap() + 45.0).abs() < 1e-6, "{undone}");
+ }
+
+ #[test]
+ fn with_the_graphic_selected_transform_info_reports_the_graphic() {
+ let (mut s, f) = rotated_frame_with_image();
+ s.execute("transform.set", &json!({"rotation": 0})).unwrap();
+ // What the Control bar and Properties read: the graphic's 0, not the frame's -45, so a
+ // spinner step from it gives 1, not -44.
+ let info = s.execute("transform.info", &json!({})).unwrap();
+ assert!(info["rotation"].as_f64().unwrap().abs() < 1e-6, "{info}");
+ let rot = info["rotation"].as_f64().unwrap() + 1.0;
+ s.execute("transform.set", &json!({"rotation": rot})).unwrap();
+ let after = s.execute("transform.info", &json!({"ids": [f]})).unwrap();
+ assert!((after["content"]["rotation"].as_f64().unwrap() - 1.0).abs() < 1e-6, "{after}");
+ assert!((after["rotation"].as_f64().unwrap() + 45.0).abs() < 1e-6, "the frame stays: {after}");
+ // `id` names the target explicitly, like `ids`: the frame.
+ let by_id = s.execute("transform.info", &json!({"id": f})).unwrap();
+ assert!((by_id["rotation"].as_f64().unwrap() + 45.0).abs() < 1e-6, "{by_id}");
+ }
+
+ #[test]
+ fn a_locked_frame_records_no_undo_step() {
+ let (mut s, f) = rotated_frame_with_image();
+ s.execute("object.lock", &json!({"ids": [f]})).unwrap();
+ s.execute("selection.set", &json!({"ids": [f], "content": true})).unwrap();
+ let undo = s.doc().unwrap().history.undo.len();
+ assert_eq!(s.execute("transform.set", &json!({"rotation": 0})).unwrap()["changed"], 0);
+ assert_eq!(s.doc().unwrap().history.undo.len(), undo, "no empty undo step");
+ }
+
+ #[test]
+ fn a_frame_selection_still_transforms_the_frame_and_an_empty_frame_has_no_content() {
+ let (mut s, f) = rotated_frame_with_image();
+ // `content: false` (or a frame selection) turns frame and image together.
+ s.execute("transform.set", &json!({"rotation": 0, "content": false})).unwrap();
+ let info = s.execute("transform.info", &json!({"ids": [f]})).unwrap();
+ assert!(info["rotation"].as_f64().unwrap().abs() < 1e-6, "{info}");
+ let e = s.execute("frame.create", &json!({"rect": [400, 100, 500, 200], "content": "graphic"})).unwrap()["id"].as_u64().unwrap();
+ assert!(s.execute("transform.set", &json!({"ids": [e], "content": true, "rotation": 10})).is_err());
+ }
+ }
diff --cc crates/ui-egui/src/panels/mod.rs
index 41565d1c4,c8b597d8a..2854f661f
--- a/crates/ui-egui/src/panels/mod.rs
+++ b/crates/ui-egui/src/panels/mod.rs
@@@ -727,88 -707,31 +735,117 @@@ mod font_menu_ui_tests
}
}
+#[cfg(test)]
+mod swatch_list_tests {
+ use super::*;
+
+ fn rects(shapes: &[egui::epaint::ClippedShape]) -> Vec<(egui::Rect, egui::Color32)> {
+ fn walk(s: &egui::Shape, out: &mut Vec<(egui::Rect, egui::Color32)>) {
+ match s {
+ egui::Shape::Rect(r) => out.push((r.rect, r.fill)),
+ egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),
+ _ => {}
+ }
+ }
+ let mut out = vec![];
+ shapes.iter().for_each(|s| walk(&s.shape, &mut out));
+ out
+ }
+
+ fn texts(shapes: &[egui::epaint::ClippedShape]) -> Vec<(String, egui::Rect)> {
+ fn walk(s: &egui::Shape, out: &mut Vec<(String, egui::Rect)>) {
+ match s {
+ egui::Shape::Text(t) => out.push((t.galley.job.text.clone(), t.visual_bounding_rect())),
+ egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),
+ _ => {}
+ }
+ }
+ let mut out = vec![];
+ shapes.iter().for_each(|s| walk(&s.shape, &mut out));
+ out
+ }
+
+ #[test]
+ fn the_swatch_under_the_pointer_is_highlighted_and_names_clear_the_scroll_bar() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", serde_json::json!({})).unwrap();
+ // A long name, as process swatches have.
+ app.run("swatch.create", serde_json::json!({"name": "C=15 M=100 Y=100 K=0 Long Name", "color": {"c": 15, "m": 100, "y": 100, "k": 0}}))
+ .unwrap();
+ let long = "C=15 M=100 Y=100 K=0 Long Name";
+ let ctx = egui::Context::default();
+ crate::theme::install_fonts(&ctx, "");
+ let tokens = Tokens::for_brightness(crate::theme::Brightness::MediumDark);
+ crate::theme::apply(&ctx, &tokens);
+ let mut time = 0.0;
+ let mut frame = |app: &mut DesignApp, events: Vec<egui::Event>| {
+ time += 0.1;
+ let raw = egui::RawInput {
+ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 700.0))),
+ time: Some(time),
+ events,
+ ..Default::default()
+ };
+ let mut out = ctx.run_ui(raw, |ui| swatch_picker(app, ui, "list", Some("[Black]".into()), |_, _| {}));
+ out.textures_delta.clear();
+ out.shapes
+ };
+ frame(&mut app, vec![]);
+ let chip = egui::pos2(17.0, 17.0);
+ for pressed in [true, false] {
+ frame(
+ &mut app,
+ vec![
+ egui::Event::PointerMoved(chip),
+ egui::Event::PointerButton { pos: chip, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() },
+ ],
+ );
+ }
+ let shapes = frame(&mut app, vec![]);
+ let (_, name) = texts(&shapes).into_iter().find(|(t, _)| t == "[Registration]").expect("the list is open");
+ let pointer = name.center();
+ frame(&mut app, vec![egui::Event::PointerMoved(pointer)]);
+ let shapes = frame(&mut app, vec![]);
+ let all = rects(&shapes);
+ let (row, _) = *all.iter().find(|(r, c)| *c == tokens.accent_strong && r.contains(pointer)).expect("the hovered row is highlighted");
+ let (list, _) = *all
+ .iter()
+ .filter(|(r, c)| *c == tokens.panel && r.contains_rect(row))
+ .min_by(|a, b| a.0.area().total_cmp(&b.0.area()))
+ .expect("the popup");
+ let scroll = ctx.global_style().spacing.scroll;
+ assert!(row.right() + scroll.bar_width <= list.right(), "rows {row:?} stop short of the scroll bar in {list:?}");
+ let (_, long_rect) = texts(&shapes).into_iter().find(|(t, _)| t == long).unwrap();
+ assert!(long_rect.right() <= row.right(), "the longest name {long_rect:?} fits its row {row:?}");
+ assert!(texts(&shapes).iter().any(|(t, r)| t == "[Black]" && r.right() <= row.right()));
+ }
+}
++
+ #[cfg(test)]
+ mod content_selection_tests {
+ use serde_json::json;
+
+ /// With a placed graphic selected (Direct Selection), X/Y/W/H are the graphic's: what the
+ /// Transform fields then set.
+ #[test]
+ fn a_selected_graphic_shows_its_own_bounds() {
+ let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let f = app.run("frame.create", json!({"rect": [100, 100, 300, 300], "content": "graphic"})).unwrap()["id"].clone();
+ let png = designcraft_render::Rendered { width: 400, height: 400, pixels: vec![200u8; 400 * 400 * 4] }.to_png();
+ let b64 = designcraft_engine::cmd::base64_encode(&png);
+ app.run("file.place", json!({"base64": b64, "name": "a.png", "frame": f})).unwrap();
+ app.run("selection.set", json!({"ids": [f]})).unwrap();
+ let frame = super::sel_info(&app).unwrap().page_rect;
+ assert!((frame.width() - 200.0).abs() < 1e-6, "{frame:?}");
+ app.run("selection.set", json!({"ids": [f], "content": true})).unwrap();
+ // Placing fitted it to 50%: back to its own 400 pt.
+ app.run("transform.set", json!({"scaleX": 100, "scaleY": 100})).unwrap();
+ let g = super::sel_info(&app).unwrap().page_rect;
+ assert!((g.width() - 400.0).abs() < 1e-6, "the graphic's width, not the frame's: {g:?}");
+ // So a width typed from it scales the graphic by that ratio, not by half.
+ app.run("transform.set", json!({"width": 401})).unwrap();
+ let after = super::sel_info(&app).unwrap().page_rect;
+ assert!((after.width() - 401.0).abs() < 1e-6, "{after:?}");
+ }
+ }