DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge PR #1657: Direct Selection: handles around the selected anchors only, and no bounding box
aiongg9b36f1f13943
diff --cc ROADMAP.mdindex 1395acef5,b3855d08d..f276088cb--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -432,11 -420,9 +432,12 @@@ Newest first- **2026-10-23** · File › File Info… edits the document's Document Title, Author, Description, Keywords, Copyright Notice and Copyright Info URL (`file.info`), and the document saves them. PDF export (PDF/X-4 and Print Booklet included) writes the title, author, description and keywords into the PDF's document information and XMP. EPUB export takes the title and author from File Info, and HTML export takes the title. A title or author given to the export replaces File Info's, and an empty Document Title leaves the document's name as the title. No readiness percentage change.- **2026-10-23** · Save and export dialogs (Save As, Save a Copy, Export PDF and the other exports, Package, libraries and books) start in the active document's folder once it has been saved, and for a document never saved in the folder of the last file saved or exported, remembered across sessions (#1653). A folder deleted since falls back to the system's choice. No readiness percentage change.- **2026-10-22** · Autoflow (Shift-click with the loaded text cursor, autoflow on Place, `text.thread {autoflow}`) fills the pages that follow before it adds any, as InDesign does: one frame per column on each following page, whatever else the page holds, then new pages at the end of the document. It inserted pages right after the story's last frame, in front of the document's own pages. Frames it set past the end of the text go again; a page the document had stays, and a page autoflow added only for such a frame goes with it. Smart Text Reflow of the primary text frame is unchanged. No readiness percentage change.+- **2026-10-18** · German text hyphenates using the MIT-licensed 2006 reform patterns (`hyph-de-1996.tex`) through `hypher`. Explicit 2006 names and plain/2006 locale codes reach both composers; traditional and unknown spelling variants stay unhyphenated. Tests cover this distinction, umlauts, ß, compounds, reformed ck/st breaks and paragraph limits. Six of InDesign's ~40 hyphenation languages. No readiness percentage change.- **2026-10-16** · Edit › Keyboard Shortcuts imports a set saved by InDesign's Show Set (.txt, Windows or Mac key names, UTF-8 or UTF-16): matched commands take its Default shortcuts or lose theirs, other commands give up keys it takes, and a report lists what it changed and the items it could not match (`window.importShortcuts`, #1180). Tool keys stay fixed. No readiness percentage change.- **2026-10-23** · Translations: a missing string shows in English and fails no test; `cargo xtask i18n-report`, run by `cargo xtask ci`, prints the missing strings per language. Tests keep duplicate-key and placeholder checks and the language mechanics (lookup, context captions, plural captions, right-to-left). No readiness percentage change.+- **2026-10-23** · Show Hidden Characters marks table cells as InDesign does: every cell shows its own spaces, tabs and paragraph returns and an end-of-story # after its text (an empty cell shows just the #), and the table paragraph's ¶ sits after the table's bottom right corner. Cells showed no marks. No readiness percentage change.+- **2026-10-23** · Tables: with the Type tool in a cell, Shift+Tab goes back a cell (it went on to the next one) and Esc toggles between the text and the cell, as in InDesign: the insertion point selects its cell, and selected cells select the text of the first one (`table.toggleSelection`). Esc left the table for the frame. No readiness percentage change.+ - **2026-10-23** · Direct Selection shows a path's direction handles as InDesign: both handles of each selected anchor and, on its neighbours, the handle shaping the segment to it; no handles with no anchor selected, and handles that don't show can't be grabbed. The tool draws the path and its points without the bounding box. Found in the Learn Skills Daily course, chapter 43. No readiness percentage change.- **2026-10-22** · Hyphenation Settings, as in InDesign: the Paragraph panel menu's Hyphenation… (`app.hyphenationDialog`) sets the selected paragraphs' Hyphenate, Words with at Least, After First, Before Last, Hyphen Limit, Hyphenation Zone, the Better Spacing ↔ Fewer Hyphens slider (InDesign's 0–10 steps), Hyphenate Capitalized Words, Last Word and Across Column, with Preview, as one undo step; Paragraph Style Options › Hyphenation has the same form. The panel menu lists its items in InDesign's order. Replicated from a hyphenation tutorial: the same text in Minion Pro breaks into the same lines as InDesign's with hyphenation on, off, and at Fewer Hyphens. No readiness percentage change.- **2026-10-22** · Hyphenate Across Column (Hyphenation Settings; IDML HyphenateAcrossColumns) is applied: with it off, a paragraph whose line ending in an automatic hyphen would end a column or frame is re-composed without that hyphenation point, so the word moves on whole, as in InDesign. Opened and imported files keep their own setting, so their layouts don't change. No readiness percentage change.- **2026-10-22** · The Paragraph panel is laid out as InDesign's: the nine alignment buttons in groups; indent, spacing and drop cap fields by their icons in two columns, with Space Between Paragraphs Using Same Style (Ignore or a space); Shading and Border with the Paragraph Borders and Shading button and colour; Hyphenate with Do Not Align / Align to Baseline Grid. Its panel menu follows InDesign's order: Paragraph and Single-line Composer, Only Align First Line to Grid, Balance Ragged Lines, Optical Margin Alignment, Justification…, Keep Options…, Span Columns…, Hyphenation…, Drop Caps and Nested Styles…, GREP Styles… (these three now open for the selected paragraphs), Paragraph Rules…, Paragraph Borders and Shading…, Bullets and Numbering…, Restart/Continue Numbering, Define Lists… and the paragraph direction. Convert Bullets and Numbering to Text is listed but not available yet. No readiness percentage change.diff --cc crates/engine/src/tests.rsindex 1b69fd773,1ec0ffb53..103a9416f--- a/crates/engine/src/tests.rs+++ b/crates/engine/src/tests.rs@@@ -1664,45 -1661,48 +1664,87 @@@ fn a_line_fits_when_its_baseline_does(assert!(overset(&mut s, 50.0), "a baseline below the frame still oversets the line");}+/// Reset To Base with a new Based On: a partial rule edit resolves over the new parent, not the+/// old one.+#[test]+fn reset_to_base_with_a_new_parent_resolves_rule_edits_over_it() {+ let mut s = session();+ let rule = |weight: f64, offset: f64| json!({"on": true, "weight": weight, "color": "[Black]", "offset": offset});+ s.execute("style.paragraph.create", &json!({"name": "Old", "para": {"ruleBelow": rule(3.0, 1.0)}})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "New", "para": {"ruleBelow": rule(1.0, 9.0)}})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "Child", "basedOn": "Old"})).unwrap();+ s.execute("style.paragraph.edit", &json!({"name": "Child", "resetToBase": true, "basedOn": "New", "para": {"ruleBelow": {"weight": 2}}}))+ .unwrap();+ let r = s.doc().unwrap().doc.styles.resolve_para_style("Child").0.rule_below;+ assert_eq!((r.weight, r.offset), (2.0, 9.0), "the offset is the new parent's");+}++/// Paragraph style references are checked: a Based On or Next Style that names no style, or+/// that isn't a name or null, is refused and changes nothing.+#[test]+fn paragraph_style_references_must_name_styles() {+ let mut s = session();+ s.execute("style.paragraph.create", &json!({"name": "Body"})).unwrap();+ assert!(s.execute("style.paragraph.create", &json!({"name": "Lost", "nextStyle": "Nowhere"})).is_err());+ assert!(s.doc().unwrap().doc.styles.para("Lost").is_none());+ // On creation too, a reference that isn't a name or null is refused, not dropped.+ for p in [json!({"name": "Lost", "nextStyle": true}), json!({"name": "Lost", "basedOn": 3})] {+ assert!(s.execute("style.paragraph.create", &p).is_err(), "{p}");+ assert!(s.doc().unwrap().doc.styles.para("Lost").is_none(), "{p}");+ }+ assert!(s.execute("style.character.create", &json!({"name": "Lost", "basedOn": ["Body"]})).is_err());+ assert!(s.doc().unwrap().doc.styles.char_style("Lost").is_none());+ s.execute("style.paragraph.create", &json!({"name": "Self", "nextStyle": "Self"})).unwrap();+ let before = s.doc().unwrap().doc.clone();+ for p in [json!({"name": "Body", "basedOn": "Nowhere"}), json!({"name": "Body", "basedOn": 3}), json!({"name": "Body", "nextStyle": true})] {+ assert!(s.execute("style.paragraph.edit", &p).is_err(), "{p}");+ }+ assert!(std::sync::Arc::ptr_eq(&before, &s.doc().unwrap().doc), "nothing changed");+ s.execute("style.paragraph.edit", &json!({"name": "Body", "basedOn": null, "nextStyle": "Self"})).unwrap();+}++ /// The course's chapter 43: with Direct Selection, a circle's selected anchor shows its handles+ /// and they drag, reshaping the curve; the handles of the anchors away from it neither show nor+ /// catch a press, as in InDesign.+ #[test]+ fn direct_selection_drags_only_the_handles_around_the_selected_anchor() {+ use designcraft_tools::{PointerEvent, PointerKind};+ let mut s = session();+ let v = ViewInfo::at_zoom(1.0);+ let id = s.execute("frame.create", &json!({"rect": [100, 300, 300, 500], "shape": "ellipse"})).unwrap()["id"].as_u64().unwrap();+ s.execute("selection.set", &json!({"ids": [id]})).unwrap();+ s.set_tool("directSelection");+ // Each anchor and its two handles, in the spread.+ let anchors = |s: &Session| {+ let st = s.doc().unwrap();+ let it = st.doc.item(designcraft_doc::ItemId(id)).unwrap();+ it.path.subpaths[0].anchors.iter().map(|a| (it.xf * a.p, it.xf * a.h_in, it.xf * a.h_out)).collect::<Vec<_>>()+ };+ let before = anchors(&s);+ let lowest = |f: &dyn Fn(f64) -> f64| (0..before.len()).min_by(|a, b| f(before[*a].0.y).total_cmp(&f(before[*b].0.y))).unwrap();+ let (bottom, top) = (lowest(&|y| -y), lowest(&|y| y));+ let press = |s: &mut Session, from: designcraft_geom::Point, to: designcraft_geom::Point| {+ s.pointer(&PointerEvent::new(PointerKind::Down, from.x, from.y), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Drag, (from.x + to.x) / 2.0, (from.y + to.y) / 2.0), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Drag, to.x, to.y), v).unwrap();+ s.pointer(&PointerEvent::new(PointerKind::Up, to.x, to.y), v).unwrap();+ };+ // Select the bottom anchor.+ let b = before[bottom].0;+ press(&mut s, b, b);+ assert_eq!(s.doc().unwrap().selection.anchors, [(designcraft_doc::ItemId(id), 0, bottom)]);+ // Its handle drags: the handle moves.+ let h = before[bottom].2;+ press(&mut s, h, h + designcraft_geom::Vec2::new(30.0, 0.0));+ let after = anchors(&s);+ assert!((after[bottom].2 - before[bottom].2).hypot() > 20.0, "the bottom handle moved: {:?} → {:?}", before[bottom], after[bottom]);+ // The top anchor's handle isn't shown, so a press on it doesn't take it.+ let t = before[top].2;+ press(&mut s, t, t + designcraft_geom::Vec2::new(0.0, -30.0));+ let after2 = anchors(&s);+ assert!((after2[top].2 - before[top].2).hypot() < 1e-6, "the top handle stays: {:?} → {:?}", before[top], after2[top]);+ }+/// Direct Selection: a marquee over the top edges of two frames selects their top points, and a/// drag on one of them slants both frames in one undo step (InDesign's way to make a row of/// parallelograms).diff --cc crates/tools/src/select.rsindex 5c8dab8bd,f254cdf33..ebc7ce4d8--- a/crates/tools/src/select.rs+++ b/crates/tools/src/select.rs@@@ -812,20 -833,7 +833,7 @@@ impl SelectionTool{let at = anchor_spread_point(cx, id, si, ai);self.drag = Drag::Anchor { id, si, ai, handle: None, start: p, at, others: vec![] };-- return vec![Action::Exec("selection.set".into(), json!({"ids": [id], "content": true})), Action::Begin("Move Anchor".into())];- }- // As in InDesign, the Direct Selection tool pressed on a corner or anchor of an object- // that isn't selected selects it and moves just that point (Chris Nielsen's "The- // InDesign Toolbox", 10:10: click outside, then pull a frame's corner).- if self.direct- && !ev.mods.shift- && let Some((_, hit)) = cx.hit(p)- && !cx.selection.contains(hit)- && let Some((id, si, ai, None)) = anchor_at_in(cx, &[hit], p)- {- let at = anchor_spread_point(cx, id, si, ai);- self.drag = Drag::Anchor { id, si, ai, handle: None, start: p, at };+ return vec![Action::Exec("selection.set".into(), json!({"ids": [id], "content": false})), Action::Begin("Move Anchor".into())];}// A selected placed graphic's own handles resize it inside its frame (the// frame's anchors, under Direct Selection, come first).