mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 08:26:04 +00:00
Direct Selection: Double-Click Adds Anchor Points preference adds an anchor on a segment (#9122)
This commit is contained in:
@@ -140,7 +140,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Add Anchor Point",
|
||||
[],
|
||||
None,
|
||||
"{id, subpath?, segment, t: 0..1} add an anchor at t on the segment → {anchor}; the direct-selected anchors and selected segments keep the same points (a selected segment it splits stays selected as its two halves), and a path that isn't selected becomes the selection with the new anchor direct-selected",
|
||||
"{id, subpath?, segment, t: 0..1, selectAnchor?: bool (the path becomes the selection with only the new anchor direct-selected, also when it is selected)} add an anchor at t on the segment → {anchor}; the direct-selected anchors and selected segments keep the same points (a selected segment it splits stays selected as its two halves), and a path that isn't selected becomes the selection with the new anchor direct-selected",
|
||||
has_doc,
|
||||
insert_anchor
|
||||
),
|
||||
@@ -2155,6 +2155,7 @@ fn insert_anchor(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let si = usize_opt(p, "subpath", "path.insertAnchor")?.unwrap_or(0);
|
||||
let seg = index_opt(p, "segment", "path.insertAnchor")?.ok_or_else(|| bad("path.insertAnchor", "missing segment"))?;
|
||||
let t = number_or(p, "t", 0.5, "path.insertAnchor")?.clamp(0.0, 1.0);
|
||||
let select_anchor = switch_or(p, "selectAnchor", false, "path.insertAnchor")?;
|
||||
let idx = s.edit("Add Anchor Point", |d, sel| {
|
||||
let path = path_mut(d, id)?;
|
||||
let sp = path.subpaths.get_mut(si).ok_or_else(|| EngineError::Other("no such subpath".into()))?;
|
||||
@@ -2164,8 +2165,9 @@ fn insert_anchor(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let idx = sp.insert_anchor(seg, t);
|
||||
renumber_after_insert(sel, id, si, idx);
|
||||
// A path that wasn't selected becomes the selection, its new anchor direct-selected, so
|
||||
// the point added shows and can be edited at once (#4237).
|
||||
if !sel.contains(id) {
|
||||
// the point added shows and can be edited at once (#4237). `selectAnchor` does the same
|
||||
// for a path that is selected.
|
||||
if select_anchor || !sel.contains(id) {
|
||||
sel.clear();
|
||||
sel.add(id);
|
||||
sel.anchors.entry(id).or_default().insert((si, idx));
|
||||
|
||||
@@ -141,6 +141,7 @@ pub const PREF_SPECS: &[PrefSpec] = &[
|
||||
p!("disableAutoAddDelete", "General", "Options", "Disable Auto Add/Delete", bool),
|
||||
p!("interpolateControlPoints", "General", "Options", "Interpolate Control Points When Moving Anchors", bool),
|
||||
p!("deleteKeepsPathsJoined", "General", "Options", "Delete Removes Anchor Points and Keeps Paths Joined", bool),
|
||||
p!("doubleClickAddsAnchorPoints", "General", "Options", "Double-Click Adds Anchor Points", bool),
|
||||
p!("usePreciseCursors", "General", "Options", "Use Precise Cursors", bool),
|
||||
p!("showToolTips", "General", "Options", "Show Tool Tips", bool),
|
||||
p!("showToolCards", "General", "Options", "Show Tool Cards", bool),
|
||||
|
||||
@@ -61,6 +61,9 @@ pub struct Prefs {
|
||||
/// the curve around each one, instead of deleting them with their segments. Off (the default),
|
||||
/// Clear opens the path there.
|
||||
pub delete_keeps_paths_joined: bool,
|
||||
/// General › Double-Click Adds Anchor Points: on, a plain double-click on a path segment with
|
||||
/// Direct Selection adds an anchor there. Off (the default), the double-click adds nothing.
|
||||
pub double_click_adds_anchor_points: bool,
|
||||
pub use_precise_cursors: bool,
|
||||
pub show_tool_tips: bool,
|
||||
/// General › Show Tool Cards: with tool tips on, a tool button's tool tip is a card with what the
|
||||
@@ -486,6 +489,7 @@ impl Default for Prefs {
|
||||
disable_auto_add_delete: false,
|
||||
interpolate_control_points: false,
|
||||
delete_keeps_paths_joined: false,
|
||||
double_click_adds_anchor_points: false,
|
||||
use_precise_cursors: false,
|
||||
show_tool_tips: true,
|
||||
show_tool_cards: false,
|
||||
|
||||
@@ -54,6 +54,7 @@ mod distort;
|
||||
mod docsetup;
|
||||
mod document_close;
|
||||
mod document_move;
|
||||
mod double_click_adds_anchor;
|
||||
mod draw2;
|
||||
mod dynamic_symbols;
|
||||
mod dynamic_text;
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//! General › Double-Click Adds Anchor Points (`doubleClickAddsAnchorPoints`). With it on, a
|
||||
//! Direct Selection double-click on a path segment adds an anchor there. Off (the default), the
|
||||
//! double-click adds nothing.
|
||||
|
||||
use serde_json::json;
|
||||
use vectorcraft_geom::kurbo::ParamCurveNearest;
|
||||
use vectorcraft_geom::{ParamCurve, PathData, Point};
|
||||
use vectorcraft_tools::{PointerEvent, PointerKind};
|
||||
|
||||
use super::history;
|
||||
use crate::*;
|
||||
|
||||
fn session() -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 800, "height": 600})).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
fn set_pref(s: &mut Session, key: &str, on: bool) {
|
||||
s.execute("prefs.set", &json!({"key": key, "value": on})).unwrap();
|
||||
}
|
||||
|
||||
fn path_of(s: &Session, id: NodeId) -> Option<PathData> {
|
||||
s.doc().unwrap().doc.node(id).and_then(|n| n.path_data().cloned())
|
||||
}
|
||||
|
||||
fn points(s: &Session, id: NodeId) -> Vec<Point> {
|
||||
path_of(s, id).unwrap().subpaths.iter().flat_map(|sp| sp.anchors.iter().map(|a| a.p)).collect()
|
||||
}
|
||||
|
||||
/// Two clicks and the double-click that follows them, with Direct Selection, at `at`. On a segment
|
||||
/// the clicks select it, so the double-click finds its path selected.
|
||||
fn double_click(s: &mut Session, at: Point) {
|
||||
let v = ViewInfo::default();
|
||||
s.select_tool("directSelection", v).unwrap();
|
||||
for kind in [PointerKind::Down, PointerKind::Up, PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick] {
|
||||
s.pointer(&PointerEvent::new(kind, at.x, at.y), v).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
/// An open curve from (100, 300) to (300, 300) whose middle, at t = 0.5, is (200, 225).
|
||||
fn arch(s: &mut Session) -> NodeId {
|
||||
let anchors = json!([{"x": 100, "y": 300, "out": [100, 200]}, {"x": 300, "y": 300, "in": [300, 200]}]);
|
||||
NodeId(s.execute("path.create", &json!({ "anchors": anchors, "closed": false })).unwrap()["id"].as_u64().unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn off_by_default() {
|
||||
let s = session();
|
||||
assert!(!s.prefs.double_click_adds_anchor_points);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_the_preference_on_a_double_click_on_a_segment_adds_an_anchor_in_one_undo_step() {
|
||||
// The clicks before the double-click select the segment either way; an unselected path at the
|
||||
// double-click is covered by the tools crate's tests.
|
||||
for selected in [true, false] {
|
||||
let mut s = session();
|
||||
set_pref(&mut s, "doubleClickAddsAnchorPoints", true);
|
||||
let id = arch(&mut s);
|
||||
if !selected {
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
}
|
||||
let curve = path_of(&s, id).unwrap().subpaths[0].segment(0);
|
||||
let before = history(&s).0;
|
||||
double_click(&mut s, Point::new(200.0, 225.0));
|
||||
assert_eq!(history(&s).0, before + 1, "one undo step (selected before the clicks: {selected})");
|
||||
assert_eq!(points(&s, id).len(), 3, "an anchor is added (selected before the clicks: {selected})");
|
||||
assert!(points(&s, id)[1].distance(Point::new(200.0, 225.0)) < 0.5, "at the clicked point: {:?}", points(&s, id));
|
||||
let halves = path_of(&s, id).unwrap().subpaths[0].clone();
|
||||
for seg in 0..2 {
|
||||
for t in [0.25, 0.5, 0.75] {
|
||||
let q = ParamCurve::eval(&halves.segment(seg), t);
|
||||
let d = ParamCurveNearest::nearest(&curve, q, 1e-9).distance_sq;
|
||||
assert!(d < 1e-6, "the curve keeps its shape at {q:?}");
|
||||
}
|
||||
}
|
||||
let st = s.doc().unwrap();
|
||||
assert_eq!(st.selection.objects, vec![id]);
|
||||
assert_eq!(st.selection.anchors.get(&id), Some(&[(0, 1)].into()), "only the new anchor is selected (selected before the clicks: {selected})");
|
||||
assert!(st.selection.segments.get(&id).is_none_or(|s| s.is_empty()), "no segment stays selected");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(points(&s, id).len(), 2, "undo removes it");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_the_preference_off_a_double_click_on_a_segment_adds_nothing() {
|
||||
let mut s = session();
|
||||
let id = arch(&mut s);
|
||||
let before = history(&s).0;
|
||||
double_click(&mut s, Point::new(200.0, 225.0));
|
||||
assert_eq!(history(&s).0, before);
|
||||
assert_eq!(points(&s, id).len(), 2);
|
||||
}
|
||||
|
||||
/// The two General preferences are separate: Delete Removes Anchor Points and Keeps Paths Joined
|
||||
/// does not turn on the double-click, and the double-click preference does not change Delete.
|
||||
#[test]
|
||||
fn the_double_click_and_delete_preferences_are_separate() {
|
||||
let mut s = session();
|
||||
set_pref(&mut s, "deleteKeepsPathsJoined", true);
|
||||
let id = arch(&mut s);
|
||||
let before = history(&s).0;
|
||||
double_click(&mut s, Point::new(200.0, 225.0));
|
||||
assert_eq!(history(&s).0, before, "deleteKeepsPathsJoined alone adds no anchor");
|
||||
assert_eq!(points(&s, id).len(), 2);
|
||||
|
||||
let mut s = session();
|
||||
set_pref(&mut s, "doubleClickAddsAnchorPoints", true);
|
||||
let anchors = json!([{"x": 100, "y": 100}, {"x": 200, "y": 100}, {"x": 200, "y": 200}, {"x": 100, "y": 200}]);
|
||||
let id = NodeId(s.execute("path.create", &json!({ "anchors": anchors, "closed": true })).unwrap()["id"].as_u64().unwrap());
|
||||
s.execute("select.anchors", &json!({"id": id.0, "anchors": [[0, 1]], "mode": "set"})).unwrap();
|
||||
s.execute("edit.clear", &json!({})).unwrap();
|
||||
assert!(!path_of(&s, id).unwrap().subpaths[0].closed, "Delete still opens the path");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_select_anchor_param_must_be_a_boolean() {
|
||||
let mut s = session();
|
||||
let id = arch(&mut s);
|
||||
assert!(s.execute("path.insertAnchor", &json!({"id": id.0, "segment": 0, "selectAnchor": "yes"})).is_err());
|
||||
assert_eq!(points(&s, id).len(), 2, "a refused call changes nothing");
|
||||
}
|
||||
@@ -618,6 +618,7 @@ impl Session {
|
||||
path_only: self.prefs.object_selection_by_path_only,
|
||||
type_path_only: self.prefs.type_selection_by_path_only,
|
||||
double_click_isolate: self.prefs.double_click_to_isolate,
|
||||
double_click_adds_anchor: self.prefs.double_click_adds_anchor_points,
|
||||
select_behind: self.prefs.ctrl_click_selects_behind,
|
||||
highlight_anchors: self.prefs.highlight_anchors_on_hover,
|
||||
snap_tolerance: self.prefs.snap_to_point_tolerance,
|
||||
|
||||
@@ -284,6 +284,9 @@ pub struct ToolContext<'a> {
|
||||
/// General → Double Click To Isolate: a double-click on a group with the Selection tool
|
||||
/// isolates it.
|
||||
pub double_click_isolate: bool,
|
||||
/// General → Double-Click Adds Anchor Points: a plain double-click on a path segment with Direct
|
||||
/// Selection adds an anchor there.
|
||||
pub double_click_adds_anchor: bool,
|
||||
/// Selection & Anchor Display → Command Click to Select Objects Behind: Cmd/Ctrl-click with the
|
||||
/// Selection tool selects the object under the selected one, the next click the one under
|
||||
/// that.
|
||||
|
||||
@@ -863,6 +863,31 @@ fn segment_at(cx: &ToolContext, id: NodeId, p: Point) -> Option<SegmentHit> {
|
||||
Some(SegmentHit { si, seg, t, curved: a.has_out() || b.has_in() })
|
||||
}
|
||||
|
||||
/// With General › Double-Click Adds Anchor Points on, a plain
|
||||
/// double-click on a path segment adds an anchor there, the new anchor alone selected. The path is
|
||||
/// the one whose stroke or outline a press at `p` hits, a clipping path included. An anchor or a
|
||||
/// center point under the pointer comes first, so nothing is added (the caller has already given
|
||||
/// way to the handles, mesh points and blend spine points a press takes first). The path's own
|
||||
/// line must pass within the pick tolerance of `p`: a click on a wide stroke or on the drawn
|
||||
/// outline of an effect farther from the path adds nothing.
|
||||
fn add_anchor_at(cx: &ToolContext, ev: &PointerEvent, p: Point) -> Option<Action> {
|
||||
let m = ev.mods;
|
||||
if !cx.double_click_adds_anchor || m.shift || m.alt || m.cmd || m.ctrl {
|
||||
return None;
|
||||
}
|
||||
let (tol, point) = (cx.pick_tol(), cx.point_tol());
|
||||
if hit_anchor(cx, p, point).is_some() || hit_center(cx, p, point).is_some() {
|
||||
return None;
|
||||
}
|
||||
let h = hit_test(cx.doc, p, cx.selection_hit_options()).filter(|h| matches!(h.kind, HitKind::Stroke | HitKind::Outline))?;
|
||||
let id = cx.doc.node(h.leaf).and_then(|n| compound_part_at(n, p, tol)).unwrap_or(h.leaf);
|
||||
if !cx.doc.node(id).is_some_and(|n| matches!(n.kind, NodeKind::Path { .. })) {
|
||||
return None;
|
||||
}
|
||||
let (id, si, seg, t) = crate::draw2::segment_in(cx, [id], p, tol)?;
|
||||
Some(Action::Exec("path.insertAnchor".into(), json!({"id": id.0, "subpath": si, "segment": seg, "t": t, "selectAnchor": true})))
|
||||
}
|
||||
|
||||
impl Tool for DirectSelectionTool {
|
||||
/// The pointer hovers nothing for the tool: no bracket is highlighted.
|
||||
fn hover_ended(&mut self, _cx: &ToolContext) {
|
||||
@@ -1484,6 +1509,9 @@ impl DirectSelectionTool {
|
||||
if crate::rulerguide::guide_at(cx, p).is_some() {
|
||||
return vec![];
|
||||
}
|
||||
if let Some(a) = add_anchor_at(cx, ev, p).filter(|_| !self.takes_point(cx, p)) {
|
||||
return vec![a];
|
||||
}
|
||||
// A double-click edits what is drawn: not a clipping path's outline.
|
||||
let hit = hit_test(cx.doc, p, cx.hit_options());
|
||||
if hit.as_ref().and_then(|h| cx.doc.node(h.leaf)).is_some_and(|n| matches!(n.kind, NodeKind::Text(_))) {
|
||||
|
||||
@@ -1355,6 +1355,110 @@ fn a_double_click_outside_isolation_leaves_it() {
|
||||
assert!(DirectSelectionTool::new(false).pointer(&cx(&d, &none, &p), &PointerEvent::new(PointerKind::DoubleClick, 700.0, 700.0)).is_empty());
|
||||
}
|
||||
|
||||
/// The anchor a Direct Selection double-click at `at` adds: (path, subpath, segment, t).
|
||||
fn double_click_adds(cx: &ToolContext, at: (f64, f64), mods: Mods) -> Option<(u64, usize, usize, f64)> {
|
||||
let a = DirectSelectionTool::new(false).pointer(cx, &PointerEvent::new(PointerKind::DoubleClick, at.0, at.1).with_mods(mods));
|
||||
a.iter().find_map(|a| match a {
|
||||
Action::Exec(c, p) if c == "path.insertAnchor" => {
|
||||
assert_eq!(p["selectAnchor"], true, "the new anchor is selected: {p}");
|
||||
Some((p["id"].as_u64()?, p["subpath"].as_u64()? as usize, p["segment"].as_u64()? as usize, p["t"].as_f64()?))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// With General › Double-Click Adds Anchor Points on, a plain
|
||||
/// Direct Selection double-click on a segment of a selected or unselected path adds an anchor at
|
||||
/// the clicked point. Off, Group Selection, a modifier, an anchor or the fill add none.
|
||||
#[test]
|
||||
fn with_the_preference_on_a_double_click_on_a_segment_adds_an_anchor_there() {
|
||||
let (d, id) = doc_with_rect();
|
||||
let p = paint();
|
||||
let mut whole = Selection::default();
|
||||
whole.add(id);
|
||||
let none = Selection::default();
|
||||
let top = d.node(id).and_then(|n| n.path_data()).map(|pd| pd.subpaths[0].clone()).unwrap_or_else(|| panic!("the rectangle"));
|
||||
for sel in [&none, &whole] {
|
||||
let on = ToolContext { double_click_adds_anchor: true, ..cx(&d, sel, &p) };
|
||||
let (path, si, seg, t) = double_click_adds(&on, (150.0, 101.0), Mods::default()).unwrap_or_else(|| panic!("an anchor is added"));
|
||||
assert_eq!((path, si), (id.0, 0));
|
||||
let c = top.segment(seg);
|
||||
assert!(c.p0.y == 100.0 && c.p3.y == 100.0, "on the top edge: {c:?}");
|
||||
let at = vectorcraft_geom::ParamCurve::eval(&c, t);
|
||||
assert!(at.distance(Point::new(150.0, 100.0)) < 1e-6, "at the clicked point: {at:?}");
|
||||
assert_eq!(double_click_adds(&on, (100.0, 100.0), Mods::default()), None, "on an anchor");
|
||||
assert_eq!(double_click_adds(&on, (150.0, 150.0), Mods::default()), None, "in the middle of the fill");
|
||||
for m in [Mods { shift: true, ..Mods::default() }, Mods { alt: true, ..Mods::default() }, Mods { cmd: true, ..Mods::default() }] {
|
||||
assert_eq!(double_click_adds(&on, (150.0, 101.0), m), None, "with {m:?}");
|
||||
}
|
||||
let group = DirectSelectionTool::new(true).pointer(&on, &PointerEvent::new(PointerKind::DoubleClick, 150.0, 101.0));
|
||||
assert!(group.is_empty(), "Group Selection: {group:?}");
|
||||
let off = cx(&d, sel, &p);
|
||||
assert!(DirectSelectionTool::new(false).pointer(&off, &PointerEvent::new(PointerKind::DoubleClick, 150.0, 101.0)).is_empty(), "off");
|
||||
}
|
||||
// On a 40 pt stroke 15 pt above the path, the stroke is hit but the path is out of reach.
|
||||
let mut wide = d.clone();
|
||||
if let Some(s) = wide.node_mut(id).and_then(|n| n.appearance.stroke_mut()) {
|
||||
s.width = 40.0;
|
||||
}
|
||||
let on = ToolContext { double_click_adds_anchor: true, ..cx(&wide, &none, &p) };
|
||||
assert!(hit_test(&wide, Point::new(150.0, 85.0), on.selection_hit_options()).is_some_and(|h| matches!(h.kind, HitKind::Stroke)));
|
||||
assert_eq!(double_click_adds(&on, (150.0, 85.0), Mods::default()), None, "away from the path");
|
||||
assert!(double_click_adds(&on, (150.0, 101.0), Mods::default()).is_some(), "on the path");
|
||||
// Without a stroke, the edge is taken within the tolerance, and the fill just past it is not.
|
||||
let mut unstroked = d.clone();
|
||||
if let Some(n) = unstroked.node_mut(id) {
|
||||
n.appearance.set_stroke(vectorcraft_color::Paint::None);
|
||||
}
|
||||
let on = ToolContext { double_click_adds_anchor: true, ..cx(&unstroked, &none, &p) };
|
||||
assert!(double_click_adds(&on, (150.0, 101.0), Mods::default()).is_some(), "on the edge of the fill");
|
||||
assert!(hit_test(&unstroked, Point::new(150.0, 104.0), on.selection_hit_options()).is_some_and(|h| matches!(h.kind, HitKind::Fill)));
|
||||
assert_eq!(double_click_adds(&on, (150.0, 104.0), Mods::default()), None, "on the fill past the tolerance");
|
||||
}
|
||||
|
||||
/// With the preference on, a double-click on a segment of a path in a group adds the anchor to
|
||||
/// that path; on the group's fill it does what it did before (nothing), and outside isolated art it
|
||||
/// still leaves isolation mode.
|
||||
#[test]
|
||||
fn with_the_preference_on_a_double_click_in_a_group_adds_only_on_a_segment() {
|
||||
let (d, inside, outside, inner, _) = nested_group_doc();
|
||||
let p = paint();
|
||||
let none = Selection::default();
|
||||
let on = ToolContext { double_click_adds_anchor: true, ..cx(&d, &none, &p) };
|
||||
assert_eq!(double_click_adds(&on, (150.0, 101.0), Mods::default()).map(|a| a.0), Some(inside.0));
|
||||
assert_eq!(double_click_adds(&on, (350.0, 301.0), Mods::default()).map(|a| a.0), Some(outside.0));
|
||||
assert!(DirectSelectionTool::new(false).pointer(&on, &PointerEvent::new(PointerKind::DoubleClick, 150.0, 150.0)).is_empty(), "the fill");
|
||||
let isolated = ToolContext { isolation: Some(inner), ..on };
|
||||
assert_eq!(double_click_adds(&isolated, (150.0, 101.0), Mods::default()).map(|a| a.0), Some(inside.0), "isolated art");
|
||||
let exit = vec![Action::Exec("object.exitIsolation".into(), json!({}))];
|
||||
assert_eq!(DirectSelectionTool::new(false).pointer(&isolated, &PointerEvent::new(PointerKind::DoubleClick, 350.0, 301.0)), exit);
|
||||
}
|
||||
|
||||
/// With the preference on, a double-click on a blend's spine point, which a press takes before the
|
||||
/// path under it, adds no anchor to that path; on the same path away from the spine point it does.
|
||||
/// A clipping path's segment, which a press takes over the art it clips, gets the anchor.
|
||||
#[test]
|
||||
fn with_the_preference_on_a_double_click_gives_way_to_spine_points_and_reaches_clipping_paths() {
|
||||
let (mut d, _) = doc_with_rect();
|
||||
let l = d.layers[0].id;
|
||||
let key = |id: NodeId, x: f64| {
|
||||
let line = vectorcraft_geom::shapes::line(Point::new(x, 310.0), Point::new(x + 40.0, 310.0));
|
||||
std::sync::Arc::new(vectorcraft_doc::Node::path(id, line, vectorcraft_doc::Appearance::default_art()))
|
||||
};
|
||||
let (g, k1, k2) = (d.alloc_id(), d.alloc_id(), d.alloc_id());
|
||||
let b = vectorcraft_doc::Node::new(g, NodeKind::Blend { children: vec![key(k1, 100.0), key(k2, 200.0)], spec: Default::default() });
|
||||
d.insert(Some(l), 1, b).unwrap();
|
||||
let p = paint();
|
||||
let none = Selection::default();
|
||||
let on = ToolContext { double_click_adds_anchor: true, ..cx(&d, &none, &p) };
|
||||
assert_eq!(double_click_adds(&on, (130.0, 310.0), Mods::default()).map(|a| a.0), Some(k1.0), "on the line");
|
||||
assert_eq!(double_click_adds(&on, (120.0, 310.0), Mods::default()), None, "on the spine point at its center");
|
||||
|
||||
let (d, _, clip, _) = doc_with_masked_square();
|
||||
let on = ToolContext { double_click_adds_anchor: true, ..cx(&d, &none, &p) };
|
||||
assert_eq!(double_click_adds(&on, (500.0, 450.0), Mods::default()).map(|a| a.0), Some(clip.0), "on the clipping path");
|
||||
}
|
||||
|
||||
/// With Direct Selection, an Alt-click on a path selected whole adds its group on release, and
|
||||
/// each further Alt-click adds the next group up, as Group Selection's clicks do, on an anchor,
|
||||
/// a segment and the fill alike. The climb stops below the layer and at the isolated group.
|
||||
|
||||
@@ -653,6 +653,7 @@ pub(crate) mod testutil {
|
||||
path_only: false,
|
||||
type_path_only: false,
|
||||
double_click_isolate: true,
|
||||
double_click_adds_anchor: false,
|
||||
select_behind: true,
|
||||
highlight_anchors: true,
|
||||
snap_tolerance: 2.0,
|
||||
|
||||
@@ -42,6 +42,7 @@ pub(crate) const DESCRIPTIONS: &[(&str, &str)] = &[
|
||||
("trackpadRotateView", "A two-finger rotate gesture on a trackpad rotates the canvas view."),
|
||||
("interpolateControlPoints", "When you move anchor points, each curve with one moved end keeps its shape relative to its ends."),
|
||||
("deleteKeepsPathsJoined", "Delete removes the selected anchor points and refits the curve around each one, instead of opening the path there."),
|
||||
("doubleClickAddsAnchorPoints", "Double-clicking a path segment with the Direct Selection tool adds an anchor point there."),
|
||||
("holdToolKeys", "Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again."),
|
||||
("holdShortcuts", "Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut."),
|
||||
("keyHoldDelay", "How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut."),
|
||||
|
||||
+14
-4
@@ -7126,7 +7126,8 @@ same way for a blend's spine point; without `handle` it is refused. These rules
|
||||
`path.insertAnchor` keeps the direct-selected anchors and selected segments of the path on the same points: those
|
||||
after the new anchor on its subpath are numbered one higher, and a selected segment that the new anchor splits stays
|
||||
selected as its two halves, with the new anchor as an end of both that moves with them. Undo restores the path and
|
||||
the selection in one step.
|
||||
the selection in one step. With `selectAnchor: true` the path becomes the selection with only the new anchor
|
||||
direct-selected, also when the path was selected; a `selectAnchor` value that is not a boolean is an error.
|
||||
`path.close {id, subpath?, at?, in?, out?, independent?}` closes an open subpath (by default the last open one). `at`
|
||||
moves the first anchor to `[x, y]`, its handles with it, before `in` and `out` are placed. `in` places
|
||||
the first anchor's incoming handle as `path.setHandle` places a handle: a smooth anchor turns its outgoing handle to
|
||||
@@ -8517,9 +8518,18 @@ The Selection & Anchor Display and General preferences apply to `pointer_gesture
|
||||
- `deleteKeepsPathsJoined` (General › Delete Removes Anchor Points and Keeps Paths Joined, off by default): the
|
||||
default of the `keepJoined` param of `edit.clear` (Delete, Backspace, Edit › Clear, and the Layers panel's Delete
|
||||
button while no row is highlighted). On, Delete removes the direct-selected anchors of a path as `path.removeAnchors` does, refitting the curve
|
||||
around each one, so a closed path stays closed and an open path stays in one piece; a path left with fewer than two
|
||||
anchors is deleted. The next anchor along (the one before at an open path's end) is then selected, so the next
|
||||
Delete goes on along the path. Off, Delete deletes the anchors with their segments and opens the path there.
|
||||
around each one, so a closed path stays closed and an open path stays in one piece. The next anchor along (the one
|
||||
before at an open path's end) is then selected, so the next Delete goes on along the path. When no subpath that lost
|
||||
an anchor keeps two anchors, the path stays selected whole, and the next Delete removes it. Off, Delete deletes the anchors with their segments and opens the path there.
|
||||
- `doubleClickAddsAnchorPoints` (General › Double-Click Adds Anchor Points, off by default): on, a double-click
|
||||
without modifier keys on a path segment with Direct Selection adds an anchor at the
|
||||
clicked point (`path.insertAnchor` with `selectAnchor: true`): the curve keeps its shape, the new anchor alone is
|
||||
selected, and the change is one undo step. The double-click takes the path whose stroke or outline is under the
|
||||
pointer, selected or not, in a group or in isolation mode, a clipping path included, and the path's own line must
|
||||
pass within the Selection & Anchor Display tolerance of the pointer. A double-click on an anchor, a direction
|
||||
handle, a center point, a mesh point or a blend's spine point, on a fill, or on a wide stroke or an effect's outline
|
||||
farther from the path, adds nothing and does what it did before. Group Selection is unchanged. Off, a Direct
|
||||
Selection double-click on a segment adds nothing.
|
||||
- `hideCornerWidgetAbove` (177° by default): corners wider than this show no Live Corners widget (a rectangle's right
|
||||
angles hide below 90°).
|
||||
- `transformPatternTiles` (off by default): the default of the transforms' `patterns` param (`object.transform`,
|
||||
|
||||
@@ -1496,6 +1496,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
With Direct Selection and Group Selection, a drag that starts on an object while the selection also holds direct-selected anchors or segments moves those anchors and the objects selected whole in one undo step (`path.moveAnchors`), as a drag of a selected anchor does, and the other anchors of a partly selected path stay in place. While Alt is held during the drag, it copies the selected objects instead (`object.transform`). When direct-selected anchors are moved or transformed together with objects selected whole (such a drag, an anchor drag, an arrow key, or Move, Rotate, Scale, Reflect and Shear without a copy), a path inside a selected group is transformed once, with the group.
|
||||
VectorCraft's own preference General › Interpolate Control Points When Moving Anchors (`interpolateControlPoints`, off by default, fixes #7832): on, a Direct Selection drag, an arrow-key nudge, a Move or a Transform Again of selected anchors re-maps both handles of each segment with one moved end by the turn, uniform scale and move that take its old ends to its new ends, so a segment between corner anchors keeps its shape; a segment with both ends moved, or with its ends at the same place before or after the move, moves rigidly, and a smooth anchor keeps its handles in line. The commands take an `interpolate` param that defaults to the preference, and the value used joins the journal and Transform Again. Each drag or nudge is one undo step (`a_nudge_with_the_preference_on_re_maps_both_handles_of_the_segment`, `a_direct_selection_drag_with_the_preference_on_re_maps_the_handles_in_one_undo_step`, `a_smooth_anchor_keeps_its_handles_in_line`).
|
||||
VectorCraft's own preference General › Delete Removes Anchor Points and Keeps Paths Joined (`deleteKeepsPathsJoined`, off by default, part of #8326): on, Delete, Backspace and Edit › Clear remove the direct-selected anchors of each path as Remove Anchor Points does, refitting the curve around each one, so a closed path stays closed and an open path stays in one piece; the next anchor along (the one before at an open path's end) is selected, so the next Delete goes on along the path. Paths with a selected segment are still cut there, objects selected whole are still deleted, and a path left with fewer than two anchors goes, in one undo step. `edit.clear` takes a `keepJoined` param that defaults to the preference, and the value used joins the journal (`with_the_preference_on_delete_keeps_a_closed_path_closed_and_selects_the_next_anchor`, `several_paths_and_an_object_selected_whole_change_in_one_undo_step`, `with_the_preference_on_delete_and_backspace_keep_the_path_joined`).
|
||||
VectorCraft's own preference General › Double-Click Adds Anchor Points (`doubleClickAddsAnchorPoints`, off by default, part of #8326): on, a double-click without modifier keys on a path segment with Direct Selection adds an anchor at the clicked point, keeping the curve's shape, with only the new anchor selected, in one undo step (`path.insertAnchor` with `selectAnchor`); on an anchor, a handle, a center point, a blend's spine point or a fill the double-click does what it did before, and a clipping path's segment gets the anchor (`with_the_preference_on_a_double_click_on_a_segment_adds_an_anchor_there`, `with_the_preference_on_a_double_click_in_a_group_adds_only_on_a_segment`, `with_the_preference_on_a_double_click_gives_way_to_spine_points_and_reaches_clipping_paths`, `with_the_preference_on_a_double_click_on_a_segment_adds_an_anchor_in_one_undo_step`, `the_double_click_and_delete_preferences_are_separate`).
|
||||
A path segment with a control point whose x or y is infinite or larger in size than `f64::MAX / 16` is measured by its control points, so its bounds hold the whole curve and the canvas check refuses an edit that leaves such a path selected (`path.create` included).
|
||||
With Direct Selection, the Pen and the anchor tools, a group, compound path or clip group selected whole shows the anchors of its paths filled, as a path selected whole does; the direction handles still show only on a path that is selected itself. Public references: [Adjust anchor point, handle, and bounding box display size](https://web.archive.org/web/20251114182206/https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/adjust-anchor-point-handle-and-bounding-box-display-size.html) and [Drawing basics](https://web.archive.org/web/20231130064834/https://helpx.adobe.com/illustrator/using/drawing-basics.html) (archived copies).
|
||||
When the Add Anchor Point tool, the Pen's Auto Add, the Smart Pen's Alt-click on a segment or Alt-click with the Scissors adds an anchor to a path with direct-selected anchors or segments (`path.insertAnchor`), the same points stay selected: the anchors and segments after the new anchor are numbered one higher, and a selected segment that the new anchor splits stays selected as its two halves.
|
||||
|
||||
Reference in New Issue
Block a user