From 37c97f3f660bcc7917f429e0cd4e2e8943a40945 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Thu, 15 Oct 2026 13:18:01 -0700 Subject: [PATCH] Layers panel: a selected Background is left out of several-layer Opacity, Fill, blend and lock changes until Photoshop's behaviour is confirmed (#5856) --- crates/ui-egui/src/layer_props_ui_tests.rs | 18 ++++++++++++++++++ crates/ui-egui/src/panels.rs | 8 +++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/layer_props_ui_tests.rs b/crates/ui-egui/src/layer_props_ui_tests.rs index 516888f359..93055ee342 100644 --- a/crates/ui-egui/src/layer_props_ui_tests.rs +++ b/crates/ui-egui/src/layer_props_ui_tests.rs @@ -58,3 +58,21 @@ fn the_basic_lock_toggle_locks_every_selected_layer() { let locked = |id: u64| st.doc.layer(photocraft_doc::LayerId(id)).unwrap().locks.all; assert!(locked(a) && locked(b), "both selected layers lock"); } + +/// The Background, selected with other layers, is left out of their change (Opacity here) +/// until Photoshop's behaviour is confirmed (#5856): it stays the Background. +#[test] +fn a_selected_background_is_left_out_of_a_several_layer_change() { + let mut h = app(); + let st = h.state().session.active().unwrap(); + let (bg, top) = (st.doc.layers[0].id.0, st.active_layer.unwrap().0); + h.state_mut().run("layer.select", json!({"layer": bg})).unwrap(); + h.state_mut().run("layer.select", json!({"layer": top, "mode": "add"})).unwrap(); + h.run_steps(3); + h.get_by_label("Lock all").click(); + h.run_steps(3); + let st = h.state().session.active().unwrap(); + let l = |id: u64| st.doc.layer(photocraft_doc::LayerId(id)).unwrap().clone(); + assert!(l(top).locks.all, "the layer locks"); + assert!(st.doc.is_background(photocraft_doc::LayerId(bg)) && !l(bg).locks.all, "the Background is left as it was"); +} diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 8548f1b041..ed35a68804 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -2238,7 +2238,13 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) { if let Some(l) = active_layer { // With several layers selected, blend mode, Opacity, Fill and the locks change every one // of them, as in Photoshop; the controls show the active layer's values. - let ids: Vec = if selection.len() > 1 && selection.contains(&l.id) { selection.clone() } else { vec![l.id] }; + // The Background stays out of a several-layer change until Photoshop's behaviour is + // confirmed (#5856): Opacity, Fill or a blend mode would turn it into Layer 0. + let ids: Vec = if selection.len() > 1 && selection.contains(&l.id) { + selection.iter().copied().filter(|id| *id == l.id || !doc.layer(*id).is_some_and(|x| crate::doc_props_ui::is_background(&doc, x))).collect() + } else { + vec![l.id] + }; let targets = if ids.len() > 1 { json!({"layers": ids.iter().map(|id| id.0).collect::>()}) } else { json!({"layer": l.id.0}) }; // Photoshop greys blend mode, Opacity and Fill for the Background layer. (With the // Background among several selected, what Photoshop does awaits a check: #5856.)