From c439525a0d2e736642df85c58e5052607c9468d8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 3 Nov 2026 11:35:22 -0800 Subject: [PATCH] Layers panel: the Artboard filter reuses the panel's selection Filter::with_selection takes the document and selection the Layers panel already reads for the frame, so the Artboard filter does not walk the document a second time on every redraw. --- crates/ui-egui/src/panels/layer_filter_ui.rs | 16 +++++++--------- crates/ui-egui/src/panels/layers.rs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/panels/layer_filter_ui.rs b/crates/ui-egui/src/panels/layer_filter_ui.rs index 84af5417b4..0409b2009f 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui.rs @@ -46,15 +46,13 @@ impl Filter { } } - /// Returns [`Filter::of`] for `app`'s settings, with `board_rows` set to the rows of the - /// artboards that hold the active document's selected layers while the panel filters by - /// Artboard. - pub fn of_app(app: &PhotocraftApp) -> Self { - let mut f = Self::of(&app.ui); - if f.by == FilterBy::Artboard - && let Some(d) = app.session.active() - { - f.board_rows = board_rows(&d.doc, &d.selected_layers()); + /// Returns [`Filter::of`] for `ui`'s settings, with `board_rows` set to the rows of the + /// artboards in `doc` that hold `selection` while the panel filters by Artboard. The Layers + /// panel passes the selection it already read for the frame. + pub fn with_selection(ui: &UiState, doc: &Document, selection: &[LayerId]) -> Self { + let mut f = Self::of(ui); + if f.by == FilterBy::Artboard { + f.board_rows = board_rows(doc, selection); } f } diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index 73d6e8e642..02ff30c01c 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -270,7 +270,7 @@ pub(super) fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) { ui.scroll_with_delta(vec2(0.0, delta)); ctx.request_repaint(); } - let filter = crate::layer_filter_ui::Filter::of_app(app); + let filter = crate::layer_filter_ui::Filter::with_selection(&app.ui, &doc, &selection); let fx_collapsed = app.session.active().map(|d| d.fx_collapsed.clone()).unwrap_or_default(); crate::layer_row_ui::begin(ui.ctx()); // The drawn rows, top to bottom (#1721): the space between them and below the last