Pen: the new-path asterisk leaves the pointer once a path is started

The Pen's pointer showed the new-path asterisk before the first anchor
and also while a path was being drawn, where a click adds the path's
next anchor. A new Cursor::PenDrawing, the pen nib without a badge, now
shows there. The close, convert and join badges still show over the
first anchor, the last anchor and another open path's end. The asterisk
shows only where a click starts a new path.

The Continue, Add and Delete badges now also show after another path
was selected while the Pen was still drawing (for example with a
Cmd-click). A click there already continued the path or added or
deleted an anchor, but the pointer showed the asterisk.
This commit is contained in:
dotCooCoo
2026-10-16 02:26:06 +07:00
committed by bflatastic
parent 35f43d631f
commit ff33e0556f
8 changed files with 104 additions and 13 deletions
+27 -2
View File
@@ -1051,7 +1051,7 @@ fn pen_with_cmd_borrows_direct_selection_and_goes_on_drawing() {
gesture(&mut s, &[(100.0, 300.0)], none);
gesture(&mut s, &[(200.0, 300.0), (250.0, 300.0)], none);
let id = s.doc().unwrap().selection.objects[0];
assert_eq!(s.cursor(Point::new(250.0, 300.0), none, v), vectorcraft_tools::Cursor::Pen);
assert_eq!(s.cursor(Point::new(250.0, 300.0), none, v), vectorcraft_tools::Cursor::PenDrawing);
assert_eq!(s.cursor(Point::new(250.0, 300.0), cmd, v), vectorcraft_tools::Cursor::ArrowHollow, "Direct Selection's");
// The new anchor's outgoing handle: it moves, its incoming one turning with it.
s.pointer(&PointerEvent::new(PointerKind::Down, 250.0, 300.0).with_mods(cmd), v).unwrap();
@@ -1089,6 +1089,31 @@ fn pen_with_cmd_borrows_direct_selection_and_goes_on_drawing() {
assert_eq!(s.tool_id(), "rectangle");
}
#[test]
fn the_pen_drops_the_new_path_asterisk_once_a_path_is_started() {
// The Pen's asterisk means a click starts a new path: it shows until the first anchor is
// placed, the pen has no badge while the path is drawn, and the asterisk comes back once the
// path is finished (Enter, or a click on the first anchor that closes it).
use vectorcraft_tools::Cursor;
let (none, v) = (Mods::default(), view());
let empty = Point::new(500.0, 500.0);
let mut s = session();
s.select_tool("pen", v).unwrap();
assert_eq!(s.cursor(empty, none, v), Cursor::Pen);
gesture(&mut s, &[(100.0, 300.0)], none);
assert_eq!(s.cursor(empty, none, v), Cursor::PenDrawing, "after the first anchor");
gesture(&mut s, &[(200.0, 300.0)], none);
assert_eq!(s.cursor(empty, none, v), Cursor::PenDrawing);
s.tool_key(ToolKey::Enter, none, v).unwrap();
assert_eq!(s.cursor(empty, none, v), Cursor::Pen, "Enter finished the path");
gesture(&mut s, &[(100.0, 400.0)], none);
gesture(&mut s, &[(200.0, 400.0)], none);
gesture(&mut s, &[(150.0, 450.0)], none);
assert_eq!(s.cursor(Point::new(100.0, 400.0), none, v), Cursor::PenClose);
gesture(&mut s, &[(100.0, 400.0)], none);
assert_eq!(s.cursor(empty, none, v), Cursor::Pen, "closing finished the path");
}
#[test]
fn reshaping_a_segment_keeps_smooth_anchors_smooth() {
// #494: the anchors at the ends of a dragged segment keep their kind: a smooth one's other
@@ -1176,7 +1201,7 @@ fn the_pen_continues_any_open_path_and_joins_another() {
gesture(&mut s, &[(200.0, 100.0)], none);
assert_eq!(s.doc().unwrap().selection.objects, vec![a]);
assert_eq!(s.cursor(Point::new(300.0, 200.0), none, v), Cursor::PenJoin);
assert_eq!(s.cursor(Point::new(350.0, 200.0), none, v), Cursor::Pen, "the middle of the other path");
assert_eq!(s.cursor(Point::new(350.0, 200.0), none, v), Cursor::PenDrawing, "the middle of the other path");
// #1009: Use Precise Cursors makes the join pointer a crosshair too.
s.execute("prefs.set", &json!({"key": "usePreciseCursors", "value": true})).unwrap();
assert_eq!(s.cursor(Point::new(300.0, 200.0), none, v), Cursor::Crosshair);
+1
View File
@@ -453,6 +453,7 @@ fn precise_cursors_replace_every_pen_state() {
use vectorcraft_tools::Cursor;
for c in [
Cursor::Pen,
Cursor::PenDrawing,
Cursor::PenAdd,
Cursor::PenDelete,
Cursor::PenClose,