DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge upstream main a930276 into tool-cursors: Pen continue resolved into the hover model
aionggfdd5da9c0e45
diff --cc crates/tools/src/pen.rsindex e7df8a958,6fe1289b5..4d953edcf--- a/crates/tools/src/pen.rs+++ b/crates/tools/src/pen.rs@@@ -1,8 -1,6 +1,8 @@@-//! InDesign. Clicking an end point of an open path (the cursor shows it) continues that path from-//! there; dragging from it first reshapes its direction lines. Between paths, a click on a selected-//! path's anchor deletes it and a click on its outline adds an anchor; the cursor shows which.+//! Pen tool (P): click for corner points, drag for smooth points, click the first point to close,- //! Enter/Esc (or switching tools) to finish an open path. Each anchor is its own undo step, as in- //! InDesign. Between paths, a click on a selected path's anchor deletes it and a click on its- //! outline adds an anchor; clicking an end point of an open path continues that path from there- //! (dragging from it first reshapes its direction lines). The cursor shows which.++//! Enter/Esc (or switching tools) to finish an open path. Each anchor is its own undo step.++//! Between paths, a click on a selected path's anchor deletes it and a click on its outline adds an++//! anchor; clicking an end point of an open path continues that path from there (dragging from it++//! first reshapes its direction lines). The cursor shows which.use designcraft_doc::{ItemId, SpreadRef};use designcraft_geom::{BezPath, Point};diff --cc crates/tools/src/tests.rsindex 1b656b3ae,aacfb8d3f..c7ac59558--- a/crates/tools/src/tests.rs+++ b/crates/tools/src/tests.rs@@@ -1106,6 -1091,6 +1091,32 @@@ fn pen_continues_an_open_path_from_eithassert_eq!(t.cursor(&cx, Point::new(at(200.0, 100.0).0, at(200.0, 100.0).1), Mods::default()), Cursor::Pen);}++#[test]++fn pen_over_a_selected_open_paths_end_point_continues_it() {++ let mut d = Document::new(&NewDocument::default());++ let lid = d.default_layer();++ let id = ItemId(d.alloc());++ let anchors = vec![++ designcraft_geom::Anchor::corner(Point::new(100.0, 100.0)),++ designcraft_geom::Anchor::corner(Point::new(200.0, 100.0)),++ designcraft_geom::Anchor::corner(Point::new(200.0, 200.0)),++ ];++ let mut it = Item::new(id, lid, Shape::Path, designcraft_geom::PathData::single(designcraft_geom::SubPath::new(anchors, false)));++ it.stroke = Stroke::default();++ d.insert_item(SpreadRef::Doc(0), it, None).unwrap();++ let (s, c, l) = (Selection::items(vec![id]), Cache::new(), CanvasLayout::new(&d, false));++ let cx = ctx(&d, &s, &c, &l);++ let off = l.xf(SpreadRef::Doc(0)).translation();++ let at = |x: f64, y: f64| Point::new(x + off.x, y + off.y);++ let mut t = create("pen");++ // The end point wins over deleting the selected path's anchor; a middle anchor still deletes.++ assert_eq!(t.cursor(&cx, at(200.0, 200.0), Mods::default()), Cursor::PenContinue);++ assert_eq!(t.cursor(&cx, at(200.0, 100.0), Mods::default()), Cursor::PenDelete);++ let p = at(200.0, 200.0);++ assert!(t.pointer(&cx, &PointerEvent::new(PointerKind::Down, p.x, p.y)).is_empty(), "no anchor is deleted");++ assert!(t.busy(), "the path is being continued");++}++#[test]fn the_selection_tool_drags_a_path_type_bracket_along_its_path() {let mut d = Document::new(&NewDocument::default());diff --cc crates/ui-egui/src/cursors.rsindex 9960e2792,15e63a732..566fe65f9--- a/crates/ui-egui/src/cursors.rs+++ b/crates/ui-egui/src/cursors.rs@@@ -1,6 -1,6 +1,6 @@@//! Tool cursors drawn in code: black glyphs with a white halo, so they read on any page colour.//! The Selection tool's filled arrow, Direct Selection's hollow arrow, the pen nib with a badge for--//! what a click does (add, delete, close, convert), and a curved double arrow for rotating.++//! what a click does (add, delete, close, convert, continue), and a curved double arrow for rotating.//! Cursors without a glyph stay system cursors.//!//! Linux and Windows show the glyphs as OS cursors ([`Images`]): the system moves them itself, so