From 7610116123ebfcddf2e37b0feb888dacbd6d3527 Mon Sep 17 00:00:00 2001 From: Marco Arnulfo <103679419+marcoarnulfo@users.noreply.github.com> Date: Tue, 13 Oct 2026 08:46:43 +0200 Subject: [PATCH] Layers panel: clicking a row's lock icon unlocks the layer (fixes #4723) (#4734) Co-authored-by: Brandon Thomas --- crates/ui-egui/src/layer_row_ui/tests.rs | 26 ++++++++++++++++++++++++ crates/ui-egui/src/panels.rs | 7 +++++++ 2 files changed, 33 insertions(+) diff --git a/crates/ui-egui/src/layer_row_ui/tests.rs b/crates/ui-egui/src/layer_row_ui/tests.rs index 0b5e9a74af..6ec1241b46 100644 --- a/crates/ui-egui/src/layer_row_ui/tests.rs +++ b/crates/ui-egui/src/layer_row_ui/tests.rs @@ -581,3 +581,29 @@ fn the_studio_lock_button_shows_every_lock() { assert_eq!(h.get_by_label("Lock layer").accesskit_node().toggled(), Some(egui::accesskit::Toggled::True), "{key}"); } } + +#[test] +fn clicking_the_lock_icon_on_a_row_unlocks_the_layer() { + // #4723: the row's lock icon was only painted. In Photoshop a click on it clears every lock, + // and on the Background makes it a normal layer. + let (s, ids) = one_lock_each(); + let bg = s.active().unwrap().doc.background().unwrap().id; + let mut h = harness(s, 1.0, "promedium", 290.0); + let active = h.state().session.active().unwrap().active_layer; + let lock_icon = |h: &Harness<'_, PhotocraftApp>, id: u64| { + let row = recorded(&h.ctx).into_iter().find(|r| r.layer == id).unwrap(); + row.indicators.into_iter().find(|(k, _)| *k == Indicator::Lock).unwrap_or_else(|| panic!("lock icon on {id}")).1.center() + }; + for &(key, id) in &ids { + let p = lock_icon(&h, id); + click(&mut h, p); + let d = h.state().session.active().unwrap(); + assert!(!d.doc.layer(photocraft_doc::LayerId(id)).unwrap().locks.any(), "{key}: unlocked"); + assert_eq!(d.active_layer, active, "{key}: the lock icon doesn't select"); + } + let p = lock_icon(&h, bg.0); + click(&mut h, p); + let doc = &h.state().session.active().unwrap().doc; + assert!(doc.background().is_none(), "the Background became a normal layer"); + assert!(!doc.layer(bg).unwrap().locks.any()); +} diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 052bde3f71..5dafa2b58d 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -2778,6 +2778,13 @@ fn layer_row( { start_fx_drag(ctx, l.id, None); } + // Clicking the lock icon unlocks the layer, and makes the Background a normal one (Photoshop, + // #4723). It takes the click from the row, so the row isn't selected. + if let Some(&(_, lock)) = indicators.iter().find(|(k, _)| *k == crate::layer_row_ui::Indicator::Lock) + && ui.interact(lock, ui.id().with(("row-lock", l.id.0)), Sense::click()).clicked() + { + actions.push(simple_lock_toggle(doc.is_background(l.id), l)); + } let name_color = if l.visible { t.text } else { t.text_faint }; let font = if selected && !t.pro { theme::medium(13.0) } else { egui::FontId::proportional(if t.pro { 12.0 } else { 13.0 }) }; // Photoshop before 2026 set the Background layer's name in italics; 2026 sets it upright.