From df614fb80c348efcf2a2f93779cb9221be781c52 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 23:58:14 -0800 Subject: [PATCH] Pen: Quick Pen tool draws lines, continuous arcs and sharp-corner arcs A new tool in the Pen tool's group, chosen with Alt+P (Option+P on macOS), draws paths of straight lines and circular arcs, as the Quick Pen help pages describe: https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/draw-with-quick-pen-tool.html https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/quick-pen-tool-keyboard-shortcuts.html - A click sets the start point; each click, or a press dragged to where it is let go, adds a line, a continuous arc (it leaves the last point in the path's direction) or a sharp-corner arc, as the tool's action says. Each piece is one undo step. - Alt (Option) pressed and let go on its own switches to the next action. C flips the last sharp-corner arc to the other side of its chord, and [ and ] make the arc size 15 degrees smaller or larger. - A click on the first point closes the path, a click on an end of an open path continues it, and Escape or Enter ends it. An edit made to the path from outside the tool also ends it. - path.quickPen {start | id, subpath?, keep?, pieces, closed?} draws the same path for agents and scripts. The action and arc size are kept with the preferences. The 180 degree default arc size, its 15 degree steps, the side an arc bulges to and Enter ending the path are VectorCraft's own rules. Part of #2660 (reported by earlvanze). Not yet: the on-canvas toolbar, dragging a path's ends to change its length, Ctrl+scroll for the arc size, and editing and deleting with the tool. --- ASSETS.md | 1 + ROADMAP.md | 1 + assets/icons/dc-quick-pen.svg | 1 + crates/engine/src/cmd/draw2.rs | 1 + crates/engine/src/cmd/draw2/commands.rs | 10 + crates/engine/src/cmd/draw2/quickpen.rs | 96 +++ crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/engine/src/tests.rs | 1 + crates/engine/src/tests/quickpen.rs | 300 +++++++++ crates/tools/src/catalog.rs | 1 + crates/tools/src/input.rs | 3 + crates/tools/src/lib.rs | 2 + crates/tools/src/quickpen.rs | 616 ++++++++++++++++++ crates/tools/src/quickpen/tests.rs | 214 ++++++ crates/tools/src/settings.rs | 1 + crates/ui-egui/src/app.rs | 1 + crates/ui-egui/src/i18n/bg.tsv | 2 + crates/ui-egui/src/i18n/bs.tsv | 2 + crates/ui-egui/src/i18n/ca.tsv | 5 + crates/ui-egui/src/i18n/cs.tsv | 5 + crates/ui-egui/src/i18n/da.tsv | 5 + crates/ui-egui/src/i18n/de.tsv | 5 + crates/ui-egui/src/i18n/el.tsv | 5 + crates/ui-egui/src/i18n/es.tsv | 5 + crates/ui-egui/src/i18n/fi.tsv | 5 + crates/ui-egui/src/i18n/fr.tsv | 5 + crates/ui-egui/src/i18n/gu.tsv | 2 + crates/ui-egui/src/i18n/hi.tsv | 5 + crates/ui-egui/src/i18n/hu.tsv | 5 + crates/ui-egui/src/i18n/id.tsv | 2 + crates/ui-egui/src/i18n/it.tsv | 5 + crates/ui-egui/src/i18n/ja.tsv | 5 + crates/ui-egui/src/i18n/ka.tsv | 5 + crates/ui-egui/src/i18n/ko.tsv | 5 + crates/ui-egui/src/i18n/nl.tsv | 5 + crates/ui-egui/src/i18n/pl.tsv | 5 + crates/ui-egui/src/i18n/pt-br.tsv | 5 + crates/ui-egui/src/i18n/ru.tsv | 5 + crates/ui-egui/src/i18n/sv.tsv | 5 + crates/ui-egui/src/i18n/tr.tsv | 5 + crates/ui-egui/src/i18n/uk.tsv | 5 + crates/ui-egui/src/i18n/vi.tsv | 5 + crates/ui-egui/src/i18n/zh-hans.tsv | 5 + crates/ui-egui/src/i18n/zh-hant.tsv | 5 + crates/ui-egui/src/icon_data.rs | 1 + crates/ui-egui/src/icons.rs | 1 + crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/shortcut_editor.rs | 7 +- crates/ui-egui/src/shortcuts.rs | 8 + crates/ui-egui/src/shortcuts/alt_tap.rs | 114 ++++ crates/ui-egui/src/shortcuts/tests.rs | 33 + crates/ui-egui/src/toolbar.rs | 2 +- docs/mcp.md | 42 ++ docs/target-app-parity.md | 1 + docs/ui-parity.md | 1 + 55 files changed, 1586 insertions(+), 4 deletions(-) create mode 100644 assets/icons/dc-quick-pen.svg create mode 100644 crates/engine/src/cmd/draw2/quickpen.rs create mode 100644 crates/engine/src/tests/quickpen.rs create mode 100644 crates/tools/src/quickpen.rs create mode 100644 crates/tools/src/quickpen/tests.rs create mode 100644 crates/ui-egui/src/shortcuts/alt_tap.rs diff --git a/ASSETS.md b/ASSETS.md index 0e4e4aa4fe..029a978153 100644 --- a/ASSETS.md +++ b/ASSETS.md @@ -221,6 +221,7 @@ Generated-in-code art is original and has no file to list. This covers the defau | `assets/icons/dc-polygon.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | | `assets/icons/dc-pucker.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | | `assets/icons/dc-puppet.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | +| `assets/icons/dc-quick-pen.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a line and a half circle with a dot at each point) | MIT OR Apache-2.0 | | | `assets/icons/dc-rearrange.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | | `assets/icons/dc-rect-cut.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | | `assets/icons/dc-rect-grid.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | | diff --git a/ROADMAP.md b/ROADMAP.md index 4d8f84de90..c4a6edc8fb 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -145,6 +145,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap - 2026-11-17: Curvature Circle tool (after the Circle tool in its group): a click on a path draws the circle that touches it there and bends as it bends, on the side it bends toward, or with Shift on the other side; a segment that is the usual cubic of a circular arc of 90° or less gives the arc's own radius, so a click on a circle draws that circle; the tool shows the circle, its center and its radius (with an asterisk for an arc's radius) until the click, or "Straight segment", "Cusp", "Corner" or "Circle too large" where it draws none (`shape.curvatureCircle`). One undo step per circle. A VectorCraft addition: headline numbers unchanged. - 2026-11-15: Circle through three points: three Shift-clicks with the Ellipse tool, or `shape.circleThroughPoints` with three points or three selected anchor points, draw the circle whose edge passes through them, with the current paint, in one undo step; after two points the tool previews the circle through the pointer, and two points that are the same or three on one line are refused with a message. Scores and estimates unchanged. - 2026-11-17: Circle tool (after the Ellipse tool in its group): two clicks or a drag draw the circle on that diameter, and a click followed by a drag from a second point to a third draws the circle through the three; Shift keeps the diameter at 45° steps, Alt rounds a two-point circle's diameter to the rulers' ticks at the current zoom, points snap to Smart Guides, and the tool shows the circle, its center, its radii and its diameter until the release, or "Circle too large" for points on one line or a circle past the canvas. `shape.circleThroughPoints` also takes two points or two selected anchor points as the ends of a diameter. One undo step per circle. A VectorCraft addition: headline numbers unchanged. +- 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-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. - 2026-11-11: Pattern libraries: Patterns › Optical Effects, a third built-in pattern library, of VectorCraft's own designs, holds eight black wave, moiré and op-art tiles (Sine Bands, Ripple Lines, Interference Rings, Offset Rings, Warped Checks, Pinched Stripes, Chevron Pulse and Radiating Lenses) of 32 to 48 pt, each drawn the same way every time; each tile is one period of its design, and art that reaches past a tile edge continues on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged. diff --git a/assets/icons/dc-quick-pen.svg b/assets/icons/dc-quick-pen.svg new file mode 100644 index 0000000000..e87a486046 --- /dev/null +++ b/assets/icons/dc-quick-pen.svg @@ -0,0 +1 @@ + diff --git a/crates/engine/src/cmd/draw2.rs b/crates/engine/src/cmd/draw2.rs index 63ae0a3e4c..885fd35988 100644 --- a/crates/engine/src/cmd/draw2.rs +++ b/crates/engine/src/cmd/draw2.rs @@ -28,6 +28,7 @@ mod commands; mod common; mod cut; mod freehand; +mod quickpen; mod smooth; pub use commands::specs; diff --git a/crates/engine/src/cmd/draw2/commands.rs b/crates/engine/src/cmd/draw2/commands.rs index 45171f62a1..e4846367b5 100644 --- a/crates/engine/src/cmd/draw2/commands.rs +++ b/crates/engine/src/cmd/draw2/commands.rs @@ -1,6 +1,7 @@ use super::anchors::{convert_anchor, curvature, curvature_edit, remove_anchor, remove_anchors, reshape_segment}; use super::cut::{erase_region, erase_segments, knife, split}; use super::freehand::{blob, freehand}; +use super::quickpen::quick_pen; use super::smooth::{join_scrub, smooth_region}; use super::{CommandSpec, cmd, has_anchors, has_doc, has_selection}; @@ -33,6 +34,15 @@ pub fn specs() -> Vec { has_doc, curvature_edit ), + cmd!( + "path.quickPen", + "Quick Pen", + [], + None, + "{start?: [x, y] (a new path starts there), id? (or: draw on this path), subpath?: index (0), keep?: count (default: all its points; the points after the first `keep` are replaced), pieces?: [{x, y, action?: \"line\" (default)|\"continuousArc\"|\"sharpArc\", turn?: 1..359 degrees (180), flip?: bool}] (at most 10000), closed?: bool} draw a path of straight lines and circular arcs as the Quick Pen tool does, each piece from the path's last point to x, y: a line; a continuous arc, which leaves its start in the direction the path arrives in (with no direction, the first piece of a path, it is drawn as a sharp-corner arc; with its end straight ahead or straight behind, as a line); a sharp-corner arc, which turns through `turn` degrees and bulges to the left of the direction drawn (with flip, to the right). A piece that ends where the path does adds nothing. closed: a last piece that ends on the first point joins it, otherwise a straight segment closes the path. A new path takes the current paint (a black stroke when it has neither fill nor stroke); the path is selected, as one undo step → {id}. Without id, `start` must be given; with id, the subpath must be open and `start` is refused", + has_doc, + quick_pen + ), cmd!( "path.removeAnchor", "Delete Anchor Point", diff --git a/crates/engine/src/cmd/draw2/quickpen.rs b/crates/engine/src/cmd/draw2/quickpen.rs new file mode 100644 index 0000000000..84640bc876 --- /dev/null +++ b/crates/engine/src/cmd/draw2/quickpen.rs @@ -0,0 +1,96 @@ +//! The Quick Pen tool's command (`path.quickPen`): a path of straight lines and circular arcs. + +use vectorcraft_tools::quickpen::{self as qp, Piece, Stroke}; + +use super::common::{path_kind, path_mut, point_entry, usize_opt, within_input_bound}; +use super::{Color, Paint, PathData, Result, Session, SubPath, Value, add_look, bad, json, number_or, object_param, switch_or}; + +const C: &str = "path.quickPen"; +/// The most pieces one request takes. +const MAX_PIECES: usize = 10_000; + +/// The `pieces` param. +fn pieces(p: &Value) -> Result> { + let list = match p.get("pieces") { + None | Some(Value::Null) => return Ok(vec![]), + Some(Value::Array(list)) if list.len() <= MAX_PIECES => list, + Some(_) => return Err(bad(C, "`pieces` must be a list of at most 10000 pieces")), + }; + list.iter() + .map(|v| { + let to = point_entry(v, C)?; + if !within_input_bound(to) { + return Err(bad(C, "x and y must be finite")); + } + let stroke = match v.get("action") { + None | Some(Value::Null) => Stroke::Line, + Some(a) => a.as_str().and_then(Stroke::parse).ok_or_else(|| { + let key = "action"; + bad(C, format!("`{key}` must be one of {}", Stroke::ALL.map(Stroke::name).join(", "))) + })?, + }; + let turn = number_or(v, "turn", qp::DEFAULT_TURN, C)?; + if !(qp::MIN_TURN..=qp::MAX_TURN).contains(&turn) { + let (key, min, max) = ("turn", qp::MIN_TURN, qp::MAX_TURN); + return Err(bad(C, format!("{key} must be a number from {min} to {max}"))); + } + let flip = switch_or(v, "flip", false, C)?; + Ok(Piece { to, stroke, turn, flip }) + }) + .collect() +} + +pub(super) fn quick_pen(s: &mut Session, p: &Value) -> Result { + let pieces = pieces(p)?; + let closed = switch_or(p, "closed", false, C)?; + let start_given = p.get("start").is_some_and(|v| !v.is_null()); + let either = "give either `start` for a new path or `id`, not both"; + let Some(id) = object_param(p, "id", C)? else { + let start = match p.get("start") { + Some(v) if start_given => point_entry(v, C)?, + _ => return Err(bad(C, either)), + }; + if !within_input_bound(start) { + return Err(bad(C, "x and y must be finite")); + } + if ["subpath", "keep"].iter().any(|key| p.get(key).is_some_and(|v| !v.is_null())) { + return Err(bad(C, "`subpath` and `keep` need `id`")); + } + let sp = qp::build(&SubPath::new(vec![vectorcraft_geom::Anchor::corner(start)], false), &pieces, closed); + let mut look = s.new_art_look(s.paint.fill.clone(), s.paint.stroke.clone(), s.paint.stroke_width); + let ap = &mut look.appearance; + if ap.stroke_paint().is_none() && ap.fill_paint().is_none() { + ap.set_stroke(Paint::solid(Color::BLACK)); + } + return add_look(s, "Quick Pen", path_kind(PathData::single(sp)), look, None); + }; + if start_given { + return Err(bad(C, either)); + } + let si = usize_opt(p, "subpath", C)?.unwrap_or(0); + let d = &s.doc()?.doc; + if !d.is_editable(id) { + return Err(bad(C, "the path is locked or hidden")); + } + let path = d.node(id).and_then(|n| n.path_data()).ok_or_else(|| bad(C, "`id` is not a path"))?; + let sp = path.subpaths.get(si).ok_or_else(|| bad(C, "no such subpath"))?; + if sp.closed { + return Err(bad(C, "the subpath is closed")); + } + let n = sp.anchors.len(); + let keep = usize_opt(p, "keep", C)?.unwrap_or(n); + if keep == 0 || keep > n { + let (key, min, max) = ("keep", 1, n); + return Err(bad(C, format!("{key} must be a number from {min} to {max}"))); + } + let base = SubPath::new(sp.anchors.get_range(..keep).unwrap_or_default(), false); + let out = qp::build(&base, &pieces, closed); + let top = super::super::path::compound_or_self(d, id); + s.edit("Quick Pen", |d, sel| { + let slot = path_mut(d, id)?.subpaths.get_mut(si).ok_or_else(|| crate::EngineError::Other("no such subpath".into()))?; + *slot = out; + sel.set([top]); + Ok(()) + })?; + Ok(json!({ "id": id.0 })) +} diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index 7925c841d4..e09e362550 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -463,6 +463,7 @@ pub(super) const ALLOWED: &[&str] = &[ "path.mirrorCut", "path.moveAnchor", "path.moveAnchors", + "path.quickPen", "path.rectCut", "path.removeAnchor", "path.removeAnchors", diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index d023d66088..815a33eeae 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -155,6 +155,7 @@ mod printps; mod printtiling; mod proxyitems; mod puppetwarp; +mod quickpen; mod rasterfilters; mod rastersettings; mod recolor; diff --git a/crates/engine/src/tests/quickpen.rs b/crates/engine/src/tests/quickpen.rs new file mode 100644 index 0000000000..66283183b9 --- /dev/null +++ b/crates/engine/src/tests/quickpen.rs @@ -0,0 +1,300 @@ +//! The Quick Pen tool driven through the session, and `path.quickPen`. + +use serde_json::{Value, json}; +use vectorcraft_doc::{NodeId, NodeKind}; +use vectorcraft_geom::{PathData, Point, SubPath}; +use vectorcraft_tools::{Mods, PointerEvent, PointerKind, ToolKey}; + +use crate::tooling::ViewInfo; +use crate::*; + +fn session() -> Session { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 600})).unwrap(); + s +} + +fn view() -> ViewInfo { + ViewInfo { smart_guides: false, ..Default::default() } +} + +fn undo_steps(s: &Session) -> usize { + s.doc().unwrap().history.undo.len() +} + +fn paths(s: &Session) -> Vec<(NodeId, PathData)> { + let mut v = vec![]; + s.doc().unwrap().doc.walk(|n| { + if let NodeKind::Path { path, .. } = &n.kind { + v.push((n.id, path.clone())); + } + }); + v +} + +fn only_path(s: &Session) -> SubPath { + let all = paths(s); + assert_eq!(all.len(), 1, "one path"); + all[0].1.subpaths[0].clone() +} + +fn pt(x: f64, y: f64) -> Point { + Point::new(x, y) +} + +fn press(s: &mut Session, pts: &[(f64, f64)]) { + let v = view(); + s.pointer(&PointerEvent::new(PointerKind::Down, pts[0].0, pts[0].1), v).unwrap(); + for &(x, y) in &pts[1..] { + s.pointer(&PointerEvent::new(PointerKind::Drag, x, y), v).unwrap(); + } + let l = pts[pts.len() - 1]; + s.pointer(&PointerEvent::new(PointerKind::Up, l.0, l.1), v).unwrap(); +} + +fn click(s: &mut Session, x: f64, y: f64) { + press(s, &[(x, y)]); +} + +fn key(s: &mut Session, k: ToolKey) { + s.tool_key(k, Mods::default(), view()).unwrap(); +} + +fn quick_pen(s: &mut Session) { + s.select_tool("quickPen", view()).unwrap(); +} + +/// Clicks draw lines; Alt tapped alone switches to the next action, so the next clicks draw a +/// continuous arc and a sharp-corner half circle. Each piece is one undo step. +#[test] +fn clicks_draw_lines_and_arcs_one_undo_step_each() { + let mut s = session(); + quick_pen(&mut s); + click(&mut s, 100.0, 100.0); + let undo = undo_steps(&s); + click(&mut s, 200.0, 100.0); + assert_eq!(undo_steps(&s), undo + 1); + key(&mut s, ToolKey::AltTap); + assert_eq!(s.tool_options()["action"], "continuousArc"); + click(&mut s, 300.0, 200.0); + key(&mut s, ToolKey::AltTap); + assert_eq!(s.tool_options()["action"], "sharpArc"); + click(&mut s, 300.0, 300.0); + assert_eq!(undo_steps(&s), undo + 3); + let sp = only_path(&s); + assert!(!sp.closed); + let ends: Vec = sp.anchors.iter().map(|a| a.p).collect(); + assert_eq!(ends.first(), Some(&pt(100.0, 100.0))); + assert_eq!(ends.last(), Some(&pt(300.0, 300.0))); + // Line (2 points), quarter circle (1 more), half circle in two quarters (2 more). + assert_eq!(ends.len(), 5); + // The continuous arc left (200, 100) heading right, as the line arrived. + let joint = sp.anchors.get(1).unwrap(); + assert!((joint.h_out - joint.p).y.abs() < 1e-9 && joint.h_out.x > joint.p.x); + // The half circle on (300, 200)–(300, 300) bulges to the left of the way it was drawn + // (downward, so to the right on the page): its middle point is at x = 350. + assert!(sp.anchors.get(3).unwrap().p.distance(pt(350.0, 250.0)) < 1e-9); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(only_path(&s).anchors.len(), 3); +} + +/// C flips the last sharp-corner arc, and [ and ] make it 15° smaller or larger, each as one +/// undo step; the next arc keeps the new size. C is not taken while the last piece is a line. +#[test] +fn c_flips_and_brackets_size_the_last_sharp_arc() { + let mut s = session(); + quick_pen(&mut s); + s.set_tool_option_cmd(&json!({"tool": "quickPen", "key": "action", "value": "sharpArc"})).unwrap(); + click(&mut s, 100.0, 300.0); + click(&mut s, 300.0, 300.0); + assert!(only_path(&s).anchors.get(1).unwrap().p.distance(pt(200.0, 200.0)) < 1e-9, "above the chord"); + assert!(s.tool_claims_key(ToolKey::Letter('c'), view())); + let undo = undo_steps(&s); + key(&mut s, ToolKey::Letter('c')); + assert!(only_path(&s).anchors.get(1).unwrap().p.distance(pt(200.0, 400.0)) < 1e-9, "below once flipped"); + assert_eq!(undo_steps(&s), undo + 1); + key(&mut s, ToolKey::BracketLeft); + assert_eq!(s.tool_options()["turn"], 165.0); + let sp = only_path(&s); + // A 165° arc is two segments; its middle point lies on the chord's perpendicular bisector, + // still below. + assert_eq!(sp.anchors.len(), 3); + let mid = sp.anchors.get(1).unwrap().p; + assert!((mid.x - 200.0).abs() < 1e-9 && mid.y > 300.0); + assert_eq!(undo_steps(&s), undo + 2); + s.set_tool_option_cmd(&json!({"tool": "quickPen", "key": "action", "value": "line"})).unwrap(); + click(&mut s, 400.0, 300.0); + assert!(!s.tool_claims_key(ToolKey::Letter('c'), view())); +} + +/// Alt tapped during a drag draws the piece with the next action: a continuous arc becomes a +/// sharp-corner arc with a corner where it starts, and the path goes on drawing after it. +#[test] +fn an_alt_tap_during_a_drag_switches_the_piece_and_drawing_goes_on() { + let mut s = session(); + quick_pen(&mut s); + click(&mut s, 100.0, 100.0); + click(&mut s, 200.0, 100.0); + s.set_tool_option_cmd(&json!({"tool": "quickPen", "key": "action", "value": "continuousArc"})).unwrap(); + // A quarter circle that arrives at (300, 200) heading down. + click(&mut s, 300.0, 200.0); + let joint = only_path(&s).anchors.len() - 1; + let v = view(); + s.pointer(&PointerEvent::new(PointerKind::Down, 200.0, 300.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Drag, 210.0, 310.0), v).unwrap(); + assert_eq!(only_path(&s).anchors.get(joint).unwrap().kind, vectorcraft_geom::AnchorKind::Smooth); + key(&mut s, ToolKey::AltTap); + s.pointer(&PointerEvent::new(PointerKind::Drag, 200.0, 300.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 200.0, 300.0), v).unwrap(); + assert_eq!(s.tool_options()["action"], "sharpArc"); + assert_eq!(only_path(&s).anchors.get(joint).unwrap().kind, vectorcraft_geom::AnchorKind::Corner); + click(&mut s, 100.0, 300.0); + assert_eq!(only_path(&s).anchors.last().unwrap().p, pt(100.0, 300.0), "the same path"); +} + +/// A click on the first point closes the path; the next click starts a new one. +#[test] +fn a_click_on_the_first_point_closes_the_path() { + let mut s = session(); + quick_pen(&mut s); + for (x, y) in [(100.0, 100.0), (200.0, 100.0), (200.0, 200.0), (101.0, 101.0)] { + click(&mut s, x, y); + } + let sp = only_path(&s); + assert!(sp.closed); + assert_eq!(sp.anchors.len(), 3); + click(&mut s, 400.0, 400.0); + assert_eq!(paths(&s).len(), 2); +} + +/// Escape ends the path: the next click starts a new path. A press dragged places the piece +/// where it is let go. +#[test] +fn escape_ends_the_path_and_a_drag_places_the_piece() { + let mut s = session(); + quick_pen(&mut s); + click(&mut s, 100.0, 100.0); + press(&mut s, &[(150.0, 100.0), (180.0, 120.0), (250.0, 150.0)]); + assert_eq!(only_path(&s).anchors.last().unwrap().p, pt(250.0, 150.0)); + assert!(s.tool_ends_on_escape(view())); + key(&mut s, ToolKey::Escape); + assert!(!s.tool_ends_on_escape(view())); + click(&mut s, 500.0, 500.0); + assert_eq!(paths(&s).len(), 2); +} + +/// An anchor moved by another command ends the path being drawn: C does not flip the old arc back +/// over the edit, and the next click starts a new path instead of rebuilding the old one. +#[test] +fn an_edit_from_outside_ends_the_path() { + let mut s = session(); + quick_pen(&mut s); + s.set_tool_option_cmd(&json!({"tool": "quickPen", "key": "action", "value": "sharpArc"})).unwrap(); + click(&mut s, 100.0, 300.0); + click(&mut s, 300.0, 300.0); + let (id, _) = paths(&s)[0].clone(); + s.execute("path.moveAnchor", &json!({"id": id.0, "anchor": 2, "x": 320, "y": 280})).unwrap(); + assert!(!s.tool_claims_key(ToolKey::Letter('c'), view())); + click(&mut s, 500.0, 500.0); + let all = paths(&s); + assert_eq!(all.len(), 2, "a new path"); + assert_eq!(all[0].1.subpaths[0].anchors.last().unwrap().p, pt(320.0, 280.0), "the edit stays"); + // The same for a point of a path the tool went on from, and for the first point of a new path. + for new in [true, false] { + let mut s = session(); + let id = if new { + quick_pen(&mut s); + click(&mut s, 100.0, 100.0); + click(&mut s, 200.0, 100.0); + paths(&s)[0].0 + } else { + let r = s.execute("shape.line", &json!({"x1": 100, "y1": 100, "x2": 200, "y2": 100})).unwrap(); + let id = NodeId(r["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + quick_pen(&mut s); + click(&mut s, 200.0, 100.0); + click(&mut s, 200.0, 200.0); + id + }; + s.execute("path.moveAnchor", &json!({"id": id.0, "anchor": 0, "x": 90, "y": 90})).unwrap(); + click(&mut s, 400.0, 400.0); + assert_eq!(paths(&s).len(), 2, "a new path (new: {new})"); + assert_eq!(s.doc().unwrap().doc.node(id).unwrap().path_data().unwrap().subpaths[0].anchors.first().unwrap().p, pt(90.0, 90.0)); + } +} + +/// A click on an end of an open path goes on drawing from it, in the same path; from its start, +/// the path is reversed first. +#[test] +fn a_click_on_an_open_end_continues_the_path() { + let mut s = session(); + let r = s.execute("shape.line", &json!({"x1": 100, "y1": 100, "x2": 200, "y2": 100})).unwrap(); + let id = NodeId(r["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + quick_pen(&mut s); + click(&mut s, 100.0, 100.0); + click(&mut s, 100.0, 200.0); + let all = paths(&s); + assert_eq!(all.len(), 1); + assert_eq!(all[0].0, id); + let ends: Vec = all[0].1.subpaths[0].anchors.iter().map(|a| a.p).collect(); + assert_eq!(ends, [pt(200.0, 100.0), pt(100.0, 100.0), pt(100.0, 200.0)]); +} + +/// `path.quickPen` makes a new path with the current paint, or a black stroke without any. +#[test] +fn path_quick_pen_makes_a_stroked_path() { + let mut s = session(); + s.execute("paint.setStroke", &json!({"none": true})).unwrap(); + s.execute("paint.setFill", &json!({"none": true})).unwrap(); + let r = s + .execute( + "path.quickPen", + &json!({"start": [0, 0], "pieces": [{"x": 100, "y": 0}, {"x": 100, "y": 100, "action": "sharpArc", "turn": 90, "flip": true}]}), + ) + .unwrap(); + let id = r["id"].as_u64().unwrap(); + let n = s.doc().unwrap().doc.node(NodeId(id)).unwrap().clone(); + assert!(!n.appearance.stroke_paint().is_none(), "a black stroke"); + assert_eq!(n.path_data().unwrap().subpaths[0].anchors.len(), 3); +} + +/// Bad params are refused and change nothing. +#[test] +fn path_quick_pen_refuses_bad_params() { + let mut s = session(); + let r = s.execute("path.quickPen", &json!({"start": [0, 0], "pieces": [{"x": 100, "y": 0}]})).unwrap(); + let id = r["id"].as_u64().unwrap(); + let before = paths(&s); + let bad: [Value; 11] = [ + json!({}), + json!({"pieces": []}), + json!({"start": [0, 0], "pieces": [{"x": 1, "y": 1, "action": "arc"}]}), + json!({"start": [0, 0], "pieces": [{"x": 1, "y": 1, "action": "sharpArc", "turn": 0}]}), + json!({"start": [0, 0], "pieces": [{"x": 1, "y": 1, "turn": 360}]}), + json!({"start": [0, 0], "pieces": [{"x": "1", "y": 1}]}), + json!({"start": [0, 0], "pieces": [{"x": 1, "y": 1, "flip": "yes"}]}), + json!({"start": [0, 0], "keep": 1}), + json!({"id": id, "keep": 0}), + json!({"id": id, "keep": 3}), + json!({"id": id, "start": [0, 0]}), + ]; + for p in bad { + assert!(s.execute("path.quickPen", &p).is_err(), "{p}"); + } + assert!(s.execute("path.quickPen", &json!({"start": [0, 0], "pieces": vec![json!({"x": 1, "y": 1}); 10_001]})).is_err()); + s.execute("path.quickPen", &json!({"id": id, "closed": true})).unwrap(); + assert!(s.execute("path.quickPen", &json!({"id": id, "pieces": [{"x": 5, "y": 5}]})).is_err(), "closed"); + assert_eq!(paths(&s).len(), before.len()); +} + +/// With `id` and `keep`, the points after the first `keep` are replaced by the pieces. +#[test] +fn path_quick_pen_replaces_the_points_after_keep() { + let mut s = session(); + let r = s.execute("path.quickPen", &json!({"start": [0, 0], "pieces": [{"x": 100, "y": 0}, {"x": 100, "y": 100}]})).unwrap(); + let id = r["id"].as_u64().unwrap(); + s.execute("path.quickPen", &json!({"id": id, "keep": 2, "pieces": [{"x": 200, "y": 0}]})).unwrap(); + let ends: Vec = only_path(&s).anchors.iter().map(|a| a.p).collect(); + assert_eq!(ends, [pt(0.0, 0.0), pt(100.0, 0.0), pt(200.0, 0.0)]); +} diff --git a/crates/tools/src/catalog.rs b/crates/tools/src/catalog.rs index 9397a79961..ed22d1be9b 100644 --- a/crates/tools/src/catalog.rs +++ b/crates/tools/src/catalog.rs @@ -34,6 +34,7 @@ pub const TOOL_GROUPS: &[&[ToolInfo]] = &[ t("addAnchor", "Add Anchor Point Tool", Some("+"), "tool-pen-add"), t("deleteAnchor", "Delete Anchor Point Tool", Some("-"), "tool-pen-delete"), t("anchorPoint", "Anchor Point Tool", Some("Shift+C"), "tool-anchor"), + t(crate::quickpen::ID, "Quick Pen Tool", Some("Alt+P"), "tool-quick-pen"), ], &[t("curvature", "Curvature Tool", Some("Shift+~"), "tool-curvature")], &[ diff --git a/crates/tools/src/input.rs b/crates/tools/src/input.rs index 80c857abe6..a4b4011bf1 100644 --- a/crates/tools/src/input.rs +++ b/crates/tools/src/input.rs @@ -217,6 +217,9 @@ pub enum ToolKey { /// A letter key a–z, lowercase (E while dragging a Selection or Group Selection marquee makes it /// select only the objects entirely inside it, and E again switches it back). Letter(char), + /// Alt (Option on macOS) pressed and let go with no other key, click or wheel turn in between + /// (the Quick Pen tool switches to its next action). + AltTap, } /// What a tool asks the engine to do. diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index c864d529a2..9483943af6 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs @@ -36,6 +36,7 @@ pub mod pen; pub mod pie; pub mod place; pub mod printtiling; +pub mod quickpen; pub mod repeat_grid; pub mod repeat_radial; pub mod rulerguide; @@ -388,6 +389,7 @@ pub fn create(id: &str) -> Box { "rectangle" | "roundedRectangle" | "ellipse" | "polygon" | "star" | "lineSegment" => Box::new(shape::ShapeTool::new(id)), circle::ID => Box::new(circle::CircleTool::default()), curvature_circle::ID => Box::new(curvature_circle::CurvatureCircleTool::default()), + quickpen::ID => Box::new(quickpen::QuickPenTool::default()), // Not in the toolbar: `file.place.queue` loads it. "place" => Box::new(place::PlaceTool::default()), other => symbolism::create(other) diff --git a/crates/tools/src/quickpen.rs b/crates/tools/src/quickpen.rs new file mode 100644 index 0000000000..140278719d --- /dev/null +++ b/crates/tools/src/quickpen.rs @@ -0,0 +1,616 @@ +//! The Quick Pen tool (Alt+P, Option+P on macOS) draws paths of straight lines and circular arcs +//! (`path.quickPen`). +//! +//! A click sets the start point, and each click or drag after it adds a piece from the last point +//! to where the pointer is let go, as the tool's action says: a straight line, a continuous arc +//! (it leaves its start in the direction the path arrives in, so the two join smoothly) or a +//! sharp-corner arc (it turns through the arc size, 180° by default, and meets the path before it +//! at a corner). Alt (Option) pressed and let go on its own switches to the next action. C flips +//! the last sharp-corner arc to the other side of its chord, and [ and ] make the arc size 15° +//! smaller or larger, for the last sharp-corner arc and the ones after it. A click on the first +//! point closes the path, a click on an end of an open path goes on drawing from it, and Escape +//! or Enter ends the path. 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. + +use std::f64::consts::{FRAC_PI_2, PI}; + +use serde_json::{Value, json}; +use vectorcraft_doc::{NodeId, NodeKind}; +use vectorcraft_geom::{Anchor, AnchorKind, BezPath, Point, SubPath, Vec2}; + +use crate::draw2::FEEDBACK; +use crate::guides::{DrawSnap, Leave}; +use crate::pen::{continue_from, open_end_at}; +use crate::{Action, Cursor, Mods, Overlay, PointerEvent, PointerKind, Tool, ToolContext, ToolKey}; + +/// The tool's id. +pub const ID: &str = "quickPen"; +/// The command that draws the path. +pub const COMMAND: &str = "path.quickPen"; +/// A sharp-corner arc's turn (degrees) until [ or ] changes it. +pub const DEFAULT_TURN: f64 = 180.0; +/// The degrees [ and ] take from or add to the arc size. +pub const TURN_STEP: f64 = 15.0; +/// The smallest and largest arc size (degrees). +pub const MIN_TURN: f64 = 1.0; +pub const MAX_TURN: f64 = 359.0; +/// Screen points the pointer moves after a press before the press drags. +const DRAG_PX: f64 = 3.0; +/// A continuous arc whose end lies within this angle (radians) of straight ahead, or of straight +/// behind, is drawn as a line: no circle runs there in the path's direction. +const STRAIGHT: f64 = 1e-6; + +/// What the next click adds. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub enum Stroke { + #[default] + Line, + ContinuousArc, + SharpArc, +} + +impl Stroke { + pub const ALL: [Stroke; 3] = [Stroke::Line, Stroke::ContinuousArc, Stroke::SharpArc]; + + /// The name commands and the tool's `action` option use. + pub fn name(self) -> &'static str { + match self { + Stroke::Line => "line", + Stroke::ContinuousArc => "continuousArc", + Stroke::SharpArc => "sharpArc", + } + } + + pub fn parse(s: &str) -> Option { + Self::ALL.into_iter().find(|k| k.name() == s) + } + + /// The action after this one: Line, Continuous Arc, Sharp Corner Arc, and round again. + pub fn next(self) -> Self { + match self { + Stroke::Line => Stroke::ContinuousArc, + Stroke::ContinuousArc => Stroke::SharpArc, + Stroke::SharpArc => Stroke::Line, + } + } +} + +/// One piece of a Quick Pen path: from the path's last point to `to`. `turn` (degrees) and `flip` +/// shape a sharp-corner arc, and a continuous arc with no direction to follow. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Piece { + pub to: Point, + pub stroke: Stroke, + pub turn: f64, + pub flip: bool, +} + +impl Piece { + pub fn to_json(&self) -> Value { + let mut v = json!({"x": self.to.x, "y": self.to.y, "action": self.stroke.name()}); + if self.stroke != Stroke::Line { + v["turn"] = json!(self.turn); + v["flip"] = json!(self.flip); + } + v + } +} + +/// `v` turned by `a` radians (clockwise on the page, whose y runs down). +fn rot(v: Vec2, a: f64) -> Vec2 { + let (s, c) = a.sin_cos(); + Vec2::new(v.x * c - v.y * s, v.x * s + v.y * c) +} + +fn unit(v: Vec2) -> Option { + let l = v.hypot(); + (l > 1e-12 && l.is_finite()).then(|| v / l) +} + +/// The direction an open subpath runs at its last point: along that point's incoming handle, or +/// else from the segment before it. None for a single point, or a path that comes back on itself. +pub fn arrival(sp: &SubPath) -> Option { + let n = sp.anchors.len(); + let last = sp.anchors.last()?; + if let Some(d) = unit(last.p - last.h_in) { + return Some(d); + } + let prev = sp.anchors.get(n.checked_sub(2)?)?; + unit(last.p - prev.h_out).or_else(|| unit(last.p - prev.p)) +} + +/// The signed turn (radians) of the arc `piece` adds from `a` to `b` on `sp`, or None for a +/// straight segment. Positive turns bulge to the left of the direction drawn. +fn turn_of(sp: &SubPath, piece: &Piece, a: Point, b: Point) -> Option { + let sharp = |p: &Piece| p.turn.to_radians() * if p.flip { -1.0 } else { 1.0 }; + match piece.stroke { + Stroke::Line => None, + Stroke::SharpArc => Some(sharp(piece)), + Stroke::ContinuousArc => match arrival(sp) { + None => Some(sharp(piece)), + Some(t) => { + let c = b - a; + let phi = t.cross(c).atan2(t.dot(c)); + (phi.abs() > STRAIGHT && phi.abs() < PI - STRAIGHT).then_some(2.0 * phi) + } + }, + } +} + +/// Adds `piece` at the end of the open subpath `sp`. A piece that ends where the subpath does adds +/// nothing (false). An arc is drawn as cubic segments of at most 90° each, its inner points smooth; +/// the new end is a corner without an outgoing handle. The point the piece leaves from is smooth +/// when a continuous arc goes on from a curve into it, and a corner otherwise. +pub fn append(sp: &mut SubPath, piece: &Piece) -> bool { + let Some(last) = sp.anchors.last().copied() else { return false }; + let (a, b) = (last.p, piece.to); + let c = b - a; + let l = c.hypot(); + if l <= 1e-9 || !l.is_finite() { + return false; + } + let Some(s) = turn_of(sp, piece, a, b) else { + if let Some(end) = sp.anchors.last_mut() { + end.h_out = end.p; + end.kind = AnchorKind::Corner; + } + sp.anchors.push(Anchor::corner(b)); + return true; + }; + let continuous = piece.stroke == Stroke::ContinuousArc && arrival(sp).is_some(); + let n = ((s.abs() / FRAC_PI_2) - 1e-9).ceil().max(1.0) as usize; + let step = s / n as f64; + let r = l / (2.0 * (s.abs() / 2.0).sin()); + let k = 4.0 / 3.0 * (step.abs() / 4.0).tan() * r; + let mut t = rot(c / l, -s / 2.0); + if let Some(end) = sp.anchors.last_mut() { + end.h_out = a + t * k; + end.kind = if continuous && end.h_in != end.p { AnchorKind::Smooth } else { AnchorKind::Corner }; + } + let mut p = a; + for i in 1..=n { + let chord = rot(t, step / 2.0) * (2.0 * r * (step.abs() / 2.0).sin()); + let t2 = rot(t, step); + let q = if i == n { b } else { p + chord }; + let mut an = Anchor::with_handles(q, q - t2 * k, q); + if i < n { + an.h_out = q + t2 * k; + an.kind = AnchorKind::Smooth; + } + sp.anchors.push(an); + (p, t) = (q, t2); + } + true +} + +/// Closes `sp`: a last point that lies on the first joins it (the first point takes its incoming +/// handle); otherwise a straight segment closes the path. Fewer than two points stay open. +pub fn close(sp: &mut SubPath) { + let n = sp.anchors.len(); + if n < 2 { + return; + } + if let (Some(first), Some(last)) = (sp.anchors.first().copied(), sp.anchors.last().copied()) + && n >= 3 + && first.p.distance(last.p) <= 1e-9 + { + sp.anchors.pop(); + if let Some(f) = sp.anchors.first_mut() { + f.h_in = last.h_in; + } + } + sp.closed = true; +} + +/// `base` with `pieces` added after it, closed when `closed`. +pub fn build(base: &SubPath, pieces: &[Piece], closed: bool) -> SubPath { + let mut sp = base.clone(); + for piece in pieces { + append(&mut sp, piece); + } + if closed { + close(&mut sp); + } + sp +} + +/// The path being drawn: subpath `si` of `id`, whose points were `base` before the tool drew on +/// (both none until the engine made a new path), then `pieces`. A new path starts at `start`. +#[derive(Clone, Debug, PartialEq)] +struct Drawing { + id: Option, + si: usize, + base: Option, + start: Option, + pieces: Vec, +} + +impl Drawing { + /// The subpath as the tool drew it. + fn drawn(&self) -> Option { + Some(build(self.base.as_ref()?, &self.pieces, false)) + } +} + +/// The press in progress: where it went down, whether it has dragged, and whether it began an undo +/// step (a piece it adds). +#[derive(Clone, Copy, Debug, PartialEq)] +struct Press { + at: Point, + dragged: bool, + begun: bool, +} + +pub struct QuickPenTool { + action: Stroke, + turn: f64, + drawing: Option, + press: Option, + hover: Option, + snap: DrawSnap, +} + +impl Default for QuickPenTool { + fn default() -> Self { + Self { action: Stroke::Line, turn: DEFAULT_TURN, drawing: None, press: None, hover: None, snap: DrawSnap::default() } + } +} + +/// Is `id` selected on its own, itself or the compound path it is in? +fn selected_alone(cx: &ToolContext, id: NodeId) -> bool { + let sel = cx.selection.objects.as_slice(); + sel == [id] || cx.doc.parent_of(id).is_some_and(|p| sel == [p] && cx.doc.node(p).is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. }))) +} + +fn point_tol(cx: &ToolContext) -> f64 { + cx.tol(5.0).max(cx.point_tol()) +} + +impl QuickPenTool { + /// The subpath being drawn, while it is selected, editable, open and still exactly what the tool + /// drew: an edit made outside the tool (a point moved, the path it went on from changed) ends + /// the drawing, so the next piece does not undo it. + fn active<'a>(&self, cx: &'a ToolContext) -> Option<(NodeId, &'a SubPath)> { + let dr = self.drawing.as_ref()?; + let id = dr.id?; + if !selected_alone(cx, id) || !cx.doc.is_editable(id) { + return None; + } + let sp = cx.doc.node(id)?.path_data()?.subpaths.get(dr.si)?; + (!sp.closed && dr.drawn()?.anchors == sp.anchors).then_some((id, sp)) + } + + /// `path.quickPen`'s params for the path being drawn, closed when `closed`. + fn params(&self, closed: bool) -> Value { + let Some(dr) = &self.drawing else { return json!({}) }; + let pieces: Vec = dr.pieces.iter().map(Piece::to_json).collect(); + let mut v = json!({"pieces": pieces}); + match (dr.id, dr.start) { + (Some(id), _) => { + v["id"] = json!(id.0); + v["subpath"] = json!(dr.si); + v["keep"] = json!(dr.base.as_ref().map_or(1, |b| b.anchors.len().max(1))); + } + (None, Some(s)) => v["start"] = json!([s.x, s.y]), + (None, None) => {} + } + if closed { + v["closed"] = json!(true); + } + v + } + + /// The last piece, while it is a sharp-corner arc and no press is under way. + fn last_sharp_arc(&self, cx: &ToolContext) -> Option { + if self.press.is_some() { + return None; + } + self.active(cx)?; + self.drawing.as_ref()?.pieces.last().copied().filter(|p| p.stroke == Stroke::SharpArc) + } + + fn piece_to(&self, to: Point) -> Piece { + Piece { to, stroke: self.action, turn: self.turn, flip: false } + } + + /// The segment from the path's last point the snapping leaves from. + fn leave(&self, cx: &ToolContext) -> Option<(NodeId, Leave)> { + let (id, sp) = self.active(cx)?; + sp.anchors.last().map(|a| (id, Leave::segment(cx, a.p, false).without_contact())) + } + + /// What a press draws: a piece on the path being drawn, its closing piece, or a new path (from + /// an end of an open path, the path goes on). + fn press_down(&mut self, cx: &ToolContext, p: Point) -> Vec { + if self.drawing.is_some() && self.active(cx).is_none() { + self.drawing = None; + } + let tol = point_tol(cx); + if let Some((id, sp)) = self.active(cx) { + let (first, last) = match (sp.anchors.first(), sp.anchors.last()) { + (Some(f), Some(l)) => (f.p, l.p), + _ => return vec![], + }; + if sp.anchors.len() >= 2 && p.distance(first) <= tol && p.distance(first) <= p.distance(last) { + let piece = self.piece_to(first); + if let Some(dr) = self.drawing.as_mut() { + dr.pieces.push(piece); + } + let out = vec![Action::Exec(COMMAND.into(), self.params(true))]; + self.drawing = None; + return out; + } + if p.distance(last) <= tol { + return vec![]; + } + let from = self.leave(cx).map(|l| l.1); + let q = self.snap.press(cx, p, &[id], from.as_ref()); + let piece = self.piece_to(q); + if let Some(dr) = self.drawing.as_mut() { + dr.pieces.push(piece); + } + self.press = Some(Press { at: p, dragged: false, begun: true }); + return vec![Action::Begin("Quick Pen".into()), Action::Preview(COMMAND.into(), self.params(false))]; + } + if let Some((id, si, at_first)) = open_end_at(cx, p, tol, None) + && cx.doc.is_editable(id) + && let Some(sp) = cx.doc.node(id).and_then(|n| n.path_data()).and_then(|pd| pd.subpaths.get(si)) + { + // From its start, `continue_from` reverses the path first. + let mut base = sp.clone(); + if at_first { + base.reverse(); + } + self.drawing = Some(Drawing { id: Some(id), si, base: Some(base), start: None, pieces: vec![] }); + return continue_from(cx, id, si, at_first); + } + let q = self.snap.press(cx, p, &[], None); + self.drawing = Some(Drawing { id: None, si: 0, base: None, start: Some(q), pieces: vec![] }); + vec![Action::Exec(COMMAND.into(), self.params(false)), Action::Notify("created".into())] + } + + /// Ends the path being drawn; a press that added a piece is taken back. + fn end(&mut self) -> Vec { + self.drawing = None; + self.snap.clear(); + match self.press.take() { + Some(pr) if pr.begun => vec![Action::Cancel], + _ => vec![], + } + } + + /// The piece the next click adds, from the end of `sp` to `h`, as a path to preview. + fn rubber_band(&self, sp: &SubPath, h: Point) -> Option { + let n = sp.anchors.len(); + let mut tail = SubPath::new(sp.anchors.get_range(n.saturating_sub(2)..)?, false); + let from = tail.anchors.len() - 1; + if !append(&mut tail, &self.piece_to(h)) { + return None; + } + let mut added = tail.anchors.get_range(from..)?; + if let Some(a) = added.first_mut() { + a.h_in = a.p; + } + let mut bp = BezPath::new(); + SubPath::new(added, false).to_bezpath_into(&mut bp); + Some(bp) + } +} + +impl Tool for QuickPenTool { + fn id(&self) -> &'static str { + ID + } + + fn busy(&self) -> bool { + self.press.is_some() + } + + fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec { + let p = ev.pos; + match ev.kind { + PointerKind::Move => { + let (on, from) = self.leave(cx).unzip(); + self.hover = Some(self.snap.hover(cx, p, on.as_slice(), from.as_ref())); + vec![] + } + PointerKind::Down => { + if self.press.is_some() { + return vec![]; + } + self.press_down(cx, p) + } + PointerKind::Drag => { + let Some(mut pr) = self.press else { return vec![] }; + if !pr.dragged && p.distance(pr.at) < cx.tol(DRAG_PX) { + return vec![]; + } + pr.dragged = true; + self.press = Some(pr); + // The snapping leaves from the point before the piece being dragged. + let from = self.drawing.as_ref().and_then(|dr| { + let sp = build(dr.base.as_ref()?, dr.pieces.split_last().map_or(&[][..], |(_, rest)| rest), false); + sp.anchors.last().map(|a| Leave::segment(cx, a.p, false).without_contact()) + }); + let q = self.snap.drag(cx, p, from.as_ref()); + if let Some(last) = self.drawing.as_mut().and_then(|dr| dr.pieces.last_mut()) { + last.to = q; + } + vec![Action::Preview(COMMAND.into(), self.params(false))] + } + PointerKind::Up => { + self.snap.clear(); + match self.press.take() { + Some(pr) if pr.begun => vec![Action::Commit], + _ => vec![], + } + } + PointerKind::DoubleClick | PointerKind::TripleClick => vec![], + } + } + + fn notify(&mut self, cx: &ToolContext, what: &str) { + if what == "created" + && let [id] = cx.selection.objects.as_slice() + && let Some(base) = cx.doc.node(*id).and_then(|n| n.path_data()).and_then(|pd| pd.subpaths.first()) + && let Some(dr) = self.drawing.as_mut() + && dr.id.is_none() + { + (dr.id, dr.si, dr.base, dr.start) = (Some(*id), 0, Some(base.clone()), None); + } + } + + /// A path being drawn: Escape ends it. + fn ends_on_escape(&self, cx: &ToolContext) -> bool { + self.active(cx).is_some() + } + + fn claims_key(&self, cx: &ToolContext, key: ToolKey) -> bool { + match key { + ToolKey::Letter('c') => self.last_sharp_arc(cx).is_some(), + ToolKey::BracketLeft | ToolKey::BracketRight | ToolKey::AltTap => true, + ToolKey::Enter => self.active(cx).is_some(), + _ => false, + } + } + + /// A dropped press does not end the path being drawn: the piece it added goes. + fn drop_press(&mut self, _cx: &ToolContext) -> Vec { + if self.press.take().is_some_and(|pr| pr.begun) + && let Some(dr) = self.drawing.as_mut() + { + dr.pieces.pop(); + } + self.snap.clear(); + vec![] + } + + fn key(&mut self, cx: &ToolContext, key: ToolKey, _mods: Mods) -> Vec { + match key { + ToolKey::Escape | ToolKey::Enter => self.end(), + ToolKey::Letter('c') => { + if self.last_sharp_arc(cx).is_none() { + return vec![]; + } + if let Some(last) = self.drawing.as_mut().and_then(|dr| dr.pieces.last_mut()) { + last.flip = !last.flip; + } + vec![Action::Exec(COMMAND.into(), self.params(false))] + } + ToolKey::BracketLeft | ToolKey::BracketRight => { + let by = if key == ToolKey::BracketLeft { -TURN_STEP } else { TURN_STEP }; + let arc = self.last_sharp_arc(cx); + let turn = arc.map_or(self.turn, |a| a.turn) + by; + if !(MIN_TURN..=MAX_TURN).contains(&turn) { + return vec![]; + } + self.turn = turn; + if arc.is_none() { + return vec![]; + } + if let Some(last) = self.drawing.as_mut().and_then(|dr| dr.pieces.last_mut()) { + last.turn = turn; + } + vec![Action::Exec(COMMAND.into(), self.params(false))] + } + ToolKey::AltTap => { + self.action = self.action.next(); + // A drag under way draws its piece with the new action. + if self.press.is_some_and(|pr| pr.begun) { + let (action, turn) = (self.action, self.turn); + if let Some(last) = self.drawing.as_mut().and_then(|dr| dr.pieces.last_mut()) { + (last.stroke, last.turn, last.flip) = (action, turn, false); + } + return vec![Action::Preview(COMMAND.into(), self.params(false))]; + } + vec![] + } + _ => vec![], + } + } + + fn deactivate(&mut self, _cx: &ToolContext) -> Vec { + self.drawing = None; + self.snap.clear(); + match self.press.take() { + Some(pr) if pr.begun => vec![Action::Commit], + _ => vec![], + } + } + + fn chosen_again(&mut self, _cx: &ToolContext) -> Vec { + if self.press.is_none() { + self.drawing = None; + } + vec![] + } + + fn hover_ended(&mut self, _cx: &ToolContext) { + self.hover = None; + } + + fn overlays(&self, cx: &ToolContext) -> Vec { + let mut o = self.snap.guides().to_vec(); + let Some((id, sp)) = self.active(cx) else { return o }; + if self.press.is_none() + && let Some(h) = self.hover + { + if cx.pen_rubber_band + && let Some(path) = self.rubber_band(sp, h) + { + o.push(Overlay::Path { path, color: cx.doc.layer_color(id), width: 1.0, dashed: false }); + } + if let Some(last) = sp.anchors.last().map(|a| a.p) + && cx.measurement_labels + && last.distance(h) > 1e-9 + { + o.push(Overlay::Measure { p: h + Vec2::new(cx.tol(12.0), cx.tol(12.0)), text: cx.segment_measure_label(last, h) }); + } + } + let n = sp.anchors.len(); + for (i, a) in sp.anchors.iter().enumerate() { + o.push(Overlay::CurvePoint { p: a.p, color: FEEDBACK, filled: i + 1 == n, size: 6.0 }); + } + o + } + + fn cursor(&self, cx: &ToolContext, p: Point, _m: Mods) -> Cursor { + let tol = point_tol(cx); + if let Some((_, sp)) = self.active(cx) { + let close = sp.anchors.len() >= 2 && sp.anchors.first().is_some_and(|f| f.p.distance(p) <= tol); + return if close { Cursor::PenClose } else { Cursor::PenDrawing }; + } + if open_end_at(cx, p, tol, None).is_some() { Cursor::PenContinue } else { Cursor::Pen } + } + + fn options(&self) -> Value { + json!({ "action": self.action.name(), "turn": self.turn }) + } + + fn set_option(&mut self, key: &str, v: &Value) { + match key { + "action" => { + if let Some(a) = v.as_str().and_then(Stroke::parse) { + self.action = a; + } + } + "turn" => { + if let Some(t) = v.as_f64().filter(|t| (MIN_TURN..=MAX_TURN).contains(t)) { + self.turn = t; + } + } + _ => {} + } + } + + fn check_option(&self, key: &str, v: &Value) -> Result<(), String> { + match key { + "action" => crate::option_check::one_of(key, v, &Stroke::ALL.map(Stroke::name)), + "turn" => crate::option_check::number(key, v, MIN_TURN, MAX_TURN), + _ => Err(crate::option_check::unknown(key)), + } + } +} + +#[cfg(test)] +mod tests; diff --git a/crates/tools/src/quickpen/tests.rs b/crates/tools/src/quickpen/tests.rs new file mode 100644 index 0000000000..f5ab9986d1 --- /dev/null +++ b/crates/tools/src/quickpen/tests.rs @@ -0,0 +1,214 @@ +use super::*; +use crate::testutil::*; +use vectorcraft_doc::Selection; +use vectorcraft_geom::{ParamCurve, PathData}; + +fn pt(x: f64, y: f64) -> Point { + Point::new(x, y) +} + +fn start(p: Point) -> SubPath { + SubPath::new(vec![Anchor::corner(p)], false) +} + +fn piece(x: f64, y: f64, stroke: Stroke) -> Piece { + Piece { to: pt(x, y), stroke, turn: DEFAULT_TURN, flip: false } +} + +/// Every sampled point of the segments from anchor `from` on lies `r` from `center`. +fn on_circle(sp: &SubPath, from: usize, center: Point, r: f64) -> bool { + (from..sp.segment_count()).all(|i| (0..=16).all(|k| (sp.segment(i).eval(k as f64 / 16.0).distance(center) - r).abs() < r * 1e-3)) +} + +#[test] +fn a_line_piece_adds_a_corner_point_and_no_handles() { + let mut sp = start(pt(0.0, 0.0)); + assert!(append(&mut sp, &piece(100.0, 0.0, Stroke::Line))); + assert_eq!(sp.anchors.len(), 2); + assert!(sp.anchors.iter().all(|a| a.h_in == a.p && a.h_out == a.p && a.kind == AnchorKind::Corner)); +} + +/// A sharp-corner arc turns 180° by default: a half circle on its chord, on the left of the +/// direction drawn (above a chord drawn to the right, since y runs down), in two quarter segments. +#[test] +fn a_sharp_corner_arc_is_a_half_circle_bulging_left() { + let mut sp = start(pt(0.0, 0.0)); + append(&mut sp, &piece(100.0, 0.0, Stroke::SharpArc)); + assert_eq!(sp.anchors.len(), 3); + assert!(on_circle(&sp, 0, pt(50.0, 0.0), 50.0)); + assert!(sp.anchors.get(1).unwrap().p.distance(pt(50.0, -50.0)) < 1e-9); + assert_eq!(sp.anchors.last().unwrap().p, pt(100.0, 0.0)); + // Flipped, it bulges the other way. + let mut sp = start(pt(0.0, 0.0)); + append(&mut sp, &Piece { flip: true, ..piece(100.0, 0.0, Stroke::SharpArc) }); + assert!(sp.anchors.get(1).unwrap().p.distance(pt(50.0, 50.0)) < 1e-9); +} + +/// The turn sets how much of a circle the arc is: 90° is one segment, 270° three. +#[test] +fn the_turn_sets_the_arc_and_its_segments() { + let mut sp = start(pt(0.0, 0.0)); + append(&mut sp, &Piece { turn: 90.0, ..piece(100.0, 0.0, Stroke::SharpArc) }); + assert_eq!(sp.anchors.len(), 2); + let r = 100.0 / (2.0 * (45f64).to_radians().sin()); + // Bulging up, so its center is below the chord. + assert!(on_circle(&sp, 0, pt(50.0, 50.0), r)); + let mut sp = start(pt(0.0, 0.0)); + append(&mut sp, &Piece { turn: 270.0, ..piece(100.0, 0.0, Stroke::SharpArc) }); + assert_eq!(sp.anchors.len(), 4); + assert!(sp.anchors.iter().skip(1).take(2).all(|a| a.kind == AnchorKind::Smooth)); +} + +/// A continuous arc leaves the end of the path in the direction the path arrives in: after a +/// line drawn to the right, an arc to a point below and to the right starts heading right. +#[test] +fn a_continuous_arc_goes_on_in_the_paths_direction() { + let mut sp = start(pt(0.0, 0.0)); + append(&mut sp, &piece(100.0, 0.0, Stroke::Line)); + append(&mut sp, &piece(200.0, 100.0, Stroke::ContinuousArc)); + let corner = sp.anchors.get(1).unwrap(); + let out = corner.h_out - corner.p; + assert!(out.y.abs() < 1e-9 && out.x > 0.0, "{out:?}"); + // The quarter circle centered at (100, 100). + assert!(on_circle(&sp, 1, pt(100.0, 100.0), 100.0)); + // Another continuous arc goes on smoothly from its end. + append(&mut sp, &piece(100.0, 200.0, Stroke::ContinuousArc)); + let joint = sp.anchors.get(2).unwrap(); + assert!((joint.p - joint.h_in).cross(joint.h_out - joint.p).abs() < 1e-6); + assert_eq!(joint.kind, AnchorKind::Smooth); +} + +/// With nothing to follow (the path's first piece) a continuous arc is drawn as a sharp-corner +/// arc; an end straight ahead is a line. +#[test] +fn a_continuous_arc_without_a_direction_or_straight_ahead() { + let mut a = start(pt(0.0, 0.0)); + let mut b = start(pt(0.0, 0.0)); + append(&mut a, &piece(100.0, 0.0, Stroke::ContinuousArc)); + append(&mut b, &piece(100.0, 0.0, Stroke::SharpArc)); + assert_eq!(a, b); + let mut sp = start(pt(0.0, 0.0)); + append(&mut sp, &piece(100.0, 0.0, Stroke::Line)); + append(&mut sp, &piece(300.0, 0.0, Stroke::ContinuousArc)); + assert_eq!(sp.anchors.len(), 3); + assert_eq!(sp.anchors.get(1).unwrap().h_out, pt(100.0, 0.0)); +} + +/// A line or a sharp-corner arc leaves a corner behind it, also after a continuous arc and from +/// the smooth end of a path it goes on from; a continuous arc leaves a smooth point. +#[test] +fn only_a_continuous_arc_leaves_a_smooth_point() { + let mut sp = start(pt(0.0, 0.0)); + append(&mut sp, &piece(100.0, 0.0, Stroke::Line)); + append(&mut sp, &piece(200.0, 100.0, Stroke::ContinuousArc)); + append(&mut sp, &piece(100.0, 200.0, Stroke::ContinuousArc)); + assert_eq!(sp.anchors.get(2).unwrap().kind, AnchorKind::Smooth); + let smooth_end = sp.anchors.len() - 1; + let mut a = sp.clone(); + a.anchors.last_mut().unwrap().kind = AnchorKind::Smooth; + let mut b = a.clone(); + append(&mut a, &piece(300.0, 300.0, Stroke::SharpArc)); + append(&mut b, &piece(300.0, 300.0, Stroke::Line)); + for sp in [a, b] { + assert_eq!(sp.anchors.get(smooth_end).unwrap().kind, AnchorKind::Corner); + } +} + +#[test] +fn a_piece_to_the_last_point_adds_nothing() { + let mut sp = start(pt(5.0, 5.0)); + assert!(!append(&mut sp, &piece(5.0, 5.0, Stroke::SharpArc))); + assert_eq!(sp.anchors.len(), 1); +} + +/// Closing on the first point joins the two; elsewhere a straight segment closes the path. +#[test] +fn closing_joins_a_last_point_on_the_first() { + let pieces = [piece(100.0, 0.0, Stroke::Line), piece(100.0, 100.0, Stroke::Line), piece(0.0, 0.0, Stroke::SharpArc)]; + let sp = build(&start(pt(0.0, 0.0)), &pieces, true); + assert!(sp.closed); + assert_eq!(sp.anchors.first().unwrap().p, pt(0.0, 0.0)); + assert!(sp.anchors.iter().filter(|a| a.p == pt(0.0, 0.0)).count() == 1); + assert_ne!(sp.anchors.first().unwrap().h_in, pt(0.0, 0.0), "the first point takes the arc's handle"); + let sp = build(&start(pt(0.0, 0.0)), &pieces[..2], true); + assert!(sp.closed && sp.anchors.len() == 3); +} + +#[test] +fn actions_cycle_and_name_themselves() { + assert_eq!(Stroke::Line.next(), Stroke::ContinuousArc); + assert_eq!(Stroke::ContinuousArc.next(), Stroke::SharpArc); + assert_eq!(Stroke::SharpArc.next(), Stroke::Line); + for s in Stroke::ALL { + assert_eq!(Stroke::parse(s.name()), Some(s)); + } + assert_eq!(Stroke::parse("arc"), None); +} + +#[test] +fn options_are_checked_and_set() { + let mut t = QuickPenTool::default(); + assert_eq!(t.options(), json!({"action": "line", "turn": 180.0})); + assert!(t.check_option("action", &json!("sharpArc")).is_ok()); + assert!(t.check_option("action", &json!("arc")).is_err()); + assert!(t.check_option("turn", &json!(0)).is_err()); + assert!(t.check_option("turn", &json!(360)).is_err()); + assert!(t.check_option("size", &json!(1)).is_err()); + t.set_option("action", &json!("continuousArc")); + t.set_option("turn", &json!(90)); + assert_eq!(t.options(), json!({"action": "continuousArc", "turn": 90.0})); +} + +/// Alt tapped alone switches to the next action; [ and ] change the arc size by 15° within 1° to +/// 359°, with no path being drawn. +#[test] +fn alt_tap_cycles_and_brackets_size_the_next_arc() { + let (d, _) = doc_with_rect(); + let s = Selection::default(); + let p = paint(); + let cx = cx(&d, &s, &p); + let mut t = QuickPenTool::default(); + assert!(t.claims_key(&cx, ToolKey::AltTap)); + for want in ["continuousArc", "sharpArc", "line"] { + assert!(t.key(&cx, ToolKey::AltTap, Mods::default()).is_empty()); + assert_eq!(t.options()["action"], want); + } + assert!(t.key(&cx, ToolKey::BracketRight, Mods::default()).is_empty()); + assert_eq!(t.options()["turn"], 195.0); + t.set_option("turn", &json!(10)); + t.key(&cx, ToolKey::BracketLeft, Mods::default()); + assert_eq!(t.options()["turn"], 10.0, "stays at or above 1°"); + // C is the Scissors' shortcut while no arc is being drawn. + assert!(!t.claims_key(&cx, ToolKey::Letter('c'))); +} + +/// The first click starts a new path and the tool picks it up once the engine made it. +#[test] +fn the_first_click_starts_a_path() { + let (d, _) = doc_with_rect(); + let s = Selection::default(); + let p = paint(); + let cx = cx(&d, &s, &p); + let mut t = QuickPenTool::default(); + let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 10.0, 10.0)); + assert!(matches!(&a[0], Action::Exec(c, v) if c == COMMAND && v["start"] == json!([10.0, 10.0]) && v["pieces"] == json!([])), "{a:?}"); + assert_eq!(a[1], Action::Notify("created".into())); + assert_eq!(t.cursor(&cx, pt(400.0, 400.0), Mods::default()), Cursor::Pen); +} + +/// The rubber band previews exactly the piece a click adds. +#[test] +fn the_rubber_band_is_the_next_piece() { + let t = QuickPenTool { action: Stroke::SharpArc, ..Default::default() }; + let sp = build(&start(pt(0.0, 0.0)), &[piece(100.0, 0.0, Stroke::Line)], false); + let band = t.rubber_band(&sp, pt(200.0, 0.0)).unwrap(); + let mut added = sp.clone(); + append(&mut added, &t.piece_to(pt(200.0, 0.0))); + let whole = PathData::single(added); + for seg in band.segments() { + for k in 0..=8 { + let q = seg.eval(k as f64 / 8.0); + assert!(whole.nearest(q).is_some_and(|n| n.4 < 1e-6), "{q:?}"); + } + } +} diff --git a/crates/tools/src/settings.rs b/crates/tools/src/settings.rs index a0800532b4..e823b5c9b1 100644 --- a/crates/tools/src/settings.rs +++ b/crates/tools/src/settings.rs @@ -20,6 +20,7 @@ pub const SYMBOLISM: &[&str] = const ROWS: &[Row] = &[ (&["dimension"], None, &["mode", "style"]), + (&[crate::quickpen::ID], None, &["action", "turn"]), // Global Brush Dimensions. (LIQUIFY, Some("liquify"), &["width", "height", "angle", "intensity", "usePressure", "showBrush"]), (LIQUIFY, None, &["detail", "simplify", "simplifyOn", "rate", "complexity", "horizontal", "vertical", "affectAnchors", "affectIn", "affectOut"]), diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 6a20976261..0fc0d136b0 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -203,6 +203,7 @@ impl VectorcraftApp { input_frames: vec![], shortcuts_frames: vec![], held_tool: Vec::new(), + alt_tap: Default::default(), hold_keys: Default::default(), synthetic_injected: false, injected_events: vec![], diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 67a9d62141..7a5495d93d 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -2682,6 +2682,8 @@ font-technology Variable Променливи PDF/A files carry their own output intent. Файловете PDF/A носят собствено предназначение за изход. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Файловете PDF/X-1a са в CMYK: всеки цвят се конвертира към дестинацията (при празно поле: CMYK профила на предназначението за изход), без етикет. Pen Tool Инструмент „Перо“ + Quick Pen Tool Инструмент „Бързо перо“ + Quick Pen Бързо перо Pencil Молив Pencil Tool Инструмент „Молив“ per slice на отрязък diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 67f101190a..1946d73d17 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -4193,6 +4193,8 @@ theme Appearance Izgled Paste Offset Pomak lijepljenja Pattern Editing Uređivanje uzorka Pen Tool Alat pero + Quick Pen Tool Alat brzo pero + Quick Pen Brzo pero Picas Pice Portuguese Portugalski Preserve Appearance and Overprints Očuvaj izgled i pretiske diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index fac4498296..ee54f85d7c 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -3438,6 +3438,8 @@ digits Malayalam Malaiàlam PDF/X-4:2010 PDF/X-4:2010 Pen Ploma Pen Tool Eina de ploma + Quick Pen Tool Eina de ploma ràpida + Quick Pen Ploma ràpida Pencil Llapis Pencil Tool Eina de llapis Pentagram Pentagrama @@ -6899,6 +6901,9 @@ liquify-list-end {0}, {1} {0} i {1} @msg `link` places a handle: give `handle` `link` col·loca una nansa: indiqueu `handle` @msg no such spine segment no existeix aquest segment de l’espina @msg no such subpath no existeix aquest subtraçat +@msg `pieces` must be a list of at most 10000 pieces `pieces` ha de ser una llista d’un màxim de 10000 trams +@msg give either `start` for a new path or `id`, not both indica `start` per a un traçat nou o bé `id`, però no tots dos +@msg `subpath` and `keep` need `id` `subpath` i `keep` necessiten `id` @msg no such user library no existeix aquesta biblioteca d’usuari @msg no such view no existeix aquesta vista @msg no such width point no existeix aquest punt d’amplada diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 98b1f10ce4..43820dad4d 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -4300,6 +4300,8 @@ theme Appearance Motiv Paste Offset Posun při vložení Pattern Editing Úpravy vzorku Pen Tool Nástroj Pero + Quick Pen Tool Nástroj Rychlé pero + Quick Pen Rychlé pero Picas Pica Portuguese Portugalština Preserve Appearance and Overprints Zachovat vzhled a přetisky @@ -5766,6 +5768,9 @@ liquify-list-end {0}, {1} {0} a {1} @msg `link` places a handle: give `handle` `link` umisťuje táhlo: zadejte `handle` @msg no such spine segment takový segment páteře neexistuje @msg no such subpath taková dílčí cesta neexistuje +@msg `pieces` must be a list of at most 10000 pieces `pieces` musí být seznam nejvýše 10000 dílů +@msg give either `start` for a new path or `id`, not both zadejte buď `start` pro novou cestu, nebo `id`, ne obojí +@msg `subpath` and `keep` need `id` `subpath` a `keep` vyžadují `id` @msg no such user library taková uživatelská knihovna neexistuje @msg no such view takové zobrazení neexistuje @msg no such width point takový bod šířky neexistuje diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 8c2008bf10..cbbd0534e5 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -6754,6 +6754,8 @@ theme Appearance Udseende Paste Offset Indsætningsforskydning Pattern Editing Mønsterredigering Pen Tool Pen-værktøj + Quick Pen Tool Hurtigpen-værktøj + Quick Pen Hurtigpen Picas Pica Portuguese Portugisisk Preserve Appearance and Overprints Bevar udseende og overprint @@ -7949,6 +7951,9 @@ imageTrace Outline Kontur @msg no such saved selection ingen sådan gemt markering @msg no such segment intet sådant segment @msg no such subpath ingen sådan delsti +@msg `pieces` must be a list of at most 10000 pieces `pieces` skal være en liste med højst 10000 stykker +@msg give either `start` for a new path or `id`, not both angiv enten `start` til en ny sti eller `id`, ikke begge +@msg `subpath` and `keep` need `id` `subpath` og `keep` kræver `id` @msg no such user library intet sådant brugerbibliotek @msg no such view ingen sådan visning @msg no such width point intet sådant breddepunkt diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 28724c3dd9..e5d29e02f6 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2744,6 +2744,8 @@ file-filter Templates Vorlagen PDF/A files carry their own output intent. PDF/A-Dateien enthalten ihre eigene Ausgabemethode. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a-Dateien sind CMYK: Jede Farbe wird in das Ziel konvertiert (leer: das CMYK-Profil der Ausgabemethode), ohne Profilkennzeichnung. Pen Tool Zeichenstift-Werkzeug + Quick Pen Tool Schnellzeichenstift-Werkzeug + Quick Pen Schnellzeichenstift Pencil Buntstift Pencil Tool Buntstift-Werkzeug per slice pro Slice @@ -5343,6 +5345,9 @@ liquify-list-end {0}, {1} {0} und {1} @msg `link` places a handle: give `handle` `link` platziert einen Griff: geben Sie `handle` an @msg no such spine segment kein solches Achsensegment @msg no such subpath kein solcher Teilpfad +@msg `pieces` must be a list of at most 10000 pieces `pieces` muss eine Liste von höchstens 10000 Stücken sein +@msg give either `start` for a new path or `id`, not both geben Sie entweder `start` für einen neuen Pfad oder `id` an, nicht beides +@msg `subpath` and `keep` need `id` `subpath` und `keep` erfordern `id` @msg no such user library keine solche Benutzerbibliothek @msg no such view keine solche Ansicht @msg no such width point kein solcher Breitenpunkt diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index dc959c57a4..eeb1ffcaee 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -2148,6 +2148,8 @@ font-technology Variable Μεταβλητές Paths Διαδρομές Pattern Μοτίβο Pen Tool Πένα (Pen Tool) + Quick Pen Tool Εργαλείο γρήγορης πένας + Quick Pen Γρήγορη πένα Pencil Μολύβι Pencil Tool Μολύβι (Pencil Tool) Percent: Ποσοστό: @@ -5402,6 +5404,9 @@ digits Malayalam Μαλαγιάλαμ @msg `link` places a handle: give `handle` το `link` τοποθετεί μια λαβή: δώστε `handle` @msg no such spine segment δεν υπάρχει τέτοιο τμήμα κεντρικής καμπύλης @msg no such subpath δεν υπάρχει τέτοια υποδιαδρομή +@msg `pieces` must be a list of at most 10000 pieces το `pieces` πρέπει να είναι λίστα με έως 10000 τμήματα +@msg give either `start` for a new path or `id`, not both δώστε είτε `start` για νέα διαδρομή είτε `id`, όχι και τα δύο +@msg `subpath` and `keep` need `id` τα `subpath` και `keep` απαιτούν `id` @msg no such user library δεν υπάρχει τέτοια βιβλιοθήκη χρήστη @msg no such view δεν υπάρχει τέτοια προβολή @msg no such width point δεν υπάρχει τέτοιο σημείο πλάτους diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 19a10b0112..7b16ec08ad 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2786,6 +2786,8 @@ font-technology Variable Variables PDF/A files carry their own output intent. Los archivos PDF/A incluyen su propio propósito de salida. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Los archivos PDF/X-1a son CMYK: todos los colores se convierten al destino (en blanco: el perfil CMYK del propósito de salida), sin etiquetar. Pen Tool Herramienta Pluma + Quick Pen Tool Herramienta Pluma rápida + Quick Pen Pluma rápida Pencil Lápiz Pencil Tool Herramienta Lápiz per slice por sector @@ -5454,6 +5456,9 @@ liquify-list-end {0}, {1} {0}, {1} @msg `link` places a handle: give `handle` `link` coloca un manejador: indique `handle` @msg no such spine segment no existe ese segmento del eje @msg no such subpath no existe ese subtrazado +@msg `pieces` must be a list of at most 10000 pieces `pieces` debe ser una lista de como máximo 10000 tramos +@msg give either `start` for a new path or `id`, not both indica `start` para un trazado nuevo o `id`, pero no ambos +@msg `subpath` and `keep` need `id` `subpath` y `keep` necesitan `id` @msg no such user library no existe esa biblioteca de usuario @msg no such view no existe esa vista @msg no such width point no existe ese punto de anchura diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index ec55691992..3d66dee459 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -4217,6 +4217,8 @@ theme Appearance Ulkoasu Paste Offset Liittämissiirtymä Pattern Editing Kuvion muokkaus Pen Tool Kynätyökalu + Quick Pen Tool Pikakynätyökalu + Quick Pen Pikakynä Picas Picat Portuguese Portugali Preserve Appearance and Overprints Säilytä ulkoasu ja päällepainatukset @@ -5687,6 +5689,9 @@ liquify-list-end {0}, {1} {0} ja {1} @msg `link` places a handle: give `handle` `link` sijoittaa kahvan: anna `handle` @msg no such spine segment selkärangan segmenttiä ei ole @msg no such subpath alipolkua ei ole +@msg `pieces` must be a list of at most 10000 pieces `pieces`-arvon on oltava luettelo, jossa on enintään 10000 osaa +@msg give either `start` for a new path or `id`, not both anna joko `start` uutta polkua varten tai `id`, ei molempia +@msg `subpath` and `keep` need `id` `subpath` ja `keep` edellyttävät `id`-arvoa @msg no such user library käyttäjäkirjastoa ei ole @msg no such view näkymää ei ole @msg no such width point leveyspistettä ei ole diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 3e851cdc46..dcefda2b66 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2774,6 +2774,8 @@ font-technology Variable Variables PDF/A files carry their own output intent. Les fichiers PDF/A contiennent leur propre mode de sortie. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Les fichiers PDF/X-1a sont en CMJN : chaque couleur est convertie vers la destination (vide : le profil CMJN du mode de sortie), sans balise. Pen Tool Outil Plume + Quick Pen Tool Outil Plume rapide + Quick Pen Plume rapide Pencil Crayon Pencil Tool Outil Crayon per slice par tranche @@ -5413,6 +5415,9 @@ liquify-list-end {0}, {1} {0} et {1} @msg `link` places a handle: give `handle` `link` place une poignée : indiquez `handle` @msg no such spine segment segment de la dorsale inexistant @msg no such subpath sous-tracé inexistant +@msg `pieces` must be a list of at most 10000 pieces `pieces` doit être une liste d’au plus 10000 segments +@msg give either `start` for a new path or `id`, not both indiquez soit `start` pour un nouveau tracé, soit `id`, mais pas les deux +@msg `subpath` and `keep` need `id` `subpath` et `keep` nécessitent `id` @msg no such user library bibliothèque utilisateur inexistante @msg no such view vue inexistante @msg no such width point point de largeur inexistant diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 10adb58853..2c530ce2a4 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -2805,6 +2805,8 @@ Pause For આ સમય માટે થોભાવો Pen પેન Pen Tool પેન ટૂલ + Quick Pen Tool ક્વિક પેન ટૂલ + Quick Pen ક્વિક પેન Pencil પેન્સિલ Pencil Tool પેન્સિલ ટૂલ Percent: ટકા: diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 8129e51fd1..9bc5a5ab3e 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -3990,6 +3990,8 @@ antiAlias Sharp शार्प PDF/X-4:2010 PDF/X-4:2010 Pen पेन Pen Tool पेन टूल + Quick Pen Tool क्विक पेन टूल + Quick Pen क्विक पेन Pencil पेंसिल Pencil Tool पेंसिल टूल Pentagram पेंटाग्राम @@ -8475,6 +8477,9 @@ liquify-list-end {0}, {1} {0} और {1} @msg no such spine point ऐसा कोई स्पाइन बिंदु नहीं @msg no such spine segment ऐसा कोई खंड नहीं @msg no such subpath ऐसा कोई उप-पाथ नहीं +@msg `pieces` must be a list of at most 10000 pieces `pieces` में अधिकतम 10000 टुकड़ों की लिस्ट होनी चाहिए +@msg give either `start` for a new path or `id`, not both नए पाथ के लिए `start` या `id` में से एक दें, दोनों नहीं +@msg `subpath` and `keep` need `id` `subpath` और `keep` के लिए `id` चाहिए @msg no such user library ऐसी कोई उपयोगकर्ता लाइब्रेरी नहीं @msg no such view कोई ऐसा दृश्य नहीं @msg no such width point ऐसी कोई चौड़ाई बिंदु नहीं diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index fd1240f844..765e03b39a 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3318,6 +3318,8 @@ file-filter Templates Sablonok PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. A PDF/X-1a-fájlok CMYK-sok: minden szín a célprofilra alakul (üresen hagyva a kimeneti cél CMYK-profiljára), profilcímke nélkül. Pen Toll Pen Tool Toll + Quick Pen Tool Gyorstoll + Quick Pen Gyorstoll Pencil Ceruza Pencil Tool Ceruza Pentagram Pentagram @@ -6147,6 +6149,9 @@ liquify-list-end {0}, {1} {0} és {1} @msg `link` places a handle: give `handle` `link` fogantyút helyez el: adja meg a `handle` értéket @msg no such spine segment nincs ilyen gerincszakasz @msg no such subpath nincs ilyen részútvonal +@msg `pieces` must be a list of at most 10000 pieces `pieces`: legfeljebb 10000 darabból álló lista kell +@msg give either `start` for a new path or `id`, not both adja meg vagy a `start` értéket egy új útvonalhoz, vagy az `id` értéket, de ne mindkettőt +@msg `subpath` and `keep` need `id` a `subpath` és a `keep` mellé `id` kell @msg no such user library nincs ilyen felhasználói könyvtár @msg no such view nincs ilyen nézet @msg no such width point nincs ilyen szélességi pont diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 05c69c56ff..a2d9e05033 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -4622,6 +4622,8 @@ theme Appearance Tampilan Paste Offset Offset tempel Pattern Editing Pengeditan pola Pen Tool Alat pena + Quick Pen Tool Alat pena cepat + Quick Pen Pena cepat Picas Pica Portuguese Portugis Preserve Appearance and Overprints Pertahankan tampilan dan overprint diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 2ca8cd2e17..ef2aa76baf 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2829,6 +2829,8 @@ file-filter Templates Modelli PDF/A files carry their own output intent. I file PDF/A includono il proprio intento di output. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. I file PDF/X-1a sono CMYK: ogni colore viene convertito nella destinazione (se vuota: il profilo CMYK dell'intento di output), senza tag. Pen Tool Strumento Penna + Quick Pen Tool Strumento Penna rapida + Quick Pen Penna rapida Pencil Matita Pencil Tool Strumento Matita per slice per sezione @@ -5480,6 +5482,9 @@ liquify-list-end {0}, {1} {0} e {1} @msg `link` places a handle: give `handle` `link` posiziona una maniglia: indica `handle` @msg no such spine segment segmento della dorsale inesistente @msg no such subpath sottotracciato inesistente +@msg `pieces` must be a list of at most 10000 pieces `pieces` deve essere un elenco di al massimo 10000 tratti +@msg give either `start` for a new path or `id`, not both indica `start` per un nuovo tracciato oppure `id`, non entrambi +@msg `subpath` and `keep` need `id` `subpath` e `keep` richiedono `id` @msg no such user library libreria utente inesistente @msg no such view vista inesistente @msg no such width point punto di larghezza inesistente diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index e478a8d794..25c8705087 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -2924,6 +2924,8 @@ antiAlias Sharp シャープ Pattern Editing パターン編集 Pattern options are available in pattern editing mode. パターンオプションはパターン編集モードで使用できます。 Pen Tool ペンツール + Quick Pen Tool クイックペンツール + Quick Pen クイックペン Pencil 鉛筆 Pencil Tool 鉛筆ツール Percent: パーセント: @@ -5024,6 +5026,9 @@ variable-list-end {0}, {1} {0}、{1} @msg `link` places a handle: give `handle` `link` はハンドルを配置します:`handle` を指定してください @msg no such spine segment 指定されたスパインセグメントが見つかりません @msg no such subpath 指定されたサブパスが見つかりません +@msg `pieces` must be a list of at most 10000 pieces `pieces` には最大 10000 個のピースのリストを指定してください +@msg give either `start` for a new path or `id`, not both 新しいパスの `start` か `id` のどちらか一方だけを指定してください +@msg `subpath` and `keep` need `id` `subpath` と `keep` には `id` が必要です @msg object {id} is not a path オブジェクト {id} はパスではありません @msg object {id} is not a selected top-level object オブジェクト {id} は選択されている最上位のオブジェクトではありません @msg nothing to redo やり直す操作がありません diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 782bf20baf..722d7a5d8c 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -6038,6 +6038,8 @@ theme Appearance იერსახე Paste Offset ჩასმის წანაცვლება Pattern Editing პატერნის რედაქტირება Pen Tool კალმის ხელსაწყო + Quick Pen Tool სწრაფი კალმის ხელსაწყო + Quick Pen სწრაფი კალამი Picas პიკები Portuguese პორტუგალიური Preserve Appearance and Overprints იერსახისა და ზედდაბეჭდვების შენარჩუნება @@ -7214,6 +7216,9 @@ font-technology Variable ცვლადი @msg no such saved selection ასეთი შენახული მონიშვნა არ არის @msg no such segment ასეთი სეგმენტი არ არის @msg no such subpath ასეთი ქვეტრაექტორია არ არის +@msg `pieces` must be a list of at most 10000 pieces `pieces` უნდა იყოს არაუმეტეს 10000 ნაწილის სია +@msg give either `start` for a new path or `id`, not both მიუთითეთ ან `start` ახალი ტრაექტორიისთვის, ან `id`, მაგრამ არა ორივე +@msg `subpath` and `keep` need `id` `subpath`-სა და `keep`-ს სჭირდება `id` @msg no such user library მომხმარებლის ასეთი ბიბლიოთეკა არ არის @msg no such view ასეთი ხედი არ არის @msg no such width point ასეთი სიგანის წერტილი არ არის diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 3945aa9ca5..7e08bc7ebc 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -2914,6 +2914,8 @@ antiAlias Sharp 날카롭게 Pattern Editing 패턴 편집 Pattern options are available in pattern editing mode. 패턴 옵션은 패턴 편집 모드에서 사용할 수 있습니다. Pen Tool 펜 도구 + Quick Pen Tool 빠른 펜 도구 + Quick Pen 빠른 펜 Pencil 연필 Pencil Tool 연필 도구 Percent: 퍼센트: @@ -4953,6 +4955,9 @@ variable-list-end {0}, {1} {0} 및 {1} @msg `link` places a handle: give `handle` `link`는 핸들을 배치합니다. `handle`을 지정하십시오 @msg no such spine segment 해당 스파인 세그먼트가 없습니다 @msg no such subpath 해당 하위 패스가 없습니다 +@msg `pieces` must be a list of at most 10000 pieces `pieces`는 최대 10000개 조각의 목록이어야 합니다 +@msg give either `start` for a new path or `id`, not both 새 패스의 `start`와 `id` 중 하나만 지정하세요 +@msg `subpath` and `keep` need `id` `subpath`와 `keep`에는 `id`가 필요합니다 @msg object {id} is not a path 개체 {id}은(는) 패스가 아닙니다 @msg object {id} is not a selected top-level object 개체 {id}은(는) 선택된 최상위 개체가 아닙니다 @msg nothing to redo 다시 실행할 항목이 없습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index eef2d12d46..07cf5ead64 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -4625,6 +4625,8 @@ theme Appearance Vormgeving Paste Offset Plakoffset Pattern Editing Patroonbewerking Pen Tool Pen-gereedschap + Quick Pen Tool Snelpen-gereedschap + Quick Pen Snelpen Picas Pica's Portuguese Portugees Preserve Appearance and Overprints Vormgeving en overprint behouden @@ -5825,6 +5827,9 @@ imageTrace Outline Contour @msg no such saved selection opgeslagen selectie bestaat niet @msg no such segment segment bestaat niet @msg no such subpath subpad bestaat niet +@msg `pieces` must be a list of at most 10000 pieces `pieces` moet een lijst van hoogstens 10000 stukken zijn +@msg give either `start` for a new path or `id`, not both geef `start` voor een nieuw pad of `id`, niet beide +@msg `subpath` and `keep` need `id` `subpath` en `keep` vereisen `id` @msg no such user library gebruikersbibliotheek bestaat niet @msg no such view weergave bestaat niet @msg no such width point breedtepunt bestaat niet diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 51ce1fd236..6491832fbb 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -4165,6 +4165,8 @@ theme Appearance Wygląd Paste Offset Przesunięcie wklejania Pattern Editing Edycja wzorka Pen Tool Narzędzie Pióro + Quick Pen Tool Narzędzie Szybkie pióro + Quick Pen Szybkie pióro Picas Pica Portuguese Portugalski Preserve Appearance and Overprints Zachowaj wygląd i nadruki @@ -5583,6 +5585,9 @@ liquify-list-end {0}, {1} {0} i {1} @msg `link` places a handle: give `handle` `link` umieszcza uchwyt: podaj `handle` @msg no such spine segment brak takiego segmentu grzbietu @msg no such subpath brak takiej ścieżki podrzędnej +@msg `pieces` must be a list of at most 10000 pieces `pieces` musi być listą co najwyżej 10000 fragmentów +@msg give either `start` for a new path or `id`, not both podaj `start` dla nowej ścieżki albo `id`, ale nie oba +@msg `subpath` and `keep` need `id` `subpath` i `keep` wymagają `id` @msg no such user library brak takiej biblioteki użytkownika @msg no such view brak takiego widoku @msg no such width point brak takiego punktu szerokości diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 585dec43d3..bf8e65b7d0 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2297,6 +2297,8 @@ antiAlias Sharp Nítido Pattern Options Opções de Padrão Pattern options are available in pattern editing mode. As opções de padrão estão disponíveis no modo de edição de padrão. Pen Tool Ferramenta Caneta + Quick Pen Tool Ferramenta Caneta rápida + Quick Pen Caneta rápida Pencil Lápis Pencil Tool Ferramenta Lápis Percent: Porcentagem: @@ -4728,6 +4730,9 @@ axis Both Ambos @msg `link` places a handle: give `handle` `link` posiciona uma alça: informe `handle` @msg no such spine segment segmento da coluna inexistente @msg no such subpath subtraçado inexistente +@msg `pieces` must be a list of at most 10000 pieces `pieces` deve ser uma lista de no máximo 10000 trechos +@msg give either `start` for a new path or `id`, not both informe `start` para um novo caminho ou `id`, mas não ambos +@msg `subpath` and `keep` need `id` `subpath` e `keep` exigem `id` @msg no such user library biblioteca do usuário inexistente @msg no such view vista inexistente @msg no such width point ponto de largura inexistente diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index b493b6d2ad..073585f665 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2811,6 +2811,8 @@ file-filter Templates Шаблоны PDF/A files carry their own output intent. Файлы PDF/A содержат собственное назначение вывода. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Файлы PDF/X-1a используют CMYK: каждый цвет преобразуется в целевой (пусто: профиль CMYK назначения вывода) без пометки. Pen Tool Инструмент «Перо» + Quick Pen Tool Инструмент «Быстрое перо» + Quick Pen Быстрое перо Pencil Карандаш Pencil Tool Инструмент «Карандаш» per slice на фрагмент @@ -5475,6 +5477,9 @@ liquify-list-end {0}, {1} {0} и {1} @msg `link` places a handle: give `handle` `link` размещает маркер: укажите `handle` @msg no such spine segment такого сегмента остова нет @msg no such subpath такого вложенного контура нет +@msg `pieces` must be a list of at most 10000 pieces `pieces` должен быть списком не более чем из 10000 фрагментов +@msg give either `start` for a new path or `id`, not both укажите либо `start` для нового контура, либо `id`, но не оба +@msg `subpath` and `keep` need `id` для `subpath` и `keep` нужен `id` @msg no such user library такой пользовательской библиотеки нет @msg no such view такого вида нет @msg no such width point такой точки ширины нет diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index bd06adf686..40ae8d1ab9 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -2706,6 +2706,8 @@ font-technology Variable Variabla PDF/A files carry their own output intent. PDF/A-filer har sin egen utgångsavsikt. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a-filer är CMYK: alla färger konverteras till målet (tomt: utgångsavsiktens CMYK-profil), otaggade. Pen Tool Pennverktyg + Quick Pen Tool Snabbpennverktyg + Quick Pen Snabbpenna Pencil Blyertspenna Pencil Tool Blyertsverktyg per slice per skiva @@ -5340,6 +5342,9 @@ liquify-list-end {0}, {1} {0} och {1} @msg `link` places a handle: give `handle` `link` placerar ett handtag: ange `handle` @msg no such spine segment ryggradssegmentet finns inte @msg no such subpath delbanan finns inte +@msg `pieces` must be a list of at most 10000 pieces `pieces` måste vara en lista med högst 10000 delar +@msg give either `start` for a new path or `id`, not both ange antingen `start` för en ny bana eller `id`, inte båda +@msg `subpath` and `keep` need `id` `subpath` och `keep` kräver `id` @msg no such user library användarbiblioteket finns inte @msg no such view vyn finns inte @msg no such width point breddpunkten finns inte diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 9e20acf6f6..e57ae9b758 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2555,6 +2555,8 @@ shape Open Açık PDF/A files carry their own output intent. PDF/A dosyaları kendi çıktı amaçlarını taşır. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a dosyaları CMYK'dir: her renk hedefe dönüştürülür (boş: çıktı hedefinin CMYK profili), etiketsiz. Pen Tool Kalem Aracı + Quick Pen Tool Hızlı Kalem Aracı + Quick Pen Hızlı Kalem Pencil Kalem Pencil Tool Kurşun Kalem Aracı per slice dilim başına @@ -5157,6 +5159,9 @@ liquify-list-end {0}, {1} {0} ve {1} @msg no such saved selection böyle kayıtlı bir seçim yok @msg no such segment öyle bir bölüm yok @msg no such subpath böyle bir alt yol yok +@msg `pieces` must be a list of at most 10000 pieces `pieces` en fazla 10000 parçadan oluşan bir liste olmalıdır +@msg give either `start` for a new path or `id`, not both yeni bir yol için `start` ya da `id` verin, ikisini birden değil +@msg `subpath` and `keep` need `id` `subpath` ve `keep` için `id` gerekir @msg no such user library böyle bir kullanıcı kütüphanesi yok @msg no such view öyle bir görüş yok @msg no such width point böyle bir genişlik noktası yok diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 81681f735f..bb919586d7 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2821,6 +2821,8 @@ file-filter Templates Шаблони PDF/A files carry their own output intent. Файли PDF/A містять власне призначення. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Файли PDF/X-1a використовують CMYK: кожен колір перетворюється на цільовий (порожньо: профіль CMYK призначення виведення) без позначки. Pen Tool Інструмент «Перо» + Quick Pen Tool Інструмент «Швидке перо» + Quick Pen Швидке перо Pencil Олівець Pencil Tool Інструмент «Олівець» per slice на фрагмент @@ -5464,6 +5466,9 @@ liquify-list-end {0}, {1} {0} і {1} @msg `link` places a handle: give `handle` `link` розміщує маркер: укажіть `handle` @msg no such spine segment такого сегмента осі немає @msg no such subpath такого вкладеного контуру немає +@msg `pieces` must be a list of at most 10000 pieces `pieces` має бути списком щонайбільше з 10000 фрагментів +@msg give either `start` for a new path or `id`, not both вкажіть або `start` для нового контуру, або `id`, але не обидва +@msg `subpath` and `keep` need `id` для `subpath` і `keep` потрібен `id` @msg no such user library такої користувацької бібліотеки немає @msg no such view такого виду немає @msg no such width point такої точки ширини немає diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index f099a0eb4c..521bcd299a 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3140,6 +3140,8 @@ digits Hindi Hindi PDF/A files carry their own output intent. Tệp PDF/A tích hợp mục đích đầu ra của riêng chúng. PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Tệp PDF/X-1a là CMYK: mọi màu được chuyển đổi sang đích (trống: hồ sơ CMYK của mục đích đầu ra), không gắn thẻ. Pen Tool Công cụ Bút + Quick Pen Tool Công cụ Bút nhanh + Quick Pen Bút nhanh Pencil Bút chì Pencil Tool Công cụ Bút chì per slice mỗi lát cắt @@ -5846,6 +5848,9 @@ liquify-list-end {0}, {1} {0} và {1} @msg `link` places a handle: give `handle` `link` đặt một tay nắm: hãy cho `handle` @msg no such spine segment không có đoạn trục như vậy @msg no such subpath không có nhánh con như vậy +@msg `pieces` must be a list of at most 10000 pieces `pieces` phải là danh sách tối đa 10000 đoạn +@msg give either `start` for a new path or `id`, not both hãy đưa `start` cho đường dẫn mới hoặc `id`, không đưa cả hai +@msg `subpath` and `keep` need `id` `subpath` và `keep` cần có `id` @msg no such user library không có thư viện người dùng như vậy @msg no such view không có chế độ xem như vậy @msg no such width point không có điểm chiều rộng như vậy diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index f4201e2cc2..2a666f94d3 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2673,6 +2673,8 @@ file-filter Templates 模板 PDF/A files carry their own output intent. PDF/A 文件自带输出意图。 PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a 文件为 CMYK:所有颜色都会转换至目的地 (留空:输出意图的 CMYK 配置文件),且不加标记。 Pen Tool 钢笔工具 + Quick Pen Tool 快速钢笔工具 + Quick Pen 快速钢笔 Pencil 铅笔 Pencil Tool 铅笔工具 per slice 每个切片 @@ -4713,6 +4715,9 @@ imageTrace Outline 轮廓 @msg no such anchor 没有此锚点 @msg no such segment 没有此线段 @msg no such subpath 没有此子路径 +@msg `pieces` must be a list of at most 10000 pieces `pieces` 必须是最多 10000 个片段的列表 +@msg give either `start` for a new path or `id`, not both 请为新路径指定 `start`,或指定 `id`,不能同时指定 +@msg `subpath` and `keep` need `id` `subpath` 和 `keep` 需要 `id` @msg object {id} is not a path 对象 {id} 不是路径 @msg object {id} is not a selected top-level object 对象 {id} 不是选中的顶层对象 @msg nothing to redo 没有可重做的操作 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 0f28d04628..7fd607b937 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2100,6 +2100,9 @@ file-filter Templates 範本 @msg no such anchor 沒有這個錨點 @msg no such segment 沒有這個線段 @msg no such subpath 沒有這個子路徑 +@msg `pieces` must be a list of at most 10000 pieces `pieces` 必須是最多 10000 個片段的清單 +@msg give either `start` for a new path or `id`, not both 請為新路徑指定 `start`,或指定 `id`,不可同時指定 +@msg `subpath` and `keep` need `id` `subpath` 與 `keep` 需要 `id` @msg object {id} is not a path 物件 {id} 不是路徑 @msg object {id} is not a selected top-level object 物件 {id} 不是已選取的最上層物件 @msg nothing to redo 沒有可重做的動作 @@ -4101,6 +4104,8 @@ liquify-list-end {0}, {1} {0}和{1} PDF/A files carry their own output intent. PDF/A 檔案自帶輸出目的。 PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a 檔案為 CMYK:所有顏色都會轉換至目的地 (留空:輸出目的的 CMYK 描述檔),且不加標記。 Pen Tool 筆型工具 + Quick Pen Tool 快速筆型工具 + Quick Pen 快速筆型 Pencil 鉛筆 Pencil Tool 鉛筆工具 per slice 每個切片 diff --git a/crates/ui-egui/src/icon_data.rs b/crates/ui-egui/src/icon_data.rs index 61a2e87a37..575ab04ea6 100644 --- a/crates/ui-egui/src/icon_data.rs +++ b/crates/ui-egui/src/icon_data.rs @@ -151,6 +151,7 @@ pub static ICONS: &[(&str, &[u8])] = &[ ("dc-polygon", include_bytes!("../../../assets/icons/dc-polygon.svg")), ("dc-pucker", include_bytes!("../../../assets/icons/dc-pucker.svg")), ("dc-puppet", include_bytes!("../../../assets/icons/dc-puppet.svg")), + ("dc-quick-pen", include_bytes!("../../../assets/icons/dc-quick-pen.svg")), ("dc-rearrange", include_bytes!("../../../assets/icons/dc-rearrange.svg")), ("dc-rect-cut", include_bytes!("../../../assets/icons/dc-rect-cut.svg")), ("dc-rect-grid", include_bytes!("../../../assets/icons/dc-rect-grid.svg")), diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index eb4aac540e..11ea305b2b 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -28,6 +28,7 @@ pub fn tool_icon(name: &str) -> &'static str { "tool-pen-add" => "pen-tool-add", "tool-pen-delete" => "pen-tool-delete", "tool-anchor" => "dc-anchor", + "tool-quick-pen" => "dc-quick-pen", "tool-curvature" => "spline", "tool-type" => "dc-type", "tool-type-area" => "dc-type-area", diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index dd7bc40c4a..a50527cede 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -395,6 +395,8 @@ pub struct VectorcraftApp { /// The single-key tool shortcuts held down, the last held last, and the tool each goes back to /// when it is let go ([`shortcuts::HeldTool`]). pub(crate) held_tool: Vec, + /// Alt held down on its own since a frame saw it go down ([`shortcuts::AltTap`]). + pub(crate) alt_tap: shortcuts::AltTap, /// A key with a hold shortcut that waits for its release, and the keys whose repeats are held /// back until they are let go ([`shortcuts::HoldKeys`]). pub(crate) hold_keys: shortcuts::HoldKeys, diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index da9c0938c0..f45a02e75e 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -802,9 +802,9 @@ fn listed(overrides: &Overrides, e: &Entry) -> bool { /// Options, Character, Set Bounds), the exports and saves that give the file back without a `path` /// (Save Document gives the file back when the document has no file yet; File › Save takes a key /// instead), the undo group's begin and end, and the commands that need a point, a value or a name -/// (Create Dimension, Edit Freeform Point, Select by Color, Move Brush, Paintbrush, Map Art). New Symbol is left out -/// because the Symbols panel runs it through the Symbol Options dialog. -const NEEDS_A_PARAM: [&str; 76] = [ +/// (Create Dimension, Edit Freeform Point, Select by Color, Move Brush, Paintbrush, Map Art, Quick Pen). New +/// Symbol is left out because the Symbols panel runs it through the Symbol Options dialog. +const NEEDS_A_PARAM: [&str; 77] = [ "transparency.set", "transparency.setOpacityMask", "stroke.set", @@ -867,6 +867,7 @@ const NEEDS_A_PARAM: [&str; 76] = [ "paint.setFill", "paint.setGradientGeom", "paint.setStroke", + "path.quickPen", "perspective.grid.define", "perspective.grid.set", "perspective.plane.move", diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index f31ed21b5c..d4cde5a873 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -11,6 +11,7 @@ use vectorcraft_tools::{Mods, SurroundingUnit, ToolKey}; use crate::VectorcraftApp; +mod alt_tap; mod held_tool; mod hold_keys; mod labels; @@ -18,6 +19,7 @@ mod paste; mod presentation; mod typing; +pub(crate) use alt_tap::AltTap; pub(crate) use held_tool::{HeldTool, note_tool_use}; pub(crate) use hold_keys::HoldKeys; #[cfg(test)] @@ -215,6 +217,7 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) { hold_keys::guard(app, ctx, focused); // A held tool shortcut that is let go returns to the tool active before it. held_tool::follow(app, ctx, focused); + let alt_tapped = alt_tap::follow(&mut app.alt_tap, ctx, focused); if !focused { crate::ime::controls_without_editor(app, ctx); return; @@ -375,6 +378,11 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) { } crate::ime::controls_without_editor(app, ctx); let to_labels = handle_clipboard(app, ctx, textless_paste); + // Alt tapped on its own: the Quick Pen tool's next action. + if alt_tapped && app.session.tool_claims_key(ToolKey::AltTap, view) { + let r = app.session.tool_key(ToolKey::AltTap, Mods::default(), view); + crate::canvas::apply_requests(app, r); + } if busy { busy_tool_keys(app, ctx, view); return; diff --git a/crates/ui-egui/src/shortcuts/alt_tap.rs b/crates/ui-egui/src/shortcuts/alt_tap.rs new file mode 100644 index 0000000000..b92d6c3800 --- /dev/null +++ b/crates/ui-egui/src/shortcuts/alt_tap.rs @@ -0,0 +1,114 @@ +//! Alt (Option on macOS) pressed and let go with no other key, click or wheel turn in between: the +//! active tool gets [`ToolKey::AltTap`](vectorcraft_tools::ToolKey::AltTap) when it claims it (the +//! Quick Pen tool switches to its next action). + +/// Alt held down since it went down, and whether anything else happened since. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub(crate) struct AltTap { + down: bool, + spoiled: bool, +} + +impl AltTap { + /// The modifiers changed: `alt` is whether Alt is held, `alone` whether it is held without + /// Shift, Ctrl or Cmd. True when Alt was let go after a press with nothing else in between. + pub(crate) fn modifiers(&mut self, alt: bool, alone: bool) -> bool { + match (self.down, alt) { + (false, true) => { + (self.down, self.spoiled) = (true, !alone); + false + } + (true, true) => { + self.spoiled |= !alone; + false + } + (true, false) => { + let tap = !self.spoiled; + *self = Self::default(); + tap + } + (false, false) => false, + } + } + + /// A key press, a click or a wheel turn: Alt held now is no tap. + pub(crate) fn other(&mut self) { + self.spoiled = true; + } +} + +fn alt_alone(m: egui::Modifiers) -> (bool, bool) { + (m.alt, !(m.shift || m.ctrl || m.command || m.mac_cmd)) +} + +/// Follows the frame's events in order, then its modifiers at its end; true when Alt was tapped, +/// also when it went down and up within the frame. A frame without the keyboard focus drops a +/// press under way. +pub(super) fn follow(tap: &mut AltTap, ctx: &egui::Context, focused: bool) -> bool { + if !focused { + *tap = AltTap::default(); + return false; + } + ctx.input(|i| { + let mut tapped = false; + for e in &i.events { + match e { + egui::Event::ModifiersChanged(m) => { + let (alt, alone) = alt_alone(*m); + tapped |= tap.modifiers(alt, alone); + } + egui::Event::Key { pressed: true, .. } + | egui::Event::PointerButton { .. } + | egui::Event::MouseWheel { .. } + | egui::Event::Touch { .. } => tap.other(), + _ => {} + } + } + let (alt, alone) = alt_alone(i.modifiers); + tapped | tap.modifiers(alt, alone) + }) +} + +#[cfg(test)] +mod tests { + use super::{AltTap, follow}; + + #[test] + fn a_press_and_release_alone_is_a_tap() { + let mut t = AltTap::default(); + assert!(!t.modifiers(true, true)); + assert!(!t.modifiers(true, true)); + assert!(t.modifiers(false, true)); + assert!(!t.modifiers(false, true), "once"); + } + + #[test] + fn anything_else_while_alt_is_down_is_no_tap() { + // A key (Alt+P), a click or a wheel turn while held. + let mut t = AltTap::default(); + t.modifiers(true, true); + t.other(); + assert!(!t.modifiers(false, true)); + // With Shift held too. + t.modifiers(true, false); + assert!(!t.modifiers(false, true)); + // Something before Alt went down does not count, and the next press starts afresh. + t.other(); + t.modifiers(true, true); + assert!(t.modifiers(false, true)); + } + + /// Alt down and up between two frames: both changes come in one frame's events, whose + /// modifiers at its end hold no Alt. + #[test] + fn a_tap_within_one_frame_counts() { + let ctx = egui::Context::default(); + let mut t = AltTap::default(); + let mut tapped = false; + let events = vec![egui::Event::ModifiersChanged(egui::Modifiers::ALT), egui::Event::ModifiersChanged(egui::Modifiers::NONE)]; + let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| tapped = follow(&mut t, ui.ctx(), true)); + out.textures_delta.clear(); + assert!(tapped); + assert_eq!(t, AltTap::default()); + } +} diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index 336af45e3d..ffb5b893c8 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -380,6 +380,39 @@ fn alt_chords_outside_text_editing_type_nothing() { } } +/// Alt+P (Option+P on macOS, which types π) chooses the Quick Pen tool, and is no Alt tap. Alt +/// then pressed and let go on its own switches the tool to its next action; Alt let go after a +/// click does not. +#[test] +fn alt_p_chooses_the_quick_pen_and_an_alt_tap_switches_its_action() { + // One headless frame with `modifiers` held at its end. + fn held(app: &mut VectorcraftApp, modifiers: Modifiers, mut events: Vec) { + events.insert(0, egui::Event::ModifiersChanged(modifiers)); + let ctx = egui::Context::default(); + let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| { + app.logic(ui.ctx()); + handle(app, ui.ctx()); + }); + out.textures_delta.clear(); + } + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + crate::shortcut_editor::sync(&app.ui); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + held(&mut app, Modifiers::ALT, alt_press(Key::P, false, Some("\u{3c0}"))); + assert_eq!(app.session.tool_id(), vectorcraft_tools::quickpen::ID); + held(&mut app, Modifiers::NONE, vec![]); + assert_eq!(app.session.tool_options()["action"], "line", "Alt+P is no tap"); + held(&mut app, Modifiers::ALT, vec![]); + held(&mut app, Modifiers::NONE, vec![]); + assert_eq!(app.session.tool_options()["action"], "continuousArc"); + held(&mut app, Modifiers::ALT, vec![]); + let click = + egui::Event::PointerButton { pos: egui::pos2(5.0, 5.0), button: egui::PointerButton::Primary, pressed: true, modifiers: Modifiers::ALT }; + held(&mut app, Modifiers::ALT, vec![click]); + held(&mut app, Modifiers::NONE, vec![]); + assert_eq!(app.session.tool_options()["action"], "continuousArc", "a click in between"); +} + /// Cmd as egui reports it on this platform: the Command key on macOS, Ctrl elsewhere. fn cmd() -> Modifiers { if crate::keymap::platform().is_mac() { Modifiers::MAC_CMD | Modifiers::COMMAND } else { Modifiers::CTRL | Modifiers::COMMAND } diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 6b47771325..0924ab152d 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -49,7 +49,7 @@ pub const BASIC: &[(&str, &[&[&str]])] = &[ &["pencil", "smooth", "pathEraser", "join"], &["eraser", "scissors", "knife", "trimAtCrossings", "mirrorCut", "lineCut", "rectCut"], &["paintbrush", "blobBrush"], - &["pen", "addAnchor", "deleteAnchor", "anchorPoint"], + &["pen", "addAnchor", "deleteAnchor", "anchorPoint", "quickPen"], &["curvature"], ], ), diff --git a/docs/mcp.md b/docs/mcp.md index 79f6183e79..75e21cb2ca 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6982,6 +6982,48 @@ toggles a point with `path.convertAnchor`; an Alt-click on an end of an open sub {"name":"run_command","arguments":{"command":"path.curvatureEdit","params":{"id":12,"op":"extend","x":650,"y":60,"from":"smooth"}}} ``` +## Drawing with the Quick Pen tool + +The Quick Pen tool (`quickPen`, in the Pen tool's group, Alt+P or Option+P on macOS) draws paths of straight lines and +circular arcs ([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), +[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)). +A click sets the start point. Each click after it, or a press dragged to where it is let go, adds a piece from the +path's last point, drawn with the tool's `action` option: + +- `"line"` (the default): a straight line. +- `"continuousArc"`: an arc that leaves the last point in the direction the path arrives there, so the two join + smoothly. The first piece of a path has no direction and is drawn as a sharp-corner arc; an end straight ahead of or + straight behind the last point gives a line. +- `"sharpArc"`: an arc that turns through the tool's `turn` option (degrees, 1 to 359, 180 by default: a half circle) + and bulges to the left of the direction drawn, meeting the path before it at a corner. + +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. 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}`). + +`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 +has neither fill nor stroke). With `id`, it draws on the open subpath `subpath` (0 when left out) of that path: its +first `keep` points stay (all of them when left out) and the pieces follow. Each piece is +`{x, y, action?, turn?, flip?}`: it ends at `x`, `y`, `action` is `"line"` when left out, `turn` is 180 when left out, +and `flip` puts a sharp-corner arc on the right of the direction drawn. A piece that ends where the path does adds +nothing. With `closed: true`, a last piece that ends on the first point joins it; otherwise a straight segment closes +the path. The command returns an error and changes nothing when both or neither of `start` and `id` are given +(`` give either `start` for a new path or `id`, not both ``), when `subpath` or `keep` comes without `id`, when +`pieces` is not a list of at most 10000 pieces, when a point's x or y is not a number or is 1e9 or more in size, for +an unknown `action`, a `turn` outside 1 to 359, a `flip` or `closed` that is not true or false, a `keep` outside 1 to +the subpath's points, and for a closed subpath, a locked or hidden path or an `id` that is not a path. + +```json +{"name":"run_command","arguments":{"command":"path.quickPen","params":{"start":[100,100],"pieces":[{"x":200,"y":100},{"x":300,"y":200,"action":"continuousArc"},{"x":300,"y":300,"action":"sharpArc","turn":90,"flip":true}]}}} +{"name":"run_command","arguments":{"command":"tool.setOption","params":{"tool":"quickPen","key":"action","value":"sharpArc"}}} +``` + ## Registration and trim marks Every document has the built-in `[Registration]` swatch (listed after None by `swatch.list`): a colour that prints on diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 83bcd03586..c06bf3f8e2 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -628,6 +628,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; 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 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` and `alt_p_chooses_the_quick_pen_and_an_alt_tap_switches_its_action`. 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. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index ddbc8a3ad2..5b80cd9eee 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -201,6 +201,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 ([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). Not yet: the on-canvas toolbar with its More menu, dragging a path's ends to change a line's or arc's length, Ctrl+scroll for the arc size, and editing and deleting with the tool | | 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` |