mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 09:28:09 +00:00
Merge pull request #8735 from storytold/train/carry8585
Direct Selection: Cmd/Ctrl added during a handle drag mirrors the opposite handle (#8585)
This commit is contained in:
@@ -451,12 +451,25 @@ impl TextObject {
|
||||
/// fractions of the path. False, changing nothing, for other type, when the anchor doesn't
|
||||
/// exist, a degenerate `xf` or a path that would not be finite.
|
||||
pub fn set_path_handle(&mut self, (si, ai): (usize, usize), out: bool, pos: Point, independent: bool) -> bool {
|
||||
self.set_path_handle_with_symmetry((si, ai), out, pos, independent, false)
|
||||
}
|
||||
/// [`Self::set_path_handle`] with an optional mirror of the opposite handle about the anchor
|
||||
/// in document space, preserving the anchor kind. `independent` takes precedence, and at an
|
||||
/// open end of the path, where no segment leaves the anchor on that side, the handle moves as
|
||||
/// it would without `symmetric`. Both handles are edited in one reshape, using the same validated
|
||||
/// document-to-text map.
|
||||
pub fn set_path_handle_with_symmetry(&mut self, (si, ai): (usize, usize), out: bool, pos: Point, independent: bool, symmetric: bool) -> bool {
|
||||
let xf = self.xf;
|
||||
matches!(self.kind, TextKind::OnPath { .. })
|
||||
&& self.reshape_local(|path, to_text| {
|
||||
let mirror = symmetric && !independent && path.subpaths.get(si).is_some_and(|sp| sp.has_segment(ai, !out));
|
||||
let Some(a) = path.anchor_mut(si, ai) else { return false };
|
||||
let mut drawn = a.transform(xf);
|
||||
drawn.set_handle(out, pos, independent);
|
||||
if mirror {
|
||||
let opposite = drawn.p - (pos - drawn.p);
|
||||
if out { drawn.h_in = opposite } else { drawn.h_out = opposite }
|
||||
}
|
||||
*a = drawn.transform(to_text);
|
||||
true
|
||||
})
|
||||
|
||||
@@ -244,12 +244,22 @@ pub(super) fn spine_move_anchor(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some(_) => return Err(bad(C, "handle must be in or out")),
|
||||
};
|
||||
let independent = switch_or(p, "independent", false, C)?;
|
||||
let symmetric = switch_or(p, "symmetric", false, C)?;
|
||||
let link = switch_or(p, "link", false, C)?;
|
||||
let with = spine_points_param(p, C)?;
|
||||
// Any `with`, even an empty list, asks to move points, which a handle drag doesn't.
|
||||
if handle.is_some() && p.get("with").is_some_and(|v| !v.is_null()) {
|
||||
return Err(bad(C, "`with` moves points, not a handle"));
|
||||
}
|
||||
if symmetric && independent {
|
||||
return Err(bad(C, "`independent` and `symmetric` cannot both be true"));
|
||||
}
|
||||
if symmetric && handle.is_none() {
|
||||
return Err(bad(C, "`symmetric` places a handle: give `handle`"));
|
||||
}
|
||||
if link && symmetric {
|
||||
return Err(bad(C, "`link` and `symmetric` cannot both be true"));
|
||||
}
|
||||
if link && independent {
|
||||
return Err(bad(C, "`link` and `independent` cannot both be true"));
|
||||
}
|
||||
@@ -264,6 +274,8 @@ pub(super) fn spine_move_anchor(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
edit_spine(s, p, C, "Reshape Spine", |sp, anchors, keys| {
|
||||
let pull_out = handle.is_some_and(|out| sp.has_segment(index, !out));
|
||||
// At an open end of the spine the handle moves as it would without `symmetric`.
|
||||
let symmetric = symmetric && pull_out;
|
||||
let a = sp.anchors.get_mut(index).ok_or_else(|| bad(C, "no such spine point"))?;
|
||||
if let Some(out) = handle {
|
||||
if link {
|
||||
@@ -271,6 +283,10 @@ pub(super) fn spine_move_anchor(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
} else {
|
||||
a.set_handle(out, q, independent);
|
||||
}
|
||||
if symmetric {
|
||||
let opposite = a.p - (q - a.p);
|
||||
if out { a.h_in = opposite } else { a.h_out = opposite }
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let delta = q - a.p;
|
||||
|
||||
@@ -99,7 +99,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Move Spine Point",
|
||||
[],
|
||||
None,
|
||||
"{id? (default: the selected blend), anchor: index, x, y, with?: [index…], handle?: in|out, independent?: bool, link?: bool} move a point of the blend's spine (its handles along), and the points `with` names by as much, or with `handle` place that handle's end at (x, y) (a smooth point keeps the other handle in line unless `independent`; `link` makes the point smooth with the other handle in line at its own length, a retracted one pulled out to the moved handle's length where a segment leaves the point on its side; `link` needs `handle` and cannot go with `independent`). A key object sitting on a moved point moves with it. The first edit turns the straight spine into a path",
|
||||
"{id? (default: the selected blend), anchor: index, x, y, with?: [index…], handle?: in|out, independent?: bool, symmetric?: bool, link?: bool} move a point of the blend's spine (its handles along), and the points `with` names by as much, or with `handle` place that handle's end at (x, y) (a smooth point keeps the other handle in line unless `independent`; `symmetric` mirrors the opposite handle about the anchor without changing its kind, except at an open end of the spine; `link` makes the point smooth with the other handle in line at its own length, a retracted one pulled out to the moved handle's length where a segment leaves the point on its side; `symmetric` and `link` need `handle`, `symmetric` cannot go with `independent`, and `link` cannot go with `independent` or `symmetric`; all default false). A key object sitting on a moved point moves with it. The first edit turns the straight spine into a path",
|
||||
has_doc,
|
||||
spine_move_anchor
|
||||
),
|
||||
|
||||
@@ -50,7 +50,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Move Direction Handle",
|
||||
[],
|
||||
None,
|
||||
"{id, subpath?, anchor, which: \"in\"|\"out\", x, y, independent?: bool, link?: bool, at?: [x,y]} move a direction handle; independent moves only that side and makes the anchor a corner; link makes the anchor smooth with the other handle in line at its own length (a retracted one is pulled out to the moved handle's length where a segment leaves the anchor on its side); link and independent cannot both be true; both default false; with link false, at moves the anchor and both handles before placing the chosen handle",
|
||||
"{id, subpath?, anchor, which: \"in\"|\"out\", x, y, independent?: bool, symmetric?: bool, link?: bool, at?: [x,y]} move a direction handle; independent moves only that side and makes the anchor a corner; symmetric mirrors the other handle about the anchor without changing its kind (not at an open end, where no segment leaves the anchor on that side); link makes the anchor smooth with the other handle in line at its own length (a retracted one is pulled out to the moved handle's length where a segment leaves the anchor on its side); independent and symmetric cannot both be true, and link cannot go with either; all default false; with link false, at moves the anchor and both handles before placing the chosen handle",
|
||||
has_doc,
|
||||
set_handle
|
||||
),
|
||||
@@ -461,6 +461,13 @@ fn set_handle(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return link_handle(s, p, id, si, ai, out, pos);
|
||||
}
|
||||
let independent = switch_or(p, "independent", false, "path.setHandle")?;
|
||||
let symmetric = switch_or(p, "symmetric", false, "path.setHandle")?;
|
||||
if symmetric && independent {
|
||||
return Err(bad("path.setHandle", "`independent` and `symmetric` cannot both be true"));
|
||||
}
|
||||
// The other handle is mirrored only where a segment leaves the anchor on its side: at an open
|
||||
// end the handle moves as it would without `symmetric`.
|
||||
let symmetric = symmetric && has_segment(s, id, si, ai, !out)?;
|
||||
let at = match p.get("at").filter(|v| !v.is_null()) {
|
||||
None => None,
|
||||
Some(v) => Some(finite_numbers(v).map(|[x, y]| Point::new(x, y)).ok_or_else(|| bad("path.setHandle", "`at` must be [x, y]"))?),
|
||||
@@ -472,6 +479,7 @@ fn set_handle(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
&& at.is_none_or(|to| to == a.p)
|
||||
&& (if out { a.h_out } else { a.h_in }) == pos
|
||||
&& !(independent && a.kind != AnchorKind::Corner)
|
||||
&& (!symmetric || (if out { a.h_in } else { a.h_out }) == a.p - (pos - a.p))
|
||||
{
|
||||
return ok();
|
||||
}
|
||||
@@ -504,6 +512,10 @@ fn set_handle(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
} else {
|
||||
a.set_handle(out, pos, independent);
|
||||
}
|
||||
if symmetric {
|
||||
let opposite = a.p - (pos - a.p);
|
||||
if out { a.h_in = opposite } else { a.h_out = opposite }
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
ok()
|
||||
@@ -519,6 +531,9 @@ fn link_handle(s: &mut Session, p: &Value, id: NodeId, si: usize, ai: usize, out
|
||||
if switch_or(p, "independent", false, C)? {
|
||||
return Err(bad(C, "`link` and `independent` cannot both be true"));
|
||||
}
|
||||
if switch_or(p, "symmetric", false, C)? {
|
||||
return Err(bad(C, "`link` and `symmetric` cannot both be true"));
|
||||
}
|
||||
if !(pos.x.abs() < 1e9 && pos.y.abs() < 1e9) {
|
||||
return Err(bad(C, "x and y must be finite"));
|
||||
}
|
||||
@@ -655,6 +670,16 @@ fn anchor_of(s: &Session, id: NodeId, si: usize, ai: usize) -> Result<Option<Anc
|
||||
Ok(d.node(id).and_then(|n| n.path_data()).and_then(|path| path.subpaths.get(si)).and_then(|sp| sp.anchors.get(ai)).copied())
|
||||
}
|
||||
|
||||
/// Whether anchor `ai` of subpath `si` of path `id` has a segment on its outgoing (`out`) or
|
||||
/// incoming side; false when the path, subpath or anchor is not there.
|
||||
fn has_segment(s: &Session, id: NodeId, si: usize, ai: usize, out: bool) -> Result<bool> {
|
||||
if s.script_running() {
|
||||
return Err(EngineError::Busy);
|
||||
}
|
||||
let d = &s.doc()?.doc;
|
||||
Ok(d.node(id).and_then(|n| n.path_data()).and_then(|path| path.subpaths.get(si)).is_some_and(|sp| sp.has_segment(ai, out)))
|
||||
}
|
||||
|
||||
fn set_anchors(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let id = object_param(p, "id", "path.setAnchors")?.ok_or_else(|| bad("path.setAnchors", "missing id"))?;
|
||||
let subs = p.get("subpaths").and_then(Value::as_array).ok_or_else(|| bad("path.setAnchors", "missing subpaths"))?;
|
||||
|
||||
@@ -122,7 +122,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Move Type Path Handle",
|
||||
[],
|
||||
None,
|
||||
"{id, subpath?, anchor, which: \"in\"|\"out\", x, y, independent?: bool} move a direction handle of an anchor of type on a path's path to (x, y), as path.setHandle moves a path's (independent: that side only, the anchor becomes a corner); the start and end brackets keep their fractions of the path and the text reflows along it (what Direct Selection does dragging a handle of the path); no undo step when the handle is already there and the path does not change",
|
||||
"{id, subpath?, anchor, which: \"in\"|\"out\", x, y, independent?: bool, symmetric?: bool} move a direction handle of an anchor of type on a path's path to (x, y), as path.setHandle moves a path's (independent: that side only, the anchor becomes a corner; symmetric: mirror the other handle about the anchor without changing its kind, except at an open end of the path; independent and symmetric cannot both be true; both default false); the start and end brackets keep their fractions of the path and the text reflows along it (what Direct Selection does dragging a handle of the path); no undo step when the handle is already there and the path does not change",
|
||||
has_doc,
|
||||
set_path_handle
|
||||
),
|
||||
@@ -1449,6 +1449,10 @@ fn set_path_handle(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let out = super::object::choice(p, C, "which", &["in", "out"])? != Some("in");
|
||||
let pos = vectorcraft_geom::Point::new(f64_req(p, "x", C)?, f64_req(p, "y", C)?);
|
||||
let independent = switch_or(p, "independent", false, C)?;
|
||||
let symmetric = switch_or(p, "symmetric", false, C)?;
|
||||
if symmetric && independent {
|
||||
return Err(bad(C, "`independent` and `symmetric` cannot both be true"));
|
||||
}
|
||||
let node = s.doc()?.doc.node(id);
|
||||
let on_path = matches!(node.map(|n| &n.kind), Some(NodeKind::Text(t)) if matches!(t.kind, vectorcraft_doc::TextKind::OnPath { .. }));
|
||||
if !on_path || node.is_some_and(|n| n.extras().perspective.is_some()) {
|
||||
@@ -1461,7 +1465,7 @@ fn set_path_handle(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let within = |t: &TextObject| {
|
||||
t.type_path().and_then(|p| p.bounds()).is_some_and(|b| [b.x0, b.y0, b.x1, b.y1].iter().all(|v| v.abs() <= crate::MAX_COORD))
|
||||
};
|
||||
if !(t.set_path_handle((si, ai), out, pos, independent) && within(t)) {
|
||||
if !(t.set_path_handle_with_symmetry((si, ai), out, pos, independent, symmetric) && within(t)) {
|
||||
t.kind = before;
|
||||
return Err(bad(C, "no such path anchor, or the path would reach past the canvas"));
|
||||
}
|
||||
|
||||
@@ -298,6 +298,10 @@ impl Session {
|
||||
let points = self.tool.options().get("meshPoints").cloned().unwrap_or_else(|| Value::Array(vec![]));
|
||||
lent.set_option("meshPoints", &points);
|
||||
}
|
||||
// The Cmd/Ctrl held for the loan is not the Cmd/Ctrl that mirrors a dragged handle (#7842).
|
||||
if id == "directSelection" {
|
||||
lent.set_option("lentByCmd", &Value::Bool(true));
|
||||
}
|
||||
self.selection_at_lend = self.active().map(|d| (d.uid, d.selection.clone()));
|
||||
self.lender = Some(std::mem::replace(&mut self.tool, lent));
|
||||
Ok((PointerEvent { mods: Mods { cmd: false, ..ev.mods }, ..*ev }, settled))
|
||||
|
||||
@@ -0,0 +1,630 @@
|
||||
//! Temporary Cmd/Control symmetry while Direct Selection drags an existing handle.
|
||||
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{Node, NodeId};
|
||||
use vectorcraft_engine::{Session, ViewInfo};
|
||||
use vectorcraft_geom::{Anchor, AnchorKind, Point};
|
||||
use vectorcraft_tools::{Mods, PointerEvent, PointerKind};
|
||||
|
||||
fn run(s: &mut Session, command: &str, params: Value) -> Value {
|
||||
s.execute(command, ¶ms).unwrap()
|
||||
}
|
||||
|
||||
fn view() -> ViewInfo {
|
||||
ViewInfo {
|
||||
smart_guides: false,
|
||||
guides: false,
|
||||
snap_to_point: false,
|
||||
snap_to_grid: false,
|
||||
snap_to_pixel: false,
|
||||
snap_to_glyph: false,
|
||||
corner_widgets: false,
|
||||
show_bbox: false,
|
||||
..ViewInfo::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn session() -> Session {
|
||||
let mut s = Session::new();
|
||||
run(&mut s, "file.new", json!({"width": 900, "height": 700}));
|
||||
for (key, value) in [("constrainAngle", json!(0)), ("showHandlesMultipleAnchors", json!(true)), ("realTimeDrawing", json!(true))] {
|
||||
run(&mut s, "prefs.set", json!({"key": key, "value": value}));
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
fn node(s: &Session, id: NodeId) -> Node {
|
||||
s.doc().unwrap().doc.node(id).unwrap().clone()
|
||||
}
|
||||
|
||||
fn curve(s: &mut Session, incoming: Point) -> NodeId {
|
||||
let id = run(
|
||||
s,
|
||||
"path.create",
|
||||
json!({"anchors": [
|
||||
{"x": 20, "y": 220},
|
||||
{"x": 100, "y": 100, "in": [incoming.x, incoming.y], "out": [180, 100]},
|
||||
{"x": 320, "y": 220}
|
||||
]}),
|
||||
);
|
||||
let id = NodeId(id["id"].as_u64().unwrap());
|
||||
s.select_tool("directSelection", view()).unwrap();
|
||||
id
|
||||
}
|
||||
|
||||
fn anchor(s: &Session, id: NodeId) -> Anchor {
|
||||
node(s, id).path_data().unwrap().subpaths[0].anchors[1]
|
||||
}
|
||||
|
||||
fn pointer(s: &mut Session, kind: PointerKind, at: Point, mods: Mods) {
|
||||
s.pointer(&PointerEvent::new(kind, at.x, at.y).with_mods(mods), view()).unwrap();
|
||||
}
|
||||
|
||||
fn press_handle(s: &mut Session, at: Point) {
|
||||
pointer(s, PointerKind::Down, at, Mods::default());
|
||||
assert_eq!(s.tool_id(), "directSelection");
|
||||
assert!(s.in_interaction(), "the visible handle press begins Reshape");
|
||||
}
|
||||
|
||||
fn near(actual: Point, expected: Point) {
|
||||
assert!(actual.distance(expected) < 1e-6, "point {actual:?}, expected {expected:?}");
|
||||
}
|
||||
|
||||
fn handles(a: Anchor, incoming: Point, outgoing: Point, kind: AnchorKind) {
|
||||
near(a.h_in, incoming);
|
||||
near(a.h_out, outgoing);
|
||||
assert_eq!(a.kind, kind);
|
||||
}
|
||||
|
||||
fn assert_other_geometry(s: &Session, id: NodeId, before: &Node) {
|
||||
let after = node(s, id);
|
||||
let (old, new) = (before.path_data().unwrap(), after.path_data().unwrap());
|
||||
assert_eq!(new.subpaths.len(), old.subpaths.len());
|
||||
assert_eq!(new.subpaths[0].closed, old.subpaths[0].closed);
|
||||
assert_eq!(new.subpaths[0].anchors.len(), 3);
|
||||
assert_eq!(new.subpaths[0].anchors[0], old.subpaths[0].anchors[0]);
|
||||
assert_eq!(new.subpaths[0].anchors[2], old.subpaths[0].anchors[2]);
|
||||
assert_eq!(new.subpaths[0].anchors[1].p, old.subpaths[0].anchors[1].p);
|
||||
assert_eq!(after.appearance, before.appearance);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_baseline_ordinary_smooth_keeps_the_opposite_length() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
let before = node(&s, id);
|
||||
assert_eq!(anchor(&s, id).kind, AnchorKind::Smooth);
|
||||
let selection = json!(s.doc().unwrap().selection);
|
||||
let undo = s.doc().unwrap().history.undo.len();
|
||||
press_handle(&mut s, Point::new(180.0, 100.0));
|
||||
let q = Point::new(180.0, 160.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, Mods::default());
|
||||
handles(anchor(&s, id), Point::new(60.0, 70.0), q, AnchorKind::Smooth);
|
||||
assert_other_geometry(&s, id, &before);
|
||||
pointer(&mut s, PointerKind::Up, q, Mods::default());
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1);
|
||||
assert_eq!(json!(s.doc().unwrap().selection), selection);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_baseline_cmd_added_mid_drag_mirrors_the_opposite() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
let before = node(&s, id);
|
||||
press_handle(&mut s, Point::new(180.0, 100.0));
|
||||
let q = Point::new(180.0, 160.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, Mods::default());
|
||||
handles(anchor(&s, id), Point::new(60.0, 70.0), q, AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Drag, q, Mods { cmd: true, ..Mods::default() });
|
||||
handles(anchor(&s, id), Point::new(20.0, 40.0), q, AnchorKind::Smooth);
|
||||
assert_other_geometry(&s, id, &before);
|
||||
pointer(&mut s, PointerKind::Up, q, Mods { cmd: true, ..Mods::default() });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_cmd_mirror_holds_through_a_space_translation() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
press_handle(&mut s, Point::new(180.0, 100.0));
|
||||
let q = Point::new(180.0, 160.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
handles(anchor(&s, id), Point::new(20.0, 40.0), q, AnchorKind::Smooth);
|
||||
// Space moves the anchor and both handles; the opposite handle stays mirrored.
|
||||
let moved = Point::new(200.0, 190.0);
|
||||
pointer(&mut s, PointerKind::Drag, moved, Mods { space: true, ..cmd() });
|
||||
let a = anchor(&s, id);
|
||||
near(a.p, Point::new(120.0, 130.0));
|
||||
handles(a, Point::new(40.0, 70.0), Point::new(200.0, 190.0), AnchorKind::Smooth);
|
||||
// Releasing Space without moving keeps the translated, mirrored handles.
|
||||
pointer(&mut s, PointerKind::Drag, moved, cmd());
|
||||
handles(anchor(&s, id), Point::new(40.0, 70.0), Point::new(200.0, 190.0), AnchorKind::Smooth);
|
||||
let next = Point::new(220.0, 190.0);
|
||||
pointer(&mut s, PointerKind::Drag, next, cmd());
|
||||
assert_mirrored(anchor(&s, id), next, AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Up, next, cmd());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_modifiers_changed_during_a_space_translation_apply_at_once() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
press_handle(&mut s, Point::new(180.0, 100.0));
|
||||
pointer(&mut s, PointerKind::Drag, Point::new(180.0, 160.0), cmd());
|
||||
let moved = Point::new(200.0, 190.0);
|
||||
pointer(&mut s, PointerKind::Drag, moved, Mods { space: true, ..cmd() });
|
||||
handles(anchor(&s, id), Point::new(40.0, 70.0), moved, AnchorKind::Smooth);
|
||||
// Releasing Cmd while Space is held gives the opposite handle its own length again.
|
||||
pointer(&mut s, PointerKind::Drag, moved, Mods { space: true, ..Mods::default() });
|
||||
let a = anchor(&s, id);
|
||||
near(a.p, Point::new(120.0, 130.0));
|
||||
handles(a, Point::new(80.0, 100.0), moved, AnchorKind::Smooth);
|
||||
// Alt while Space is held leaves the opposite handle where the translation put it.
|
||||
pointer(&mut s, PointerKind::Drag, moved, Mods { space: true, alt: true, ..cmd() });
|
||||
handles(anchor(&s, id), Point::new(70.0, 130.0), moved, AnchorKind::Corner);
|
||||
pointer(&mut s, PointerKind::Up, moved, Mods { alt: true, ..cmd() });
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct Snapshot {
|
||||
document: Value,
|
||||
selection: Value,
|
||||
undo: usize,
|
||||
redo: usize,
|
||||
}
|
||||
|
||||
fn snapshot(s: &Session) -> Snapshot {
|
||||
let st = s.doc().unwrap();
|
||||
Snapshot { document: json!(st.doc), selection: json!(st.selection), undo: st.history.undo.len(), redo: st.history.redo.len() }
|
||||
}
|
||||
|
||||
fn assert_content(s: &Session, expected: &Snapshot) {
|
||||
let got = snapshot(s);
|
||||
assert_eq!(got.document, expected.document);
|
||||
assert_eq!(got.selection, expected.selection);
|
||||
}
|
||||
|
||||
fn cmd() -> Mods {
|
||||
Mods { cmd: true, ..Mods::default() }
|
||||
}
|
||||
|
||||
fn reflected(a: Point, q: Point) -> Point {
|
||||
a - (q - a)
|
||||
}
|
||||
|
||||
fn constrained(a: Point, q: Point) -> Point {
|
||||
a + vectorcraft_geom::constrain_angle_from(q - a, 45.0, 0.0)
|
||||
}
|
||||
|
||||
fn assert_mirrored(a: Anchor, q: Point, kind: AnchorKind) {
|
||||
handles(a, reflected(a.p, q), q, kind);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_stationary_cmd_release_repress_commit_and_next_gesture() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
let before = snapshot(&s);
|
||||
press_handle(&mut s, Point::new(180.0, 100.0));
|
||||
let q = Point::new(180.0, 160.0);
|
||||
for (mods, opposite) in [(cmd(), Point::new(20.0, 40.0)), (Mods::default(), Point::new(60.0, 70.0)), (cmd(), Point::new(20.0, 40.0))] {
|
||||
pointer(&mut s, PointerKind::Drag, q, mods);
|
||||
handles(anchor(&s, id), opposite, q, AnchorKind::Smooth);
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), before.undo, "previews are not separate edits");
|
||||
}
|
||||
pointer(&mut s, PointerKind::Up, q, cmd());
|
||||
let committed = snapshot(&s);
|
||||
assert_eq!(committed.undo, before.undo + 1);
|
||||
assert_eq!(committed.selection, before.selection);
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_content(&s, &before);
|
||||
run(&mut s, "edit.redo", json!({}));
|
||||
assert_content(&s, &committed);
|
||||
// Cmd did not install a persistent coupling mode: a later ordinary Smooth drag keeps
|
||||
// the opposite handle's committed length, rather than matching the newly dragged length.
|
||||
press_handle(&mut s, q);
|
||||
let next = Point::new(180.0, 200.0);
|
||||
pointer(&mut s, PointerKind::Drag, next, Mods::default());
|
||||
let a = anchor(&s, id);
|
||||
near(a.h_out, next);
|
||||
assert_eq!(a.kind, AnchorKind::Smooth);
|
||||
assert!((a.h_in.distance(a.p) - 100.0).abs() < 1e-6);
|
||||
assert!((a.h_in.distance(a.p) - a.h_out.distance(a.p)).abs() > 20.0);
|
||||
assert!(((a.h_in - a.p).cross(a.h_out - a.p)).abs() < 1e-6);
|
||||
pointer(&mut s, PointerKind::Up, next, Mods::default());
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), before.undo + 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_shift_constrains_before_mirroring_and_alt_takes_priority() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
let p = anchor(&s, id).p;
|
||||
press_handle(&mut s, Point::new(180.0, 100.0));
|
||||
let raw = Point::new(180.0, 150.0);
|
||||
let q = constrained(p, raw);
|
||||
let shifted = Mods { shift: true, ..cmd() };
|
||||
pointer(&mut s, PointerKind::Drag, raw, shifted);
|
||||
assert_mirrored(anchor(&s, id), q, AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Drag, raw, Mods { alt: true, ..shifted });
|
||||
handles(anchor(&s, id), Point::new(50.0, 100.0), q, AnchorKind::Corner);
|
||||
// Removing Alt rebuilds from the original Smooth anchor, not the Corner preview.
|
||||
pointer(&mut s, PointerKind::Drag, raw, shifted);
|
||||
assert_mirrored(anchor(&s, id), q, AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Drag, raw, Mods { alt: true, ..cmd() });
|
||||
handles(anchor(&s, id), Point::new(50.0, 100.0), raw, AnchorKind::Corner);
|
||||
pointer(&mut s, PointerKind::Up, raw, Mods { alt: true, ..cmd() });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_corner_with_collapsed_partner_is_reversible_without_changing_kind() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(100.0, 100.0));
|
||||
let before = snapshot(&s);
|
||||
assert_eq!(anchor(&s, id).kind, AnchorKind::Corner);
|
||||
press_handle(&mut s, Point::new(180.0, 100.0));
|
||||
let q = Point::new(180.0, 160.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
assert_mirrored(anchor(&s, id), q, AnchorKind::Corner);
|
||||
pointer(&mut s, PointerKind::Drag, q, Mods::default());
|
||||
handles(anchor(&s, id), Point::new(100.0, 100.0), q, AnchorKind::Corner);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
assert_mirrored(anchor(&s, id), q, AnchorKind::Corner);
|
||||
s.tool_key(vectorcraft_tools::ToolKey::Escape, Mods::default(), view()).unwrap();
|
||||
assert_eq!(snapshot(&s), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_stationary_drag_still_mirrors_unequal_partner_but_equal_is_noop() {
|
||||
for (incoming, changes) in [(Point::new(50.0, 100.0), true), (Point::new(20.0, 100.0), false)] {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, incoming);
|
||||
let before = snapshot(&s);
|
||||
let q = Point::new(180.0, 100.0);
|
||||
press_handle(&mut s, q);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
assert_mirrored(anchor(&s, id), q, AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Up, q, cmd());
|
||||
if changes {
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), before.undo + 1);
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_content(&s, &before);
|
||||
} else {
|
||||
assert_eq!(snapshot(&s), before, "an already reflected pair records no edit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_escape_restores_document_selection_and_existing_redo() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
run(&mut s, "shape.rectangle", json!({"x": 500, "y": 400, "width": 25, "height": 30}));
|
||||
let redo_document = snapshot(&s).document;
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
run(&mut s, "select.set", json!({"ids": [id.0]}));
|
||||
let before = snapshot(&s);
|
||||
assert_eq!(before.redo, 1, "a real existing Redo is the cancellation control");
|
||||
press_handle(&mut s, Point::new(180.0, 100.0));
|
||||
let q = Point::new(180.0, 160.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
assert_mirrored(anchor(&s, id), q, AnchorKind::Smooth);
|
||||
s.tool_key(vectorcraft_tools::ToolKey::Escape, Mods::default(), view()).unwrap();
|
||||
assert!(!s.in_interaction());
|
||||
assert_eq!(snapshot(&s), before);
|
||||
pointer(&mut s, PointerKind::Up, q, Mods::default());
|
||||
assert_eq!(snapshot(&s), before, "a later release does not commit the canceled preview");
|
||||
run(&mut s, "edit.redo", json!({}));
|
||||
assert_eq!(snapshot(&s).document, redo_document, "the prior Redo still restores its actual content");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_cmd_before_press_still_lends_selection_and_returns_direct() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
let before = snapshot(&s);
|
||||
let a = anchor(&s, id);
|
||||
pointer(&mut s, PointerKind::Down, a.p, cmd());
|
||||
assert_eq!(s.tool_id(), "selection", "Cmd before Down keeps the existing Selection loan");
|
||||
pointer(&mut s, PointerKind::Up, a.p, cmd());
|
||||
assert_eq!(s.tool_id(), "directSelection");
|
||||
assert_eq!(anchor(&s, id), a);
|
||||
assert_eq!(snapshot(&s).document, before.document);
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), before.undo);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_cmd_that_lends_direct_selection_from_the_pen_does_not_mirror() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
s.select_tool("pen", view()).unwrap();
|
||||
let before = node(&s, id);
|
||||
let undo = s.doc().unwrap().history.undo.len();
|
||||
pointer(&mut s, PointerKind::Down, Point::new(180.0, 100.0), cmd());
|
||||
assert_eq!(s.tool_id(), "directSelection", "Cmd lends the Pen the last selection tool");
|
||||
let q = Point::new(180.0, 160.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
handles(anchor(&s, id), Point::new(60.0, 70.0), q, AnchorKind::Smooth);
|
||||
// Cmd let go and pressed again during the drag mirrors, as it does in Direct Selection itself.
|
||||
pointer(&mut s, PointerKind::Drag, q, Mods::default());
|
||||
handles(anchor(&s, id), Point::new(60.0, 70.0), q, AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
handles(anchor(&s, id), Point::new(20.0, 40.0), q, AnchorKind::Smooth);
|
||||
assert_other_geometry(&s, id, &before);
|
||||
pointer(&mut s, PointerKind::Up, q, cmd());
|
||||
assert_eq!(s.tool_id(), "pen");
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_cmd_held_through_a_pen_lent_drag_leaves_the_opposite_length() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
s.select_tool("pen", view()).unwrap();
|
||||
pointer(&mut s, PointerKind::Down, Point::new(180.0, 100.0), cmd());
|
||||
let q = Point::new(180.0, 160.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
pointer(&mut s, PointerKind::Up, q, cmd());
|
||||
assert_eq!(s.tool_id(), "pen");
|
||||
handles(anchor(&s, id), Point::new(60.0, 70.0), q, AnchorKind::Smooth);
|
||||
}
|
||||
|
||||
fn text_anchor(s: &Session, id: NodeId) -> Anchor {
|
||||
let n = node(s, id);
|
||||
let vectorcraft_doc::NodeKind::Text(t) = n.kind else { panic!("text on a path") };
|
||||
t.type_path().unwrap().subpaths[0].anchors[1]
|
||||
}
|
||||
|
||||
fn text_properties(s: &Session, id: NodeId) -> Value {
|
||||
let n = node(s, id);
|
||||
let vectorcraft_doc::NodeKind::Text(t) = n.kind else { panic!("text on a path") };
|
||||
let vectorcraft_doc::TextKind::OnPath { start, end, .. } = &t.kind else { panic!("path text") };
|
||||
json!({"runs": t.runs, "para": t.para, "paras": t.paras, "xf": t.xf, "start": start, "end": end,
|
||||
"effect": t.path_effect, "align": t.path_align, "spacing": t.path_spacing, "appearance": n.appearance})
|
||||
}
|
||||
|
||||
fn path_text(s: &mut Session) -> NodeId {
|
||||
let path = curve(s, Point::new(50.0, 100.0));
|
||||
let made = run(
|
||||
s,
|
||||
"text.createInPath",
|
||||
json!({"path": path.0, "mode": "onPath", "text": "Along the original curve", "font": "Source Sans 3", "size": 12}),
|
||||
);
|
||||
let id = NodeId(made["id"].as_u64().unwrap());
|
||||
run(s, "type.pathOptions", json!({"id": id.0, "start": 0.15, "end": 0.85}));
|
||||
run(s, "object.transform", json!({"ids": [id.0], "matrix": [1.5, 0.4, 0.25, 0.9, 250, 80]}));
|
||||
s.select_tool("directSelection", view()).unwrap();
|
||||
id
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_affine_path_text_mirrors_in_drawn_space_and_keeps_brackets() {
|
||||
let mut s = session();
|
||||
let id = path_text(&mut s);
|
||||
let before = snapshot(&s);
|
||||
let properties = text_properties(&s, id);
|
||||
assert_eq!(properties["start"], json!(0.15));
|
||||
assert_eq!(properties["end"], json!(0.85));
|
||||
let a = text_anchor(&s, id);
|
||||
assert_eq!(a.kind, AnchorKind::Smooth);
|
||||
near(a.p, Point::new(425.0, 210.0));
|
||||
near(a.h_out, Point::new(545.0, 242.0));
|
||||
assert!((a.h_in.distance(a.p) - a.h_out.distance(a.p)).abs() > 40.0);
|
||||
press_handle(&mut s, a.h_out);
|
||||
let raw = a.p + vectorcraft_geom::Vec2::new(80.0, 60.0);
|
||||
pointer(&mut s, PointerKind::Drag, raw, cmd());
|
||||
assert_mirrored(text_anchor(&s, id), raw, AnchorKind::Smooth);
|
||||
assert_eq!(text_properties(&s, id), properties);
|
||||
let shifted = Mods { shift: true, ..cmd() };
|
||||
pointer(&mut s, PointerKind::Drag, raw, shifted);
|
||||
assert_mirrored(text_anchor(&s, id), constrained(a.p, raw), AnchorKind::Smooth);
|
||||
assert_eq!(text_properties(&s, id), properties);
|
||||
pointer(&mut s, PointerKind::Up, raw, shifted);
|
||||
let after = snapshot(&s);
|
||||
assert_eq!(after.undo, before.undo + 1);
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_content(&s, &before);
|
||||
run(&mut s, "edit.redo", json!({}));
|
||||
assert_content(&s, &after);
|
||||
}
|
||||
|
||||
fn blend_state(s: &Session, id: NodeId) -> (Anchor, Value, Vec<u32>) {
|
||||
let n = node(s, id);
|
||||
let vectorcraft_doc::NodeKind::Blend { children, spec } = n.kind else { panic!("blend") };
|
||||
assert!(spec.spine.is_some(), "the fixture uses an already pinned spine");
|
||||
let path = vectorcraft_doc::live::blend_spine(&children, &spec).unwrap().0;
|
||||
(path.subpaths[0].anchors[1], json!(children), spec.key_anchors.clone())
|
||||
}
|
||||
|
||||
fn blend(s: &mut Session) -> NodeId {
|
||||
let a = run(s, "shape.rectangle", json!({"x": 15, "y": 95, "width": 10, "height": 10}))["id"].as_u64().unwrap();
|
||||
let b = run(s, "shape.rectangle", json!({"x": 295, "y": 95, "width": 10, "height": 10}))["id"].as_u64().unwrap();
|
||||
let made = run(s, "object.blend.make", json!({"ids": [a, b], "steps": 2}));
|
||||
let id = NodeId(made["id"].as_u64().unwrap());
|
||||
let added = run(s, "object.blend.spine.addAnchor", json!({"id": id.0, "x": 100, "y": 100}));
|
||||
assert_eq!(added["anchor"], json!(1));
|
||||
run(s, "object.blend.spine.convertAnchor", json!({"id": id.0, "anchor": 1, "to": "smooth", "x": 180, "y": 100}));
|
||||
run(s, "object.blend.spine.moveAnchor", json!({"id": id.0, "anchor": 1, "handle": "in", "x": 50, "y": 100}));
|
||||
run(s, "select.set", json!({"ids": [id.0]}));
|
||||
s.select_tool("directSelection", view()).unwrap();
|
||||
let (middle, _, keys) = blend_state(s, id);
|
||||
near(middle.p, Point::new(100.0, 100.0));
|
||||
handles(middle, Point::new(50.0, 100.0), Point::new(180.0, 100.0), AnchorKind::Smooth);
|
||||
assert_eq!(keys, [0, 2]);
|
||||
// An actual spine-point click makes its handles visible to Direct Selection.
|
||||
pointer(s, PointerKind::Down, middle.p, Mods::default());
|
||||
pointer(s, PointerKind::Up, middle.p, Mods::default());
|
||||
assert!(!s.in_interaction());
|
||||
id
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_pinned_blend_spine_cmd_shift_preserves_keys_and_mapping() {
|
||||
let mut s = session();
|
||||
let id = blend(&mut s);
|
||||
let before = snapshot(&s);
|
||||
let (a, keys, mapping) = blend_state(&s, id);
|
||||
press_handle(&mut s, a.h_out);
|
||||
let q = Point::new(180.0, 160.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
assert_mirrored(blend_state(&s, id).0, q, AnchorKind::Smooth);
|
||||
let raw = Point::new(180.0, 150.0);
|
||||
let shifted = Mods { shift: true, ..cmd() };
|
||||
pointer(&mut s, PointerKind::Drag, raw, shifted);
|
||||
assert_mirrored(blend_state(&s, id).0, constrained(a.p, raw), AnchorKind::Smooth);
|
||||
// The existing spine Shift-only path is deliberately unconstrained; Cmd's new rule
|
||||
// must not leak into that old branch after the modifier is released.
|
||||
pointer(&mut s, PointerKind::Drag, raw, Mods { shift: true, ..Mods::default() });
|
||||
near(blend_state(&s, id).0.h_out, raw);
|
||||
pointer(&mut s, PointerKind::Drag, raw, shifted);
|
||||
let (after_anchor, after_keys, after_mapping) = blend_state(&s, id);
|
||||
assert_mirrored(after_anchor, constrained(a.p, raw), AnchorKind::Smooth);
|
||||
assert_eq!(after_keys, keys, "handle edits leave the actual key art unchanged");
|
||||
assert_eq!(after_mapping, mapping);
|
||||
pointer(&mut s, PointerKind::Up, raw, shifted);
|
||||
let after = snapshot(&s);
|
||||
assert_eq!(after.undo, before.undo + 1);
|
||||
assert_eq!(after.selection, before.selection);
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_content(&s, &before);
|
||||
run(&mut s, "edit.redo", json!({}));
|
||||
assert_content(&s, &after);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_incoming_drag_mirrors_outgoing_and_release_restores_ordinary_length() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
let before = snapshot(&s);
|
||||
let original = node(&s, id);
|
||||
press_handle(&mut s, Point::new(50.0, 100.0));
|
||||
let q = Point::new(40.0, 20.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, Mods::default());
|
||||
handles(anchor(&s, id), q, Point::new(148.0, 164.0), AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
handles(anchor(&s, id), q, Point::new(160.0, 180.0), AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Drag, q, Mods::default());
|
||||
handles(anchor(&s, id), q, Point::new(148.0, 164.0), AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
assert_other_geometry(&s, id, &original);
|
||||
pointer(&mut s, PointerKind::Up, q, cmd());
|
||||
handles(anchor(&s, id), q, Point::new(160.0, 180.0), AnchorKind::Smooth);
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), before.undo + 1);
|
||||
assert_eq!(snapshot(&s).selection, before.selection);
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_content(&s, &before);
|
||||
}
|
||||
|
||||
/// `command` with `params` is refused with an error containing `message`, and the document,
|
||||
/// selection and undo history stay as they were.
|
||||
fn refused(s: &mut Session, command: &str, params: Value, message: &str) {
|
||||
let before = snapshot(s);
|
||||
let err = s.execute(command, ¶ms).unwrap_err().to_string();
|
||||
assert!(err.contains(message), "{command} {params}: {err}");
|
||||
assert_eq!(snapshot(s), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_set_handle_symmetric_mirrors_refuses_bad_values_and_records_no_step_when_in_place() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
let at = |x: f64, y: f64| json!({"id": id.0, "anchor": 1, "which": "out", "x": x, "y": y});
|
||||
for bad in [json!("yes"), json!(1)] {
|
||||
let mut p = at(180.0, 160.0);
|
||||
p["symmetric"] = bad;
|
||||
refused(&mut s, "path.setHandle", p, "`symmetric` must be true or false");
|
||||
}
|
||||
let mut both = at(180.0, 160.0);
|
||||
both["symmetric"] = json!(true);
|
||||
both["independent"] = json!(true);
|
||||
refused(&mut s, "path.setHandle", both, "`independent` and `symmetric` cannot both be true");
|
||||
|
||||
let undo = s.doc().unwrap().history.undo.len();
|
||||
let mut mirror = at(180.0, 160.0);
|
||||
mirror["symmetric"] = json!(true);
|
||||
run(&mut s, "path.setHandle", mirror.clone());
|
||||
handles(anchor(&s, id), Point::new(20.0, 40.0), Point::new(180.0, 160.0), AnchorKind::Smooth);
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1);
|
||||
let placed = snapshot(&s);
|
||||
run(&mut s, "path.setHandle", mirror);
|
||||
assert_eq!(snapshot(&s), placed, "both handles already in place record no undo step");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn symmetric_leaves_the_other_handle_retracted_at_an_open_end() {
|
||||
let mut s = session();
|
||||
let id = curve(&mut s, Point::new(50.0, 100.0));
|
||||
let first = |s: &Session| node(s, id).path_data().unwrap().subpaths[0].anchors[0];
|
||||
let p = first(&s).p;
|
||||
run(&mut s, "path.setHandle", json!({"id": id.0, "anchor": 0, "which": "out", "x": 60, "y": 180, "symmetric": true}));
|
||||
handles(first(&s), p, Point::new(60.0, 180.0), AnchorKind::Corner);
|
||||
|
||||
let mut s = session();
|
||||
let blend_id = blend(&mut s);
|
||||
let end = |s: &Session| {
|
||||
let n = node(s, blend_id);
|
||||
let vectorcraft_doc::NodeKind::Blend { children, spec } = n.kind else { panic!("blend") };
|
||||
vectorcraft_doc::live::blend_spine(&children, &spec).unwrap().0.subpaths[0].anchors[0]
|
||||
};
|
||||
let start = end(&s);
|
||||
run(&mut s, "object.blend.spine.moveAnchor", json!({"id": blend_id.0, "anchor": 0, "handle": "out", "x": 60, "y": 60, "symmetric": true}));
|
||||
near(end(&s).h_out, Point::new(60.0, 60.0));
|
||||
near(end(&s).h_in, start.h_in);
|
||||
near(end(&s).h_in, start.p);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spine_and_type_path_handles_refuse_bad_symmetric_values() {
|
||||
let mut s = session();
|
||||
let id = blend(&mut s);
|
||||
let spine = |extra: Value| {
|
||||
let mut p = json!({"id": id.0, "anchor": 1, "handle": "out", "x": 180, "y": 160});
|
||||
p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone());
|
||||
p
|
||||
};
|
||||
refused(&mut s, "object.blend.spine.moveAnchor", spine(json!({"symmetric": "yes"})), "`symmetric` must be true or false");
|
||||
refused(
|
||||
&mut s,
|
||||
"object.blend.spine.moveAnchor",
|
||||
spine(json!({"symmetric": true, "independent": true})),
|
||||
"`independent` and `symmetric` cannot both be true",
|
||||
);
|
||||
refused(
|
||||
&mut s,
|
||||
"object.blend.spine.moveAnchor",
|
||||
json!({"id": id.0, "anchor": 1, "x": 180, "y": 160, "symmetric": true}),
|
||||
"`symmetric` places a handle",
|
||||
);
|
||||
|
||||
let text = path_text(&mut s);
|
||||
let a = text_anchor(&s, text);
|
||||
let at = json!({"id": text.0, "anchor": 1, "which": "out", "x": a.h_out.x, "y": a.h_out.y + 20.0});
|
||||
let mut bad = at.clone();
|
||||
bad["symmetric"] = json!(0);
|
||||
refused(&mut s, "text.setPathHandle", bad, "`symmetric` must be true or false");
|
||||
let mut both = at;
|
||||
both["symmetric"] = json!(true);
|
||||
both["independent"] = json!(true);
|
||||
refused(&mut s, "text.setPathHandle", both, "`independent` and `symmetric` cannot both be true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_handle_cmd_that_lends_direct_selection_from_the_pen_does_not_mirror_type_on_a_path() {
|
||||
let mut s = session();
|
||||
let id = path_text(&mut s);
|
||||
let a = text_anchor(&s, id);
|
||||
let length = a.h_in.distance(a.p);
|
||||
s.select_tool("pen", view()).unwrap();
|
||||
pointer(&mut s, PointerKind::Down, a.h_out, cmd());
|
||||
assert_eq!(s.tool_id(), "directSelection");
|
||||
let q = a.p + vectorcraft_geom::Vec2::new(80.0, 60.0);
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
let held = text_anchor(&s, id);
|
||||
near(held.h_out, q);
|
||||
assert!((held.h_in.distance(held.p) - length).abs() < 1e-6, "the other handle keeps its length");
|
||||
pointer(&mut s, PointerKind::Drag, q, Mods::default());
|
||||
pointer(&mut s, PointerKind::Drag, q, cmd());
|
||||
assert_mirrored(text_anchor(&s, id), q, AnchorKind::Smooth);
|
||||
pointer(&mut s, PointerKind::Up, q, cmd());
|
||||
assert_eq!(s.tool_id(), "pen");
|
||||
}
|
||||
@@ -78,6 +78,8 @@ struct HandleDrag {
|
||||
offset: Vec2,
|
||||
space: bool,
|
||||
independent: bool,
|
||||
/// The opposite handle mirrors this one ([`DirectSelectionTool::mirrors`]).
|
||||
symmetric: bool,
|
||||
translated: bool,
|
||||
}
|
||||
|
||||
@@ -261,9 +263,27 @@ pub struct DirectSelectionTool {
|
||||
frame_click: Option<(NodeId, AnchorRef)>,
|
||||
/// Where the pointer last hovered: the type on a path bracket under it draws thicker.
|
||||
bracket_hover: Option<Point>,
|
||||
/// The Cmd/Ctrl press that lent this tool for one gesture (`lentByCmd`) is still
|
||||
/// held: it does not mirror a dragged handle. Once Cmd/Ctrl is let go, pressing it again does.
|
||||
lent_cmd: bool,
|
||||
}
|
||||
|
||||
impl DirectSelectionTool {
|
||||
/// Whether a handle drag with `ev`'s modifiers mirrors the opposite handle: Cmd/Ctrl held
|
||||
/// without Alt, unless it is still the press that lent this tool for one gesture while another
|
||||
/// tool, such as the Pen, is chosen.
|
||||
fn mirrors(&self, ev: &PointerEvent) -> bool {
|
||||
ev.mods.cmd && !ev.mods.alt && !self.lent_cmd
|
||||
}
|
||||
|
||||
/// Forget the lending Cmd/Ctrl once an event comes without it. The session takes Cmd/Ctrl off
|
||||
/// the press it lends the tool for, while the drags after it still carry it.
|
||||
fn track_lent_cmd(&mut self, ev: &PointerEvent) {
|
||||
if ev.kind != PointerKind::Down {
|
||||
self.lent_cmd &= ev.mods.cmd;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(group: bool) -> Self {
|
||||
Self {
|
||||
group,
|
||||
@@ -291,6 +311,7 @@ impl DirectSelectionTool {
|
||||
frame_revision: (0, 0),
|
||||
frame_click: None,
|
||||
bracket_hover: None,
|
||||
lent_cmd: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,6 +462,21 @@ fn spine_anchor(cx: &ToolContext, (id, ai): (NodeId, usize)) -> Option<vectorcra
|
||||
spine_path(cx, id)?.subpaths.first()?.anchors.get(ai).copied()
|
||||
}
|
||||
|
||||
/// Preview a drag of the clicked blend-spine direction handle.
|
||||
/// `symmetric`: the opposite handle mirrors the dragged one ([`DirectSelectionTool::mirrors`]).
|
||||
fn drag_spine_handle(cx: &ToolContext, ev: &PointerEvent, (id, anchor, out): (NodeId, usize, bool), p: Point, symmetric: bool) -> Vec<Action> {
|
||||
let q = if symmetric && ev.mods.shift {
|
||||
spine_anchor(cx, (id, anchor)).map_or(p, |a| a.p + vectorcraft_geom::constrain_angle_from(p - a.p, 45.0, cx.constrain_angle))
|
||||
} else {
|
||||
p
|
||||
};
|
||||
let mut params = json!({"id": id.0, "anchor": anchor, "handle": if out {"out"} else {"in"}, "x": q.x, "y": q.y, "independent": ev.mods.alt});
|
||||
if symmetric {
|
||||
params["symmetric"] = json!(true);
|
||||
}
|
||||
vec![Action::Preview("object.blend.spine.moveAnchor".into(), params)]
|
||||
}
|
||||
|
||||
/// Blend `id`'s spine, built once for callers that look up several of its points.
|
||||
fn spine_path(cx: &ToolContext, id: NodeId) -> Option<PathData> {
|
||||
match &cx.doc.node(id)?.kind {
|
||||
@@ -789,10 +825,15 @@ impl Tool for DirectSelectionTool {
|
||||
}
|
||||
/// Direct Selection picks the gradient mesh points the Eyedropper held (`meshPoints`); Group
|
||||
/// Selection, which selects whole objects, does not.
|
||||
/// The session sets `lentByCmd` on the tool Cmd/Ctrl lends for one gesture
|
||||
/// ([`DirectSelectionTool::mirrors`]).
|
||||
fn set_option(&mut self, key: &str, value: &Value) {
|
||||
if key == "meshPoints" && !self.group {
|
||||
self.mesh.set_options(value);
|
||||
}
|
||||
if key == "lentByCmd" {
|
||||
self.lent_cmd = value.as_bool().unwrap_or(false);
|
||||
}
|
||||
}
|
||||
/// Escape during a drag (anchors, handles, segments, objects, type areas, blend spines, mesh
|
||||
/// points, corner widgets, the brackets of type on a path, a marquee) cancels it: what it moved
|
||||
@@ -851,6 +892,7 @@ impl Tool for DirectSelectionTool {
|
||||
}
|
||||
fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec<Action> {
|
||||
self.bracket_hover = (ev.kind == PointerKind::Move).then_some(ev.pos);
|
||||
self.track_lent_cmd(ev);
|
||||
if let Some(out) = self.guide.pointer(cx, ev) {
|
||||
return out;
|
||||
}
|
||||
@@ -908,6 +950,7 @@ impl Tool for DirectSelectionTool {
|
||||
offset: Vec2::ZERO,
|
||||
space: false,
|
||||
independent: false,
|
||||
symmetric: false,
|
||||
translated: false,
|
||||
})
|
||||
}
|
||||
@@ -1012,10 +1055,11 @@ impl Tool for DirectSelectionTool {
|
||||
self.snapped = snapped(q.to_vec2(), p.to_vec2(), ev.mods.shift, &guides);
|
||||
self.guides = guides;
|
||||
let cmd = if cx.doc.node(id).is_some_and(is_path_type) { "text.setPathHandle" } else { "path.setHandle" };
|
||||
vec![Action::Preview(
|
||||
cmd.into(),
|
||||
json!({"id": id.0, "subpath": si, "anchor": ai, "which": if out {"out"} else {"in"}, "x": q.x, "y": q.y, "independent": ev.mods.alt}),
|
||||
)]
|
||||
let mut params = json!({"id": id.0, "subpath": si, "anchor": ai, "which": if out {"out"} else {"in"}, "x": q.x, "y": q.y, "independent": ev.mods.alt});
|
||||
if self.mirrors(ev) {
|
||||
params["symmetric"] = json!(true);
|
||||
}
|
||||
vec![Action::Preview(cmd.into(), params)]
|
||||
}
|
||||
(PointerKind::Drag, State::SpinePoint { id, anchor, from, start, began }) => {
|
||||
let mut out = vec![];
|
||||
@@ -1053,10 +1097,7 @@ impl Tool for DirectSelectionTool {
|
||||
));
|
||||
out
|
||||
}
|
||||
(PointerKind::Drag, State::SpineHandle { id, anchor, out }) => vec![Action::Preview(
|
||||
"object.blend.spine.moveAnchor".into(),
|
||||
json!({"id": id.0, "anchor": anchor, "handle": if out {"out"} else {"in"}, "x": p.x, "y": p.y, "independent": ev.mods.alt}),
|
||||
)],
|
||||
(PointerKind::Drag, State::SpineHandle { id, anchor, out }) => drag_spine_handle(cx, ev, (id, anchor, out), p, self.mirrors(ev)),
|
||||
(PointerKind::Drag, State::Mesh) => self.mesh.drag_to(p).unwrap_or_default(),
|
||||
(PointerKind::Up, State::Mesh) => {
|
||||
self.state = State::Idle;
|
||||
@@ -1568,15 +1609,20 @@ impl DirectSelectionTool {
|
||||
self.snapped = snapped(q.to_vec2(), input.to_vec2(), ev.mods.shift, &guides);
|
||||
self.guides = guides;
|
||||
drag.handle = q;
|
||||
drag.independent = ev.mods.alt;
|
||||
}
|
||||
}
|
||||
// Alt and Cmd/Ctrl take effect on every event, while Space is held too.
|
||||
drag.independent = ev.mods.alt;
|
||||
drag.symmetric = self.mirrors(ev);
|
||||
drag.last = p;
|
||||
drag.space = ev.mods.space;
|
||||
let mut params = json!({
|
||||
"id": id.0, "subpath": si, "anchor": ai, "which": if out { "out" } else { "in" },
|
||||
"x": drag.handle.x, "y": drag.handle.y, "independent": drag.independent,
|
||||
});
|
||||
if drag.symmetric {
|
||||
params["symmetric"] = json!(true);
|
||||
}
|
||||
if drag.translated {
|
||||
params["at"] = json!([drag.at.x, drag.at.y]);
|
||||
}
|
||||
|
||||
@@ -144,6 +144,8 @@ from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall
|
||||
|
||||
macOS cursor delivery (#2292) is narrowed to a native host adapter using the existing artwork and aligned 1×/2× representations. Headless tests cover visible fallbacks, preparation and ownership; native focus/menu/handback timing, mixed displays, Spotlight and full-screen Spaces remain open validation work (see [hardware parity](hardware-parity.md)). This does not close the interaction-fidelity gap or change its score/estimate.
|
||||
|
||||
- **Temporary handle mirroring (#7842):** with Direct Selection, add Control (Command on macOS) after a direction-handle drag begins to mirror the opposite handle at equal length. This includes ordinary paths, type on a path and blend spines; a missing opposite handle is pulled out while the modifier is held. At an open end, where no segment leaves the anchor on the other side, the handle moves as it does without the modifier. Letting go returns to the drag's normal handle behavior, Shift constrains before mirroring, and Alt takes independent-handle priority. The existing Control/Command-before-press Selection-tool loan is unchanged, and the Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again. This does not add a persistent coupling mode or change Pen, mesh or warp gestures; the broader G1 scope and estimates remain.
|
||||
|
||||
- **Selection fill eligibility (#6625):** Path and compound-path interiors use any enabled non-None fill row (#6625). A lower visible fill remains selectable beneath a top None row in the same object; hidden-only and true-None interiors miss. Zero-opacity fills remain selectable. Original CPU-render and document-hit regressions in `crates/engine/tests/path_fill_hits.rs` cover seven Path and five Compound cases, including stroke edges, geometric outlines, Outline/path-only modes and compound holes. Hidden-fill and no-fill stroked paths must respect butt, round and square caps and bevel, round and miter joins. Focused cap/join CPU regressions passed. Scores and estimates unchanged.
|
||||
|
||||
- **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged.
|
||||
|
||||
+18
-7
@@ -2335,7 +2335,7 @@ naming the key, and leave the document and its undo history as they were: `opaci
|
||||
The blend and envelope commands refuse a string, a number or another value that is not true or false with
|
||||
`` `smooth` must be true or false ``, naming the key, and leave the document, its undo history and the options new
|
||||
blends and envelopes start with as they were: `smooth` in `object.blend.make` and `object.blend.options`;
|
||||
`independent` and `link` in `object.blend.spine.moveAnchor`; `perpendicular` in `object.blend.spine.reshapeSegment`; `horizontal`
|
||||
`independent`, `symmetric` and `link` in `object.blend.spine.moveAnchor`; `perpendicular` in `object.blend.spine.reshapeSegment`; `horizontal`
|
||||
in `object.envelope.makeWithWarp`, `resetWithWarp` and `options`, also when an `orientation` is given; `maintainShape`
|
||||
in `object.envelope.resetWithMesh`; `antiAlias`, `distortAppearance`, `distortLinearGradients` and
|
||||
`distortPatternFills` in `object.envelope.options`; and `editing` in `object.envelope.editContents`. A null is read as
|
||||
@@ -6750,6 +6750,14 @@ is not a whole number of 0 or more, such as 1.5, -1 or "1" ("`subpath` must be a
|
||||
an `anchor` or `segment` in the same way. The document does not change and no undo step is recorded.
|
||||
`path.moveAnchor` to the point the anchor is at, and `path.setHandle` to the point the handle is at on an anchor that
|
||||
keeps its kind, leave the document as it is and record no undo step.
|
||||
`path.setHandle` with `symmetric: true` also places the anchor's other handle opposite the moved one at the same
|
||||
length, and the anchor keeps its kind. At an open end, where no segment leaves the anchor on the other side,
|
||||
`symmetric` has no effect and the handle moves as it would without it. Both `symmetric` and `independent` default to false, and a call with both true is
|
||||
refused with `` `independent` and `symmetric` cannot both be true ``; the document does not change and no undo step
|
||||
is recorded. Direct Selection sends `symmetric` while Cmd/Ctrl is held during a handle drag, unless that Cmd/Ctrl
|
||||
press lent Direct Selection for the gesture while another tool, such as the Pen, was chosen and has not been let go
|
||||
since (#7842). A call that puts both handles where they already are records no undo step. `symmetric: true` with `link: true` is refused
|
||||
("`link` and `symmetric` cannot both be true"), and so is `symmetric: true` with `link: true` in `object.blend.spine.moveAnchor`.
|
||||
`path.setHandle` with `link: true` (the Anchor Point tool's Alt-drag on a handle) places the handle and makes the
|
||||
anchor smooth: the other handle turns to lie in line on the far side of the anchor and keeps its length. A retracted
|
||||
other handle is pulled out to the placed handle's length when a segment leaves the anchor on its side, and stays
|
||||
@@ -6876,7 +6884,7 @@ Left out or null, `width` is 8 pt. The range is VectorCraft's own value.
|
||||
|
||||
These commands refuse a string, a number or another value that is not true or false with
|
||||
`` `closed` must be true or false ``, naming the key; the document does not change and no undo step is recorded:
|
||||
`independent` in `path.close` and `path.setHandle`; `link` in `path.setHandle`; `patterns` in `path.moveAnchors`; `closed`, `keepSelected` and
|
||||
`independent` in `path.close` and `path.setHandle`; `symmetric` and `link` in `path.setHandle`; `patterns` in `path.moveAnchors`; `closed`, `keepSelected` and
|
||||
`fill` in `path.freehand` (and in `brush.freehand`); `closed` and the `corner` of a point in `path.curvature`; `corner`
|
||||
in `path.curvatureEdit`; `perpendicular` in `path.reshapeSegment`; and `keepSelected`, `mergeOnlySelection` and
|
||||
`merge` in `path.blob`. A null is read as a key left out.
|
||||
@@ -10911,10 +10919,12 @@ undo step. Object › Transform › Scale, the Scale tool and the Transform pane
|
||||
`text.reshapePath {id, anchors: [[subpath, anchor]…], dx, dy}` does the same for the path of type on a path
|
||||
(Direct Selection dragging one of its anchors): the start and end brackets keep their fractions of the path and the
|
||||
text reflows along it.
|
||||
`text.setPathHandle {id, subpath?, anchor, which: "in"|"out", x, y, independent?}` moves a direction handle of one
|
||||
of its anchors, as `path.setHandle` moves a path's (Direct Selection dragging a handle of the path, #3565), in one
|
||||
undo step. A call of `text.reshapeArea`, `text.reshapePath` or `text.setPathHandle` that changes nothing (`dx` and
|
||||
`dy` both 0, or a handle moved to where it already is) adds no undo step and keeps redo.
|
||||
`text.setPathHandle {id, subpath?, anchor, which: "in"|"out", x, y, independent?, symmetric?}` moves a direction handle
|
||||
of one of its anchors, as `path.setHandle` moves a path's (Direct Selection dragging a handle of the path, #3565), in
|
||||
one undo step. With `symmetric: true` the other handle goes opposite the moved one at the same length, measured on
|
||||
the page, as in `path.setHandle`; `symmetric` and `independent` cannot both be true. A call of `text.reshapeArea`,
|
||||
`text.reshapePath` or `text.setPathHandle` that changes nothing (`dx` and `dy` both 0, or handles left where they
|
||||
already are) adds no undo step and keeps redo.
|
||||
|
||||
```json
|
||||
{"name":"run_command","arguments":{"command":"text.reshapeArea","params":{"id":42,"anchors":[[0,2]],"dx":40,"dy":60}}}
|
||||
@@ -13575,7 +13585,8 @@ the compound path selected), and the next click starts a new path. Choosing any
|
||||
A blend's spine is the straight lines between its key centres until it is edited. `object.blend.info` lists it
|
||||
(`spine.anchors`, `keyAnchors`: the point each key sits on). `object.blend.spine.addAnchor {x, y}` adds a point where
|
||||
the spine passes nearest, `object.blend.spine.moveAnchor {anchor, x, y}` moves a point (a key on it moves along; with
|
||||
`handle: "in" | "out"` it places that handle), `object.blend.spine.convertAnchor {anchor, to: "smooth" | "corner", x?, y?}` converts a point's handles (a Smooth drag with `x, y` creates opposite handles; Corner retracts both), `object.blend.spine.reshapeSegment {segment, t, dx, dy, perpendicular?}` bends a segment
|
||||
`handle: "in" | "out"` it places that handle, and with `symmetric: true` also the other handle opposite it at the
|
||||
same length, as `path.setHandle` does; `symmetric` needs `handle` and cannot go with `independent`), `object.blend.spine.convertAnchor {anchor, to: "smooth" | "corner", x?, y?}` converts a point's handles (a Smooth drag with `x, y` creates opposite handles; Corner retracts both), `object.blend.spine.reshapeSegment {segment, t, dx, dy, perpendicular?}` bends a segment
|
||||
so its point at `t` moves by (dx, dy), turning a straight spine into a curve (`perpendicular` works as in `path.reshapeSegment`), and `object.blend.spine.removeAnchor
|
||||
{anchor}` deletes a point no key sits on; the first edit turns the spine into a path. Moving a key moves its end of the spine. Release
|
||||
(`object.blend.release`) leaves the spine of a blend that has one as a path that paints nothing (`spines` in the result):
|
||||
|
||||
@@ -745,6 +745,7 @@ since 2026-10-01.
|
||||
- **Clipping paths on their outline (G1):** the selection tools (Selection, Direct Selection, Group Selection), Object Highlighting and a right-click take a clipping path on its outline before the art it clips; Select Behind lists the same; the eyedropper, the tools that act on what is drawn and the selection tools' double-clicks, loaded text and guide release take the art. Doc and tool regression tests; score unchanged.
|
||||
- **Link cursor for loaded text:** with text loaded from a port, the Selection tool's pointer adds a link badge over a closed path, area type or type on a path that a click threads the text into, and keeps the loaded text elsewhere; a click on a frame already in a thread or a path inside a compound path makes a new frame instead of a `text.thread.add` error (`select::tests::loaded_text_shows_the_link_cursor_where_a_click_threads_it_into_the_object`, `cursors::tests::loaded_text_link_cursor_is_the_loaded_text_with_a_link_badge`); score unchanged.
|
||||
- **Copy and Cut of anchors picked with a lent Direct Selection (#6123):** with the Pen or the Curvature tool, Cmd/Ctrl held lends Direct Selection for the gesture; the anchors and segments it picks are what Edit › Copy and Cut take once the key is let go, as with Direct Selection chosen, while the last anchor the Pen leaves selected as it draws still makes Copy take the whole path (#2122). A Cmd gesture that leaves the selection as it was (a Shift marquee over nothing) picks nothing. Regression test: `tests::draw2::pen_cmd_selected_anchors_are_what_copy_and_cut_take`.
|
||||
- **Mirrored handles in a Direct Selection drag (#7842):** Cmd/Ctrl added after a handle drag begins puts the anchor's other handle opposite the dragged one at the same length, on paths, type on a path and blend spines, and the anchor keeps its kind; Shift constrains the dragged handle first, and Alt keeps the handles independent. At an open end, where no segment leaves the anchor on the other side, the handle moves as it does without Cmd/Ctrl. When Cmd/Ctrl lends Direct Selection for the gesture while another tool, such as the Pen, is chosen, that press does not mirror; letting it go and pressing it again during the drag does. This is VectorCraft's own behavior. Regression tests: `crates/engine/tests/direct_handle_mirror.rs`.
|
||||
- **Cut of picked anchors (#6361):** Edit › Cut removes direct-selected anchors from their path and from a compound path's member, with the segments attached to them, as Clear does. Picked segments still lose only those segments. When a path also has a picked segment, Cut removes and copies only its picked segments and ignores its picked anchors, on every contour, as Clear does; an anchor left without a surviving segment is removed with them. Regression tests: `cut_*_anchors_*` and `cut_of_an_anchor_with_a_segment_on_another_contour_leaves_the_source_as_clear_does` in `crates/engine/tests/it/copy_direct_selection.rs`.
|
||||
- **Escape in Selection tool drags:** Escape during a Selection tool move or Alt-drag copy, a bounding-box scale or rotation, a marquee, or a corner widget, pie widget or bracket drag cancels it: the art returns to its state at the press, no copy is left, no undo step is added, the release does nothing, and the tool stays chosen. This is VectorCraft's own behavior. Regression tests: `escape_cancels_*` in `select/tests.rs` and `pie.rs`, and `escape_cancels_a_selection_tool_move_copy_scale_or_rotation` in `tests/selectescape.rs`.
|
||||
- **Large Shift-marquee selections and Select › Inverse:** `select.toggle` and `select.add` with many ids (a Shift-drag marquee sends them together) go through the selection once instead of once per id, and Select › Inverse looks each object up in a set of the selected ones. The resulting selection, its order and the reply are the same as before. With 50,000 objects the selection step of toggling every object off took 528 to 655 ms before and 2.5 to 4.6 ms after in 7 runs, wall clock on a machine that was running other builds (`cargo run --release -p vectorcraft-engine --example selection_bench`). Regression tests: `add_all_does_what_adding_each_does` and `toggle_all_does_what_toggling_each_does` in `crates/doc/src/selection/tests.rs`, and `toggle_and_add_handle_each_listed_id_in_order` in `crates/engine/tests/it/selection_commands.rs`.
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ tools, never checked side by side) isn't captured row by row.
|
||||
| Drag a curved segment to bend it, a straight one to move its anchors | done | |
|
||||
| Drag by an anchor of a path selected whole moves the whole path; Alt-drag by an anchor or a segment copies it, Alt toggles the copy during the drag, and the copy snaps by the anchor pressed, onto the original too | done | #1104 |
|
||||
| Handles shown are the handles that drag; tolerance from Selection & Anchor Display | done | #494 |
|
||||
| Drag a handle with Shift (45° about its anchor), Alt (move one handle alone), Space (ordinary paths: move its anchor and both handles) | done | handles snap to smart guides; handle and anchor drags no longer stall when the pointer leaves and re-enters the window, and a move in the release's frame lands (#834); Space pressed during an ordinary path's handle drag moves its owning anchor and both handles; releasing Space while keeping the mouse down resumes handle adjustment. This also applies while Cmd/Ctrl lends Direct Selection to the Pen, which then continues the same path (#7237, request 3 only) |
|
||||
| Drag a handle with Shift (45° about its anchor), Alt (move one handle alone), Control/Command added mid-drag (mirror the opposite handle), Space (ordinary paths: move its anchor and both handles) | done | handles snap to smart guides; handle and anchor drags no longer stall when the pointer leaves and re-enters the window, and a move in the release's frame lands (#834); #7842: temporary mirroring covers paths, transformed type on a path and blend spines, preserves the anchor mode and the pre-press selection-tool loan, and keeps Alt independent priority; the Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again; `crates/engine/tests/direct_handle_mirror.rs`; Space pressed during an ordinary path's handle drag moves its owning anchor and both handles; releasing Space while keeping the mouse down resumes handle adjustment. This also applies while Cmd/Ctrl lends Direct Selection to the Pen, which then continues the same path (#7237, request 3 only) |
|
||||
| Show handles when multiple anchors are selected; Highlight anchors on mouse over; anchor and handle size | done | Preferences › Selection & Anchor Display |
|
||||
| Convert selected anchors to corner/smooth from the Control bar and Properties | done | |
|
||||
| Cut path at selected anchors, Remove Anchor Points, Delete removes segments | done | Open-path anchor Delete removes adjoining segments without bridging the gap; #3380 (deletion only): disconnected survivors of an ordinary contour become independent selected sibling objects, while multi-subpath paths and compound members stay intact; targeted core and full-frame Delete/Backspace regressions pass for survivor selection and Undo/Redo. Explicit Remove Anchor Points keeps its reconnect/refit behavior; #1278: segment Delete preserves neighboring edges and endpoint anchors; a second Delete removes all selected surviving objects; explicit anchor Delete retains its behavior; #1674: Delete removes every selected anchor of a closed path and objects selected whole along with them, and keeps the surviving objects selected; #2241: Remove Anchor Points then selects the next anchor along the path (the one before at an open end), so it can be run again without picking each anchor |
|
||||
|
||||
Reference in New Issue
Block a user