Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge #902 (Direct Selection pulls a corner of an unselected object) into direct-select-anchor-points

moppeeera1d4b1bc2756
diff --cc ROADMAP.md
index c29decaa5,f7bf311f6..b4e89178a
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -359,7 -359,7 +359,8 @@@ Newest first
- **2026-10-16** · Lock Guides and Lock Column Guides are commands in View ▸ Grids & Guides (`view.lockGuides`, ⌥⌘;, and `view.lockColumnGuides`), so the control channel and MCP reach them. Lock Column Guides is an undo step, is saved with the document, on in new ones, and read from and written to IDML's `ColumnGuideLocked`, which export always wrote as locked (#1096). No readiness percentage change.
- **2026-10-16** · IDML: a page keeps column guides that were dragged off centre (InDesign's Custom columns). They were divided evenly on import, so the gutter sprang back to the middle; the imported positions now place the columns, with the canvas guides, snapping and text placement following them, and they are written back on export. Layout › Margins and Columns re-divides them evenly when the count or gutter changes, as InDesign's does. No readiness percentage change.
- **2026-10-16** · IDML: custom column positions are checked before they are used (#1096). A set must give two edges per column, ascending from the left margin to the right one; any other (a wrong count, unsorted or non-numeric values, a list longer than 216 columns allow, or positions left behind by a margin or page-size change) is the even split, in the canvas, on import and on export, instead of columns drawn outside the margins. No readiness percentage change.
+ - **2026-10-14** · The Direct Selection tool pressed on a corner or anchor of an object that isn't selected selects it and pulls just that point, as in InDesign (it moved the whole object). No readiness percentage change.
+- **2026-10-20** · Direct Selection selects anchor points: a marquee selects the points inside it on every path it reaches, a click selects one point and Shift+click adds or removes one, selected points show solid, and dragging one (Shift: at 45° steps) or pressing the arrow keys moves them all in one step (`selection.set {anchors}`, `path.moveAnchors {points}`). No readiness percentage change.
- **2026-10-16** · Type › Reload Fonts (`font.reload`): fonts installed, edited or removed while DesignCraft runs are read again without a restart, and the open documents recompose with them (#328, #547). An edited font file is noticed by its length and modification time; bundled, added and document fonts stay as they are. InDesign does this by itself, so noticing changes automatically is still open (gap 6). No readiness percentage change.
- **2026-10-16** · Parents can be deleted from their Pages-panel context menu or `layout.parents.delete {id}`. Applied-page and based-on references are cleared, local override copies survive, and Undo restores the parent. Addresses the deletion portion of #956; no readiness percentage change.
- **2026-10-17** · File › Package writes the document's and the IDML's links relative to the package (`Links/logo.png`, `file:Links/logo.png`), so a package holds no path from the machine that made it; opening a document resolves them to the files beside it. Links › Copy Link(s) To still links by full path. (#340). No readiness percentage change.
diff --cc crates/engine/src/tests.rs
index 9ec67f598,fdb9067cf..634e22cb8
--- a/crates/engine/src/tests.rs
+++ b/crates/engine/src/tests.rs
@@@ -1652,37 -1652,44 +1652,79 @@@ fn a_line_fits_when_its_baseline_does(
assert!(overset(&mut s, 50.0), "a baseline below the frame still oversets the line");
}
+/// 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).
+#[test]
+fn direct_selection_moves_the_points_of_several_frames_at_once() {
+ use designcraft_tools::{Mods, PointerEvent, PointerKind};
+ let mut s = session();
+ let v = ViewInfo::at_zoom(1.0);
+ let a = s.execute("frame.create", &json!({"rect": [100, 300, 200, 400]})).unwrap()["id"].as_u64().unwrap();
+ let b = s.execute("frame.create", &json!({"rect": [200, 300, 300, 400]})).unwrap()["id"].as_u64().unwrap();
+ s.execute("selection.set", &json!({"ids": []})).unwrap();
+ s.set_tool("directSelection");
+ s.pointer(&PointerEvent::new(PointerKind::Down, 80.0, 280.0), v).unwrap();
+ s.pointer(&PointerEvent::new(PointerKind::Drag, 320.0, 320.0), v).unwrap();
+ s.pointer(&PointerEvent::new(PointerKind::Up, 320.0, 320.0), v).unwrap();
+ let sel = s.doc().unwrap().selection.clone();
+ assert_eq!(sel.anchors.len(), 4, "{:?}", sel.anchors);
+ assert!(sel.items.contains(&designcraft_doc::ItemId(a)) && sel.items.contains(&designcraft_doc::ItemId(b)));
+ let shift = Mods { shift: true, ..Default::default() };
+ s.pointer(&PointerEvent::new(PointerKind::Down, 100.0, 300.0), v).unwrap();
+ s.pointer(&PointerEvent::new(PointerKind::Drag, 136.0, 302.0).with_mods(shift), v).unwrap();
+ s.pointer(&PointerEvent::new(PointerKind::Up, 136.0, 302.0).with_mods(shift), v).unwrap();
+ let corners = |s: &Session, id: u64| -> Vec<(f64, f64)> {
+ let st = s.doc().unwrap();
+ let it = st.doc.item(designcraft_doc::ItemId(id)).unwrap();
+ it.path.subpaths[0].anchors.iter().map(|an| ((it.xf * an.p).x.round(), (it.xf * an.p).y.round())).collect()
+ };
+ // Both frames: top points 36 pt to the right, bottom points where they were.
+ assert_eq!(corners(&s, a), vec![(136.0, 300.0), (236.0, 300.0), (200.0, 400.0), (100.0, 400.0)]);
+ assert_eq!(corners(&s, b), vec![(236.0, 300.0), (336.0, 300.0), (300.0, 400.0), (200.0, 400.0)]);
+ s.execute("edit.undo", &json!({})).unwrap();
+ assert_eq!(corners(&s, a), vec![(100.0, 300.0), (200.0, 300.0), (200.0, 400.0), (100.0, 400.0)]);
+ assert_eq!(corners(&s, b), vec![(200.0, 300.0), (300.0, 300.0), (300.0, 400.0), (200.0, 400.0)]);
+}
++
+ #[test]
+ fn direct_selection_pulls_one_corner_of_an_unselected_frame() {
+ // Chris Nielsen's "The Adobe InDesign Toolbox" (10:10): with the White Arrow, click outside,
+ // then press on a frame's corner and pull it: only that corner moves (a triangle, nearly).
+ use designcraft_tools::{PointerEvent, PointerKind, SnapView};
+ 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": [156, 219, 455, 569], "content": "graphic"})).unwrap()["id"].as_u64().unwrap();
+ s.execute("edit.deselectAll", &json!({})).unwrap();
+ let corners = |s: &Session| {
+ let d = &s.doc().unwrap().doc;
+ let it = d.item(designcraft_doc::ItemId(id)).unwrap();
+ it.path.subpaths[0].anchors.iter().map(|a| it.xf * a.p).collect::<Vec<_>>()
+ };
+ let before = corners(&s);
+ s.set_tool("directSelection");
+ let v = ViewInfo { snap: SnapView::OFF, ..ViewInfo::at_zoom(1.0) };
+ let layout = s.layout();
+ let at = |x: f64, y: f64| layout.to_canvas(designcraft_doc::SpreadRef::Doc(0), designcraft_geom::Point::new(x, y));
+ let (a, b) = (at(455.0, 219.0), at(455.0, 150.0));
+ s.pointer(&PointerEvent::new(PointerKind::Down, a.x, a.y), v).unwrap();
+ s.pointer(&PointerEvent::new(PointerKind::Drag, a.x, a.y - 30.0), 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 after = corners(&s);
+ let moved: Vec<_> = before.iter().zip(&after).filter(|(p, q)| (**p - **q).hypot() > 1e-6).collect();
+ assert_eq!(moved.len(), 1, "one corner moved: {before:?} → {after:?}");
+ assert!((*moved[0].1 - designcraft_geom::Point::new(455.0, 150.0)).hypot() < 1e-6, "{after:?}");
+ assert_eq!(s.doc().unwrap().selection.items, [designcraft_doc::ItemId(id)], "the frame is selected");
+ // One undo step puts the corner back.
+ s.execute("edit.undo", &json!({})).unwrap();
+ assert_eq!(corners(&s), before);
+ // Away from its corners, the White Arrow still drags the whole unselected frame.
+ s.execute("edit.deselectAll", &json!({})).unwrap();
+ let (c, d) = (at(300.0, 219.0), at(300.0, 269.0));
+ s.pointer(&PointerEvent::new(PointerKind::Down, c.x, c.y), v).unwrap();
+ s.pointer(&PointerEvent::new(PointerKind::Drag, c.x, c.y + 20.0), v).unwrap();
+ s.pointer(&PointerEvent::new(PointerKind::Drag, d.x, d.y), v).unwrap();
+ s.pointer(&PointerEvent::new(PointerKind::Up, d.x, d.y), v).unwrap();
+ assert!(corners(&s).iter().zip(&before).all(|(p, q)| (p.y - q.y - 50.0).abs() < 1e-6), "{:?}", corners(&s));
+ }
diff --cc crates/tools/src/select.rs
index 81589885f,389706f7b..5853536aa
--- a/crates/tools/src/select.rs
+++ b/crates/tools/src/select.rs
@@@ -804,39 -746,22 +804,52 @@@ impl Tool for SelectionTool
&& let Some((id, si, ai, handle)) = anchor_at(cx, p)
{
let at = anchor_spread_point(cx, id, si, ai);
- self.drag = Drag::Anchor { id, si, ai, handle, start: p, at };
- return vec![Action::Begin(if handle.is_some() { "Move Direction Handle".into() } else { "Move Anchor".into() })];
+ let mut out = vec![];
+ let mut others = vec![];
+ if handle.is_none() {
+ // InDesign's anchor point selection: a click selects the point, Shift+click
+ // adds it or takes it away, and dragging a selected point moves all of them.
+ let me = (ItemId(id), si, ai);
+ let mut points = cx.selection.anchors.clone();
+ let was = points.contains(&me);
+ if ev.mods.shift && was {
+ // Kept selected so a Shift-drag can constrain it; a click still takes it
+ // away, on release, as for objects.
+ self.anchor_release = Some(me);
+ } else if ev.mods.shift {
+ points.push(me);
+ } else if !was {
+ points = vec![me];
+ }
+ if points != cx.selection.anchors {
+ out.push(Action::Exec("selection.set".into(), anchor_selection(cx, &points)));
+ }
+ others = points.iter().filter(|a| **a != me).map(|(i, s, a)| (i.0, *s, *a)).collect();
+ }
+ let label = if handle.is_some() {
+ "Move Direction Handle"
+ } else if others.is_empty() {
+ "Move Anchor"
+ } else {
+ "Move Anchors"
+ };
+ self.drag = Drag::Anchor { id, si, ai, handle, start: p, at, others };
+ out.push(Action::Begin(label.into()));
+ return out;
}
+ // 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 };
++ 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())];
+ }
// A selected placed graphic's own handles resize it inside its frame (the
// frame's anchors, under Direct Selection, come first).
if let Some((id, h)) = content_handle_at(cx, p)