diff --git a/crates/ui-egui/src/layer_row_ui/rename_tests.rs b/crates/ui-egui/src/layer_row_ui/rename_tests.rs index b7e7e84f37..a4e985a293 100644 --- a/crates/ui-egui/src/layer_row_ui/rename_tests.rs +++ b/crates/ui-egui/src/layer_row_ui/rename_tests.rs @@ -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] diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 8ca27becd9..fb6dc5b0af 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -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);