DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge branch 'codex/page-tool-control-panel' into codex/liquid-object-pins
moppeeer2a9e29f6ff53
diff --cc ROADMAP.mdindex 5c16da0c0,8ac26c2a1..beb30ae92--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -129,9 -128,15 +128,17 @@@ list) · [roadmap.md](docs/roadmap.md)Newest first.+- **2026-10-14** · With the Page tool, the Control panel shows the page as InDesign's does: W/H from a reference point, page-size preset (US Business Card added), orientation, Liquid Page Rule (now with Controlled by Parent) and Show Parent Page Overlay, which draws the parent page's size over a resized page. No readiness percentage change.+- **2026-10-14** · On an object-based page the Page tool shows a selected object's liquid pins and resize locks as InDesign does: a click pins a side to the page edge or locks the width or height, with InDesign's tooltips. No readiness percentage change.+ - **2026-10-14** · With the Page tool, the Control panel shows the page as InDesign's does: W/H from a reference point, page-size preset (US Business Card added), orientation, Liquid Page Rule and Show Parent Page Overlay, which draws the parent page's size over a resized page. No readiness percentage change.- **2026-10-14** · The Page tool works as InDesign's: a click selects a page and shows its handles and liquid page rule; dragging a handle previews the rule and springs back, Alt-drag resizes the page from the opposite edge, Shift keeps proportions, with a W/H readout. 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** · macOS Dock Quit uses the same unsaved-document prompts as window and menu Quit. Repeated requests keep the current answers; Cancel retains every tab and unsaved recovery checkpoint, and completed Save/Don't Save answers exit through the ordinary event loop. No readiness percentage change.- **2026-10-12** · Orderly native exit writes the latest recovery state after finalizing current quit approvals; incomplete or stale plans keep their documents, and Undo to the saved state clears stale recovery. Unavailable or failed recovery is reported. Cancelable macOS Dock Quit remains open (#544). No readiness percentage change.- **2026-10-12** · Recovered documents keep a checkpoint until saved, closed or reverted, including a second crash before autosave. Restarted document IDs and explicit recovery folders preserve other snapshots; failed republishing retains the original. No readiness percentage change.diff --cc crates/engine/src/tests.rsindex af54bb942,a89c579e1..e74485df3--- a/crates/engine/src/tests.rs+++ b/crates/engine/src/tests.rs@@@ -668,58 -668,102 +668,158 @@@ fn controlled_by_parent_takes_the_parenassert!(s.execute("layout.pageOptions", &json!({"pages": [2], "showParentOverlay": true})).is_err());}+#[test]+fn page_tool_pins_and_locks_objects_on_object_based_pages() {+ use designcraft_tools::{CanvasLayout, Mods, PointerEvent, PointerKind};+ let mut s = Session::new();+ s.execute("file.new", &json!({"width": 612, "height": 792, "facingPages": false})).unwrap();+ let id = s.execute("frame.create", &json!({"rect": [256, 72, 356, 132]})).unwrap()["id"].as_u64().unwrap();+ s.execute("liquid.pageRule", &json!({"rule": "objectBased"})).unwrap();+ s.execute("edit.deselectAll", &json!({})).unwrap();+ s.set_tool("page");+ let v = ViewInfo::at_zoom(1.0);+ let ev =+ |kind, p: designcraft_geom::Point, alt: bool| PointerEvent { mods: Mods { alt, ..Default::default() }, ..PointerEvent::new(kind, p.x, p.y) };+ let canvas = |s: &Session| {+ let d = &s.doc().unwrap().doc;+ let l = CanvasLayout::new(d, false);+ (+ l.page_rect(d, 0).unwrap(),+ l.xf(designcraft_doc::SpreadRef::Doc(0)).transform_rect_bbox(d.item(designcraft_doc::ItemId(id)).unwrap().bounds()),+ )+ };+ let click = |s: &mut Session, p: designcraft_geom::Point| {+ s.pointer(&ev(PointerKind::Down, p, false), v).unwrap();+ s.pointer(&ev(PointerKind::Up, p, false), v).unwrap();+ };+ let liquid = |s: &Session| s.doc().unwrap().doc.item(designcraft_doc::ItemId(id)).unwrap().liquid;+ // A click on the object selects it with its page; its pins and locks show.+ let (_, o) = canvas(&s);+ click(&mut s, o.center());+ let sel = s.doc().unwrap().selection.clone();+ assert_eq!((sel.page, sel.items.clone()), (Some(0), vec![designcraft_doc::ItemId(id)]));+ assert!(+ s.overlays(v)+ .iter()+ .any(|o| matches!(o, designcraft_tools::Overlay::LiquidPins { pins: [false, false, false, false], resize: [true, true], .. }))+ );+ // The right pin (14 px outside the right edge) and the width lock (10 px right of the centre).+ click(&mut s, designcraft_geom::Point::new(o.x1 + 14.0, o.center().y));+ click(&mut s, designcraft_geom::Point::new(o.center().x + 10.0, o.center().y));+ let l = liquid(&s).unwrap();+ assert!(l.pin_right && !l.resize_width && l.resize_height && !l.pin_left, "{l:?}");+ // Alt-drag the page 100 pt wider: the pinned, width-locked frame keeps its size by the right edge.+ let (p, _) = canvas(&s);+ let right = designcraft_geom::Point::new(p.x1, p.center().y);+ s.pointer(&ev(PointerKind::Down, right, true), v).unwrap();+ s.pointer(&ev(PointerKind::Drag, right + designcraft_geom::Vec2::new(100.0, 0.0), true), v).unwrap();+ s.pointer(&ev(PointerKind::Up, right + designcraft_geom::Vec2::new(100.0, 0.0), true), v).unwrap();+ let d = &s.doc().unwrap().doc;+ let (pg, b) = (&d.spreads[0].pages[0], d.item(designcraft_doc::ItemId(id)).unwrap().bounds());+ assert_eq!(pg.width, 712.0);+ assert!((b.width() - 100.0).abs() < 1e-6 && (pg.x + pg.width - b.x1 - 256.0).abs() < 1e-6, "{b:?}");+ // Hovering a pin shows its tooltip.+ let (_, o) = canvas(&s);+ s.pointer(&ev(PointerKind::Move, designcraft_geom::Point::new(o.x1 + 14.0, o.center().y), false), v).unwrap();+ assert!(s.overlays(v).iter().any(|o| matches!(o, designcraft_tools::Overlay::Tip { text, .. } if text.starts_with("Object is pinned"))));+}+++ /// Load the text from a frame's out port with the Selection tool and click on the pasteboard:+ /// a new frame is threaded there and the overset text flows into it.+ #[test]+ fn threading_with_the_loaded_text_cursor_on_the_sample() {+ use designcraft_tools::{PointerEvent, PointerKind};+ let mut s = Session::new();+ s.execute("file.newSample", &json!({})).unwrap();+ let d = s.doc().unwrap().doc.clone();+ let (sid, first) = d.stories.values().find(|st| st.frames.len() >= 2).map(|st| (st.id, st.frames[0])).expect("a threaded story");+ // Break the thread so the first frame is overset, and select it.+ s.execute("text.unthread", &json!({"frame": first.0})).unwrap();+ assert!(s.cache.get(&s.doc().unwrap().doc, sid, None).is_overset());+ s.execute("selection.set", &json!({"ids": [first.0]})).unwrap();+ s.set_tool("selection");+ let v = ViewInfo::at_zoom(1.0);+ let layout = s.layout();+ let port = designcraft_tools::thread::port_center(&s.doc().unwrap().doc, &layout, first, true, v.zoom).unwrap();+ let ev = |k, p: designcraft_geom::Point| PointerEvent::new(k, p.x, p.y);+ s.pointer(&ev(PointerKind::Down, port), v).unwrap();+ s.pointer(&ev(PointerKind::Up, port), v).unwrap();+ assert_eq!(s.cursor(port + designcraft_geom::Vec2::new(-2000.0, 0.0), Default::default(), v), designcraft_tools::Cursor::LoadedText);+ // On the pasteboard left of the first spread.+ let b = layout.slots[0].bounds;+ let at = designcraft_geom::Point::new(b.x0 - 300.0, b.y0 + 100.0);+ let undo = s.doc().unwrap().history.undo.len();+ s.pointer(&ev(PointerKind::Down, at), v).unwrap();+ s.pointer(&ev(PointerKind::Up, at), v).unwrap();+ let st = s.doc().unwrap();+ assert_eq!(st.history.undo.len(), undo + 1, "one undo step");+ let frames = st.doc.story(sid).unwrap().frames.clone();+ assert_eq!(frames.len(), 2);+ let new = frames[1];+ assert_eq!(st.selection.items, [new]);+ let cs = s.cache.get(&s.doc().unwrap().doc, sid, None);+ assert!(cs.frames.iter().any(|f| f.frame == new && !f.range.is_empty()), "the text flows into the new frame");+ let nb = s.doc().unwrap().doc.item(new).unwrap().bounds();+ assert!((nb.y0 - layout.to_spread(designcraft_doc::SpreadRef::Doc(0), at).y).abs() < 1e-6, "{nb:?}");+ }++ /// Drag a selection handle of item 0 on spread 0 from the edge point `at` by `by` (canvas units).+ fn drag_handle(s: &mut Session, at: designcraft_geom::Point, by: designcraft_geom::Vec2, v: ViewInfo) {+ use designcraft_tools::{PointerEvent, PointerKind};+ let p = s.layout().to_canvas(designcraft_doc::SpreadRef::Doc(0), at);+ s.pointer(&PointerEvent::new(PointerKind::Down, p.x, p.y), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Drag, p.x + by.x / 2.0, p.y + by.y / 2.0), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Drag, p.x + by.x, p.y + by.y), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Up, p.x + by.x, p.y + by.y), v).unwrap();+ }++ #[test]+ fn text_frame_resize_snaps_to_the_margins() {+ use designcraft_geom::{Point, Vec2};+ for zoom in [1.0, 0.5] {+ let mut s = Session::new();+ s.execute("file.newSample", &json!({})).unwrap();+ let margin = s.doc().unwrap().doc.spreads[0].pages[0].margin_rect();+ let (x0, y0) = (margin.x0 + 40.0, margin.y0 + 40.0);+ s.execute("frame.create", &json!({"rect": [x0, y0, x0 + 200.0, y0 + 200.0], "content": "text"})).unwrap();+ s.set_tool("selection");+ let v = ViewInfo::at_zoom(zoom);+ let b0 = s.doc().unwrap().doc.spreads[0].items.last().unwrap().bounds();+ // Right handle to 1.5 pt short of the right margin.+ drag_handle(&mut s, Point::new(b0.x1, b0.center().y), Vec2::new(margin.x1 - 1.5 - b0.x1, 0.0), v);+ let b = s.doc().unwrap().doc.spreads[0].items.last().unwrap().bounds();+ assert!((b.x1 - margin.x1).abs() < 1e-6, "zoom {zoom}: right edge {} not on the margin {}", b.x1, margin.x1);+ // Bottom handle to 1.5 pt past the bottom margin.+ drag_handle(&mut s, Point::new(b.center().x, b.y1), Vec2::new(0.0, margin.y1 + 1.5 - b.y1), v);+ let b = s.doc().unwrap().doc.spreads[0].items.last().unwrap().bounds();+ assert!((b.y1 - margin.y1).abs() < 1e-6, "zoom {zoom}: bottom edge {} not on the margin {}", b.y1, margin.y1);+ // Top-left corner handle onto the top and left margins.+ drag_handle(&mut s, Point::new(b.x0, b.y0), Vec2::new(margin.x0 + 1.0 - b.x0, margin.y0 - 1.0 - b.y0), v);+ let b = s.doc().unwrap().doc.spreads[0].items.last().unwrap().bounds();+ assert!((b.x0 - margin.x0).abs() < 1e-6 && (b.y0 - margin.y0).abs() < 1e-6, "zoom {zoom}: corner {b:?} not on the margins {margin:?}");+ }+ }++ #[test]+ fn type_tool_frames_snap_to_the_margins() {+ use designcraft_geom::Point;+ use designcraft_tools::{PointerEvent, PointerKind};+ let mut s = session();+ let margin = s.doc().unwrap().doc.spreads[0].pages[0].margin_rect();+ s.set_tool("type");+ let v = ViewInfo::at_zoom(1.0);+ let c = |s: &Session, x: f64, y: f64| s.layout().to_canvas(designcraft_doc::SpreadRef::Doc(0), Point::new(x, y));+ // From 1.5 pt off the top-left margin corner to 1.5 pt off the right margin.+ let a = c(&s, margin.x0 + 1.5, margin.y0 + 1.5);+ let b = c(&s, margin.x1 - 1.5, margin.y0 + 101.5);+ let before = s.doc().unwrap().doc.spreads[0].items.len();+ s.pointer(&PointerEvent::new(PointerKind::Down, a.x, a.y), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Drag, (a.x + b.x) / 2.0, b.y), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Drag, b.x, b.y), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Up, b.x, b.y), v).unwrap();+ let items = &s.doc().unwrap().doc.spreads[0].items;+ assert_eq!(items.len(), before + 1, "a frame was drawn");+ let r = items.last().unwrap().bounds();+ assert!((r.x0 - margin.x0).abs() < 1e-6 && (r.y0 - margin.y0).abs() < 1e-6, "press point {r:?} vs {margin:?}");+ assert!((r.x1 - margin.x1).abs() < 1e-6, "right edge {} vs {}", r.x1, margin.x1);+ }diff --cc docs/target-app-parity.mdindex 816f5940d,5011b3450..8e02e1187--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@@ -396,7 -398,7 +398,8 @@@ It is evidence of breadth: each item ex- Type on a Path (⇧T tool, `type.onPath`): a story along any line, curve or shape on screen and in PDF; Type on a Path Options (start, flip, baseline/ascender/descender/centre) and Delete Type from Path. Round-trips through IDML as TextPath; on-path caret drawing is still to come.- Preferences › Appearance of Black: 100% K on screen accurately (dark grey) or as rich black (`window.richBlack`); the printing/export side is still to come.- Spreads of up to 10 pages: Add to Previous Spread and Allow Spread to Shuffle (Pages panel; `layout.pages.toSpread`, `layout.spreadShuffle`); inserted pages go around kept spreads.+- Page tool (⇧P) and `layout.pageSize`: pages of their own size (or a preset); the spine stays put and objects keep their place on their page. A click selects a page (handles, its liquid page rule tagged above it); dragging a handle previews the liquid rule and springs back, Alt-drag resizes, Shift keeps proportions, with a W/H readout; `anchor` keeps a reference point in place; double-click for exact sizes. With the Page tool the Control panel shows the page (reference point, W/H, preset, orientation, Liquid Page Rule including Controlled by Parent, Show Parent Page Overlay); X/Y and Objects Move with Page are shown, but pages don't move within their spread yet. On an object-based page it selects objects and shows their pins and width/height locks on the canvas (click to toggle, with tooltips).+ - Page tool (⇧P) and `layout.pageSize`: pages of their own size (or a preset); the spine stays put and objects keep their place on their page. A click selects a page (handles, its liquid page rule tagged above it); dragging a handle previews the liquid rule and springs back, Alt-drag resizes, Shift keeps proportions, with a W/H readout; `anchor` keeps a reference point in place; double-click for exact sizes. With the Page tool the Control panel shows the page (reference point, W/H, preset, orientation, Liquid Page Rule, Show Parent Page Overlay); X/Y are shown, but pages don't move within their spread yet.- File › Print (⌘P): printer, copies, page range, spreads, marks, bleed; printed as PDF through the system spooler (`file.print`, `file.printers`, `dryRun` for agents). Shortcuts now act like choosing the menu item (dialogs open), and UI commands win shortcut ties (⌘N opens New Document).- Nested styles (through/up to N sentences, words, characters, letters, digits, tabs, breaks, spaces or given characters) and GREP styles (regex → character style), edited in Paragraph Style Options and composed under local formatting; `ui.dialog.open` for agents. Nested line styles are still to come; nested and GREP styles round-trip through IDML.- Table and cell styles (round-trip through IDML): cell styles (fill, insets, vertical justification, strokes, paragraph style) and table styles (region cell styles, border, alternating rows, spacing); apply from the Table panel, edits re-apply to every user; `style.cell.*`, `style.table.*`.