Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge PR #8243: Pen: ⌥/Alt-drag grabs the last anchor's incoming handle too (#6077)

aiongga036d9630233
diff --cc crates/ui-egui/src/vector_ui.rs
index 78be5262c,ae91497d1..71688e6b9
--- a/crates/ui-egui/src/vector_ui.rs
+++ b/crates/ui-egui/src/vector_ui.rs
@@@ -237,21 -225,9 +240,22 @@@ pub fn closes_path_at(app: &PhotocraftA
/// or add a new anchor (dragging a new anchor pulls symmetrical handles). With ⇧ a new anchor
/// lands on the nearest 45° ray from the previous one, at the pointer's projection onto it.
pub fn pen_down(app: &mut PhotocraftApp, x: f64, y: f64, shift: bool) {
+ if !cancel_stale(app) {
+ return;
+ }
let tol = 6.0 / app.point_zoom().max(0.01) as f64;
+ if app.ui.pen.is_none() {
+ app.ui.pen_doc = app.session.active().map(|st| st.doc.id);
+ }
+ // A press on an endpoint of an open path carries on drawing it, as in Photoshop (#6593): the
+ // press then acts on its last anchor, so a drag pulls out the next segment's handle.
+ if app.ui.pen.as_ref().is_none_or(|p| p.knots.is_empty())
+ && let Some(resumed) = resume_at(app, x, y, tol)
+ {
+ app.ui.pen = Some(resumed);
+ }
let pen = app.ui.pen.get_or_insert_with(PenPath::default);
+ pen.adjusting_in = false;
if let Some(first) = pen.knots.first().map(|k| k[0])
&& on_closing_anchor(pen, x, y, tol)
{