fix(layers): double-clicking just above or below a layer name renames it (#823)

The rename hit box was only the name's glyph height (about 15 px of a 32 px row), so a double-click a few pixels off vertically opened Layer Style. The name's column now spans the row's full height; to the right of the name still opens Layer Style. Refs #651.
This commit is contained in:
reese authored and GitHub committed 2026-10-07 14:45:44 -07:00
1 parent 03ffca0d54
commit 9a9eb013db
2 files changed
+23 -5

No files matched your search

@@ -191,6 +191,24 @@ fn a_rename_ends_when_its_layer_goes_away() {
assert_eq!(h.state().ui.tool, crate::state::Tool::Move);
}
/// #651: a double-click just above or below the name, still over it, renames rather than opening
/// Layer Style.
#[test]
fn double_click_above_or_below_the_name_renames() {
for ppp in [1.0, 2.0] {
let (mut h, [a, ..]) = harness(ppp);
let row = recorded(&h.ctx).into_iter().find(|r| r.layer == a).unwrap();
let name = row.name.expect("name drawn");
for y in [row.row.top() + 1.0, row.row.bottom() - 2.0] {
assert!(!name.expand(2.0).contains(pos2(name.center().x, y)), "@{ppp}x: off the glyphs");
double_click(&mut h, pos2(name.center().x, y));
assert_eq!(renaming(&h.ctx), Some(a), "@{ppp}x: y {y} renames");
assert!(h.state().ui.dialogs.is_empty(), "@{ppp}x: no Layer Style");
key(&mut h, Key::Escape);
}
}
}
/// #350: a double-click on the row outside the name opens Layer Style for that layer; on the
/// name it still renames; on a Smart Object's thumbnail it opens the contents.
#[test]
+5 -5
View File
@@ -1774,17 +1774,17 @@ fn layer_row(
actions.push(("ui.maskTarget".into(), json!(false)));
}
}
// Double-click: the name renames in place; the Background, which can't be renamed while
// it's locked, becomes a normal layer; an adjustment or fill thumbnail opens its settings and
// a Smart Object thumbnail its contents, and a type thumbnail edits its text; anywhere else
// on the row opens Layer Style (#350, #537).
// Double-click: the name renames in place (over the row's full height, not just the glyphs:
// #651); the Background, which can't be renamed while it's locked, becomes a normal layer; an
// adjustment or fill thumbnail opens its settings and a Smart Object thumbnail its contents,
// and a type thumbnail edits its text; anywhere else on the row opens Layer Style (#350, #537).
// The first click already made this the active layer.
if resp.double_clicked() {
let pos = resp.interact_pointer_pos();
let on = |r: Rect| pos.is_some_and(|p| r.expand(2.0).contains(p));
if crate::doc_props_ui::is_background(doc, l) {
actions.push(("layer.new.layerFromBackground".into(), json!({})));
} else if name_rect.is_some_and(on) {
} else if name_rect.is_some_and(|n| on(Rect::from_x_y_ranges(n.x_range(), rect.y_range()))) {
if let Some(done) = crate::layer_row_ui::start_rename(ctx, l.id.0, &l.name) {
// One rename at a time: starting this one commits any other (#314).
actions.push(done);