From 39a3bc53771d4ae83e6be7531cb432feaa578850 Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Tue, 24 Nov 2026 22:45:41 +0100 Subject: [PATCH] fix(vector): keep the options bar's new ingredients cheap (#12890) The hidden Work Path went into the region's version through its serialized form, which hashes a whole path every frame inside the memo system. Hold its place instead: which document is active and which document's path is hidden. A hidden path's content can only change with the document's revision, which every version already holds, and hiding or showing one moves that pair. Corrects the ingredient list from the previous commit: the Paths panel's selection is already hashed by the version every region shares, where `the_tool_and_the_target_move_every_version` pins it, so the bar's own list drops it instead of hashing it twice. --- crates/ui-egui/src/panels/region_versions.rs | 10 ++++++---- .../src/tools/vector_ui/pen_history_steps_tests.rs | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/panels/region_versions.rs b/crates/ui-egui/src/panels/region_versions.rs index 022e8e0af0..daa4d3047b 100644 --- a/crates/ui-egui/src/panels/region_versions.rs +++ b/crates/ui-egui/src/panels/region_versions.rs @@ -68,16 +68,18 @@ pub(crate) fn show_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: &str) { /// 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, 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). +/// colours, and the vector bar's "Make" row's own two ingredients: the Pen draft's anchor count and the Work Path the +/// app hides (#12892), which a Pen drawing click by click changes with no History step (#12890). Which path is +/// selected is already in [`version`]; the hidden path is held as its document's place, since its content can only +/// change with the document's revision, which `version` holds too. 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); - let paths = (app.ui.pen.as_ref().map(|p| p.draft.knots.len()), app.ui.selected_path.clone(), serialized(&app.ui.hidden_work_path)); + let hidden = app.session.active().map(|st| (st.doc.id.0, app.ui.hidden_work_path.as_ref().map(|(id, _)| *id))); + let paths = (app.ui.pen.as_ref().map(|p| p.draft.knots.len()), hidden); version(app, (view(app), sessions, shown, brush(app), colours(app), gesture, paths)) } diff --git a/crates/ui-egui/src/tools/vector_ui/pen_history_steps_tests.rs b/crates/ui-egui/src/tools/vector_ui/pen_history_steps_tests.rs index c24332f073..d40ada59e6 100644 --- a/crates/ui-egui/src/tools/vector_ui/pen_history_steps_tests.rs +++ b/crates/ui-egui/src/tools/vector_ui/pen_history_steps_tests.rs @@ -294,9 +294,10 @@ fn another_tool_keeps_its_own_step_names_over_the_pen_steps() { /// The options bar replays its last render while its version holds (`panels::region_versions::options_bar`), so each /// thing that row works from has to move the version on its own. A Pen path drawn click by click (#12890) changes -/// them with no History step, so nothing else redraws the bar; the draft being drawn is pinned by -/// `pen_enter_deselects_tests::enter_deselects_the_work_path_and_the_next_path_replaces_it`, and here the other two -/// ingredients move alone, with no document command between the passes. +/// those with no History step, so nothing else would redraw the bar. Here every ingredient moves alone, with no +/// document command between the passes: the Paths panel's selection (the version every region shares already holds it), +/// the Work Path the app hides (#12892) and the draft being drawn - which +/// `pen_enter_deselects_tests::enter_deselects_the_work_path_and_the_next_path_replaces_it` pins as well. #[test] fn the_options_bar_row_follows_each_path_ingredient_on_its_own() { let mut app = app();