DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge PR #764
Brandon Thomas2805b3d0412b
diff --cc ROADMAP.mdindex 03ca8e42a,bf06425bc..6872c4eb3--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -217,14 -153,10 +217,15 @@@ Newest first- **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** · The Eyedropper samples a placed image: clicking the photo with text (or objects) selected fills them with the image's colour under the pointer, as an unnamed colour (`color.sample`), as in InDesign. Images on locked layers can be sampled. 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** · 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** · A gradient feather on a group fades the group as one, on screen and in PDF. Before, the screen ignored it, and PDF masked the group with a box of zero size because a group has no path of its own. No readiness percentage change.+- **2026-10-12** · In a CMYK transparency blend space (print documents), blend modes blend in CMYK on screen as in InDesign. Color Dodge with 100% K text turns coloured areas under it white and leaves the paper alone, where RGB blending changed almost nothing. PDF export already did this. 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** · `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-13** · Dropping an `.ase` file on the window loads its swatches, as Load Swatches does (the drop failed with "Can't Place the File"). 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-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.diff --cc crates/ui-egui/src/lib.rsindex f15e2b4dd,568587759..89b3d3925--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@@ -1131,38 -969,14 +1131,42 @@@ impl DesignApp}}- /// A file dropped on the window: documents open, anything else is placed on the spread in- /// view (a parent spread while parents are being edited).+ /// A file dropped on the window: documents open, the swatches in a swatch exchange (.ase) file- /// are loaded, and anything else is placed.++ /// are loaded, and anything else is placed on the spread in view (a parent spread while parents++ /// are being edited).pub fn open_dropped(&mut self, path: &str) -> Result<Value, String> {+ self.open_dropped_at(path, None)+ }++ /// [`Self::open_dropped`] at the pointer: a graphic's top left lands where the file was+ /// dropped on the canvas, text goes to a new frame on the page there.+ pub fn open_dropped_at(&mut self, path: &str, pointer: Option<egui::Pos2>) -> Result<Value, String> {+ if path.to_ascii_lowercase().ends_with(".ase") {+ return self.run("swatch.load", json!({"path": path}));+ }- let cmd = if opens_as_document(path) { "file.open" } else { "file.place" };- self.open_file(cmd, json!({"path": path}))+ if opens_as_document(path) {+ return self.open_file("file.open", json!({"path": path}));+ }+ let mut params = json!({"path": path});+ if let (Some((sr, at)), Some(o)) = (canvas::drop_point(self, pointer), params.as_object_mut()) {+ o.insert("spread".into(), serde_json::to_value(sr).unwrap_or(Value::Null));+ o.insert("x".into(), json!(at.x));+ o.insert("y".into(), json!(at.y));+ if let (designcraft_doc::SpreadRef::Doc(si), Some(st)) = (sr, self.session.active()) {+ let pi = st.doc.spreads.get(si).and_then(|s| s.page_at_x(at.x)).unwrap_or(0);+ o.insert("page".into(), json!(st.doc.first_page_of_spread(si) + pi + 1));+ }+ }+ self.open_file("file.place", params)+ }++ /// File › Place: the file fills the selected empty or graphic frame; with none, an image loads+ /// into the place cursor (click to place at its natural size, drag to draw the frame).+ pub(crate) fn place_file(&mut self, mut params: Value) -> Result<Value, String> {+ if let Some(o) = params.as_object_mut() {+ o.insert("loadCursor".into(), json!(true));+ }+ self.open_file("file.place", params)}/// Open (`file.open`, `file.openBytes`) or place (`file.place`) a file the user chose. A file@@@ -2114,23 -1892,28 +2118,45 @@@ mod testsassert_eq!(alert(&app), ("Can't Place the File".to_string(), e));}+ #[test]+ fn a_file_dropped_while_a_parent_is_open_lands_on_the_parent() {+ let mut app = DesignApp::new(Session::new(), Services::default());+ app.run("file.new", json!({"pages": 3})).unwrap();+ app.canvas_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)));+ app.run("layout.parents.edit", json!({"on": true})).unwrap();+ let _ = app.view_mut();+ let path = std::env::temp_dir().join(format!("designcraft-ui-{}-drop.png", std::process::id()));+ std::fs::write(&path, designcraft_render::Rendered { width: 10, height: 10, pixels: vec![200; 400] }.to_png()).unwrap();+ let r = app.open_dropped(&path.to_string_lossy());+ let _ = std::fs::remove_file(&path);+ r.unwrap();+ let d = &app.session.doc().unwrap().doc;+ assert_eq!(d.parents[0].items.len(), 1, "the graphic is on the parent spread");+ assert!(d.spreads.iter().all(|s| s.items.is_empty()), "no document page gets it");+ }++ #[test]+ fn dropping_an_ase_file_loads_its_swatches() {+ let mut source = Session::new();+ source.execute("file.new", &json!({})).unwrap();+ source.execute("swatch.create", &json!({"name": "Dropped Teal", "color": "#108080"})).unwrap();+ let data = source.execute("swatch.save", &json!({"names": ["Dropped Teal"]})).unwrap();+ let bytes = designcraft_engine::cmd::base64_decode(data["base64"].as_str().unwrap());+ for name in ["palette.ase", "PALETTE.ASE"] {+ let path = std::env::temp_dir().join(format!("designcraft-ui-{}-{name}", std::process::id()));+ std::fs::write(&path, &bytes).unwrap();+ let mut app = DesignApp::new(Session::new(), Services::default());+ app.run("file.new", json!({})).unwrap();+ let r = app.open_dropped(&path.to_string_lossy());+ let _ = std::fs::remove_file(&path);+ assert!(app.ui.dialog.is_none(), "{name}: {:?}", app.ui.dialog.as_ref().map(|d| &d.fields));+ assert_eq!(r, Ok(json!({"added": 1, "replaced": 0})), "{name}");+ let doc = &app.session.doc().unwrap().doc;+ assert!(doc.swatches.iter().any(|s| s.name == "Dropped Teal"), "{name}");+ assert!(doc.assets.is_empty(), "{name} isn't placed");+ }+ }+#[test]fn file_open_failures_show_an_alert() {let path = unreadable_file("open.designcraft");