Layers panel: a selected Background is left out of several-layer Opacity, Fill, blend and lock changes until Photoshop's behaviour is confirmed (#5856)

This commit is contained in:
Tanish Manku
2026-10-15 13:18:01 -07:00
parent 383371386a
commit 37c97f3f66
2 changed files with 25 additions and 1 deletions
@@ -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");
}
+7 -1
View File
@@ -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<LayerId> = 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<LayerId> = 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::<Vec<_>>()}) } 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.)