From 6119c009624d22579a9cb5d9c8a6078e989bf917 Mon Sep 17 00:00:00 2001 From: BFlat Date: Wed, 7 Oct 2026 08:37:47 +0700 Subject: [PATCH] Layers panel: double-click beside a layer's name opens Layer Style (#350) (#452) A double-click anywhere on a Layers row started a rename. Now only a double-click on the name renames; the rest of the row follows the layer's kind: an adjustment or fill thumbnail opens its Properties (Layer Content Options), a Smart Object thumbnail opens its contents (Edit Contents), and anywhere else opens Layer Style (Blending Options). The Background still becomes a normal layer, mask thumbnails keep their own clicks, and a command that's disabled for the layer does nothing. docs/ui-design.md lists the row's double-click targets. Co-authored-by: Claude Opus 5.5 --- .../ui-egui/src/layer_row_ui/rename_tests.rs | 37 +++++++++++++++++++ crates/ui-egui/src/panels.rs | 26 ++++++++++--- docs/ui-design.md | 1 + 3 files changed, 59 insertions(+), 5 deletions(-) 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 85511c155b..b7e7e84f37 100644 --- a/crates/ui-egui/src/layer_row_ui/rename_tests.rs +++ b/crates/ui-egui/src/layer_row_ui/rename_tests.rs @@ -190,3 +190,40 @@ fn a_rename_ends_when_its_layer_goes_away() { key(&mut h, Key::V); assert_eq!(h.state().ui.tool, crate::state::Tool::Move); } + +/// #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] +fn double_click_beside_the_name_opens_layer_style() { + let (mut h, [a, b, c]) = harness(1.0); + let styles = |h: &Harness<'_, PhotocraftApp>| h.state().ui.dialogs.iter().filter(|d| d.kind == crate::state::DialogKind::LayerStyle).count(); + // Select Alpha with one click, then double-click the empty part of its row. + let at = name_at(&h, a); + click(&mut h, at); + let row = recorded(&h.ctx).into_iter().find(|r| r.layer == a).unwrap(); + let name = row.name.expect("name drawn"); + let beside = pos2(name.right() + 40.0, row.row.center().y); + assert!(row.indicators.iter().all(|(_, r)| !r.expand(2.0).contains(beside)) && row.row.contains(beside)); + double_click(&mut h, beside); + assert_eq!(styles(&h), 1, "Layer Style opened"); + assert_eq!(renaming(&h.ctx), None, "not a rename"); + assert_eq!(h.state().session.active().unwrap().active_layer, Some(photocraft_doc::LayerId(a))); + h.state_mut().ui.dialogs.clear(); + h.run_steps(2); + // The name still renames. + start(&mut h, b); + assert_eq!(styles(&h), 0); + key(&mut h, Key::Escape); + // A Smart Object's thumbnail opens its contents instead of Layer Style. + h.state_mut().run("layer.select", json!({"layer": c})).unwrap(); + h.state_mut().run("edit.fill", json!({"color": "#808080"})).unwrap(); + h.state_mut().run("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + h.run_steps(4); + let docs = h.state().session.documents().len(); + let smart = h.state().session.active().unwrap().active_layer.unwrap().0; + let name = recorded(&h.ctx).into_iter().find(|r| r.layer == smart).and_then(|r| r.name).expect("smart row drawn"); + // The thumbnail sits just left of the name (a Smart Object has no mask thumbnail). + double_click(&mut h, pos2(name.left() - 18.0, name.center().y)); + assert_eq!(h.state().session.documents().len(), docs + 1, "Edit Contents opened the source"); + assert_eq!(styles(&h), 0); +} diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 555b2124e1..930d344e3f 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -1703,14 +1703,30 @@ fn layer_row( actions.push(("ui.maskTarget".into(), json!(false))); } } - // Double-click the name to rename in place (Photoshop ergonomics). The Background can't be - // renamed while it's locked, so a double-click turns it into a normal layer instead. + // 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; anywhere else on the row opens Layer Style (#350). + // 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 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); + } else if name_rect.is_some_and(on) { + 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); + } + } else if pos.and_then(|p| masks.hit(p)).is_none() { + let id = match &l.content { + LayerContent::Adjustment(_) | LayerContent::Fill(_) if on(thumb) => "layer.layerContentOptions", + LayerContent::Smart(_) if on(thumb) => "layer.smartObjects.editContents", + _ => "layer.layerStyle.blendingOptions", + }; + if crate::menus::is_enabled(app, id) { + // Null params: run like the menu item, dialog included. + actions.push((id.into(), Value::Null)); + } } } let edit_rect = Rect::from_min_max(pos2(x - 3.0, rect.center().y - 11.0), pos2(name_right.max(x + 40.0), rect.center().y + 11.0)); diff --git a/docs/ui-design.md b/docs/ui-design.md index c7aaee3e1d..26b6dc6b0c 100644 --- a/docs/ui-design.md +++ b/docs/ui-design.md @@ -40,6 +40,7 @@ curl -sfL -o assets/icons/.svg https://raw.githubusercontent.com/lucide-ic |---|---|---| | Type tool | `type_tool.rs` | Click: point text with the placeholder "Lorem Ipsum" selected. Drag: paragraph box. Inline caret and selection drawn from the text engine layout. ⌥/⌘ word and line navigation, ↩ newline, ⌘↩ or Esc commits, a click outside commits. One history step per session (`coalesce`). A new layer is named after its text; an empty one is deleted. | | Free Transform | `transform_tool.rs` | ⌘T. Corners scale proportionally (⇧ frees them); edges scale one axis; ⌥ scales about the reference point; ⌘-corner distorts; dragging outside rotates (⇧ snaps to 15°); dragging inside moves. Preview = document without the moving pixels + a textured 24×24 mesh. ↩ or a double-click commits via `edit.transform {rect, quad}`. | +| Layers rows | `panels.rs` | Double-click: on the name renames in place; on the Background makes it a normal layer; on an adjustment or fill thumbnail opens its Properties; on a Smart Object thumbnail opens its contents (Edit Contents); anywhere else on the row opens Layer Style. | | Layer masks | `panels.rs` | Clicking the mask thumbnail targets the mask (corner-bracket frame; the tab reads "Layer, Layer Mask/8"). Brush, eraser (paints background colour), gradient and bucket then send `"target": "mask"`. Adjustment and fill layers target their mask automatically. | | Levels / Curves | `tone.rs` | Histogram of the image *below* the adjustment. Curves: click to add a point, drag out to delete. Every change is a coalesced `layer.setAdjustment`, so one drag = one undo step and the canvas updates at full resolution on the GPU. |