DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
M4: the Pen previews the segment a dragged smooth point shapes and curves the rubber band after one (#1438)
Trevor Brown93999750aa05
diff --git a/ROADMAP.md b/ROADMAP.mdindex 58a1913e5..2ce77baa6 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -382,6 +382,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m## Progress log+- **2026-11-02** · The Pen shows the segment a dragged smooth point shapes while it is dragged, and its rubber band curves out of a smooth point's direction line (#1438, first item). No readiness percentage change.- **2026-11-02** · Windows: the custom title bar window stays borderless, so the content is no longer drawn offset by the caption and border (black bars at the top and left, clicks landing off target). The workaround goes when winit carries the fix (storytold/winit#17). No readiness percentage change.- **2026-10-30** · The Color Picker takes an eyedropper: dragged from the picker onto the page, it takes the colour the canvas shows (proofed under Proof Colors). No readiness percentage change.- **2026-10-30** · The Color Picker is laid out as the reference app's: a field and slider for the component chosen, HSB, Lab, RGB and CMYK values, the old colour, and Add CMYK Swatch; Enter and Esc close it once. No readiness percentage change.diff --git a/crates/tools/src/pen.rs b/crates/tools/src/pen.rsindex 21e85f010..2404cb762 100644--- a/crates/tools/src/pen.rs+++ b/crates/tools/src/pen.rs@@ -299,21 +299,37 @@ impl Tool for PenTool {return out;};let xf = cx.layout.xf(sr);+ let blue = [79, 153, 255];if let Some(last) = self.anchors.last()&& !self.dragging{- // Rubber band to the pointer.- out.push(Overlay::Line { a: xf * last.0, b: self.hover, color: [79, 153, 255], dashed: true });+ // Rubber band to the pointer: the segment the next click would make, straight from+ // a corner, curved out of a smooth point's direction line (#1438).+ if (last.2 - last.0).hypot() > 1e-9 {+ let mut path = BezPath::new();+ path.move_to(xf * last.0);+ path.curve_to(xf * last.2, self.hover, self.hover);+ out.push(Overlay::Path { path, color: blue, dashed: true });+ } else {+ out.push(Overlay::Line { a: xf * last.0, b: self.hover, color: blue, dashed: true });+ }}if self.path.is_none() && self.anchors.len() == 1 {let a = self.anchors[0];- out.push(Overlay::Line { a: xf * a.1, b: xf * a.2, color: [79, 153, 255], dashed: false });+ out.push(Overlay::Line { a: xf * a.1, b: xf * a.2, color: blue, dashed: false });}if self.dragging&& let Some(a) = self.anchors.last(){- out.push(Overlay::Line { a: xf * a.1, b: xf * a.2, color: [79, 153, 255], dashed: false });- let _ = BezPath::new();+ // The direction line being dragged out, and the segment it shapes: from the previous+ // anchor's out handle to the new anchor's in handle, live under the pointer (#1438).+ out.push(Overlay::Line { a: xf * a.1, b: xf * a.2, color: blue, dashed: false });+ if let Some(prev) = self.anchors.len().checked_sub(2).and_then(|i| self.anchors.get(i)) {+ let mut path = BezPath::new();+ path.move_to(xf * prev.0);+ path.curve_to(xf * prev.2, xf * a.1, xf * a.0);+ out.push(Overlay::Path { path, color: blue, dashed: false });+ }}// Guides are already canvas. Do not run them through the spread transform again.out.extend(self.guides.iter().cloned());diff --git a/crates/tools/src/tests.rs b/crates/tools/src/tests.rsindex 9e2421db5..177f114b5 100644--- a/crates/tools/src/tests.rs+++ b/crates/tools/src/tests.rs@@ -888,6 +888,62 @@ fn pen_click_snaps_to_a_guide() {assert!((x - 100.0).abs() < 1e-6, "anchor x {x}");}+/// #1438: dragging a smooth point shows the segment it shapes under the pointer (from the+/// previous anchor's out handle to the new anchor's in handle), and after a smooth point the+/// rubber band to the pointer curves out of its direction line; a corner keeps the straight one.+#[test]+fn pen_previews_the_curve_while_dragging_and_after_a_smooth_point() {+ use designcraft_geom::{BezPath, PathEl};+ let d = Document::new(&NewDocument::default());+ let (s, c, l) = (Selection::default(), Cache::new(), CanvasLayout::new(&d, false));+ let cx = ctx(&d, &s, &c, &l);+ let (sr, _) = cx.layout.spread_at(Point::new(100.0, 100.0)).expect("the page is under the pointer");+ let xf = cx.layout.xf(sr);+ let sp = |x: f64, y: f64| cx.layout.to_spread(sr, Point::new(x, y));+ let near = |a: Point, b: Point| (a - b).hypot() < 1e-6;+ let paths = |t: &dyn Tool, dashed: bool| -> Vec<BezPath> {+ t.overlays(&cx)+ .into_iter()+ .filter_map(|o| match o {+ Overlay::Path { path, dashed: d, .. } if d == dashed => Some(path),+ _ => None,+ })+ .collect()+ };+ let mut t = create("pen");+ t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 100.0, 100.0));+ t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 100.0, 100.0));+ // A corner's rubber band is a straight line: no curve.+ t.pointer(&cx, &PointerEvent::new(PointerKind::Move, 150.0, 120.0));+ assert!(paths(&*t, true).is_empty() && paths(&*t, false).is_empty(), "a corner's rubber band is a line");+ // Dragging the second anchor out: the segment from the first anchor is previewed live.+ t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 200.0, 100.0));+ t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 230.0, 130.0));+ let [p] = &paths(&*t, false)[..] else { panic!("one solid curve preview: {:?}", t.overlays(&cx)) };+ let in_handle = sp(200.0, 100.0) - (sp(230.0, 130.0) - sp(200.0, 100.0));+ match p.elements() {+ [PathEl::MoveTo(a), PathEl::CurveTo(c1, c2, b)] => {+ assert!(near(*a, xf * sp(100.0, 100.0)) && near(*c1, xf * sp(100.0, 100.0)), "from the corner, whose out handle is itself: {a:?} {c1:?}");+ assert!(near(*c2, xf * in_handle) && near(*b, xf * sp(200.0, 100.0)), "to the dragged anchor by its in handle: {c2:?} {b:?}");+ }+ other => panic!("{other:?}"),+ }+ // Let go: the anchor is committed and the segment preview goes; the rubber band now curves+ // out of the smooth point's direction line towards the pointer.+ let up = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 230.0, 130.0));+ assert!(matches!(&up[..], [Action::Exec(cmd, _)] if cmd == "path.create"), "{up:?}");+ assert!(paths(&*t, false).is_empty(), "no segment preview once let go");+ t.pointer(&cx, &PointerEvent::new(PointerKind::Move, 300.0, 100.0));+ let [band] = &paths(&*t, true)[..] else { panic!("a curved rubber band: {:?}", t.overlays(&cx)) };+ match band.elements() {+ [PathEl::MoveTo(a), PathEl::CurveTo(c1, c2, b)] => {+ assert!(near(*a, xf * sp(200.0, 100.0)) && near(*c1, xf * sp(230.0, 130.0)), "{a:?} {c1:?}");+ assert!(near(*c2, Point::new(300.0, 100.0)) && near(*b, Point::new(300.0, 100.0)), "{c2:?} {b:?}");+ }+ other => panic!("{other:?}"),+ }+}+/// A text frame with overset text (selected), an empty frame and a threaded pair x → y, on page 1.struct ThreadDoc {d: Document,diff --git a/docs/ui-parity.md b/docs/ui-parity.mdindex 3e6cac78a..bea0224b2 100644--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@ -1,6 +1,6 @@# UI and interaction parity-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Table of Contents dialog: title field keeps its width, More Options toggles without losing hidden settings; Story panel; text Control panel Character/Paragraph modes; Properties ••• expands Character and Paragraph; live corners work; document views row: scrollbars, Alt pans while editing text; Tabs panel listed as present (#343); spring-loaded Zoom navigation; paragraph style override feedback and clearing) · **Target:** Adobe InDesign 2026 (21.6, Medium Dark, macOS)+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-02 · **Change:** patch (the Pen previews the curve while a smooth point is dragged and curves the rubber band after one, #1438; Table of Contents dialog: title field keeps its width, More Options toggles without losing hidden settings; Story panel; text Control panel Character/Paragraph modes; Properties ••• expands Character and Paragraph; live corners work; document views row: scrollbars, Alt pans while editing text; Tabs panel listed as present (#343); spring-loaded Zoom navigation; paragraph style override feedback and clearing) · **Target:** Adobe InDesign 2026 (21.6, Medium Dark, macOS)Tools, handles, snapping, nudging, modifiers, shortcuts, panels, menus, context menus and feel,against InDesign 2026. The look was measured from the running app@@ -29,7 +29,7 @@ basics of editing fail for too many users on Windows and Linux.| Chrome: app bar, Control panel, Tools panel, dock, doc tabs, status bar | Medium Dark, measured sizes | measured look; the text Control panel switches between Character (A) and Paragraph (¶) Formatting Controls (¶ with the Bulleted and Numbered List buttons, Shading and Border), and Escape in a field reverts what was typed | ✓ | 11-observed-ui.md; Learn Skills Daily course, chapter 16 || Properties panel and Contextual Task Bar | per selection | ✓, task bar movable (#143); ••• expands Character (scales, baseline shift, skew, language, case and position buttons) and Paragraph (indents, spacing, drop cap, baseline grid, hyphenation) in place | ✓ | Learn Skills Daily course, chapter 16; `properties.rs` `more_options_expand_character_and_paragraph_in_place` || Selection tool: click, marquee, move, Alt-duplicate, resize handles, rotate from corners | ✓ | ✓ | ✓ | Cmd/Ctrl held with another tool borrows the selection tool used last (Selection or Direct Selection) for one gesture, #919 |-| Direct Selection, Pen family, Pencil, Scissors | ✓ | ✓ | ~ | moving reference point "0" fails (#337) |+| Direct Selection, Pen family, Pencil, Scissors | ✓ | ✓ | ~ | the Pen previews the segment while a smooth point is dragged out and curves the rubber band out of a smooth point's direction line (`pen_previews_the_curve_while_dragging_and_after_a_smooth_point`, #1438); moving reference point "0" fails (#337) || Live corners (yellow handle) | ✓ | ✓ widget on a selected rectangle frame; diamonds drag the corner size (Shift: one corner), Alt-click steps the shape (Shift+Alt: all) | ✓ | #186 || Content grabber, frame fitting by double-click | ✓ | ✓ | ✓ | || Overset mark (red + at the out port) | selected frame only | every overset frame, groups included, while frame edges show | ✓ | a deliberate step past InDesign: grouped labels that overflow were invisible until Preflight |@@ -134,6 +134,7 @@ covers checking the sampled and redefined settings in the styles tutorial (2:45| Date | Change | Summary ||---|---|---|+| 2026-11-02 | patch | Pen: while a smooth point's direction line is dragged out, the segment it shapes (from the previous anchor's out handle to the new anchor's in handle) shows live under the pointer; after a smooth point the rubber band to the pointer curves out of its direction line, a corner's stays straight (#1438, first item; the Option/Alt handle split is the other). Test: `pen_previews_the_curve_while_dragging_and_after_a_smooth_point` || 2026-10-30 | minor | Dialogs: Table of Contents title field keeps its edit width; More Options toggles without losing hidden settings || 2026-10-24 | minor | Panels row: Story panel (Optical Margin Alignment and its size) || 2026-10-21 | minor | Chrome row: the text Control panel's A/¶ modes; Properties row: ••• expands Character and Paragraph in place |