DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge branch 'pr/524' into batch1
Brandon Thomasd1452a3e3f60
diff --cc ROADMAP.mdindex ac0fbcf7a,add862906..de1bc834b--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -141,16 -132,7 +141,17 @@@ Newest first- **2026-10-12** · Window close and application/menu Quit ask about unsaved documents; later Cancel keeps every tab open, including earlier Don't Save choices. Approvals are rechecked after edits. Cancelable macOS Dock Quit remains open (#544). No readiness percentage change.- **2026-10-12** · Each running app keeps recovery data in its own locked folder; current folder and lock ownership are checked before writes and cleanup. Failed isolation disables recovery with a warning instead of sharing document IDs. No readiness percentage change.- **2026-10-12** · Native engine saves and exports replace files atomically; failed writes retain the original, private staging preserves Unix permissions, and valid long filenames work. Desktop Services and CLI raster exports remain separate follow-ups. No readiness percentage change.+- **2026-10-12** · Hyphenation Zone applies to the Single-line Composer only, as in InDesign. With the default Paragraph Composer, ragged text hyphenates where InDesign does (aper-natem), giving the same line breaks. No readiness percentage change.+- **2026-10-12** · The Tools panel's Fill/Stroke keys work: D (default fill and stroke), X (fill or stroke in front), Shift+X (swap per object, tints included) and / (Apply None), as `color.*` commands; swap and default are one undo step (`object.swapFillStroke`, `object.defaultFillStroke`); the Color panel follows the proxy's fill/stroke choice. 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** · `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** · 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-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** · 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** · 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** · 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-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-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-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-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.diff --cc crates/ui-egui/src/panels/properties.rsindex d48ac6e91,baf167447..76ddf6b42--- a/crates/ui-egui/src/panels/properties.rs+++ b/crates/ui-egui/src/panels/properties.rs@@@ -2280,134 -2234,46 +2306,177 @@@ mod testsassert_eq!(after, name, "clicking the swatch chip applies it");}+ #[test]+ fn transform_flips_and_rotates_from_properties() {+ 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]})).unwrap()["id"].as_u64().unwrap();+ app.run("selection.set", json!({"ids": [id]})).unwrap();+ let mut h = Harness::builder().with_size(vec2(320.0, 1400.0)).build_ui_state(+ |ui, app: &mut DesignApp| {+ let id = egui::Id::new("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;+ }+ show(app, ui);+ },+ app,+ );+ h.run_steps(3);+ let xf = |h: &Harness<'_, DesignApp>| h.state().session.active().unwrap().doc.item(designcraft_doc::ids::ItemId(id)).unwrap().xf;+ // Flip Horizontal mirrors the frame (a negative determinant); Flip Vertical as well brings it+ // back to a half turn, as in the tutorial's petal.+ h.get_by_label("Flip Horizontal").click();+ h.run_steps(3);+ assert!(xf(&h).determinant() < 0.0, "{:?}", xf(&h));+ h.get_by_label("Flip Vertical").click();+ h.run_steps(3);+ let c = xf(&h).as_coeffs();+ assert!((c[0] + 1.0).abs() < 1e-9 && (c[3] + 1.0).abs() < 1e-9, "a half turn: {c:?}");+ let info = h.state_mut().session.execute("transform.info", &json!({})).unwrap();+ assert!((info["rotation"].as_f64().unwrap().abs() - 180.0).abs() < 1e-6, "{info}");+ // A quarter turn clockwise from there.+ h.get_by_label("Rotate 90° Clockwise").click();+ h.run_steps(3);+ let info = h.state_mut().session.execute("transform.info", &json!({})).unwrap();+ assert!((info["rotation"].as_f64().unwrap() - 90.0).abs() < 1e-6, "{info}");+ // The angle and scale fields are there.+ assert!(h.query_by(|n| n.role() == egui::accesskit::Role::TextInput && n.value().as_deref() == Some("90°")).is_some());+ }+}++#[cfg(test)]+mod effects_panel_tests {+ use super::*;++ /// One frame of the Effects panel: the text painted and where.+ fn frame(app: &mut DesignApp, ctx: &egui::Context, events: Vec<egui::Event>) -> Vec<(String, egui::Rect)> {+ let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 400.0));+ let time = ctx.input(|i| i.time) + 1.0 / 60.0;+ let mut out =+ ctx.run_ui(egui::RawInput { screen_rect: Some(screen), time: Some(time), events, ..Default::default() }, |ui| effects_panel(app, ui));+ out.textures_delta.clear();+ let mut v = Vec::new();+ for s in out.shapes {+ if let egui::Shape::Text(t) = s.shape {+ v.push((t.galley.job.text.clone(), t.visual_bounding_rect()));+ }+ }+ v+ }++ fn click(app: &mut DesignApp, ctx: &egui::Context, label: &str) {+ let labels = frame(app, ctx, vec![]);+ let pos = labels.iter().find(|(t, _)| t == label).unwrap_or_else(|| panic!("{label} is painted")).1.center();+ for pressed in [true, false] {+ frame(+ app,+ ctx,+ vec![+ egui::Event::PointerMoved(pos),+ egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE },+ ],+ );+ }+ }++ #[test]+ fn the_effects_panel_shows_the_level_and_isolate_blending_and_knockout_group_for_groups() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), Default::default());+ app.run("file.new", json!({})).unwrap();+ let a = app.run("frame.create", json!({"rect": [72, 72, 144, 144]})).unwrap()["id"].as_u64().unwrap();+ let b = app.run("frame.create", json!({"rect": [100, 100, 200, 200]})).unwrap()["id"].as_u64().unwrap();+ let g = app.run("object.group", json!({"ids": [a, b]})).unwrap()["id"].as_u64().unwrap();+ app.run("selection.set", json!({"ids": [g]})).unwrap();+ app.run("object.opacity", json!({"opacity": 1.0, "blend": "colorDodge"})).unwrap();+ let ctx = egui::Context::default();+ crate::theme::install_fonts(&ctx, "en");+ crate::theme::apply(&ctx, &Tokens::for_brightness(crate::theme::Brightness::default()));+ let texts: Vec<String> = frame(&mut app, &ctx, vec![]).into_iter().map(|(t, _)| t).collect();+ for expected in ["Group:", "Color Dodge 100%", "Isolate Blending", "Knockout Group"] {+ assert!(texts.iter().any(|t| t == expected), "{expected} in {texts:?}");+ }+ let item = |app: &DesignApp, id: u64| app.session.doc().unwrap().doc.item(designcraft_doc::ItemId(id)).cloned().unwrap();+ click(&mut app, &ctx, "Isolate Blending");+ assert!(item(&app, g).isolate);+ click(&mut app, &ctx, "Knockout Group");+ assert!(item(&app, g).knockout);+ // Another object: the level is Object, and the group options are greyed.+ app.run("selection.set", json!({"ids": [a]})).unwrap();+ let texts: Vec<String> = frame(&mut app, &ctx, vec![]).into_iter().map(|(t, _)| t).collect();+ assert!(texts.iter().any(|t| t == "Object:"), "{texts:?}");+ click(&mut app, &ctx, "Knockout Group");+ assert!(!item(&app, a).knockout);+ }++ #[test]+ fn pasted_into_frames_keep_object_level_and_disable_group_blending() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), Default::default());+ app.run("file.new", json!({})).unwrap();+ let child = app.run("frame.create", json!({"rect": [80, 80, 120, 120]})).unwrap()["id"].clone();+ app.run("selection.set", json!({"ids": [child]})).unwrap();+ app.run("edit.copy", json!({})).unwrap();+ let container = app.run("frame.create", json!({"rect": [72, 72, 200, 200]})).unwrap()["id"].as_u64().unwrap();+ app.run("selection.set", json!({"ids": [container]})).unwrap();+ app.run("edit.pasteInto", json!({})).unwrap();+ app.run("selection.set", json!({"ids": [container]})).unwrap();+ let ctx = egui::Context::default();+ crate::theme::install_fonts(&ctx, "en");+ crate::theme::apply(&ctx, &Tokens::for_brightness(crate::theme::Brightness::default()));+ let texts: Vec<String> = frame(&mut app, &ctx, vec![]).into_iter().map(|(t, _)| t).collect();+ assert!(texts.iter().any(|t| t == "Object:"), "a frame remains an object after Paste Into: {texts:?}");+ let undo = app.session.doc().unwrap().history.undo.len();+ click(&mut app, &ctx, "Isolate Blending");+ click(&mut app, &ctx, "Knockout Group");+ let st = app.session.doc().unwrap();+ let it = st.doc.item(designcraft_doc::ItemId(container)).unwrap();+ assert!(it.has_nested_items());+ assert!(!it.isolate && !it.knockout, "group-only options stay disabled for a frame holding content");+ assert_eq!(st.history.undo.len(), undo, "disabled controls do not create undo steps");+ }+++ fn panel(app: DesignApp) -> Harness<'static, DesignApp> {+ let mut h = Harness::builder().with_size(vec2(320.0, 1400.0)).build_ui_state(+ |ui, app: &mut DesignApp| {+ let id = egui::Id::new("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;+ }+ show(app, ui);+ },+ app,+ );+ h.run_steps(3);+ h+ }++ #[test]+ fn several_shapes_show_pathfinder_and_intersect_combines_them() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let a = app.run("frame.create", json!({"rect": [100, 100, 300, 300], "shape": "ellipse"})).unwrap()["id"].clone();+ let b = app.run("frame.create", json!({"rect": [200, 100, 300, 200]})).unwrap()["id"].clone();+ // One shape: no Pathfinder section.+ app.run("selection.set", json!({"ids": [a]})).unwrap();+ let mut h = panel(app);+ assert!(h.query_by_label("Pathfinder").is_none());+ // Two: the section and its five buttons; Intersect leaves one shape, the ellipse's quarter.+ h.state_mut().run("selection.set", json!({"ids": [a, b]})).unwrap();+ h.run_steps(3);+ assert!(h.query_by_label("Pathfinder").is_some());+ for op in ["Add", "Subtract", "Intersect", "Exclude Overlap", "Minus Back"] {+ assert!(h.query_by_label(op).is_some(), "{op}");+ }+ h.get_by_label("Intersect").click();+ h.run_steps(3);+ let doc = &h.state().session.active().unwrap().doc;+ let items = &doc.spreads[0].items;+ assert_eq!(items.len(), 1, "one shape left");+ let r = items[0].bounds();+ assert!((r.x0 - 200.0).abs() < 0.5 && (r.y1 - 200.0).abs() < 0.5 && (r.x1 - 300.0).abs() < 0.5, "{r:?}");+ }}