mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 12:35:48 -05:00
Merge pull request #8808 from dotCooCoo/feat/quick-pen-scroll-arc
Quick Pen: Ctrl+wheel over the canvas changes the arc size
This commit is contained in:
12 files changed
+702
-23
No files matched your search
@@ -155,6 +155,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
|
||||
- 2026-11-19: Quick Pen tool, in the Pen tool's group (Alt+P, Option+P on macOS): clicks or drags add straight lines, continuous arcs or sharp-corner arcs; Alt tapped on its own switches the action, C flips the last arc, `[` and `]` size it, a click on the first point closes the path and a click on an open end continues it (`path.quickPen`, part of #2660). Headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen length handles: a handle beyond the start and the end of the path being drawn, or of the selected path, makes the line or arc there longer or shorter when dragged; a line keeps its direction and an arc its circle (`path.quickPenLength`, part of #2660). Headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen toolbar on the canvas while the tool is active: Straight Line, Continuous Arc and Sharp Corner Arc, Flip Arc, and More Options with Hide Toolbar, Pin Toolbar Position and Reset Toolbar Position; it follows the drawing beside the path's last point and its handle drags it (`tool.quickPen.flipArc`, `window.quickPenToolbar`, Window › Quick Pen Toolbar; part of #2660). Headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen arc size with Ctrl+wheel: over the canvas, a touchpad scroll or a mouse wheel turned with Ctrl makes the arc size 15° larger or smaller per step, as `]` and `[` do, and the view stays put (`tool.quickPen.arcLarger`, `tool.quickPen.arcSmaller`; part of #2660). Headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen editing: with no path being drawn, a drag on an anchor or a segment of a selected path moves it, a line staying a line and an arc an arc beside a moved corner anchor (at a smooth anchor the handles stay in line and the segments bend to meet); a click selects an anchor, Shift-click adds one, and the canvas context menu's Delete removes the selected anchors (`path.moveAnchors`, `edit.clear`; #2660). Headline numbers unchanged.
|
||||
- 2026-10-31: Pattern libraries: Window › Swatch Libraries › Patterns and the Swatches panel's library menu open Geometric Patterns, a built-in library of eleven pattern swatches (dots, stripes, checks, a grid and shapes); clicking one adds its pattern and swatch to the document, once, and applies it to the active fill or stroke (`swatch.library.add`).
|
||||
- 2026-11-11: Pattern libraries: Patterns › Grit Textures, a second built-in pattern library, holds eight seamless black textures (Fine Grain, Coarse Grit, Sand, Speckle, Stipple, Scratches, Sparse Flecks and Dense Flecks) on tiles of 18 to 36 pt, each drawn the same way every time; marks that reach past a tile edge continue on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged.
|
||||
|
||||
@@ -735,6 +735,18 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"",
|
||||
"{} flip the last sharp-corner arc of the path the Quick Pen tool is drawing to the other side of its chord, as C and the toolbar's Flip Arc button do, as one undo step; first finishes any pending tool edit (which can change the document), then returns false, changing nothing more, when the Quick Pen tool is not active, no path is being drawn or the last piece is not a sharp-corner arc",
|
||||
),
|
||||
(
|
||||
"tool.quickPen.arcLarger",
|
||||
"Increase Arc Size",
|
||||
"",
|
||||
"{} make the Quick Pen tool's arc size 15° larger, for the last sharp-corner arc of the path being drawn and the arcs after it, as ] and Ctrl+wheel up over the canvas do; first finishes any pending tool edit (which can change the document), then returns false, changing nothing more, when the Quick Pen tool is not active or a step would take the arc size above 359°",
|
||||
),
|
||||
(
|
||||
"tool.quickPen.arcSmaller",
|
||||
"Decrease Arc Size",
|
||||
"",
|
||||
"{} make the Quick Pen tool's arc size 15° smaller, for the last sharp-corner arc of the path being drawn and the arcs after it, as [ and Ctrl+wheel down over the canvas do; first finishes any pending tool edit (which can change the document), then returns false, changing nothing more, when the Quick Pen tool is not active or a step would take the arc size below 1°",
|
||||
),
|
||||
(
|
||||
"window.dock",
|
||||
"Panels",
|
||||
|
||||
@@ -6,7 +6,7 @@ use craft::behavior::{CanvasView, PressPhase};
|
||||
use craft::keymap::Mods;
|
||||
use craft::ui::canvas::{
|
||||
Canvas, CanvasScrollbars, CanvasSpace, ContextSource, RotateView, ToolHostResponse, ToolPass, ViewCommands, ViewRequest, ViewTarget,
|
||||
canvas_space, tool_pass,
|
||||
canvas_space, tool_pass, with_canvas_space,
|
||||
};
|
||||
use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::primitives::PaintSlot;
|
||||
@@ -37,6 +37,7 @@ mod outline;
|
||||
mod overlays;
|
||||
pub(crate) mod panes;
|
||||
mod quick_pen_bar;
|
||||
mod quick_pen_wheel;
|
||||
mod raster;
|
||||
pub(crate) mod rulers;
|
||||
pub(crate) mod selection;
|
||||
@@ -143,6 +144,8 @@ struct Body {
|
||||
context_key: bool,
|
||||
/// 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_view: Option<CanvasView>,
|
||||
}
|
||||
|
||||
/// Window `win`'s document in the framework canvas, filling the rest of `ui`. True when the canvas
|
||||
@@ -208,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))
|
||||
@@ -229,8 +233,40 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
};
|
||||
let mut body = Body::default();
|
||||
let shown = canvas.show(ui, |ui, env| {
|
||||
if let Some(space) = canvas_space(&env.env) {
|
||||
body = show_body(app, ui, &space, tool_pass(&env.env).as_ref(), win, kind);
|
||||
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(arc_view);
|
||||
}
|
||||
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
|
||||
};
|
||||
let bar_shapes = bar_paint.take_after(ui.ctx());
|
||||
// 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(arc_view);
|
||||
if let Some(pass) = pass.as_mut() {
|
||||
pass.space = Some(space);
|
||||
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_view = arc_turn.then_some(arc_view);
|
||||
}
|
||||
});
|
||||
let output = shown.output;
|
||||
@@ -243,16 +279,20 @@ 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 } = body;
|
||||
let Body { reply, context_at, context_key, edited, arc_view } = body;
|
||||
let request = reply
|
||||
.as_ref()
|
||||
.and_then(|r| r.context.as_ref())
|
||||
.map(|c| context_menu::Request { at: c.at, key: c.source == ContextSource::Key })
|
||||
.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.
|
||||
let view_now =
|
||||
if presenting && ui.input(|i| i.pointer.middle_down()) { given } else { edited.or(reply.and_then(|r| r.view)).or(output.view).unwrap_or(cv) };
|
||||
// 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 leaves other view requests in place.
|
||||
let view_now = if presenting && ui.input(|i| i.pointer.middle_down()) {
|
||||
given
|
||||
} else {
|
||||
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);
|
||||
// Fitted once, the view stays where it is moved.
|
||||
@@ -280,7 +320,15 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
|
||||
/// The body of the canvas in order: controls that take presses first, the tool host, the selection's marks and the
|
||||
/// display-only widgets over it, the picture last.
|
||||
fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: Option<&ToolPass>, win: Win, kind: BodyKind) -> Body {
|
||||
fn show_body(
|
||||
app: &mut VectorcraftApp,
|
||||
ui: &mut Ui,
|
||||
space: &CanvasSpace,
|
||||
pass: Option<&ToolPass>,
|
||||
win: Win,
|
||||
kind: BodyKind,
|
||||
bar_shapes: Vec<egui::Shape>,
|
||||
) -> Body {
|
||||
let live = kind == BodyKind::Live;
|
||||
let presenting = app.ui.screen_mode == 3;
|
||||
let background = space.background();
|
||||
@@ -319,7 +367,7 @@ fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: O
|
||||
// The bars give way to a drag, not to a click.
|
||||
let dragging = in_gesture(app, ui.ctx()) && ui.input(|i| i.pointer.is_decidedly_dragging());
|
||||
let task_bar = (app.ui.task_bar && !revolve_editing(app) && !strip && !dragging).then(|| task_bar::task_bar(app, ui, space)).flatten();
|
||||
quick_pen_bar::quick_pen_bar(app, ui, space);
|
||||
PaintSlot::reserve(ui.painter()).extend(ui.ctx(), bar_shapes);
|
||||
contour_bar::contour_bar(app, ui, space);
|
||||
// After the task bar, which the row of character alternates keeps clear of.
|
||||
alternates_bar::alternates_bar(app, ui, space, task_bar);
|
||||
|
||||
@@ -26,20 +26,20 @@ use super::{Ui, VectorcraftApp, json};
|
||||
|
||||
/// The Quick Pen toolbar, while the Quick Pen tool is active, Window › Quick Pen Toolbar is on and
|
||||
/// no gesture is under way on the canvas. Selecting the tool turns Window › Quick Pen Toolbar on
|
||||
/// ([`VectorcraftApp::try_select_tool`]).
|
||||
pub(super) fn quick_pen_bar(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) {
|
||||
/// ([`VectorcraftApp::try_select_tool`]). Returns the toolbar's rect when it showed.
|
||||
pub(super) fn quick_pen_bar(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) -> Option<egui::Rect> {
|
||||
if !app.ui.quick_pen_bar || app.session.tool_id() != quickpen::ID {
|
||||
return;
|
||||
return None;
|
||||
}
|
||||
// PLAN: assumed `super::tool_adapter::in_gesture(app: &VectorcraftApp, ctx: &egui::Context) -> bool` (cv.S3)
|
||||
if super::tool_adapter::in_gesture(app, ui.ctx()) {
|
||||
return;
|
||||
return None;
|
||||
}
|
||||
// A middle-button drag pans the canvas, which hides the toolbar as a tool's drag does.
|
||||
if ui.input(|i| i.pointer.middle_down() && i.pointer.press_origin().is_some_and(|p| space.view.rect.contains(p))) {
|
||||
return;
|
||||
return None;
|
||||
}
|
||||
let Some(uid) = app.session.active().map(|st| st.uid) else { return };
|
||||
let uid = app.session.active().map(|st| st.uid)?;
|
||||
let view = app.view_info();
|
||||
let end = app.session.tool_drawing_end(view);
|
||||
let flip = app.session.tool_claims_key(vectorcraft_tools::ToolKey::Letter('c'), view);
|
||||
@@ -112,4 +112,5 @@ pub(super) fn quick_pen_bar(app: &mut VectorcraftApp, ui: &mut Ui, space: &Canva
|
||||
{
|
||||
app.ui.status = e;
|
||||
}
|
||||
shown.output.rect.is_positive().then_some(shown.output.rect)
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
//! Ctrl+wheel over the canvas with the Quick Pen tool: the arc size, in place of the view.
|
||||
//!
|
||||
//! Public behavior: Ctrl + scroll on a trackpad makes the arc size larger or smaller, on Windows
|
||||
//! and on macOS alike
|
||||
//! ([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)).
|
||||
//! VectorCraft's own rules: a mouse wheel turned with Ctrl does the same; a mouse wheel makes one
|
||||
//! step of 15°, as `[` and `]` do, for each net whole wheel line (at least one for each nonzero share
|
||||
//! of wheel motion the canvas reads), and a touchpad makes one step for each wheel line of its
|
||||
//! gesture's motion; up makes the arc larger and down smaller, and sideways motion makes no step
|
||||
//! (with Ctrl on Windows and Linux, where the wheel reaches the canvas as a zoom, sideways motion
|
||||
//! counts as up and down); and momentum after the fingers lift makes no step.
|
||||
//!
|
||||
//! Everything here is read from the canvas's share of the framework's wheel (`space.wheel()`): its
|
||||
//! modifiers, its device, its motion in lines (`lines`, or `zoom_lines` for a wheel that reaches the
|
||||
//! canvas as a zoom), its gesture's motion so far (`gathered`, `zoom_gathered`), the keys held during
|
||||
//! the gesture (`held`) and whether the gesture began under a modal window (`modal`).
|
||||
|
||||
use craft::behavior::{Wheel, WheelSource, WheelUnit};
|
||||
use craft::keymap::{Mods, Platform};
|
||||
use craft::ui::canvas::CanvasSpace;
|
||||
|
||||
use super::{VectorcraftApp, json};
|
||||
|
||||
/// Most steps one share of the wheel makes: from 1° to 359° is fewer than 24 steps of 15°.
|
||||
const MOST_STEPS: f32 = 24.0;
|
||||
|
||||
/// How far a line's worth of motion may fall short of a whole line and still count as one.
|
||||
const LINE_SLACK: f32 = 1e-3;
|
||||
|
||||
/// The Control key alone: Ctrl on Windows and Linux, which the keymap folds into `cmd`, and the
|
||||
/// Control key on macOS, where `cmd` is ⌘.
|
||||
fn ctrl_alone(m: Mods, os: Platform) -> bool {
|
||||
let control = if os.is_mac() { m.ctrl && !m.cmd } else { m.cmd && !m.ctrl };
|
||||
control && !(m.alt || m.shift)
|
||||
}
|
||||
|
||||
/// The share's up and down motion in wheel lines, up positive. A wheel turned with egui's zoom
|
||||
/// modifier (Ctrl on Windows and Linux) reaches the canvas as a zoom, and the framework counts its
|
||||
/// lines in `zoom_lines`; sideways motion there adds to up and down, as egui's zoom factor does.
|
||||
/// Points of a touchpad or a browser are lines of `line` points.
|
||||
fn lines(wheel: &Wheel, line: f32) -> f32 {
|
||||
// Wheel exposes only the share's signed totals, without individual events or separate up/down
|
||||
// counts. Opposite notches in one pass cancel; their order and steps at the arc limits cannot
|
||||
// be recovered. Count the net lines the framework reports.
|
||||
let d = if wheel.zoom_lines != egui::Vec2::ZERO {
|
||||
wheel.zoom_lines.x + wheel.zoom_lines.y
|
||||
} else if wheel.scroll.y != 0.0 {
|
||||
if wheel.unit == WheelUnit::Line { wheel.lines.y } else { wheel.scroll.y / line }
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
if d.is_finite() { d } else { 0.0 }
|
||||
}
|
||||
|
||||
/// Whether `wheel`, of `lines` wheel lines, comes from a touchpad and not from a mouse wheel's
|
||||
/// notches. egui names the source on macOS and reports it unknown elsewhere. There, point motion
|
||||
/// (Wayland, a Windows precision touchpad) and line motion that is not whole lines (Windows and X11)
|
||||
/// count as a touchpad. A browser reports a mouse wheel in points, so the web build counts only line
|
||||
/// motion that is not whole lines.
|
||||
fn fine(wheel: &Wheel, lines: f32) -> bool {
|
||||
match wheel.source {
|
||||
WheelSource::Trackpad | WheelSource::Momentum => true,
|
||||
WheelSource::Unknown if wheel.unit == WheelUnit::Point => !cfg!(target_arch = "wasm32"),
|
||||
WheelSource::Unknown => (lines - lines.round()).abs() >= LINE_SLACK,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
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 };
|
||||
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.
|
||||
fn whole(v: f32) -> f32 {
|
||||
(v + LINE_SLACK * v.signum()).trunc()
|
||||
}
|
||||
|
||||
/// The steps `wheel` makes, up positive: a mouse wheel's whole lines, at least one; one for a share
|
||||
/// of points or pages from a mouse; and for a touchpad the whole lines of the motion the tool took in
|
||||
/// this turn, with the fraction kept in `rest`. Momentum after the fingers lift makes no step.
|
||||
fn steps(wheel: &Wheel, line: f32, rest: &mut f32) -> f32 {
|
||||
if wheel.source == WheelSource::Momentum {
|
||||
return 0.0;
|
||||
}
|
||||
let d = lines(wheel, line);
|
||||
if d == 0.0 {
|
||||
return 0.0;
|
||||
}
|
||||
if fine(wheel, d) {
|
||||
*rest += d;
|
||||
let steps = whole(*rest);
|
||||
*rest -= steps;
|
||||
return steps.clamp(-MOST_STEPS, MOST_STEPS);
|
||||
}
|
||||
let notches = if wheel.unit == WheelUnit::Line { (d.abs() + LINE_SLACK).trunc() } else { 1.0 };
|
||||
d.signum() * notches.clamp(1.0, MOST_STEPS)
|
||||
}
|
||||
|
||||
/// With the Quick Pen tool active, the wheel share the canvas read this pass (`wheel`), turned with
|
||||
/// the Control key alone and not over the Quick Pen toolbar (`bar`), makes the arc size larger (up)
|
||||
/// or smaller (down). A touchpad gesture counts the keys held at any point of it, keys tapped
|
||||
/// between its events included. No step is made while a modal window is up, nor for the rest of a
|
||||
/// turn begun under one. Returns true while the tool takes the turn, so the view does not zoom or
|
||||
/// scroll for the rest of it. A turn is the framework's wheel gesture, and the tool keeps no state of
|
||||
/// its own: it claims each share it reads (`CanvasSpace::claim_wheel`), recording as `spent.x` the
|
||||
/// touchpad motion it kept, in wheel lines, so `claimed_spent.x` is the motion of the turn not yet
|
||||
/// turned into a step.
|
||||
pub(super) fn arc_size(app: &mut VectorcraftApp, ctx: &egui::Context, space: &CanvasSpace, bar: Option<egui::Rect>) -> bool {
|
||||
let Some(w) = space.wheel() else { return false };
|
||||
// The framework marks a turn a modal layer held (`modal`); a turn that reaches the canvas while one
|
||||
// of the app's own modal windows is up is marked too, and stays muted until the framework starts a
|
||||
// new one.
|
||||
let app_modal = crate::panel_docking::modal_window_up(app);
|
||||
if app_modal {
|
||||
space.mark_wheel_modal(ctx);
|
||||
}
|
||||
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 && 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
|
||||
// canvas's output keeps the view for this pass.
|
||||
space.claim_wheel(ctx, egui::vec2(rest - w.claimed_spent.x, 0.0));
|
||||
taken = true;
|
||||
runs = made;
|
||||
}
|
||||
let cmd = if runs > 0.0 { "tool.quickPen.arcLarger" } else { "tool.quickPen.arcSmaller" };
|
||||
for _ in 0..(runs.abs() as u32) {
|
||||
match app.run(cmd, json!({})) {
|
||||
Ok(serde_json::Value::Bool(true)) => {}
|
||||
Ok(_) => break,
|
||||
Err(e) => {
|
||||
app.ui.status = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
quick_pen && taken
|
||||
}
|
||||
@@ -734,6 +734,39 @@ fn run_ui_part6(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
}
|
||||
"tool.quickPen.arcLarger" | "tool.quickPen.arcSmaller" => {
|
||||
// `]` or `[`, for Ctrl+wheel over the canvas: the arc size 15° larger or smaller. Input
|
||||
// held for an edit is finished first, as for Flip Arc. False, with nothing changed beyond
|
||||
// that, while the Quick Pen tool is not active or the step would leave 1° to 359°.
|
||||
match app.session.finish_tool_edit() {
|
||||
Ok(reqs) => crate::canvas::apply_requests(app, Ok(reqs)),
|
||||
Err(e) => return Some(Err(e.to_string())),
|
||||
}
|
||||
if app.session.tool_id() != vectorcraft_tools::quickpen::ID {
|
||||
return Some(Ok(json!(false)));
|
||||
}
|
||||
let key =
|
||||
if id == "tool.quickPen.arcLarger" { vectorcraft_tools::ToolKey::BracketRight } else { vectorcraft_tools::ToolKey::BracketLeft };
|
||||
// A step changes the tool's size, or draws the arc again: as an edit between presses, or
|
||||
// as the preview of a drag (applied, or kept for the release with Real-time Drawing off).
|
||||
let state = |app: &VectorcraftApp| {
|
||||
let d = app.session.active();
|
||||
(
|
||||
app.session.tool_options()["turn"].clone(),
|
||||
d.map(|d| d.revision),
|
||||
d.and_then(|d| d.interaction.as_ref()).and_then(|it| it.preview.clone()),
|
||||
)
|
||||
};
|
||||
let before = state(app);
|
||||
let view = app.view_info();
|
||||
match app.session.tool_key(key, vectorcraft_tools::Mods::default(), view) {
|
||||
Ok(reqs) => {
|
||||
crate::canvas::apply_requests(app, Ok(reqs));
|
||||
Ok(json!(state(app) != before))
|
||||
}
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
}
|
||||
"window.dock" => match app.ui_ctx.clone() {
|
||||
// Tab: hide the panels, the toolbars and the Control bar, or show what the last Tab
|
||||
// hid; the window's shell applies it in its next pass.
|
||||
|
||||
@@ -736,6 +736,18 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"",
|
||||
"{} flip the last sharp-corner arc of the path the Quick Pen tool is drawing to the other side of its chord, as C and the toolbar's Flip Arc button do, as one undo step; first finishes any pending tool edit (which can change the document), then returns false, changing nothing more, when the Quick Pen tool is not active, no path is being drawn or the last piece is not a sharp-corner arc",
|
||||
),
|
||||
(
|
||||
"tool.quickPen.arcLarger",
|
||||
"Increase Arc Size",
|
||||
"",
|
||||
"{} make the Quick Pen tool's arc size 15° larger, for the last sharp-corner arc of the path being drawn and the arcs after it, as ] and Ctrl+wheel up over the canvas do; first finishes any pending tool edit (which can change the document), then returns false, changing nothing more, when the Quick Pen tool is not active or a step would take the arc size above 359°",
|
||||
),
|
||||
(
|
||||
"tool.quickPen.arcSmaller",
|
||||
"Decrease Arc Size",
|
||||
"",
|
||||
"{} make the Quick Pen tool's arc size 15° smaller, for the last sharp-corner arc of the path being drawn and the arcs after it, as [ and Ctrl+wheel down over the canvas do; first finishes any pending tool edit (which can change the document), then returns false, changing nothing more, when the Quick Pen tool is not active or a step would take the arc size below 1°",
|
||||
),
|
||||
(
|
||||
"window.dock",
|
||||
"Panels",
|
||||
|
||||
@@ -34,6 +34,7 @@ mod plugins;
|
||||
mod printps;
|
||||
mod printtiling;
|
||||
mod quickpenbar;
|
||||
mod quickpenwheel;
|
||||
mod recolor;
|
||||
mod recovery;
|
||||
pub(super) mod removeanchors;
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
//! Ctrl+wheel over the canvas with the Quick Pen tool changes the arc size and leaves the view as it
|
||||
//! 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;
|
||||
use vectorcraft_geom::SubPath;
|
||||
use vectorcraft_tools::{PointerEvent, PointerKind};
|
||||
|
||||
use super::taskbar::{Rig, on_canvas};
|
||||
use crate::VectorcraftApp;
|
||||
|
||||
fn app() -> VectorcraftApp {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
app.select_tool("quickPen");
|
||||
app.run("tool.setOption", json!({"key": "action", "value": "sharpArc"})).unwrap();
|
||||
app
|
||||
}
|
||||
|
||||
/// The Control key as egui reports it: with Command on Windows and Linux, alone on macOS.
|
||||
fn ctrl() -> Modifiers {
|
||||
if crate::keymap::platform().is_mac() { Modifiers::CTRL } else { Modifiers { ctrl: true, command: true, ..Modifiers::NONE } }
|
||||
}
|
||||
|
||||
fn wheel(unit: MouseWheelUnit, dy: f32, phase: TouchPhase, modifiers: Modifiers, source: MouseWheelSource) -> Event {
|
||||
Event::MouseWheel { unit, delta: vec2(0.0, dy), phase, modifiers, source }
|
||||
}
|
||||
|
||||
/// A mouse wheel's notches of `dy` lines in one event.
|
||||
fn notch(dy: f32, modifiers: Modifiers) -> Event {
|
||||
wheel(MouseWheelUnit::Line, dy, TouchPhase::Move, modifiers, MouseWheelSource::Wheel)
|
||||
}
|
||||
|
||||
/// A touchpad's motion of `dy` points.
|
||||
fn pad(phase: TouchPhase, dy: f32, modifiers: Modifiers) -> Event {
|
||||
wheel(MouseWheelUnit::Point, dy, phase, modifiers, MouseWheelSource::Trackpad)
|
||||
}
|
||||
|
||||
/// The points of a touchpad's motion that make one wheel line: on macOS a line of the canvas's
|
||||
/// navigation; on Windows and Linux, where the framework reads a touchpad's Ctrl+scroll as a pinch,
|
||||
/// egui's line scroll speed.
|
||||
fn line(rig: &Rig) -> f32 {
|
||||
if crate::keymap::platform().is_mac() {
|
||||
crate::app::view::navigation(&rig.app().session.prefs).wheel_line
|
||||
} else {
|
||||
rig.fx.ctx().options(|o| o.input_options.line_scroll_speed)
|
||||
}
|
||||
}
|
||||
|
||||
fn center(rig: &Rig) -> Pos2 {
|
||||
rig.app().canvas_view().unwrap().rect.center()
|
||||
}
|
||||
|
||||
/// One frame with the pointer over `at` and `events`, then a pause past the end of a wheel turn.
|
||||
fn turn_at(rig: &mut Rig, at: Pos2, events: Vec<Event>) {
|
||||
rig.fx.frame(vec![Event::PointerMoved(at)]);
|
||||
rig.fx.frame(events);
|
||||
rig.fx.advance(1.5);
|
||||
rig.fx.frame(vec![]);
|
||||
}
|
||||
|
||||
fn turn(rig: &mut Rig, events: Vec<Event>) {
|
||||
let at = center(rig);
|
||||
turn_at(rig, at, events);
|
||||
}
|
||||
|
||||
fn click_doc(rig: &Rig, x: f64, y: f64) {
|
||||
let mut app = rig.app();
|
||||
let v = app.view_info();
|
||||
for kind in [PointerKind::Down, PointerKind::Up] {
|
||||
app.session.pointer(&PointerEvent::new(kind, x, y), v).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn paths(app: &VectorcraftApp) -> Vec<SubPath> {
|
||||
let mut v = vec![];
|
||||
app.session.active().unwrap().doc.walk(|n| {
|
||||
if let NodeKind::Path { path, .. } = &n.kind {
|
||||
v.extend(path.subpaths.iter().cloned());
|
||||
}
|
||||
});
|
||||
v
|
||||
}
|
||||
|
||||
fn arc_size(rig: &Rig) -> f64 {
|
||||
rig.app().session.tool_options()["turn"].as_f64().unwrap()
|
||||
}
|
||||
|
||||
fn undo_len(rig: &Rig) -> usize {
|
||||
rig.app().session.active().unwrap().history.undo.len()
|
||||
}
|
||||
|
||||
fn view(rig: &Rig) -> CanvasView {
|
||||
rig.app().canvas_view().unwrap()
|
||||
}
|
||||
|
||||
/// Ctrl+wheel with the Quick Pen tool: a notch up makes the last sharp-corner arc 15° larger and
|
||||
/// notches down make it 15° smaller per notch, each as one undo step; the view neither zooms nor
|
||||
/// scrolls. With Shift or Alt added the wheel leaves the arc size; without Ctrl it scrolls the view.
|
||||
#[test]
|
||||
fn ctrl_wheel_changes_the_arc_size_and_not_the_view() {
|
||||
let mut app = app();
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
click_doc(rig, 100.0, 150.0);
|
||||
click_doc(rig, 200.0, 150.0);
|
||||
let drawn = paths(&rig.app())[0].clone();
|
||||
let undo = undo_len(rig);
|
||||
let still = view(rig);
|
||||
|
||||
turn(rig, vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0);
|
||||
assert_ne!(paths(&rig.app())[0], drawn, "the last arc changed");
|
||||
assert_eq!(paths(&rig.app()).len(), 1);
|
||||
assert_eq!(undo_len(rig), undo + 1);
|
||||
assert_eq!(view(rig), still, "Ctrl+wheel did not zoom or scroll");
|
||||
|
||||
turn(rig, vec![notch(-1.0, ctrl()), notch(-1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 165.0, "two notches down");
|
||||
assert_eq!(undo_len(rig), undo + 3);
|
||||
assert_eq!(view(rig), still);
|
||||
|
||||
for modifiers in [Modifiers { shift: true, ..ctrl() }, Modifiers { alt: true, ..ctrl() }] {
|
||||
turn(rig, vec![notch(1.0, modifiers)]);
|
||||
assert_eq!(arc_size(rig), 165.0, "{modifiers:?}");
|
||||
}
|
||||
|
||||
let still = view(rig);
|
||||
turn(rig, vec![notch(1.0, Modifiers::NONE)]);
|
||||
assert_eq!(arc_size(rig), 165.0, "a plain wheel");
|
||||
assert_ne!(view(rig), still, "a plain wheel scrolls the view");
|
||||
});
|
||||
}
|
||||
|
||||
/// The first claimed share keeps both the stored view and the tool host's document point.
|
||||
#[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);
|
||||
rig.fx.frame(vec![Event::PointerMoved(at)]);
|
||||
let still = view(rig);
|
||||
let point = rig.app().hover_doc.expect("the pointer is over the canvas");
|
||||
let win = crate::doc_windows::current(&rig.app()).unwrap();
|
||||
let id = crate::canvas::canvas_id(win);
|
||||
let shown = craft::ui::canvas::ToolHost::shown_space(rig.fx.ctx(), id).unwrap().view;
|
||||
rig.fx.frame(vec![notch(1.0, ctrl())]);
|
||||
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() {
|
||||
let mut app = app();
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
rig.fx.frame(vec![Event::PointerMoved(center(rig) + vec2(80.0, 40.0))]);
|
||||
let win = crate::doc_windows::current(&rig.app()).unwrap();
|
||||
let id = crate::canvas::canvas_id(win);
|
||||
let shown = craft::ui::canvas::ToolHost::shown_space(rig.fx.ctx(), id).unwrap().view;
|
||||
for (start, notches, expected) in
|
||||
[(345, vec![1.0, -1.0], 345.0), (345, vec![1.0, 1.0, -1.0], 345.0), (180, vec![1.0, -1.0], 180.0), (180, vec![1.0, 1.0, -1.0], 195.0)]
|
||||
{
|
||||
rig.app().run("tool.setOption", json!({"key": "turn", "value": start})).unwrap();
|
||||
rig.fx.frame(notches.into_iter().map(|dy| notch(dy, ctrl())).collect());
|
||||
assert_eq!(arc_size(rig), expected, "the framework reports net lines, including at the arc limit");
|
||||
assert_eq!(craft::ui::canvas::ToolHost::shown_space(rig.fx.ctx(), id).unwrap().view, shown, "mixed notches keep the tool host's view");
|
||||
rig.fx.advance(1.5);
|
||||
rig.fx.frame(vec![]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// A touchpad steps once per wheel line of motion: half a line makes no step, the second half of the
|
||||
/// same gesture makes one, and momentum after it makes none (egui reports momentum on macOS). Half a
|
||||
/// line in a later turn does not add to the half before it.
|
||||
#[test]
|
||||
fn a_touchpad_steps_once_per_wheel_line() {
|
||||
let mut app = app();
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
let line = line(rig);
|
||||
let still = view(rig);
|
||||
rig.fx.hold(ctrl());
|
||||
rig.fx.frame(vec![Event::PointerMoved(center(rig))]);
|
||||
rig.fx.frame(vec![pad(TouchPhase::Start, 0.0, ctrl())]);
|
||||
rig.fx.frame(vec![pad(TouchPhase::Move, line / 2.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 180.0, "half a line");
|
||||
rig.fx.frame(vec![pad(TouchPhase::Move, line / 2.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0, "a whole line");
|
||||
rig.fx.frame(vec![pad(TouchPhase::End, 0.0, ctrl())]);
|
||||
if crate::keymap::platform().is_mac() {
|
||||
rig.fx.frame(vec![wheel(MouseWheelUnit::Point, 3.0 * line, TouchPhase::Move, ctrl(), MouseWheelSource::Momentum)]);
|
||||
assert_eq!(arc_size(rig), 195.0, "momentum makes no step");
|
||||
}
|
||||
assert_eq!(view(rig), still, "the view stays");
|
||||
|
||||
rig.fx.advance(2.0);
|
||||
turn(rig, vec![pad(TouchPhase::Move, line / 2.0, ctrl())]);
|
||||
turn(rig, vec![pad(TouchPhase::Move, line / 2.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0, "two turns of half a line each");
|
||||
rig.fx.hold(Modifiers::NONE);
|
||||
});
|
||||
}
|
||||
|
||||
/// Shift pressed and let go between two wheel events of a touchpad gesture held with Ctrl counts for
|
||||
/// the rest of the gesture; Ctrl let go during the gesture still counts until it ends. egui reports a
|
||||
/// touchpad gesture's phases on macOS; on Windows and Linux the framework reads a touchpad's
|
||||
/// Ctrl+scroll as a pinch, which carries no phases.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[test]
|
||||
fn keys_held_during_a_touchpad_gesture_count_until_it_ends() {
|
||||
let mut app = app();
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
let line = line(rig);
|
||||
let both = Modifiers { shift: true, ..ctrl() };
|
||||
rig.fx.frame(vec![Event::PointerMoved(center(rig))]);
|
||||
rig.fx.frame(vec![pad(TouchPhase::Start, 0.0, ctrl())]);
|
||||
rig.fx.frame(vec![pad(TouchPhase::Move, line, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0, "a line up with Ctrl");
|
||||
rig.fx.frame(vec![pad(TouchPhase::Move, line, Modifiers::NONE)]);
|
||||
assert_eq!(arc_size(rig), 210.0, "Ctrl let go still counts");
|
||||
rig.fx.frame(vec![Event::ModifiersChanged(both), Event::ModifiersChanged(ctrl())]);
|
||||
rig.fx.frame(vec![pad(TouchPhase::Move, line, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 210.0, "Shift tapped mid-gesture");
|
||||
rig.fx.frame(vec![pad(TouchPhase::End, 0.0, ctrl())]);
|
||||
});
|
||||
}
|
||||
|
||||
/// Ctrl+wheel over the Quick Pen toolbar, under a modal window, and for the rest of a turn begun
|
||||
/// under one, leaves the arc size.
|
||||
#[test]
|
||||
fn ctrl_wheel_over_the_toolbar_or_under_a_dialog_makes_no_step() {
|
||||
let mut app = app();
|
||||
on_canvas(&mut app, |rig| {
|
||||
let bar = rig.target("Quick Pen").expect("the toolbar shows").rect;
|
||||
turn_at(rig, bar.center(), vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 180.0, "over the toolbar");
|
||||
|
||||
rig.app().run("edit.preferences", json!({})).unwrap();
|
||||
rig.fx.settle();
|
||||
let at = center(rig);
|
||||
rig.fx.frame(vec![Event::PointerMoved(at)]);
|
||||
rig.fx.frame(vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 180.0, "under the dialog");
|
||||
rig.app().prefs = None;
|
||||
rig.fx.frame(vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 180.0, "the rest of a turn begun under the dialog");
|
||||
rig.fx.advance(1.5);
|
||||
turn(rig, vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(arc_size(rig), 195.0, "a new turn");
|
||||
});
|
||||
}
|
||||
|
||||
/// With another tool, Ctrl+wheel leaves the Quick Pen's arc size and moves the view as before.
|
||||
#[test]
|
||||
fn ctrl_wheel_with_another_tool_moves_the_view() {
|
||||
let mut app = app();
|
||||
app.select_tool("pen");
|
||||
on_canvas(&mut app, |rig| {
|
||||
rig.fx.settle();
|
||||
let still = view(rig);
|
||||
turn(rig, vec![notch(1.0, ctrl())]);
|
||||
assert_eq!(rig.app().session.tool_options_of("quickPen")["turn"], json!(180.0));
|
||||
assert_ne!(view(rig), still);
|
||||
});
|
||||
}
|
||||
|
||||
/// The arc size commands step the size by 15° within 1° to 359°, return false at the ends and with
|
||||
/// another tool, and change the last sharp-corner arc of the path being drawn, also while a press
|
||||
/// drags it.
|
||||
#[test]
|
||||
fn the_arc_size_commands_step_within_the_range() {
|
||||
let mut app = app();
|
||||
let arc = |app: &VectorcraftApp| app.session.tool_options()["turn"].as_f64().unwrap();
|
||||
assert_eq!(app.run("tool.quickPen.arcLarger", json!({})).unwrap(), json!(true));
|
||||
assert_eq!(arc(&app), 195.0);
|
||||
assert_eq!(app.run("tool.quickPen.arcSmaller", json!({})).unwrap(), json!(true));
|
||||
for _ in 0..10 {
|
||||
assert_eq!(app.run("tool.quickPen.arcLarger", json!({})).unwrap(), json!(true));
|
||||
}
|
||||
assert_eq!(arc(&app), 330.0);
|
||||
assert_eq!(app.run("tool.quickPen.arcLarger", json!({})).unwrap(), json!(true));
|
||||
assert_eq!(app.run("tool.quickPen.arcLarger", json!({})).unwrap(), json!(false), "360° is past 359°");
|
||||
assert_eq!(arc(&app), 345.0);
|
||||
|
||||
let v = vectorcraft_engine::ViewInfo { smart_guides: false, ..Default::default() };
|
||||
for kind in [PointerKind::Down, PointerKind::Up] {
|
||||
app.session.pointer(&PointerEvent::new(kind, 100.0, 150.0), v).unwrap();
|
||||
}
|
||||
for kind in [PointerKind::Down, PointerKind::Up] {
|
||||
app.session.pointer(&PointerEvent::new(kind, 200.0, 150.0), v).unwrap();
|
||||
}
|
||||
let drawn = paths(&app)[0].clone();
|
||||
let undo = app.session.active().unwrap().history.undo.len();
|
||||
assert_eq!(app.run("tool.quickPen.arcSmaller", json!({})).unwrap(), json!(true));
|
||||
assert_ne!(paths(&app)[0], drawn);
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), undo + 1);
|
||||
|
||||
// During a drag the arc being dragged takes the new size and the drag goes on; the piece and its
|
||||
// size change are one undo step.
|
||||
app.run("tool.setOption", json!({"key": "turn", "value": 180})).unwrap();
|
||||
let undo = app.session.active().unwrap().history.undo.len();
|
||||
app.session.pointer(&PointerEvent::new(PointerKind::Down, 260.0, 150.0), v).unwrap();
|
||||
app.session.pointer(&PointerEvent::new(PointerKind::Drag, 280.0, 150.0), v).unwrap();
|
||||
assert!(app.session.tool_busy(), "the press drags");
|
||||
let dragged = paths(&app)[0].clone();
|
||||
assert_eq!(app.run("tool.quickPen.arcLarger", json!({})).unwrap(), json!(true));
|
||||
assert_eq!(arc(&app), 195.0);
|
||||
assert!(app.session.tool_busy(), "the drag goes on");
|
||||
assert_ne!(paths(&app)[0], dragged, "the arc being dragged is drawn again with the new size");
|
||||
// The tool's size set ahead of the dragged arc's: a step that brings the arc to it still reports
|
||||
// the change.
|
||||
app.run("tool.setOption", json!({"key": "turn", "value": 210})).unwrap();
|
||||
let sized = paths(&app)[0].clone();
|
||||
assert_eq!(app.run("tool.quickPen.arcLarger", json!({})).unwrap(), json!(true));
|
||||
assert_eq!(arc(&app), 210.0);
|
||||
assert_ne!(paths(&app)[0], sized);
|
||||
app.session.pointer(&PointerEvent::new(PointerKind::Up, 280.0, 150.0), v).unwrap();
|
||||
assert!(!app.session.tool_busy());
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), undo + 1, "the piece and its size changes are one undo step");
|
||||
|
||||
app.select_tool("pen");
|
||||
assert_eq!(app.run("tool.quickPen.arcSmaller", json!({})).unwrap(), json!(false));
|
||||
assert_eq!(app.session.tool_options_of("quickPen")["turn"], json!(210.0));
|
||||
}
|
||||
+18
-6
@@ -9038,16 +9038,28 @@ 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, 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
|
||||
arcs after it, as `tool.quickPen.arcSmaller {}` and `tool.quickPen.arcLarger {}` do (each first finishes any pending
|
||||
tool edit, then returns false, changing nothing more, when the Quick Pen tool is not active or the step would leave 1° to
|
||||
359°). `tool.quickPen.arcSmaller` and `tool.quickPen.arcLarger` run in the desktop app (`--connect`). Ctrl with a
|
||||
scroll on a touchpad over the canvas (the Control key on macOS too) changes the arc size as well, as
|
||||
[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)
|
||||
lists: the touchpad makes one step for each wheel line of its motion, and motion that goes on after the fingers lift
|
||||
makes none. A mouse wheel turned with Ctrl over the canvas does the same, one step for each net whole wheel line
|
||||
reported by the canvas framework, with at least one step for a nonzero share. The framework sums events within a
|
||||
frame, so opposite notches cancel and their order is unavailable. Up makes the arc size larger and down smaller.
|
||||
Sideways motion makes no step, except when Ctrl on Windows or Linux makes the framework report it as zoom motion.
|
||||
The view does not zoom or scroll for the rest of that wheel turn. During a drag,
|
||||
C, `[` `]` and the wheel 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
|
||||
arc size of 180°, its 15° steps, the side an arc bulges to, what C, `[` `]` and the wheel do during a drag, Enter
|
||||
ending the path, the mouse wheel changing the arc size, and the wheel's step per net wheel line and its direction are
|
||||
VectorCraft's own rules. The tool keeps `action` and `turn` with the preferences
|
||||
(`tool.setOption {tool: "quickPen", key, value}`).
|
||||
|
||||
While an arc is drawn, by a drag or as the piece the next click adds, the tool shows a protractor around the arc's
|
||||
|
||||
@@ -697,7 +697,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 `]` 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.
|
||||
- **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.
|
||||
|
||||
|
||||
+1
-1
@@ -220,7 +220,7 @@ tools, never checked side by side) isn't captured row by row.
|
||||
| Busy cursor during long operations | done | Background open, save and export show the system progress cursor (gap G1) |
|
||||
| Each anchor snaps to Smart Guides and construction angles | done | `DrawSnap` |
|
||||
| Curvature tool: click/drag points, double-click or Alt-click for a corner, temporary Direct Selection, point conversion | partial | circular point markers without direction handles or duplicate markers, Anchor Size and Hide Edges regression-tested (#1236, in part); curve geometry: each stretch of three points follows the circle through them (handles along its tangent, chord/(3·cos²(α/2)) long, shorter in a turn tighter than 30°), open ends curving in, the same rule for the rubber band, dragged, inserted and converted points (#1236, in part); neighbours of a point dragged on an existing path keep their tangents, and modifiers requested in #975 remain |
|
||||
| Quick Pen tool: straight lines, continuous arcs and sharp-corner arcs, Alt/Option to switch action, C to flip an arc, `[` / `]` for its size, Alt+P / Option+P, close on the first point, continue from an end, Escape to end, drag the handle at a path's start or end to make its line or arc longer or shorter, drag anchors or segments to edit, right-click Delete ([help page](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/draw-with-quick-pen-tool.html), [shortcuts](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/quick-pen-tool-keyboard-shortcuts.html)) | partial | `path.quickPen` and the tool in `crates/tools/src/quickpen.rs`, in the Pen tool's group (#2660); the length handles in `quickpen/length.rs` and `path.quickPenLength`, on the path being drawn or the selected path (a line keeps its direction, an arc its circle, up to 359°); the on-canvas toolbar with its actions, Flip Arc and its More menu (Hide Toolbar and Reset Toolbar Position, and VectorCraft's own Pin Toolbar Position) in `crates/ui-egui/src/canvas/quick_pen_bar.rs`; with no path being drawn, drags on a selected path's anchors and segments move them (`quickpen/edit.rs`, `path.moveAnchors`), clicks select anchors, and the canvas context menu has Delete (`edit.clear`). Not yet: Ctrl+scroll for the arc size |
|
||||
| Quick Pen tool: straight lines, continuous arcs and sharp-corner arcs, Alt/Option to switch action, C to flip an arc, `[` / `]` and Ctrl+scroll for its size, Alt+P / Option+P, close on the first point, continue from an end, Escape to end, drag the handle at a path's start or end to make its line or arc longer or shorter, drag anchors or segments to edit, right-click Delete ([help page](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/draw-with-quick-pen-tool.html), [shortcuts](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/quick-pen-tool-keyboard-shortcuts.html)) | partial | `path.quickPen` and the tool in `crates/tools/src/quickpen.rs`, in the Pen tool's group (#2660); the length handles in `quickpen/length.rs` and `path.quickPenLength`, on the path being drawn or the selected path (a line keeps its direction, an arc its circle, up to 359°); the on-canvas toolbar with its actions, Flip Arc and its More menu (Hide Toolbar and Reset Toolbar Position, and VectorCraft's own Pin Toolbar Position) in `crates/ui-egui/src/canvas/quick_pen_bar.rs`; Ctrl+scroll on a touchpad, and VectorCraft's own Ctrl+mouse wheel, over the canvas for the arc size in `crates/ui-egui/src/canvas/quick_pen_wheel.rs` (`tool.quickPen.arcLarger`, `tool.quickPen.arcSmaller`); with no path being drawn, drags on a selected path's anchors and segments move them (`quickpen/edit.rs`, `path.moveAnchors`), clicks select anchors, and the canvas context menu has Delete (`edit.clear`) |
|
||||
| Icon-strip flyout resizing (#5713) | done | Canvas-side edge and bottom; user size persists after reopening and workspace restore; Glyphs and Artboards pointer/cursor regression |
|
||||
| Icon-strip flyout resizing from the top (storytold/craft-libs#1094) | done | Top edge (a 4 pt band over the tab strip) and the canvas-side top corner; the bottom and the icon-column edge stay; the moved top persists after reopening and workspace restore; `an_icon_flyout_grows_upward_from_its_top_edge_and_free_corner` |
|
||||
| Graphic Styles list fills a taller panel (#2992) | done | Docked, floating or in a resized flyout, the list takes the height above the panel's footer, as the Artboards list does; outside a sized panel it stays 220 pt; `the_list_fills_a_tall_panel_above_its_footer` |
|
||||
|
||||
Reference in new issue
Block a user