diff --git a/crates/ui-egui/src/panels/layer_filter_ui.rs b/crates/ui-egui/src/panels/layer_filter_ui.rs index d9c9041dd7..a56c349833 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui.rs @@ -72,17 +72,16 @@ impl Filter { /// Returns [`Filter::of`] for `app`'s settings, with the active document's missing linked /// files while the panel filters by Smart Object, and `board_rows` set to the rows of the - /// artboards that hold the active document's selected layers while it filters by Artboard, - /// and `empty` set while it filters by Empty or Not Empty. - pub fn of_app(app: &PhotocraftApp) -> Self { + /// artboards in `doc` that hold `selection` while it filters by Artboard, and `empty` set + /// while it filters by Empty or Not Empty. The Layers panel passes the document and the + /// selection it already read for the frame. + pub fn with_selection(app: &PhotocraftApp, doc: &Document, selection: &[LayerId]) -> Self { let mut f = Self::of(&app.ui); if f.by == FilterBy::SmartObject { f.missing = app.session.missing_links(); } - if f.by == FilterBy::Artboard - && let Some(d) = app.session.active() - { - f.board_rows = board_rows(&d.doc, &d.selected_layers()); + if f.by == FilterBy::Artboard { + f.board_rows = board_rows(doc, selection); } if f.by == FilterBy::Attribute { f.empty = attribute::empty_layers(app, f.attribute); @@ -90,6 +89,15 @@ impl Filter { f } + /// Returns [`Filter::with_selection`] for the active document and its selected layers, or + /// [`Filter::of`] with no artboard rows when no document is open. + pub fn of_app(app: &PhotocraftApp) -> Self { + match app.session.active() { + Some(d) => Self::with_selection(app, &d.doc, &d.selected_layers()), + None => Self::of(&app.ui), + } + } + /// Whether the panel is filtered. Like Photoshop, Effect, Mode, Attribute and Color always /// filter (by Bevel & Emboss, by Normal, by Visible and by no colour at first); Kind, Name and /// Smart Object only once a toggle is on or some text is typed; Artboard only while some layers diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index ea5d672058..835b370af2 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -271,7 +271,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, &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