From 315dcd64e0c06f0c992e639d494ec550fa2e0fee Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Tue, 24 Nov 2026 21:30:56 +0100 Subject: [PATCH] fix(vector): the options bar follows a Pen path drawn click by click (#12890) The options bar is a version-gated region: it replays its last render while its version holds. A Pen drawing click by click into the live Work Path changes which path the bar's "Make" row works from without adding a History step, so the version held and the bar went on answering for the path that was being drawn: Enter hid the Work Path and the buttons stayed live. The bar's version now stands for the Pen draft, the Work Path a finish showed or hid, and the Paths panel's selection. Every finish used to write a step, which is what kept this hidden. Three gates on the same route: a pick-up whose write the document refuses no longer leaves a live path behind, so the draft keeps its anchors and the finish takes them, as before; a Work Path that a finish hid cannot be carried on from, which is what `resume_target` already refuses for the press itself; and Undo over a live draft with no anchors of its own lets the draft go instead of taking a step for an anchor the draft never had. --- crates/ui-egui/src/panels/region_versions.rs | 11 +++++++---- crates/ui-egui/src/tools/vector_ui/host.rs | 7 +++++++ crates/ui-egui/src/tools/vector_ui/pen.rs | 17 ++++++++++++----- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/panels/region_versions.rs b/crates/ui-egui/src/panels/region_versions.rs index 4d2a087910..022e8e0af0 100644 --- a/crates/ui-egui/src/panels/region_versions.rs +++ b/crates/ui-egui/src/panels/region_versions.rs @@ -65,17 +65,20 @@ pub(crate) fn show_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: &str) { /// The version of the options bar: every tool option (`app.ui.tool_options`, all of which the bar shows; keys, the /// canvas menu, the canvas and its task bars, panels and presets write them without a command), the commit and cancel /// cells and hints of an edit the canvas opens or ends ([`options_bar::edit_key`](super::options_bar::edit_key)), the -/// Zoom tool's view, and an open Free Transform, Puppet Warp or Perspective Warp, which shows its own members in place +/// Zoom tool's view, an open Free Transform, Puppet Warp or Perspective Warp, which shows its own members in place /// of the tool's, with what a drag on the canvas changes (the box, the picked pin, the planes; Escape ends them without -/// a command, #15547), the Crop tool's frame state, the type members' caret or selection, the brush and its presets and -/// the colours. +/// a command, #15547), the Crop tool's frame state, the type members' caret or selection, the brush and its presets, the +/// colours, and the path the vector bar's "Make" row works from (a Pen draft, the Work Path a finish showed or hid +/// (#12892) and the Paths panel's selection), which a Pen drawing click by click changes without a History step +/// (#12890). pub(crate) fn options_bar(app: &PhotocraftApp) -> u64 { let sessions = (crate::transform_tool::bar_key(app), crate::puppet_ui::bar_key(app), crate::perspective_ui::bar_key(app), crate::crop_ui::bar::bar_key(app)); let shown = (serialized(&app.ui.tool_options), super::options_bar::edit_key(app), text_target(app)); // A canvas gesture's start and end change what the bar enables (the symmetry menu's Transform entry). let gesture = crate::canvas::tools::in_gesture(app); - version(app, (view(app), sessions, shown, brush(app), colours(app), gesture)) + let paths = (app.ui.pen.as_ref().map(|p| p.draft.knots.len()), app.ui.selected_path.clone(), serialized(&app.ui.hidden_work_path)); + version(app, (view(app), sessions, shown, brush(app), colours(app), gesture, paths)) } /// The version of the title bar: the title it shows (the active document's name and its unsaved mark), the language diff --git a/crates/ui-egui/src/tools/vector_ui/host.rs b/crates/ui-egui/src/tools/vector_ui/host.rs index 5d70676aef..3835c76594 100644 --- a/crates/ui-egui/src/tools/vector_ui/host.rs +++ b/crates/ui-egui/src/tools/vector_ui/host.rs @@ -215,6 +215,13 @@ pub(crate) fn remove_last(app: &mut PhotocraftApp) -> bool { return false; } let Some(pen) = app.ui.pen.as_ref() else { return false }; + // A live draft with no anchors of its own has nothing of its own for Undo to take: its path already holds what was + // drawn, so the draft simply goes and History takes the real step instead, as the tool's own EmptyDraft end does + // (#12890). + if (pen.live_layer || pen.live_path) && pen.draft.knots.is_empty() { + drop_draft(app); + return false; + } // A live shape layer's anchors are History steps (#12909): Undo takes back the last one the layer took. Anchors it // refused are the draft's alone, and the Pen takes those back first, one by one. A live Work Path is the same, one // step per click (#12890). diff --git a/crates/ui-egui/src/tools/vector_ui/pen.rs b/crates/ui-egui/src/tools/vector_ui/pen.rs index 85ba45bac4..53777bec40 100644 --- a/crates/ui-egui/src/tools/vector_ui/pen.rs +++ b/crates/ui-egui/src/tools/vector_ui/pen.rs @@ -609,7 +609,9 @@ pub(super) fn start_live_path(app: &mut PhotocraftApp) { /// Is `pen` a draft carried on from the end point of an open subpath of the Work Path, drawn live like a fresh one /// (#12890)? The press that picked it up is the step "Pick-up Path". The Curvature Pen and Freeform Pen, a saved path, -/// a vector mask and the other Path Operations were not measured and keep today's route. +/// a vector mask and the other Path Operations were not measured and keep today's route. A Work Path that a finish hid +/// (#12892) is not drawn, so nothing can be carried on from it: `resume_target` refuses it the same way, and minting +/// from it here would put a live path back beside a hidden one. fn carries_on_live_path(app: &PhotocraftApp, pen: &PenPath) -> bool { !pen.curvature && !pen.live_layer @@ -619,6 +621,7 @@ fn carries_on_live_path(app: &PhotocraftApp, pen: &PenPath) -> bool { && app.ui.tool_options.vector_mode == VectorMode::Path && pen_path_op(&app.ui.tool_options) == Some("combine") && targeted_vector_mask(app).is_none() + && work_path_shown(app) && pen.resumes.as_ref().is_some_and(|r| r.layer.is_none() && r.path == "work") } @@ -631,11 +634,15 @@ pub(super) fn pick_up_live_path(app: &mut PhotocraftApp) { let drawn = path_json(&pen_path(pen)); let (name, full) = (r.path.clone(), app.session.active().and_then(|st| with_resumed_subpath(&st.doc, r, &drawn))); let Some(full) = full else { return }; - if let Some(pen) = app.ui.pen.as_mut() { - pen.live_path = true; - } match run_beside_draft(app, "path.set", json!({"name": name, "path": full, "historyName": "Pick-up Path"})) { - Ok(_) => follow_live_layer(app), + // Only a write that went through makes the draft live: a refused one keeps today's route, with the anchors in + // the draft and the finish taking them, and leaves no live path behind (#12890). + Ok(_) => { + if let Some(pen) = app.ui.pen.as_mut() { + pen.live_path = true; + } + follow_live_layer(app); + } Err(e) => { app.ui.status = e; app.ui.status_error = true;