Layers panel: clicking a row's lock icon unlocks the layer (fixes #4723) (#4734)

Co-authored-by: Brandon Thomas <[email protected]>
This commit is contained in:
Marco ArnulfoandBrandon Thomas authored and GitHub committed 2026-10-13 02:46:43 -04:00
1 parent 10b936f159
commit 7610116123
2 files changed
+33

No files matched your search

+26
View File
@@ -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());
}
+7
View File
@@ -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.