DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge document-grid: View draws the document grid (#530)
aiongg1a9499b4651d
diff --cc ROADMAP.mdindex cf14cff3c,ba91c3337..020518b92--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -129,28 -129,8 +129,30 @@@ list) · [roadmap.md](docs/roadmap.md)Newest first.+- **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** · 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-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, CLIsmoke-tested under QEMU).diff --cc crates/ui-egui/src/canvas.rsindex e9e0a328a,970ee8a7c..d3b55f6ac--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@@ -2579,439 -1804,54 +2585,487 @@@ mod tests}}+ /// The live-corner widget draws on a selected rectangle frame; clicking it draws the diamonds.+ #[test]+ fn live_corner_widget_and_diamonds_draw() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ app.run("frame.create", json!({"rect": [100, 100, 300, 250], "content": "graphic"})).unwrap();+ let id = app.session.doc().unwrap().doc.spreads[0].items[0].id;+ app.run("selection.set", json!({"ids": [id.0]})).unwrap();+ let mut h = Harness::builder().with_size(vec2(1440.0, 900.0)).with_pixels_per_point(1.0).wgpu().build_ui_state(+ |ui, app: &mut DesignApp| {+ let ctx = ui.ctx().clone();+ app.logic(&ctx);+ app.ui(ui);+ },+ app,+ );+ h.run_steps(4);+ let screen = |h: &Harness<'_, DesignApp>, x: f64, y: f64| {+ let app = h.state();+ let layout = CanvasLayout::new(&app.session.doc().unwrap().doc, false);+ let xf = Xf::new(app.canvas_rect.unwrap(), app.view().unwrap());+ xf.to_screen(layout.to_canvas(SpreadRef::Doc(0), Point::new(x, y)))+ };+ let widget = screen(&h, 300.0, 100.0) + vec2(0.0, 11.5);+ let diamond = screen(&h, 100.0, 100.0) + vec2(12.0, 0.0);+ let yellow = |h: &mut Harness<'_, DesignApp>, p: Pos2| -> Option<bool> {+ let img = match h.render() {+ Ok(img) => img,+ Err(e) => {+ eprintln!("skipped: no offscreen renderer ({e})");+ return None;+ }+ };+ let px = img.get_pixel(p.x.round() as u32, p.y.round() as u32).0;+ Some(px[0] > 200 && px[1] > 180 && px[2] < 100)+ };+ let Some(w) = yellow(&mut h, widget) else { return };+ assert!(w, "no widget at {widget:?}");+ assert_eq!(yellow(&mut h, diamond), Some(false));+ h.hover_at(widget);+ h.step();+ for pressed in [true, false] {+ h.event(egui::Event::PointerButton { pos: widget, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() });+ h.step();+ }+ h.run_steps(3);+ assert_eq!(yellow(&mut h, diamond), Some(true), "no diamond at {diamond:?}");+ assert_eq!(yellow(&mut h, widget), Some(false));+ }++ /// A harness whose frames are 1 ms apart, so two clicks make a double-click.+ fn fast_harness(app: DesignApp) -> Harness<'static, DesignApp> {+ let mut h = Harness::builder().with_size(vec2(1440.0, 900.0)).with_step_dt(0.001).build_ui_state(+ |ui, app: &mut DesignApp| {+ let ctx = ui.ctx().clone();+ app.logic(&ctx);+ app.ui(ui);+ },+ app,+ );+ h.run_steps(4);+ h+ }++ fn primary(h: &mut Harness<'_, DesignApp>, pos: Pos2, pressed: bool) {+ h.event(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() });+ h.run_steps(2);+ }++ fn corner_drag(h: &mut Harness<'_, DesignApp>, from: Pos2, to: Pos2) {+ h.hover_at(from);+ h.step();+ primary(h, from, true);+ h.event(egui::Event::PointerMoved(from + (to - from) / 2.0));+ h.run_steps(2);+ h.event(egui::Event::PointerMoved(to));+ h.run_steps(2);+ primary(h, to, false);+ }++ fn corner_click(h: &mut Harness<'_, DesignApp>, p: Pos2) {+ h.hover_at(p);+ h.step();+ primary(h, p, true);+ primary(h, p, false);+ }++ /// Where the rulers measure from (canvas coordinates): the document's zero point on the+ /// spread in view (its first page, for a page origin).+ fn ruler_zero(app: &DesignApp, doc: &Document, layout: &CanvasLayout) -> Option<Point> {+ ruler_pieces(app, doc, layout, doc.zero_point()).first().map(|p| p.2)+ }++ fn zero_point(h: &Harness<'_, DesignApp>) -> [f64; 2] {+ h.state().session.doc().unwrap().doc.settings.zero_point+ }++ #[test]+ fn the_ruler_corner_drags_resets_and_locks_the_zero_point() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({"pages": 3})).unwrap();+ let mut h = fast_harness(app);+ let rect = h.state().canvas_rect.unwrap();+ let corner = rect.min - vec2(RULER / 2.0, RULER / 2.0);+ // A click that stays in the corner leaves the zero point.+ corner_click(&mut h, corner);+ assert_eq!(zero_point(&h), [0.0, 0.0]);+ // Dragged out, it lands where released, measured from the spread in view.+ let dest = rect.min + vec2(80.0, 50.0);+ let expected = {+ let app = h.state();+ let st = app.session.active().unwrap();+ let layout = CanvasLayout::new(&st.doc, false);+ let slot = layout.slots[current_slot(app, &layout).unwrap()];+ let sp = slot.to_spread(Xf::new(rect, app.view().unwrap()).to_canvas(dest));+ let b = st.doc.spread(slot.spread).unwrap().bounds();+ [sp.x - b.x0, sp.y - b.y0]+ };+ corner_drag(&mut h, corner, dest);+ let zp = zero_point(&h);+ assert!((zp[0] - expected[0]).abs() < 0.5 && (zp[1] - expected[1]).abs() < 0.5, "{zp:?} vs {expected:?}");+ assert!(zp[0].abs() > 1.0 && zp[1].abs() > 1.0, "moved: {zp:?}");+ // The rulers measure from the point it was dropped on.+ {+ let app = h.state();+ let st = app.session.active().unwrap();+ let layout = CanvasLayout::new(&st.doc, false);+ let o = ruler_zero(app, &st.doc, &layout).unwrap();+ let on_screen = Xf::new(rect, app.view().unwrap()).to_screen(o);+ assert!((on_screen - dest).length() < 0.5, "{on_screen:?} vs {dest:?}");+ }+ // A double-click resets it.+ corner_click(&mut h, corner);+ corner_click(&mut h, corner);+ assert_eq!(zero_point(&h), [0.0, 0.0]);+ // Locked from the corner's context menu, the corner ignores drags and double-clicks.+ right_click(&mut h, corner);+ h.get_by_label("Lock Zero Point").click();+ h.run_steps(3);+ assert!(h.state().session.doc().unwrap().doc.settings.zero_point_locked);+ corner_drag(&mut h, corner, dest);+ assert_eq!(zero_point(&h), [0.0, 0.0]);+ // Unlocked again from the same menu.+ right_click(&mut h, corner);+ h.get_by_label("Unlock Zero Point").click();+ h.run_steps(3);+ corner_drag(&mut h, corner, dest);+ assert_ne!(zero_point(&h), [0.0, 0.0]);+ h.state_mut().run("view.lockZeroPoint", json!({"on": true})).unwrap();+ corner_click(&mut h, corner);+ corner_click(&mut h, corner);+ assert_ne!(zero_point(&h), [0.0, 0.0], "a locked zero point isn't reset");+ }++ #[test]+ fn cmd_dragging_the_ruler_corner_makes_a_guide_each_way() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let mut h = harness(app);+ let rect = h.state().canvas_rect.unwrap();+ let corner = rect.min - vec2(RULER / 2.0, RULER / 2.0);+ let dest = rect.min + vec2(120.0, 90.0);+ let (r, at) = {+ let app = h.state();+ let st = app.session.active().unwrap();+ CanvasLayout::new(&st.doc, false).spread_at(Xf::new(rect, app.view().unwrap()).to_canvas(dest)).unwrap()+ };+ h.event(egui::Event::ModifiersChanged(egui::Modifiers::COMMAND));+ h.step();+ corner_drag(&mut h, corner, dest);+ h.event(egui::Event::ModifiersChanged(egui::Modifiers::NONE));+ h.step();+ let doc = h.state().session.doc().unwrap().doc.clone();+ let guides: Vec<_> = doc.spread(r).unwrap().pages.iter().flat_map(|p| p.guides.clone()).collect();+ assert_eq!(guides.len(), 2, "{guides:?}");+ let pos = |o: designcraft_doc::Orientation| guides.iter().find(|g| g.orientation == o).map(|g| g.position).unwrap();+ assert!((pos(designcraft_doc::Orientation::Horizontal) - at.y).abs() < 0.5);+ assert!((pos(designcraft_doc::Orientation::Vertical) - at.x).abs() < 0.5);+ assert!(guides.iter().all(|g| g.spread));+ assert_eq!(doc.settings.zero_point, [0.0, 0.0], "the zero point stays");+ }++ #[test]+ fn rulers_and_xy_fields_measure_from_the_zero_point_on_every_spread() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ // Spread 0: page 1; spread 1: pages 2 and 3.+ app.run("file.new", json!({"pages": 3})).unwrap();+ app.run("view.zeroPoint", json!({"at": [100, 50]})).unwrap();+ app.session.prefs.dimensions_include_stroke = false;+ let mut h = harness(app);+ let rect = h.state().canvas_rect.unwrap();+ for (spread, x0) in [(0usize, 136.0), (1, 736.0)] {+ let app = h.state_mut();+ let id = app.run("frame.create", json!({"spread": spread, "rect": [x0, 70, x0 + 50.0, 120]})).unwrap()["id"].clone();+ app.run("selection.set", json!({"ids": [id]})).unwrap();+ // X/Y (Control, Properties and Info panels).+ let r = crate::panels::sel_info(app).unwrap().page_rect;+ assert!((r.x0 - (x0 - 100.0)).abs() < 1e-6 && (r.y0 - 20.0).abs() < 1e-6, "spread {spread}: {r:?}");+ // The rulers, with that spread in view.+ let layout = CanvasLayout::new(&app.session.active().unwrap().doc, false);+ let slot = layout.slots[spread];+ let v = app.view_mut().unwrap();+ let zoom = v.zoom;+ let c = slot.bounds.center();+ v.origin = Point::new(c.x - rect.width() as f64 / 2.0 / zoom, c.y - rect.height() as f64 / 2.0 / zoom);+ h.run_steps(2);+ let app = h.state();+ let doc = app.session.active().unwrap().doc.clone();+ assert_eq!(current_slot(app, &layout), Some(spread));+ let o = ruler_zero(app, &doc, &layout).unwrap();+ assert!((o.x - slot.bounds.x0 - 100.0).abs() < 1e-6 && (o.y - slot.bounds.y0 - 50.0).abs() < 1e-6, "spread {spread}: {o:?}");+ }+ }++ /// Screen position of spread 0's point (x, y).+ fn screen_of(h: &Harness<'_, DesignApp>, x: f64, y: f64) -> Pos2 {+ let app = h.state();+ let st = app.session.active().unwrap();+ let xf = Xf::new(app.canvas_rect.unwrap(), app.view().unwrap());+ xf.to_screen(CanvasLayout::new(&st.doc, st.editing_parents).xf(SpreadRef::Doc(0)) * Point::new(x, y))+ }++ /// A menu row: a button that isn't a toggle, named by its label, then its shortcut if it has+ /// one. Toggle buttons with the same name (the Task Bar's icons) don't match.+ fn menu_row<'h>(h: &'h Harness<'_, DesignApp>, label: &'h str) -> Option<egui_kittest::Node<'h>> {+ h.query_by(move |n| {+ n.role() == egui::accesskit::Role::Button+ && n.toggled().is_none()+ && n.label().is_some_and(|l| l == label || l.strip_prefix(label).and_then(|r| r.strip_prefix(' ')).is_some_and(|r| !r.contains(' ')))+ })+ }++ fn enabled(h: &Harness<'_, DesignApp>, label: &str) -> bool {+ use egui_kittest::kittest::NodeT;+ !menu_row(h, label).unwrap_or_else(|| panic!("no menu row {label}")).accesskit_node().is_disabled()+ }++ fn spread_items(h: &Harness<'_, DesignApp>) -> Vec<u64> {+ h.state().session.doc().unwrap().doc.spreads[0].items.iter().map(|i| i.id.0).collect()+ }++ fn selected(h: &Harness<'_, DesignApp>) -> Vec<u64> {+ h.state().session.doc().unwrap().selection.items.iter().map(|i| i.0).collect()+ }++ #[test]+ fn right_clicking_an_object_selects_it_and_its_menu_arranges_it() {+ 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": [36, 36, 200, 200]})).unwrap()["id"].as_u64().unwrap();+ let b = app.run("frame.create", json!({"rect": [150, 150, 300, 300]})).unwrap()["id"].as_u64().unwrap();+ let mut h = harness(app);+ assert_eq!(selected(&h), [b]);+ let on_a = screen_of(&h, 60.0, 60.0);+ right_click(&mut h, on_a);+ assert_eq!(selected(&h), [a], "the object under the pointer is selected first");+ // An empty frame's menu: Content, but no Fitting (nothing to fit) and no text frame entries.+ assert!(menu_row(&h, "Content").is_some());+ assert!(menu_row(&h, "Fitting").is_none() && menu_row(&h, "Text Frame Options…").is_none());+ // Paste is available with nothing copied here: the system clipboard may hold another app's text.+ assert!(enabled(&h, "Copy") && enabled(&h, "Paste"));+ menu_row(&h, "Arrange").unwrap().click();+ h.run_steps(3);+ menu_row(&h, "Bring to Front").unwrap().click();+ h.run_steps(3);+ assert_eq!(spread_items(&h), [b, a]);+ assert!(menu_row(&h, "Arrange").is_none(), "choosing an entry closes the menu");+ }++ #[test]+ fn right_clicking_empty_canvas_offers_paste_after_a_copy() {+ 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": [36, 36, 200, 200]})).unwrap()["id"].as_u64().unwrap();+ app.run("edit.copy", json!({})).unwrap();+ app.select_tool("rectangleFrame");+ let mut h = harness(app);+ let empty = screen_of(&h, 400.0, 500.0);+ right_click(&mut h, empty);+ assert_eq!(selected(&h), [a], "a right-click on nothing keeps the selection");+ assert!(menu_row(&h, "Arrange").is_none(), "the page menu, not the object menu");+ assert!(enabled(&h, "Paste in Place"));+ assert!(menu_row(&h, "✓ Show/Hide Rulers").is_some(), "toggles show their state");+ // Escape closes the menu and does nothing else: the tool would deselect, the shortcuts+ // would switch to the Selection tool.+ h.key_press(egui::Key::Escape);+ h.run_steps(3);+ assert!(menu_row(&h, "Paste in Place").is_none());+ assert_eq!((h.state().session.tool_id(), selected(&h)), ("rectangleFrame", vec![a]));+ right_click(&mut h, empty);+ menu_row(&h, "Paste").unwrap().click();+ h.run_steps(3);+ assert_eq!(spread_items(&h).len(), 2);+ }++ #[test]+ fn right_clicking_another_object_while_the_menu_is_open_reopens_it_there() {+ 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": [36, 36, 200, 200]})).unwrap()["id"].as_u64().unwrap();+ let b = app.run("frame.create", json!({"rect": [36, 600, 200, 760]})).unwrap()["id"].as_u64().unwrap();+ let mut h = harness(app);+ // The menu opens down from A, with the pointer on its first row (no submenu open); B is below it.+ let (on_a, on_b) = (screen_of(&h, 60.0, 60.0), screen_of(&h, 50.0, 700.0));+ right_click(&mut h, on_a);+ assert_eq!(selected(&h), [a]);+ assert!(menu_row(&h, "Arrange").is_some());+ right_click(&mut h, on_b);+ assert_eq!(selected(&h), [b]);+ assert!(menu_row(&h, "Arrange").is_some(), "the menu reopens at the new click");+ }++ #[test]+ fn a_context_menu_in_one_pane_keeps_the_keys_from_the_other() {+ 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": [36, 36, 100, 100]})).unwrap()["id"].as_u64().unwrap();+ app.select_tool("rectangleFrame");+ app.split = true;+ let mut h = harness(app);+ // The focused pane is the left one; this point is near its right edge, away from the frame.+ let left = h.state().canvas_rect.unwrap();+ right_click(&mut h, pos2(left.max.x - 40.0, left.center().y));+ assert!(menu_row(&h, "Paste in Place").is_some());+ // Escape closes the left pane's menu before the right pane handles the keys.+ h.key_press(egui::Key::Escape);+ h.run_steps(3);+ assert!(menu_row(&h, "Paste in Place").is_none());+ assert_eq!((h.state().session.tool_id(), selected(&h)), ("rectangleFrame", vec![a]));+ }++ #[test]+ fn right_clicking_text_keeps_the_selected_text_or_places_the_caret() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ app.run("frame.create", json!({"rect": [36, 36, 400, 200], "content": "text"})).unwrap();+ app.select_tool("type");+ app.run("text.insert", json!({"text": "Hello world"})).unwrap();+ let sid = *app.session.doc().unwrap().doc.stories.keys().next().unwrap();+ app.run("text.select", json!({"story": sid.0, "anchor": 0, "focus": 5})).unwrap();+ let mut h = harness(app);+ let text_sel = |h: &Harness<'_, DesignApp>| h.state().session.doc().unwrap().selection.text.as_ref().map(|t| (t.anchor, t.focus));+ // Inside "Hello": the selection stays.+ let inside = screen_of(&h, 45.0, 44.0);+ right_click(&mut h, inside);+ assert_eq!(text_sel(&h), Some((0, 5)));+ assert!(menu_row(&h, "Paste without Formatting").is_some(), "the text menu");+ h.key_press(egui::Key::Escape);+ h.run_steps(3);+ // Past the end of the line: the caret goes there.+ let past_end = screen_of(&h, 300.0, 44.0);+ right_click(&mut h, past_end);+ assert_eq!(text_sel(&h), Some((11, 11)));+ assert!(menu_row(&h, "Paste without Formatting").is_some());+ }++ #[test]+ fn rows_hidden_in_the_menu_bar_are_hidden_in_context_menus() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ app.run("frame.create", json!({"rect": [36, 36, 200, 200]})).unwrap();+ app.ui.hidden_menu_items.push(crate::menus::menu_key("Object/Arrange", "Bring to Front"));+ let mut h = harness(app);+ let on_frame = screen_of(&h, 60.0, 60.0);+ right_click(&mut h, on_frame);+ menu_row(&h, "Arrange").unwrap().click();+ h.run_steps(3);+ assert!(menu_row(&h, "Bring to Front").is_none());+ assert!(menu_row(&h, "Send to Back").is_some());+ assert!(h.query_by_label("Show All Menu Items").is_some());+ }++ #[test]+ fn a_secondary_drag_neither_moves_marquees_nor_draws() {+ 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": [36, 36, 200, 200]})).unwrap()["id"].as_u64().unwrap();+ let mut h = harness(app);+ // A secondary-button drag between spread points.+ let drag = |h: &mut Harness<'_, DesignApp>, from: (f64, f64), to: (f64, f64)| {+ let (from, to) = (screen_of(h, from.0, from.1), screen_of(h, to.0, to.1));+ h.hover_at(from);+ h.step();+ h.event(egui::Event::PointerButton { pos: from, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });+ h.step();+ for t in [0.25, 0.5, 0.75, 1.0] {+ h.event(egui::Event::PointerMoved(from + (to - from) * t));+ h.step();+ }+ h.event(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });+ h.run_steps(3);+ };+ let xf = |h: &Harness<'_, DesignApp>| h.state().session.doc().unwrap().doc.item(designcraft_doc::ItemId(a)).unwrap().xf;+ let before = xf(&h);+ // Selection tool: on the object (no move), and from empty page across it (no marquee).+ drag(&mut h, (100.0, 100.0), (300.0, 300.0));+ assert_eq!(xf(&h), before);+ h.state_mut().run("edit.deselectAll", json!({})).unwrap();+ drag(&mut h, (400.0, 400.0), (20.0, 20.0));+ assert!(selected(&h).is_empty());+ // Rectangle Frame tool: no frame.+ h.state_mut().select_tool("rectangleFrame");+ drag(&mut h, (300.0, 300.0), (500.0, 500.0));+ assert_eq!(spread_items(&h), [a]);+ }++ #[test]+ fn tools_show_their_own_cursors_over_the_page() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let mut h = harness(app);+ let p = h.state().canvas_rect.unwrap().center();+ let mut shown = |tool: &str| {+ h.state_mut().run("tool.select", json!({"tool": tool})).unwrap();+ h.hover_at(p);+ h.run_steps(2);+ let out = &h.output().platform_output;+ (out.cursor_icon, out.cursor_image.clone())+ };+ let (pen, direct, text) = (shown("pen"), shown("directSelection"), shown("type"));+ let ppp = h.ctx.pixels_per_point();+ let images = &mut h.state_mut().cursors;+ match crate::cursors::MODE {+ crate::cursors::Mode::Os => {+ assert_eq!(pen.1, images.get(Cursor::Pen, ppp), "Pen");+ assert_eq!(direct.1, images.get(Cursor::ArrowHollow, ppp), "Direct Selection");+ assert_eq!(text, (egui::CursorIcon::Text, None), "the I-beam stays a system cursor");+ }+ crate::cursors::Mode::Painted => assert_eq!((pen.0, direct.0), (egui::CursorIcon::None, egui::CursorIcon::None)),+ crate::cursors::Mode::System => assert_eq!(pen, (egui::CursorIcon::Crosshair, None)),+ }+ }++ #[test]+ fn document_grid_is_drawn_where_points_snap_to_it() {+ use designcraft_tools::{SnapView, ToolContext};+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let doc = app.session.active().unwrap().doc.clone();+ let layout = CanvasLayout::new(&doc, false);+ let sr = SpreadRef::Doc(0);+ // Where the grid snaps a point in the first page (72 pt / 8 subdivisions = 9 pt).+ let page = doc.spreads[0].pages[0].bounds();+ let sel = Selection::default();+ let cx = ToolContext {+ doc: &doc,+ selection: &sel,+ cache: &app.session.cache,+ layout: &layout,+ zoom: 1.0,+ layer: doc.layers[0].id,+ snap: SnapView { snap_to_document_grid: true, zone_px: 20.0, ..SnapView::OFF },+ unit: Unit::Points,+ };+ let (snapped, _) = designcraft_tools::snap::snap_point(&cx, sr, Point::new(page.x0 + 31.3, page.y0 + 47.9));+ assert_eq!((snapped.x - page.x0, snapped.y - page.y0), (27.0, 45.0));+ // Render 40 × 40 pt around it at 4 px/pt.+ let scale = 4.0;+ let corner = layout.xf(sr) * Point::new(snapped.x - 20.0, snapped.y - 20.0);+ let view = Affine::scale(scale) * Affine::translate((-corner.x, -corner.y));+ let placed: Vec<_> = layout.slots.iter().map(|s| designcraft_render::Placed { spread: s.spread, xf: s.xf }).collect();+ let render = |app: &DesignApp| {+ let opts = screen_options(app, &layout, false, 1.0);+ designcraft_render::Renderer::new().render(&doc, &app.session.cache, &placed, 160, 160, view, &opts)+ };+ // The snapped point is at pixel (80, 80); halfway to the next line is 18 px further.+ let darkest = |img: &designcraft_render::Rendered, xs: [u32; 2], ys: [u32; 2]| {+ (xs[0]..xs[1]).flat_map(|x| (ys[0]..ys[1]).map(move |y| (x, y))).map(|(x, y)| img.pixel(x, y)[0]).min().unwrap()+ };+ let off = render(&app);+ assert_eq!(darkest(&off, [78, 82], [60, 64]), 255, "no grid while it is hidden");+ app.run("view.documentGrid", json!({})).unwrap();+ let on = render(&app);+ assert!(darkest(&on, [79, 81], [60, 64]) < 250, "a vertical line at the snapped x");+ assert!(darkest(&on, [60, 64], [79, 81]) < 250, "a horizontal line at the snapped y");+ assert_eq!(darkest(&on, [96, 100], [96, 100]), 255, "nothing between lines");+ // Preview hides it.+ app.ui.screen_mode = ScreenMode::Preview;+ assert!(screen_options(&app, &layout, true, 1.0).document_grid.is_empty());+ }+#[test]fn rulers_open_no_units_menu_without_a_document() {let mut h = harness(DesignApp::new(designcraft_engine::Session::new(), crate::Services::default()));diff --cc docs/control-protocol.mdindex ed16482d1,54e6d75e4..bf405b8c0--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@@ -37,11 -37,10 +37,11 @@@ so only enable it while you use it. Tra| `ui.inspect` | — | Tool, UI state, view (zoom/origin), canvas rect, perf || `ui.menu.list` / `ui.tool.list` | — | Menu tree / Tools panel groups || `ui.tool.select` | `{tool}` | Select a tool (`selection`, `type`, `rectangleFrame`, …) |-| `ui.pointer` | `{events:[{kind: down\|drag\|up\|move\|doubleclick, x, y, space?: "screen"\|"canvas"}], mods?}` | Drive the active tool through the same code path as the mouse |+| `ui.pointer` | `{events:[{kind: down\|drag\|up\|move\|doubleclick, x, y, space?: "screen"\|"canvas", clicks?}], mods?}` | Drive the active tool through the same code path as the mouse; `clicks` on a `down` is the press count (3 = triple click); returns the selection, the tool and its cursor at the last event (e.g. `LoadedText`, `ThreadLink`, `Unthread`) || `ui.key` / `ui.text` | `{key, shift?, alt?, cmd?}` / `{text}` | Synthetic keyboard input (typing into a text frame) |+| `ui.ime` | `{preedit?, active?: [start, end], commit?}` | Input method events as the system IME sends them: marked text (shown in place, `active` is the clause being converted, in characters) and the committed text (typed as one `text.insert`) || `ui.move` / `ui.click` / `ui.drag` | screen points, `button?: left\|right\|middle` | Real egui pointer input — reaches every widget, menu and panel |- | `ui.set` | `{brightness?, panel?, rulers?, guides?, frameEdges?, baselineGrid?, textThreads?, screenMode?, zoom?, page?, fit?}` | UI state |+ | `ui.set` | `{brightness?, panel?, rulers?, guides?, frameEdges?, baselineGrid?, documentGrid?, textThreads?, screenMode?, zoom?, page?, fit?}` | UI state || `ui.dialog.open` | `{id, fields?}` | Open a dialog by id (e.g. `paragraphStyleOptions` or `characterStyleOptions` with `{name, section}`, or `{new: true}` for a new style) || `ui.dialog.set` / `ui.dialog.confirm` / `ui.dialog.cancel` | `{field, value}` | Fill and confirm the open dialog || `ui.resize`, `ui.focus` | | Window control |diff --cc docs/target-app-parity.mdindex 34ec16578,0fb26c74a..e081dd9d9--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@@ -268,8 -268,8 +268,8 @@@ It is evidence of breadth: each item ex- Text engine: Knuth–Plass paragraph composer and single-line composer, dictionary hyphenation (public-domain Moby list + our own trained Liang patterns), justification with word/letter/glyph-scaling ranges, keep options (keep with next, keep lines together, widows/orphans), balance ragged lines, optical margin alignment, hyphenation zone/limit, columns, threading across frames and spreads, tabs, bullets/numbering, rules, shading, baseline grid, first-baseline options, vertical justification, wrap exclusions, overset detection, caret/hit testing.- FID2: IDML underline/strikethrough Text Color resets survive style inheritance and roundtrip. Raster and PDF paint underlines behind glyphs, retain strikethrough above, and center rules on their offsets; synthetic overlap tests cover both backends.- Rendering: vello_cpu (SIMD, multithreaded) — pages, items, images with mip levels, gradients, composed text.- - UI (egui): application bar + menus, Control panel (object and text modes), Tools panel with flyouts, document tabs, rulers, pasteboard, guides (margins, columns, bleed, baseline grid), frame edges, selection handles, text ports and threads, Properties / Pages / Layers dock, Swatches, Styles, Character, Paragraph, Stroke, Text Wrap panels, New Document and Preferences dialogs, Quick Apply (⌘Return), 4 brightness themes.+ - UI (egui): application bar + menus, Control panel (object and text modes), Tools panel with flyouts, document tabs, rulers, pasteboard, guides (margins, columns, bleed, baseline grid), document grid (View ▸ Grids & Guides, ⌘', on the snap positions, behind or in front of items), frame edges, selection handles, text ports and threads, Properties / Pages / Layers dock, Swatches, Styles, Character, Paragraph, Stroke, Text Wrap panels, New Document and Preferences dialogs, Quick Apply (⌘Return), 4 brightness themes.-- Pen tool, Direct Selection anchor/handle editing, rotate from corners, Rotate/Scale/Shear tools, Eyedropper, snapping & smart guides, Align/Distribute, Find/Change (text + GREP), Story Editor, Paragraph Style Options, Effects panel, hidden characters, native macOS menu bar, measured InDesign 2026 look (Medium Dark): Properties sections per selection state, 21 pt spinner fields with arithmetic, Contextual Task Bar, inverse (black) text selection, Pages panel with drag-and-drop reorder / parent apply, Layers panel with per-object rows.+- Pen tool, Direct Selection anchor/handle editing, rotate from corners, Rotate/Scale/Shear tools, Eyedropper, snapping & smart guides, Align/Distribute, Find/Change (text + GREP), Story Editor, Paragraph Style Options, Effects panel, hidden characters, native macOS menu bar, measured InDesign 2026 look (Medium Dark): Properties sections per selection state, 21 pt spinner fields with arithmetic, Contextual Task Bar, inverse (black) text selection, Pages panel with drag-and-drop reorder / parent apply, Layers panel with per-object rows, expandable groups and drag-and-drop reorder of layers and objects (the selection square moves the selection to another layer).- Tools: Selection (click, marquee, move, Alt-duplicate, resize handles), Direct Selection, Type (draw frame, click caret, select, type), Rectangle/Ellipse/Polygon (+ frame variants), Line, Hand, Zoom.- PDF export (krilla): real selectable text with embedded font subsets, DeviceCMYK/RGB + spot Separations, bleed boxes, crop/bleed marks + page info, pages or spreads, PDF/A-2b (PDF/X-4 output intent pending) — `file.exportPdf`, File › Export PDF…, `designcraft-cli run --export out.pdf`. File › Export PDF… now opens an "Export PDF" options dialog (General / Compression / Marks and Bleeds / Advanced) and remembers the last-used settings across exports and sessions.- IDML interchange (`designcraft-idml`): export and import of swatches, styles, fonts, preferences, parent spreads, spreads/pages, frames, groups, images (embedded or linked), formatted threaded stories — opens in InDesign 2026 and round-trips InDesign-exported files (`file.exportIdml`, `file.openIdml`, File → Export IDML…, CLI `--in x.idml` / `--export x.idml`).