From beb2fab945b7bebdef4b16478e9e86f6f1bc2585 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 12:13:09 -0800 Subject: [PATCH] Pen: state which Quick Pen edits end the path, and redraw tests docs/mcp.md now says that an edit made by another command during a drag ends the path whether it changes the path or other art, and that with the realTimeDrawing preference off such a press adds no piece while the edit stays. A flip or size change made during a drag is part of that piece's undo step; one made between presses is its own step. The paragraph is wrapped at the file's width again. The progress line lists a dragged piece ending at the release point and C, [ and ] changing the arc being dragged with VectorCraft's own rules. The bracket test checks that the arc being dragged is drawn again, the drag test checks that the next click starts a new path, and new tests cover an edit to other art during a click and an edit during a drag with realTimeDrawing off. The tool no longer keeps the path as it was before a press once the press ends. --- crates/engine/src/tests/quickpen.rs | 50 +++++++++++++++++++++++++-- crates/tools/src/quickpen.rs | 3 ++ crates/ui-egui/src/shortcuts.rs | 2 ++ crates/ui-egui/src/shortcuts/tests.rs | 14 ++++++++ docs/mcp.md | 19 +++++----- docs/target-app-parity.md | 2 +- 6 files changed, 79 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/tests/quickpen.rs b/crates/engine/src/tests/quickpen.rs index 890e279893..033f51e0c5 100644 --- a/crates/engine/src/tests/quickpen.rs +++ b/crates/engine/src/tests/quickpen.rs @@ -295,8 +295,8 @@ fn a_look_edit_during_a_drag_ends_the_path() { assert_eq!(paths(&s).len(), 2, "a new path"); } -/// An edit made by another command to another object during a drag stays: the press previews no -/// more, and its piece stays as last shown. +/// An edit made by another command to another object during a drag stays and ends the path: the +/// press previews no more, its piece stays as last shown, and the next click starts a new path. #[test] fn an_edit_to_another_object_during_a_drag_stays() { let mut s = session(); @@ -315,6 +315,52 @@ fn an_edit_to_another_object_during_a_drag_stays() { let pen = paths(&s).into_iter().find(|(id, _)| *id != rect).unwrap().1; let ends: Vec = pen.subpaths[0].anchors.iter().map(|a| a.p).collect(); assert_eq!(ends, [pt(100.0, 100.0), pt(200.0, 100.0), pt(200.0, 200.0)], "the piece as last shown"); + click(&mut s, 400.0, 400.0); + assert_eq!(paths(&s).len(), 3, "a new path"); +} + +/// With Real-time Drawing off, a drag during which another command edits the path adds no piece, +/// and the edit stays. +#[test] +fn an_edit_during_a_deferred_drag_stays() { + let mut s = session(); + s.execute("prefs.set", &json!({"key": "realTimeDrawing", "value": false})).unwrap(); + quick_pen(&mut s); + click(&mut s, 100.0, 100.0); + click(&mut s, 200.0, 100.0); + let id = paths(&s)[0].0; + let v = view(); + s.pointer(&PointerEvent::new(PointerKind::Down, 200.0, 180.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Drag, 200.0, 200.0), v).unwrap(); + s.execute("path.moveAnchor", &json!({"id": id.0, "anchor": 0, "x": 90, "y": 90})).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Drag, 250.0, 250.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 260.0, 260.0), v).unwrap(); + let ends: Vec = only_path(&s).anchors.iter().map(|a| a.p).collect(); + assert_eq!(ends, [pt(90.0, 90.0), pt(200.0, 100.0)], "the edit, and no piece"); +} + +/// An edit made by another command to another object during a click stays, and the path goes on: +/// a click previews its piece only when the press begins. +#[test] +fn an_edit_to_another_object_during_a_click_stays() { + let mut s = session(); + s.execute("shape.rectangle", &json!({"x": 500, "y": 400, "width": 50, "height": 50})).unwrap(); + let rect = s.doc().unwrap().selection.objects[0]; + quick_pen(&mut s); + click(&mut s, 100.0, 100.0); + click(&mut s, 200.0, 100.0); + let v = view(); + s.pointer(&PointerEvent::new(PointerKind::Down, 200.0, 200.0), v).unwrap(); + s.execute("paint.setStroke", &json!({"ids": [rect.0], "color": "#00ff00"})).unwrap(); + let edited = s.doc().unwrap().doc.node(rect).unwrap().clone(); + s.pointer(&PointerEvent::new(PointerKind::Up, 200.0, 200.0), v).unwrap(); + assert_eq!(*s.doc().unwrap().doc.node(rect).unwrap(), edited, "the other object's edit stays"); + click(&mut s, 300.0, 200.0); + let all = paths(&s); + assert_eq!(all.len(), 2, "no new path"); + let pen = all.into_iter().find(|(id, _)| *id != rect).unwrap().1; + let ends: Vec = pen.subpaths[0].anchors.iter().map(|a| a.p).collect(); + assert_eq!(ends, [pt(100.0, 100.0), pt(200.0, 100.0), pt(200.0, 200.0), pt(300.0, 200.0)]); } /// An edit made by another command during a click (a press let go where it went down) ends the diff --git a/crates/tools/src/quickpen.rs b/crates/tools/src/quickpen.rs index 18230345e4..6c546aad0f 100644 --- a/crates/tools/src/quickpen.rs +++ b/crates/tools/src/quickpen.rs @@ -536,6 +536,9 @@ impl Tool for QuickPenTool { } _ => vec![], }; + if let Some(dr) = self.drawing.as_mut() { + dr.before_press = None; + } self.press = None; self.snap.clear(); out diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index bf2dff9b68..462adb62d2 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -971,6 +971,8 @@ fn busy_tool_keys(app: &mut VectorcraftApp, ctx: &egui::Context, view: ViewInfo) let _ = app.session.tool_key(ToolKey::Digit(d), Mods::default(), view); } // `[` and `]` while the Quick Pen tool draws a piece: the arc being dragged takes the new size. + // The Blob Brush, Eraser and Symbolism tools do not get them during a press, so their size and + // intensity stay as they were when the press began. if app.session.tool_id() == vectorcraft_tools::quickpen::ID { tool_brackets(app, ctx, view); } diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index c751c15611..9a408090ed 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -2252,8 +2252,22 @@ fn brackets_size_the_quick_pen_arc_being_dragged() { app.session.pointer(&PointerEvent::new(PointerKind::Down, 280.0, 300.0), v).unwrap(); app.session.pointer(&PointerEvent::new(PointerKind::Drag, 300.0, 300.0), v).unwrap(); assert!(app.session.tool_busy()); + let points = |app: &VectorcraftApp| { + let mut v = vec![]; + app.session.doc().unwrap().doc.walk(|n| { + if let Some(pd) = n.path_data() { + v.extend(pd.subpaths.iter().flat_map(|sp| sp.anchors.iter().map(|a| a.p))); + } + }); + v + }; + let before = points(&app); + assert_eq!(before.len(), 3, "the arc being dragged is drawn"); frame(&mut app, vec![egui::Event::Text("[".into())]); assert_eq!(app.session.tool_options()["turn"], 165.0); + let after = points(&app); + assert_eq!(after.len(), 3); + assert_ne!(after[1], before[1], "the arc being dragged is drawn again with the new size"); } fn remembered_paint_app() -> VectorcraftApp { diff --git a/docs/mcp.md b/docs/mcp.md index 7a4f49e794..bf4572d85b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -7165,14 +7165,17 @@ path's last point, drawn with the tool's `action` option: Alt (Option on macOS) pressed and let go with no other key, click or wheel turn in between switches to the next action: Line, Continuous Arc, Sharp Corner Arc, and back to Line. C flips the last piece, while it is a sharp-corner arc, to the other side of its chord. `[` and `]` make the arc size 15° smaller or larger, for the last sharp-corner arc and the -arcs after it. During a drag, C and `[` `]` change the sharp-corner arc being dragged, within the drag's undo step, and -Alt switches its action. A dragged piece ends where the press is let go. An edit made to the path by another command -during a drag ends the path: the piece stays as last shown, and the edit stays. An edit to other art during a drag also -leaves the piece as last shown, and the edit stays. A click on the first point closes the -path, and a click on an end of an open path goes on drawing from that end. Escape or Enter ends the path, and so does an edit made to it by another command. The path's points show as circles without handles, and a preview shows the -piece the next click adds. Points snap to Smart Guides. Each piece, flip and size change is one undo step. The arc -size of 180°, its 15° steps, the side an arc bulges to and Enter ending the path are VectorCraft's own rules. The -tool keeps `action` and `turn` with the preferences (`tool.setOption {tool: "quickPen", key, value}`). +arcs after it. During a drag, C and `[` `]` change the sharp-corner arc being dragged, and Alt switches its action. A +dragged piece ends where the press is let go. A click on the first point closes the path, and a click on an end of an +open path goes on drawing from that end. Escape or Enter ends the path, and so does an edit made to it by another +command. An edit made by another command during a drag, to the path or to other art, also ends the path: the edit +stays, and the piece stays as last shown. With the `realTimeDrawing` preference off, a press during which another +command edits the document adds no piece, and the edit stays. The path's points show as circles without handles, and a +preview shows the piece the next click adds. Points snap to Smart Guides. Each piece is one undo step, together with the +flips and size changes made during its drag, and each flip or size change made between presses is one undo step. The +arc size of 180°, its 15° steps, the side an arc bulges to, what C and `[` `]` do during a drag and Enter ending the +path are VectorCraft's own rules. The tool keeps `action` and `turn` with the preferences +(`tool.setOption {tool: "quickPen", key, value}`). `path.quickPen {start?: [x, y], id?, subpath?, keep?, pieces?, closed?}` draws such a path and selects it, as one undo step, and answers `{id}`. With `start`, it makes a new path with the current paint (a black stroke when the paint diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index cdf7741f88..5f6c556c0f 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -629,7 +629,7 @@ since 2026-10-01. - **Guide row highlight (#7344):** `guide_row_highlight_stays_selected_without_hover` in `crates/ui-egui/src/panels/layers/tests.rs` checks selected guide background after the pointer leaves, with unselected guide and ordinary row controls. Guide selection, dragging and deletion are unchanged. Scores and estimates unchanged. - **Recolor picker follow-up (#8031/#4028):** native Lab numeric entry, document/loaded-library swatches in the Color Picker, and Assign-row Pick from Swatches / Limit to Library menus. #4090 provided the double-click picker and #5113 the Assign sliders. Regression tests `native_lab_entry_in_color_picker` and `row_context_menu_pick_from_swatches_and_limit_to_library` exercise the fields and menu callbacks rather than writing their result state. Area score and hours unchanged. -- **Quick Pen tool (#2660, in part):** a tool in the Pen tool's group (Alt+P, Option+P on macOS) draws straight lines, continuous arcs and sharp-corner arcs, one undo step per piece, a dragged piece ending where the press is let go; Alt pressed and let go on its own switches the action, C flips the last sharp-corner arc or the one being dragged, `[` and `]` change the arc size by 15°, a click on the first point closes the path, a click on an open end continues it, and Escape or Enter ends it (`path.quickPen`), as [Draw with the Quick Pen tool](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/draw-with-quick-pen-tool.html) and [Quick Pen tool keyboard shortcuts](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/quick-pen-tool-keyboard-shortcuts.html) describe. The 180° default arc, its 15° steps and the side an arc bulges to are VectorCraft's own rules. Tests: tools `quickpen::tests`, engine `tests::quickpen`, ui-egui `shortcuts::alt_tap::tests`, `alt_p_chooses_the_quick_pen_and_an_alt_tap_switches_its_action` and `brackets_size_the_quick_pen_arc_being_dragged`. Score and hours unchanged. +- **Quick Pen tool (#2660, in part):** a tool in the Pen tool's group (Alt+P, Option+P on macOS) draws straight lines, continuous arcs and sharp-corner arcs, one undo step per piece; Alt pressed and let go on its own switches the action, C flips the last sharp-corner arc, `[` and `]` change the arc size by 15°, a click on the first point closes the path, a click on an open end continues it, and Escape or Enter ends it (`path.quickPen`), as [Draw with the Quick Pen tool](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/draw-with-quick-pen-tool.html) and [Quick Pen tool keyboard shortcuts](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/quick-pen-tool-keyboard-shortcuts.html) describe. The 180° default arc, its 15° steps, the side an arc bulges to, a dragged piece ending where the press is let go, and C, `[` and `]` changing the arc being dragged are VectorCraft's own rules. Tests: tools `quickpen::tests`, engine `tests::quickpen`, ui-egui `shortcuts::alt_tap::tests`, `alt_p_chooses_the_quick_pen_and_an_alt_tap_switches_its_action` and `brackets_size_the_quick_pen_arc_being_dragged`. Score and hours unchanged. - **Optional compact Tools (#7234):** Window > Toolbars > Compact Tools reduces row and column spacing and the main panel's allocated width in one or two columns, docked or floating. The setting is saved with the UI state and applies to Basic, Advanced and edited main Tools layouts; the selected tool, icon size, footer controls and tool-flyout behavior are retained. Turning it off restores the existing layout, which remains the default. Named custom toolbars and flyout spacing are unchanged. Public regressions in `crates/ui-egui/tests/toolbar_compact.rs` cover the actual toolbar layout against the default control, the command and saved-state roundtrip, tool selection, flyouts, footer controls and short-window reachability. This is an optional layout choice, without a styling-parity or score claim; hours are unchanged.