mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
Quick Pen: the arc-size wheel keeps other view changes and pinches
A Ctrl+wheel share the tool takes now restores only the zoom, pan and rotation from before the wheel, so the content rect beside the rulers stays as the canvas settled it and a view command queued in the same frame still applies. A share outside the content rect makes no step, a native pinch with Control held zooms as usual, and the toolbar is shown in the restored space. The parity entry says one step per net whole wheel line.
This commit is contained in:
1 parent
f4888892d0
commit
9a843a5f0e
4 files changed
+100
-14
No files matched your search
@@ -145,7 +145,7 @@ struct Body {
|
||||
/// A view a compass or scroll bar edit made this pass.
|
||||
edited: Option<CanvasView>,
|
||||
/// The Quick Pen tool took this pass's wheel for its arc size ([`quick_pen_wheel::arc_size`]).
|
||||
arc_turn: bool,
|
||||
arc_view: Option<CanvasView>,
|
||||
}
|
||||
|
||||
/// Window `win`'s document in the framework canvas, filling the rest of `ui`. True when the canvas
|
||||
@@ -211,6 +211,7 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
// cursors the tools are told about.
|
||||
let precise = app.precise_cursors() != host_caps_lock;
|
||||
let prefs = &app.session.prefs;
|
||||
let before_wheel = cv;
|
||||
let mut canvas = Canvas::new("Document")
|
||||
.id(canvas_id(win))
|
||||
.view(Bind::bound(&mut cv))
|
||||
@@ -235,12 +236,21 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
if let Some(mut space) = canvas_space(&env.env) {
|
||||
let mut pass = tool_pass(&env.env);
|
||||
let bar_paint = PaintSlot::reserve(ui.painter());
|
||||
let mut arc_view = space.target();
|
||||
if space.wheel().is_some_and(|w| !w.claimed && quick_pen_wheel::control_turn(app, &w)) {
|
||||
arc_view.zoom = before_wheel.zoom;
|
||||
arc_view.center = before_wheel.center;
|
||||
arc_view.rotation = before_wheel.rotation;
|
||||
for request in &queued {
|
||||
request.command().apply(&mut arc_view, &target, Some(&layers), ppp, &scheme);
|
||||
}
|
||||
}
|
||||
let arc_turn = if kind == BodyKind::Live && app.ui.screen_mode < 3 {
|
||||
let mut bar_space = space;
|
||||
if space.wheel().is_some_and(|w| w.claimed || quick_pen_wheel::control_turn(app, &w)) {
|
||||
bar_space.set_view(given);
|
||||
bar_space.set_view(arc_view);
|
||||
}
|
||||
let bar = quick_pen_bar::quick_pen_bar(app, ui, &bar_space);
|
||||
let bar = with_canvas_space(ui, bar_space, |ui| quick_pen_bar::quick_pen_bar(app, ui, &bar_space));
|
||||
quick_pen_wheel::arc_size(app, ui.ctx(), &space, bar)
|
||||
} else {
|
||||
false
|
||||
@@ -249,14 +259,14 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
// The framework settles wheel navigation before the body. A claimed share uses the
|
||||
// saved view for the controls, painting and tool host, including its first pass.
|
||||
if arc_turn {
|
||||
space.set_view(given);
|
||||
space.set_view(arc_view);
|
||||
if let Some(pass) = pass.as_mut() {
|
||||
pass.space = Some(space);
|
||||
pass.view = Some(given);
|
||||
pass.view = Some(arc_view);
|
||||
}
|
||||
}
|
||||
body = with_canvas_space(ui, space, |ui| show_body(app, ui, &space, pass.as_ref(), win, kind, bar_shapes));
|
||||
body.arc_turn = arc_turn;
|
||||
body.arc_view = arc_turn.then_some(arc_view);
|
||||
}
|
||||
});
|
||||
let output = shown.output;
|
||||
@@ -269,7 +279,7 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
rulers::apply(app, ui, out);
|
||||
}
|
||||
let pressed = matches!(output.press.phase, PressPhase::Down { .. });
|
||||
let Body { reply, context_at, context_key, edited, arc_turn } = body;
|
||||
let Body { reply, context_at, context_key, edited, arc_view } = body;
|
||||
let request = reply
|
||||
.as_ref()
|
||||
.and_then(|r| r.context.as_ref())
|
||||
@@ -277,13 +287,11 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
.or(context_at.map(|at| context_menu::Request { at, key: context_key }));
|
||||
let jumped = edited.is_some();
|
||||
// Presentation Mode keeps its view through a drag of the middle button, which the canvas pans on its own, and a
|
||||
// wheel turn the Quick Pen tool takes for its arc size keeps the view the pass began with.
|
||||
// wheel turn the Quick Pen tool takes for its arc size leaves other view requests in place.
|
||||
let view_now = if presenting && ui.input(|i| i.pointer.middle_down()) {
|
||||
given
|
||||
} else if arc_turn {
|
||||
edited.unwrap_or(given)
|
||||
} else {
|
||||
edited.or(reply.and_then(|r| r.view)).or(output.view).unwrap_or(cv)
|
||||
edited.or(reply.and_then(|r| r.view)).or(arc_view).or(output.view).unwrap_or(cv)
|
||||
};
|
||||
if let Some(view) = doc_windows::view_mut(app, win) {
|
||||
view.set_canvas(&view_now, scaling);
|
||||
|
||||
@@ -69,7 +69,9 @@ fn fine(wheel: &Wheel, lines: f32) -> bool {
|
||||
pub(super) fn control_turn(app: &VectorcraftApp, wheel: &Wheel) -> bool {
|
||||
let line = crate::app::view::navigation(&app.session.prefs).wheel_line.max(1.0);
|
||||
let mods = if fine(wheel, lines(wheel, line)) { wheel.held } else { wheel.mods };
|
||||
ctrl_alone(mods, crate::keymap::platform())
|
||||
let scrolling =
|
||||
(wheel.scroll.is_finite() && wheel.scroll != egui::Vec2::ZERO) || (wheel.zoom_lines.is_finite() && wheel.zoom_lines != egui::Vec2::ZERO);
|
||||
ctrl_alone(mods, crate::keymap::platform()) && (wheel.claimed || scrolling)
|
||||
}
|
||||
|
||||
/// Whole lines in `v`, toward zero, with [`LINE_SLACK`] for rounding.
|
||||
@@ -119,10 +121,11 @@ pub(super) fn arc_size(app: &mut VectorcraftApp, ctx: &egui::Context, space: &Ca
|
||||
let muted = w.modal || app_modal;
|
||||
let line = crate::app::view::navigation(&app.session.prefs).wheel_line.max(1.0);
|
||||
let over_bar = w.at.zip(bar).is_some_and(|(at, bar)| bar.contains(at));
|
||||
let over_content = w.at.is_some_and(|at| space.view.rect.contains(at));
|
||||
let quick_pen = app.session.tool_id() == vectorcraft_tools::quickpen::ID;
|
||||
let mut taken = w.claimed;
|
||||
let mut runs = 0.0;
|
||||
if quick_pen && !muted && !over_bar && control_turn(app, &w) {
|
||||
if quick_pen && !muted && !over_bar && over_content && control_turn(app, &w) {
|
||||
let mut rest = w.claimed_spent.x;
|
||||
let made = steps(&w, line, &mut rest);
|
||||
// A share of a gesture another scroller owns cannot be claimed; the tool still takes it, as the
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//! is; the arc size commands step it as `[` and `]` do.
|
||||
|
||||
use craft::behavior::CanvasView;
|
||||
use craft::ui::canvas::{ViewCommands, ViewRequest};
|
||||
use egui::{Event, Modifiers, MouseWheelSource, MouseWheelUnit, Pos2, TouchPhase, vec2};
|
||||
use serde_json::json;
|
||||
use vectorcraft_doc::NodeKind;
|
||||
@@ -138,6 +139,7 @@ fn ctrl_wheel_changes_the_arc_size_and_not_the_view() {
|
||||
#[test]
|
||||
fn the_first_ctrl_wheel_frame_keeps_the_view_and_pointer() {
|
||||
let mut app = app();
|
||||
app.ui.view.rulers = true;
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
let at = center(rig) + vec2(80.0, 40.0);
|
||||
@@ -151,11 +153,84 @@ fn the_first_ctrl_wheel_frame_keeps_the_view_and_pointer() {
|
||||
assert_eq!(arc_size(rig), 195.0);
|
||||
assert_eq!(view(rig).zoom, still.zoom, "the first share keeps the zoom");
|
||||
assert_eq!(view(rig).center, still.center, "the first share keeps the pan");
|
||||
assert_eq!(view(rig).rect, still.rect, "the content stays inside the rulers");
|
||||
assert_eq!(craft::ui::canvas::ToolHost::shown_space(rig.fx.ctx(), id).unwrap().view, shown, "the tool host sees the saved view");
|
||||
assert_eq!(rig.app().hover_doc, Some(point), "the tool host uses the saved view in the same frame");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_queued_fit_survives_the_first_ctrl_wheel_frame() {
|
||||
let mut app = app();
|
||||
app.session.prefs.animated_zoom = false;
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
let fitted = view(rig);
|
||||
rig.app().run("view.zoomIn", json!({})).unwrap();
|
||||
rig.fx.settle();
|
||||
assert_ne!(view(rig).zoom, fitted.zoom);
|
||||
rig.fx.frame(vec![Event::PointerMoved(center(rig))]);
|
||||
rig.app().request_view(ViewRequest::Command(ViewCommands::FitArtboard), None);
|
||||
rig.fx.frame(vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0);
|
||||
assert_eq!(view(rig), fitted, "the queued fit reaches the stored view in the same frame");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_toolbar_keeps_its_anchor_on_the_first_ctrl_wheel_frame() {
|
||||
let mut app = app();
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
click_doc(rig, 100.0, 150.0);
|
||||
rig.fx.settle();
|
||||
let bar = rig.target("Quick Pen").unwrap().rect;
|
||||
rig.fx.frame(vec![Event::PointerMoved(center(rig) + vec2(-120.0, -80.0))]);
|
||||
rig.fx.frame(vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0);
|
||||
assert_eq!(rig.target("Quick Pen").unwrap().rect, bar, "the toolbar maps its anchor through the saved space");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_claimed_wheel_makes_no_step_outside_the_content() {
|
||||
let mut app = app();
|
||||
app.ui.view.rulers = true;
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
rig.fx.frame(vec![Event::PointerMoved(center(rig))]);
|
||||
let still = view(rig);
|
||||
rig.fx.frame(vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0);
|
||||
let outside = egui::pos2(still.rect.left() - 1.0, still.rect.center().y);
|
||||
rig.fx.frame(vec![Event::PointerMoved(outside)]);
|
||||
rig.fx.frame(vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0, "a share over a ruler makes no step");
|
||||
assert_eq!(view(rig), still, "the claimed gesture still keeps the view");
|
||||
rig.fx.frame(vec![Event::PointerMoved(center(rig))]);
|
||||
rig.fx.frame(vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 210.0, "the gesture resumes inside the content");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_native_pinch_with_control_zooms_the_view() {
|
||||
let mut app = app();
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
rig.fx.hold(ctrl());
|
||||
rig.fx.frame(vec![Event::PointerMoved(center(rig))]);
|
||||
let still = view(rig);
|
||||
rig.fx.frame(vec![Event::Zoom(1.25)]);
|
||||
assert!(view(rig).zoom > still.zoom, "a native pinch keeps its zoom");
|
||||
assert_eq!(arc_size(rig), 180.0);
|
||||
let zoomed = view(rig);
|
||||
rig.fx.frame(vec![Event::Zoom(1.25)]);
|
||||
assert!(view(rig).zoom > zoomed.zoom, "the pinch was not claimed as an arc gesture");
|
||||
rig.fx.hold(Modifiers::NONE);
|
||||
});
|
||||
}
|
||||
|
||||
/// Opposite notches in one frame use the framework's net lines and keep the tool host's view.
|
||||
#[test]
|
||||
fn opposite_notches_use_the_frameworks_reported_net_motion() {
|
||||
|
||||
@@ -706,7 +706,7 @@ since 2026-10-01.
|
||||
- **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 editing (#2660):** with no path being drawn, the Quick Pen tool moves an anchor or a segment of a selected path by a drag (`path.moveAnchors` with `interpolate`, one undo step; beside a moved corner anchor a line stays a line and an arc an arc, and at a moved smooth anchor the handles stay in line and the segments bend to meet), selects an anchor with a click and adds one with Shift-click, and the canvas context menu's Delete removes the selected anchors (`edit.clear`), 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) describes. Which presses select and which move, and the drag snapping only an anchor, are VectorCraft's own rules. Tests: tools `quickpen::tests::a_selected_paths_anchors_and_segments_show_the_edit_cursors`, engine `tests::quickpen` (`a_drag_on_an_anchor_moves_it_and_the_arc_stays_an_arc`, `a_drag_on_a_segment_moves_its_ends`, `a_drag_on_an_open_end_moves_it`, `a_release_past_the_drag_distance_moves_the_anchor`, `clicks_select_anchors_for_delete`, `escape_takes_back_an_anchor_drag`, `a_press_while_drawing_adds_a_piece`), ui-egui `tests::contextmenu::the_quick_pen_menu_deletes_the_selected_anchors`. Score and hours unchanged.
|
||||
- **Recolor with Preset asks for a library first:** Edit › Edit Colors › Recolor with Preset (1, 2 and 3 Color Job, Color Library) opens a Recolor with Preset dialog whose Limit to Library menu (None, Document Swatches or a library) is applied when Recolor Artwork opens (<https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=251>, "Quickly reduce colors using a preset"). A 1 Color Job limited to the document's swatches with a spot or global ink picked turns gray art into tints of that ink linked to its swatch, so editing the swatch recolors the art. Tests `recolor_with_preset_asks_for_a_library_first` and `a_one_color_job_limited_to_document_swatches_links_gray_art_to_the_ink`. 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; Alt pressed and let go on its own switches the action, C flips the last sharp-corner arc, `[` and `]` and Ctrl with a touchpad scroll or a mouse wheel over the canvas change the arc size by 15° (`tool.quickPen.arcLarger`, `tool.quickPen.arcSmaller`), 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, C, `[` and `]` changing the arc being dragged, the mouse wheel changing the arc size, and one step per wheel event of a mouse wheel are VectorCraft's own rules. Tests: tools `quickpen::tests`, engine `tests::quickpen`, ui-egui `shortcuts::alt_tap::tests`, `tests::quickpenwheel`, `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 `]` and Ctrl with a touchpad scroll or a mouse wheel over the canvas change the arc size by 15° (`tool.quickPen.arcLarger`, `tool.quickPen.arcSmaller`), 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, C, `[` and `]` changing the arc being dragged, the mouse wheel changing the arc size, and one step per net whole wheel line of a mouse wheel are VectorCraft's own rules. Tests: tools `quickpen::tests`, engine `tests::quickpen`, ui-egui `shortcuts::alt_tap::tests`, `tests::quickpenwheel`, `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 protractor:** while an arc is drawn, by a drag or as the piece the next click adds, the Quick Pen tool shows a protractor around the arc's center: a tick every 15° from the arc's start, a longer one every 90°, and one at its end; the next click's piece shows it only with Enable Rubber Band for the Pen tool on. With Smart Guides on, the end of a continuous arc snaps onto the nearest tick within the snapping tolerance of the pointer when no other Smart Guide snaps the point and neither Snap to Grid nor Snap to Pixel snaps drawn points; Shift does not change it. A continuous arc that starts a path sweeps the arc size and does not snap to a tick, Alt tapped during a press moves the piece's end onto or off the tick for the new action, and a hover hides its preview after a snap setting changes until the pointer moves. The protractor, its 15° step and the tick snapping are VectorCraft's own behavior. Tests: tools `the_arc_circle_is_the_circle_the_arc_is_drawn_on`, `a_continuous_arc_end_goes_to_the_nearest_tick`, `a_tick_past_the_coordinate_limit_is_not_used`, `a_continuous_arc_without_a_direction_has_no_tick`, `the_protractor_ticks_lie_across_the_arc`; engine `a_continuous_arc_end_snaps_to_the_protractor`, `a_click_puts_a_continuous_arc_end_on_a_tick`, `an_alt_tap_during_a_press_moves_the_end_for_the_new_action`, `a_click_on_a_tick_leaves_no_preview_back_to_the_pointer`, `a_hover_snaps_to_a_tick_only_for_a_continuous_arc`, `a_hover_shows_nothing_after_smart_guides_change`, `a_click_that_adds_nothing_keeps_a_stale_hover_hidden`, `a_hover_is_hovered_again_when_the_art_changes`, `an_arc_drag_shows_the_protractor`, `a_hovered_arc_shows_the_protractor_with_the_rubber_band`. New tests of existing Quick Pen behavior: `a_point_snaps_to_a_smart_guide`, `hovering_shows_the_distance_label`. Score and hours unchanged.
|
||||
- **Quick Pen arc center:** wherever the Quick Pen tool shows an arc's protractor, it also marks the arc's center with a small cross. The cross is VectorCraft's own behavior. Test: engine `an_arc_shows_a_cross_at_its_center`. Score and hours unchanged.
|
||||
|
||||
|
||||
Reference in new issue
Block a user