Skip to content

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

Merge PR #1390: Properties: Text Wrap shows the four wrap offsets, as in the reference app

aiongge703cd6f2468
diff --cc ROADMAP.md
index 1810a80e0,4f59b82b2..6245d69bf
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -455,11 -443,7 +455,12 @@@ Newest first
- **2026-10-16** · Lock Guides and Lock Column Guides are commands in View ▸ Grids & Guides (`view.lockGuides`, ⌥⌘;, and `view.lockColumnGuides`), so the control channel and MCP reach them. Lock Column Guides is an undo step, is saved with the document, on in new ones, and read from and written to IDML's `ColumnGuideLocked`, which export always wrote as locked (#1096). No readiness percentage change.
- **2026-10-16** · IDML: a page keeps column guides that were dragged off centre (InDesign's Custom columns). They were divided evenly on import, so the gutter sprang back to the middle; the imported positions now place the columns, with the canvas guides, snapping and text placement following them, and they are written back on export. Layout › Margins and Columns re-divides them evenly when the count or gutter changes, as InDesign's does. No readiness percentage change.
- **2026-10-16** · IDML: custom column positions are checked before they are used (#1096). A set must give two edges per column, ascending from the left margin to the right one; any other (a wrong count, unsorted or non-numeric values, a list longer than 216 columns allow, or positions left behind by a margin or page-size change) is the even split, in the canvas, on import and on export, instead of columns drawn outside the margins. No readiness percentage change.
+- **2026-10-21** · Effects dialog: the Angle field of the shadows, Bevel and Emboss, Satin and Gradient Feather has InDesign's dial beside it, its radius pointing where the light comes from; a click or drag on it sets the angle. Found in the Learn Skills Daily course, chapter 14. No readiness percentage change.
+- **2026-10-21** · A double-click on a Fill or Stroke chip of Properties › Appearance opens the Color Picker with its colour, as in InDesign (a click still opens the swatches); for selected text, its own chips open it for the text. Found in the Learn Skills Daily course, chapter 23. No readiness percentage change.
+- **2026-10-20** · Properties › Appearance: with several text frames selected, the Fill and Stroke popups offer Apply To Frame or Text, as with one frame, so their text can be coloured at once, as in InDesign. No readiness percentage change.
+- **2026-10-20** · Properties › Appearance: the arrow beside Opacity opens a slider under the field, as in InDesign, instead of the Effects panel; a drag shows the opacity live and is one undo step (the Opacity link still opens Effects). No readiness percentage change.
+- **2026-10-20** · Properties › Frame Fitting has InDesign's Auto-Fit checkbox and Options button (Frame Fitting Options); the app's checkboxes are now named and ticked-or-not for screen readers. No readiness percentage change.
+ - **2026-10-20** · Properties › Text Wrap shows the four wrap offsets under the wrap buttons, with the link that makes them the same, as InDesign's Properties panel does (greyed with no wrap). No readiness percentage change.
- **2026-10-21** · Properties › Character and Paragraph: ••• (More Options) expands the section in place, as InDesign's: Character adds vertical and horizontal scale, baseline shift, skew, language and OpenType, and All Caps, Small Caps, Superscript, Subscript, Underline and Strikethrough; Paragraph adds the left, right, first line and last line indents, space before and after, the drop cap's lines and characters, Align to Baseline Grid and Hyphenate. It used to open the Character or Paragraph panel; the language field moved under ••• as in InDesign. Found in the Learn Skills Daily course, chapter 16. No readiness percentage change.
- **2026-10-21** · The text Control panel has InDesign's two modes: A (Character Formatting Controls: font and style, size and leading, All Caps/Superscript/Underline and Small Caps/Subscript/Strikethrough, kerning and tracking, vertical and horizontal scale, baseline shift and skew, character style and language) and ¶ (Paragraph Formatting Controls: the nine alignments, left/first line and right/last line indents, space before and after, the drop cap's lines and characters, paragraph style, Hyphenate and Align to Baseline Grid). It used to show a fixed mix of both. Found in the Learn Skills Daily course, chapter 16. No readiness percentage change.
- **2026-10-20** · With the Type tool, the Control panel's font size, leading and tracking fields have a spinner and a list of common values, as in InDesign (auto leading in parentheses). No readiness percentage change.
diff --cc crates/ui-egui/src/panels/properties/tests.rs
index 28c9ba525,1ac82ab9f..b3a8e7953
--- a/crates/ui-egui/src/panels/properties/tests.rs
+++ b/crates/ui-egui/src/panels/properties/tests.rs
@@@ -770,90 -710,71 +770,155 @@@ fn several_shapes_show_pathfinder_and_i
assert!((r.x0 - 200.0).abs() < 0.5 && (r.y1 - 200.0).abs() < 0.5 && (r.x1 - 300.0).abs() < 0.5, "{r:?}");
}
+/// The arrow beside Opacity opens a slider, as in InDesign: a drag shows the opacity live and
+/// is one undo step; the Opacity link still opens the Effects panel.
+#[test]
+fn the_opacity_arrow_opens_a_slider_and_a_drag_is_one_undo_step() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let id = app.run("frame.create", json!({"rect": [72, 72, 300, 200], "shape": "rectangle"})).unwrap()["id"].as_u64().unwrap();
+ app.run("selection.set", json!({"ids": [id]})).unwrap();
+ let opacity = |app: &DesignApp| app.session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().opacity;
+ let steps = undo_steps(&app);
+ let mut h = Harness::builder().with_size(vec2(320.0, 1400.0)).build_ui_state(
+ |ui, app: &mut DesignApp| {
+ let id = egui::Id::unique("test_fonts");
+ if ui.data(|d| d.get_temp::<bool>(id)).is_none() {
+ crate::theme::install_fonts(ui.ctx(), "");
+ ui.data_mut(|d| d.insert_temp(id, true));
+ return;
+ }
+ app.settle_live_preview();
+ show(app, ui);
+ },
+ app,
+ );
+ h.run_steps(3);
+ assert!(h.query_by_role(egui::accesskit::Role::Slider).is_none());
+ h.get_by(|n| n.role() == egui::accesskit::Role::Button && n.label().as_deref() == Some("Opacity")).click();
+ h.run_steps(3);
+ assert!(
+ h.query_by(|n| n.role() == egui::accesskit::Role::Slider && n.label().as_deref() == Some("Opacity")).is_some(),
+ "assistive technology names the slider"
+ );
+ let track = h.get_by_role(egui::accesskit::Role::Slider).rect();
+ let y = track.center().y;
+ h.hover_at(egui::pos2(track.right() - 1.0, y));
+ h.run_steps(1);
+ h.drag_at(egui::pos2(track.right() - 1.0, y));
+ h.run_steps(1);
+ for k in 1..=5 {
+ h.hover_at(egui::pos2(track.right() - track.width() * 0.05 * k as f32, y));
+ h.run_steps(1);
+ assert_eq!(undo_steps(h.state()), steps, "no undo step while dragging");
+ }
+ let previewed = opacity(h.state());
+ assert!(previewed < 0.9 && previewed > 0.5, "the drag shows the opacity live: {previewed}");
+ // Let go further along than the last move: the release frame changes the value too.
+ h.drop_at(egui::pos2(track.right() - track.width() * 0.3, y));
+ h.run_steps(3);
+ assert_eq!(undo_steps(h.state()), steps + 1, "the whole drag is one undo step");
+ assert!(opacity(h.state()) < previewed, "the release position is applied: {previewed} → {}", opacity(h.state()));
+ assert_ne!(h.state().ui.open_panel.as_deref(), Some("effects"), "the arrow doesn't open Effects");
+ h.state_mut().run("edit.undo", json!({})).unwrap();
+ assert_eq!(opacity(h.state()), 1.0);
+}
+
+/// Properties › Frame Fitting has Auto-Fit and an Options button, as InDesign's: ticking
+/// Auto-Fit makes the picture refit when its frame is resized.
+#[test]
+fn properties_frame_fitting_sets_auto_fit_and_opens_its_options() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let id = app.run("frame.create", json!({"rect": [72, 72, 272, 172]})).unwrap()["id"].as_u64().unwrap();
+ let png = designcraft_render::Rendered { width: 40, height: 20, pixels: vec![200; 40 * 20 * 4] }.to_png();
+ app.run("file.place", json!({"base64": designcraft_engine::cmd::base64_encode(&png), "name": "p.png", "frame": id})).unwrap();
+ app.run("selection.set", json!({"ids": [id]})).unwrap();
+ let graphic = |app: &DesignApp| app.session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().graphic().unwrap().clone();
+ assert_eq!(graphic(&app).auto_fit, designcraft_doc::Fitting::None);
+ let mut h = panel(app);
+ // A checkbox its section disables says so: Invert, with no text wrap.
+ use egui_kittest::kittest::NodeT;
+ assert!(h.get_by_label("Invert").accesskit_node().is_disabled());
+ assert!(!h.get_by_label("Auto-Fit").accesskit_node().is_disabled());
+ h.get_by_label("Auto-Fit").click();
+ h.run_steps(3);
+ assert_ne!(graphic(h.state()).auto_fit, designcraft_doc::Fitting::None, "Auto-Fit is on");
+ // The frame resized: the picture follows it.
+ h.state_mut().run("transform.resize", json!({"from": [72, 72, 272, 172], "to": [72, 72, 372, 272]})).unwrap();
+ let g = graphic(h.state());
+ let r = g.xf.transform_rect_bbox(designcraft_geom::Rect::new(0.0, 0.0, g.size.0, g.size.1));
+ assert!(r.width() > 250.0, "refitted to the larger frame: {r:?}");
+ h.get_by_label("Options").click();
+ h.run_steps(3);
+ assert!(h.state().ui.dialog.is_some(), "Frame Fitting Options opens");
+}
+
+ /// Properties › Text Wrap shows the four offsets under the wrap buttons, as InDesign's
+ /// Properties panel does: linked at first, so one value sets all four; unlinked, one side.
+ #[test]
+ fn properties_text_wrap_shows_and_sets_the_offsets() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let id = app.run("frame.create", json!({"rect": [72, 72, 300, 200], "shape": "rectangle"})).unwrap()["id"].as_u64().unwrap();
+ app.run("selection.set", json!({"ids": [id]})).unwrap();
+ app.run("object.textWrap", json!({"mode": "boundingBox", "offset": 0})).unwrap();
+ let offsets = |app: &DesignApp| app.session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().wrap.offsets;
+ let mut h = panel(app);
+ // The fields between the Text Wrap heading and Quick Actions: Top, Left, Bottom, Right.
+ let fields = |h: &Harness<'_, DesignApp>| {
+ let (top, bottom) = (h.get_by_label("Text Wrap").rect().bottom(), h.get_by_label("Quick Actions").rect().top());
+ let mut v: Vec<egui::Rect> =
+ h.get_all_by_role(egui::accesskit::Role::TextInput).map(|n| n.rect()).filter(|r| r.center().y > top && r.center().y < bottom).collect();
+ v.sort_by(|a, b| (a.top(), a.left()).partial_cmp(&(b.top(), b.left())).unwrap());
+ v
+ };
+ let f = fields(&h);
+ assert_eq!(f.len(), 4, "four offsets: {f:?}");
+ let type_in = |h: &mut Harness<'_, DesignApp>, at: egui::Rect, text: &str| {
+ h.hover_at(at.center());
+ h.drag_at(at.center());
+ h.drop_at(at.center());
+ h.run_steps(2);
+ h.event(egui::Event::Key { key: egui::Key::A, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::COMMAND });
+ h.event(egui::Event::Text(text.into()));
+ h.key_press(egui::Key::Enter);
+ h.run_steps(3);
+ };
+ // Linked: the top offset sets all four.
+ type_in(&mut h, f[0], "12pt");
+ assert_eq!(offsets(h.state()), [12.0; 4]);
+ // Unlinked: the bottom one alone.
+ let (top, bottom) = (h.get_by_label("Text Wrap").rect().bottom(), h.get_by_label("Quick Actions").rect().top());
+ h.get_all_by_label("Make all settings the same").find(|n| n.rect().center().y > top && n.rect().center().y < bottom).unwrap().click();
+ h.run_steps(2);
+ let f = fields(&h);
+ type_in(&mut h, f[2], "6pt");
+ assert_eq!(offsets(h.state()), [12.0, 12.0, 6.0, 12.0], "[top, left, bottom, right]");
+ // Two objects with different offsets: a side typed in changes that side on each, and
+ // each keeps its other three.
+ let other = h.state_mut().run("frame.create", json!({"rect": [72, 300, 300, 400], "shape": "rectangle"})).unwrap()["id"].as_u64().unwrap();
+ h.state_mut().run("object.textWrap", json!({"mode": "contour", "offset": [3, 4, 5, 6], "ids": [other]})).unwrap();
+ let of =
+ |h: &Harness<'_, DesignApp>, id: u64| h.state().session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().wrap.offsets;
+ h.state_mut().run("selection.set", json!({"ids": [id, other]})).unwrap();
+ h.run_steps(3);
+ let f = fields(&h);
+ type_in(&mut h, f[0], "9pt");
+ assert_eq!((of(&h, id), of(&h, other)), ([9.0, 12.0, 6.0, 12.0], [9.0, 4.0, 5.0, 6.0]), "the top alone, on each");
+ let mode =
+ |h: &Harness<'_, DesignApp>, id: u64| h.state().session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().wrap.mode;
+ assert_eq!((mode(&h, id), mode(&h, other)), (designcraft_doc::WrapMode::BoundingBox, designcraft_doc::WrapMode::Contour), "each keeps its mode");
+ // An object whose offsets are the same starts linked, though the link was off before.
+ let third = h.state_mut().run("frame.create", json!({"rect": [320, 72, 500, 200], "shape": "rectangle"})).unwrap()["id"].as_u64().unwrap();
+ h.state_mut().run("object.textWrap", json!({"mode": "boundingBox", "offset": 4, "ids": [third]})).unwrap();
+ h.state_mut().run("selection.set", json!({"ids": [third]})).unwrap();
+ h.run_steps(3);
+ let f = fields(&h);
+ type_in(&mut h, f[2], "8pt");
+ assert_eq!(of(&h, third), [8.0; 4], "linked again for this selection");
+ }
+
const CYAN: &str = "C=100 M=0 Y=0 K=0";
#[test]