From a6eddde4aa6738b1728c6d88c56ccdb5ba9af4a4 Mon Sep 17 00:00:00 2001 From: NaufalDzz Date: Wed, 4 Nov 2026 11:36:55 +0700 Subject: [PATCH 1/6] =?UTF-8?q?Select=20=E2=80=BA=20Find=20Layers=20opens?= =?UTF-8?q?=20the=20Layers=20panel's=20Name=20filter=20(#10884)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As in Photoshop, Find Layers (Ctrl+Alt+Shift+F) no longer selects the layers whose name matches. From the menu or its shortcut it shows the Layers panel, switches the filter to Name and puts the caret in the Name field with its text selected, so typing replaces it. With a `name` param (scripts and agents) it sets the Name text instead. The layer selection is unchanged either way. select.findLayers no longer changes the selection and no longer fails when nothing matches; its reply lists the matching ids in `selected`, as before, and the Name filter applied in a new `layerFilter` field. Fixes #10884 --- crates/engine/src/cmd/layer_multi_cmds.rs | 10 +- .../src/cmd/layer_multi_cmds/selection.rs | 24 +++-- .../engine/src/cmd/layer_multi_cmds/tests.rs | 15 ++- crates/ui-egui/src/menus/invoke.rs | 2 + crates/ui-egui/src/panels/layer_filter_ui.rs | 8 +- .../src/panels/layer_filter_ui/find.rs | 44 +++++++++ .../src/panels/layer_filter_ui/find_tests.rs | 99 +++++++++++++++++++ docs/control-protocol.md | 1 + 8 files changed, 188 insertions(+), 15 deletions(-) create mode 100644 crates/ui-egui/src/panels/layer_filter_ui/find.rs create mode 100644 crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs diff --git a/crates/engine/src/cmd/layer_multi_cmds.rs b/crates/engine/src/cmd/layer_multi_cmds.rs index ada040e8b7..dfbe283dfc 100644 --- a/crates/engine/src/cmd/layer_multi_cmds.rs +++ b/crates/engine/src/cmd/layer_multi_cmds.rs @@ -101,7 +101,15 @@ pub fn specs() -> Vec { } Ok(Value::Null) }), - spec!("select.findLayers", "Find Layers", &["Select"], Some("Cmd+Alt+Shift+F"), r##"{"name":str (case-insensitive substring)}"##, has_doc, find_layers), + spec!( + "select.findLayers", + "Find Layers", + &["Select"], + Some("Cmd+Alt+Shift+F"), + r##"{"name":str?} (filters the Layers panel by Name, a case-insensitive substring, without changing the selection; replies with the matching layers)"##, + has_doc, + find_layers + ), spec!("layer.selectLinkedLayers", "Select Linked Layers", &["Layer"], None, "{}", has_linked, |s, _| select_linked(s)), spec!("layer.align.topEdges", "Top Edges", &["Layer", "Align"], None, ALIGN, can_align, |s, p| align(s, p, "topEdges")), spec!("layer.align.verticalCenters", "Vertical Centers", &["Layer", "Align"], None, ALIGN, can_align, |s, p| align(s, p, "verticalCenters")), diff --git a/crates/engine/src/cmd/layer_multi_cmds/selection.rs b/crates/engine/src/cmd/layer_multi_cmds/selection.rs index e5e361fb1c..80422ce552 100644 --- a/crates/engine/src/cmd/layer_multi_cmds/selection.rs +++ b/crates/engine/src/cmd/layer_multi_cmds/selection.rs @@ -334,16 +334,26 @@ pub(super) fn select_all_layers(s: &mut Session) -> Result { Ok(json!({"selected": n})) } +/// Select › Find Layers (#10884): as in Photoshop it filters the Layers panel by Name and leaves the +/// layer selection alone. The reply's `layerFilter` is the Name filter the app applies (`name` only +/// when one is given) and `selected` lists the layers it matches: part of the name, trimmed and +/// ignoring case, as the panel matches (none without a name). pub(super) fn find_layers(s: &mut Session, p: &Value) -> Result { - let needle = p.get("name").and_then(Value::as_str).ok_or_else(|| bad("select.findLayers", "missing `name`"))?.to_lowercase(); + let name = match p.get("name") { + None | Some(Value::Null) => None, + Some(v) => Some(v.as_str().ok_or_else(|| bad("select.findLayers", "`name` must be a string"))?), + }; let d = s.active().ok_or(EngineError::NoDocument)?; - let ids: Vec = d.doc.walk().into_iter().filter(|(_, _, l)| l.name.to_lowercase().contains(&needle)).map(|(_, _, l)| l.id).collect(); - if ids.is_empty() { - return Err(EngineError::Other(format!("no layer name contains \"{needle}\""))); + let needle = name.map(|n| n.trim().to_lowercase()).filter(|n| !n.is_empty()); + let ids: Vec = match &needle { + Some(n) => d.doc.walk().into_iter().filter(|(_, _, l)| l.name.to_lowercase().contains(n.as_str())).map(|(_, _, l)| l.id.0).collect(), + None => Vec::new(), + }; + let mut filter = json!({"by": "name"}); + if let Some(n) = name { + filter["name"] = json!(n); } - let out = ids.iter().map(|l| l.0).collect::>(); - set_selection(s, ids, None, None)?; - Ok(json!({"selected": out})) + Ok(json!({"selected": ids, "layerFilter": filter})) } pub(super) fn select_linked(s: &mut Session) -> Result { diff --git a/crates/engine/src/cmd/layer_multi_cmds/tests.rs b/crates/engine/src/cmd/layer_multi_cmds/tests.rs index a3c055cf7b..fbd3cd87cb 100644 --- a/crates/engine/src/cmd/layer_multi_cmds/tests.rs +++ b/crates/engine/src/cmd/layer_multi_cmds/tests.rs @@ -586,9 +586,18 @@ fn find_layers_by_name() { s.execute("layer.renameLayer", json!({"layer": a.0, "name": "Sky photo"})).unwrap(); s.execute("layer.renameLayer", json!({"layer": b.0, "name": "Photo of sea"})).unwrap(); assert_eq!(doc(&s).layer(a).unwrap().name, "Sky photo"); - let r = s.execute("select.findLayers", json!({"name": "PHOTO"})).unwrap(); - assert_eq!(r["selected"], json!([a.0, b.0])); - assert!(s.execute("select.findLayers", json!({"name": "nothing"})).is_err()); + // #10884: Find Layers filters the Layers panel by Name and leaves the selection alone. + s.execute("layer.select", json!({"layer": a.0})).unwrap(); + let r = s.execute("select.findLayers", json!({"name": " PHOTO "})).unwrap(); + assert_eq!(r["selected"], json!([a.0, b.0]), "the matching layers, trimmed and ignoring case"); + assert_eq!(r["layerFilter"], json!({"by": "name", "name": " PHOTO "}), "the app sets the Name text as given"); + assert_eq!(s.active().unwrap().selected_layers(), [a], "the selection is unchanged"); + let r = s.execute("select.findLayers", json!({"name": "nothing"})).unwrap(); + assert_eq!(r["selected"], json!([]), "no match lists nothing and is no error"); + let r = s.execute("select.findLayers", json!({})).unwrap(); + assert_eq!((&r["selected"], &r["layerFilter"]), (&json!([]), &json!({"by": "name"})), "without a name it only switches to Name"); + assert_eq!(s.active().unwrap().selected_layers(), [a]); + assert!(s.execute("select.findLayers", json!({"name": 3})).is_err()); assert!(s.execute("layer.renameLayer", json!({})).is_err()); } diff --git a/crates/ui-egui/src/menus/invoke.rs b/crates/ui-egui/src/menus/invoke.rs index a089803be8..c995068197 100644 --- a/crates/ui-egui/src/menus/invoke.rs +++ b/crates/ui-egui/src/menus/invoke.rs @@ -414,6 +414,8 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id: let dialog = crate::channel_options_ui::open_new_spot(app).ok_or("no document is open")?; Ok(json!({"dialog": dialog})) } + // Select › Find Layers: the Layers panel's Name filter (#10884). + "select.findLayers" => crate::layer_filter_ui::find::invoke(app, ctx, params), // Photoshop's "Select and Mask…" is the engine's select.refineEdge. // Select › Color Range… from the menu: the dialog (with params: the engine directly). "select.colorRange" if params.as_object().is_none_or(|o| o.is_empty()) => Ok(json!({"dialog": crate::color_range_ui::open(app)})), diff --git a/crates/ui-egui/src/panels/layer_filter_ui.rs b/crates/ui-egui/src/panels/layer_filter_ui.rs index 0634d39918..ad3a741a4b 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui.rs @@ -276,10 +276,7 @@ pub fn bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } } } - FilterBy::Name => { - let width = ui.available_width().max(48.0); - widgets::text_field(ui, ui.scope_id().with("layer-filter-name"), &mut app.ui.layer_filter_name, tl!("Search"), width, false); - } + FilterBy::Name => find::name_field(app, ui), FilterBy::Effect => effect::controls(app, ui), FilterBy::Mode => { let modes: Vec<(BlendMode, &str)> = std::iter::once(BlendMode::PassThrough).chain(BlendMode::LAYER_MODES).map(|m| (m, m.label())).collect(); @@ -316,8 +313,11 @@ pub fn bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } pub mod effect; +pub mod find; #[cfg(test)] mod effect_tests; #[cfg(test)] +mod find_tests; +#[cfg(test)] mod tests; diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find.rs b/crates/ui-egui/src/panels/layer_filter_ui/find.rs new file mode 100644 index 0000000000..964b76f056 --- /dev/null +++ b/crates/ui-egui/src/panels/layer_filter_ui/find.rs @@ -0,0 +1,44 @@ +//! #10884: Select › Find Layers (⌥⇧⌘F) filters the Layers panel by Name, as in Photoshop: it shows +//! the Layers panel, switches the filter to Name and puts the caret in its field with the text +//! selected, so typing replaces it. The layer selection is not changed. With a `name` param +//! (scripts and agents) it sets the Name text to it instead of focusing the field. + +use serde_json::{Value, json}; + +use super::FilterBy; +use crate::{PhotocraftApp, widgets}; + +/// The egui memory flag: focus the Name field the next time it is drawn. +fn focus_flag() -> egui::Id { + egui::Id::unique("layer-filter-find-focus") +} + +/// Run `select.findLayers`: the engine checks `params` and lists the layers the Name text matches; +/// then the Name filter is applied. Without a `name` the text is kept, and the Layers panel is +/// shown with the field focused. +pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, params: Value) -> Result { + let given = params.get("name").is_some_and(|n| !n.is_null()); + let params = if given { params } else { json!({"name": app.ui.layer_filter_name}) }; + let reply = app.run("select.findLayers", params)?; + app.ui.layer_filter_by = FilterBy::Name; + if let Some(name) = reply["layerFilter"]["name"].as_str() { + app.ui.layer_filter_name = name.to_string(); + } + if !given { + *crate::dock::Group::Layers.tab_mut(&mut app.ui.dock_tabs) = 0; + crate::dock::reveal(app, crate::dock::Group::Layers); + ctx.data_mut(|d| d.insert_temp(focus_flag(), true)); + } + Ok(reply) +} + +/// The Name filter's text field, taking the focus with its text selected after [`invoke`]. +pub fn name_field(app: &mut PhotocraftApp, ui: &mut egui::Ui) { + let id = ui.scope_id().with("layer-filter-name"); + if ui.ctx().data_mut(|d| d.remove_temp::(focus_flag())).unwrap_or(false) { + ui.memory_mut(|m| m.request_focus(id)); + widgets::field_tab::select_all(ui.ctx(), id, &app.ui.layer_filter_name); + } + let width = ui.available_width().max(48.0); + widgets::text_field(ui, id, &mut app.ui.layer_filter_name, tl!("Search"), width, false); +} diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs new file mode 100644 index 0000000000..ea1dccd5ab --- /dev/null +++ b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs @@ -0,0 +1,99 @@ +//! #10884: Select › Find Layers opens the Layers panel's Name filter, against the cases measured in +//! Photoshop. + +use egui::vec2; +use egui_kittest::Harness; +use photocraft_doc::LayerId; +use serde_json::json; + +use super::{Filter, FilterBy}; +use crate::PhotocraftApp; + +/// "LinkA", "Other" and "LinkB" over the Background, "Other" selected. +fn harness() -> Harness<'static, PhotocraftApp> { + let mut s = photocraft_engine::Session::new(); + s.execute("file.new", json!({"width": 64, "height": 48})).unwrap(); + for name in ["LinkA", "Other", "LinkB"] { + s.execute("layer.new.layer", json!({"name": name})).unwrap(); + } + let mut h = Harness::builder().with_size(vec2(1440.0, 900.0)).with_max_steps(64).build_eframe(move |cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); + PhotocraftApp::new(s, crate::Services::default()) + }); + h.run_steps(8); + let other = id(&h, "Other"); + h.state_mut().session.execute("layer.select", json!({"layer": other.0})).unwrap(); + h.run_steps(4); + h +} + +fn id(h: &Harness<'_, PhotocraftApp>, name: &str) -> LayerId { + h.state() + .session + .active() + .unwrap() + .doc + .walk() + .into_iter() + .find(|(_, _, l)| l.name == name) + .map(|(_, _, l)| l.id) + .unwrap_or_else(|| panic!("no layer {name}")) +} + +fn selected(h: &Harness<'_, PhotocraftApp>) -> Vec { + h.state().session.active().unwrap().selected_layers() +} + +/// The names the panel's filter lists, top to bottom. +fn listed(h: &Harness<'_, PhotocraftApp>) -> Vec { + let f = Filter::of_app(h.state()); + let doc = &h.state().session.active().unwrap().doc; + crate::layer_tree_ui::display_rows(doc, f.active()).into_iter().filter(|(_, l)| f.shows(l)).map(|(_, l)| l.name.clone()).collect() +} + +fn find(h: &mut Harness<'_, PhotocraftApp>, params: serde_json::Value) -> serde_json::Value { + let ctx = h.ctx.clone(); + let reply = crate::menus::invoke(h.state_mut(), &ctx, "select.findLayers", params).unwrap(); + h.run_steps(4); + reply +} + +#[test] +fn the_menu_item_shows_the_layers_panel_and_focuses_the_name_field() { + let mut h = harness(); + h.state_mut().ui.panels.layers = false; + h.state_mut().ui.layer_filter_name = "old".into(); + h.run_steps(4); + let before = selected(&h); + find(&mut h, json!({})); + assert!(h.state().ui.panels.layers, "the Layers panel is shown"); + assert_eq!(h.state().ui.layer_filter_by, FilterBy::Name); + assert!(h.ctx.memory(|m| m.focused()).is_some(), "the caret is in the Name field"); + // The existing text is selected, so typing replaces it. + h.event(egui::Event::Text("lin".into())); + h.run_steps(4); + assert_eq!(h.state().ui.layer_filter_name, "lin"); + assert_eq!(listed(&h), ["LinkB", "LinkA"]); + assert_eq!(selected(&h), before, "Find Layers does not change the layer selection"); +} + +#[test] +fn a_name_param_sets_the_filter_text_without_changing_the_selection() { + let mut h = harness(); + let before = selected(&h); + let reply = find(&mut h, json!({"name": "link"})); + assert_eq!((h.state().ui.layer_filter_by, h.state().ui.layer_filter_name.as_str()), (FilterBy::Name, "link")); + assert_eq!(reply["selected"], json!([id(&h, "LinkA").0, id(&h, "LinkB").0]), "the reply lists the matching layers"); + assert_eq!(listed(&h), ["LinkB", "LinkA"]); + assert_eq!(selected(&h), before); + assert!(h.ctx.memory(|m| m.focused()).is_none(), "a script does not take the keyboard focus"); +} + +#[test] +fn the_shortcut_runs_find_layers() { + let mut h = harness(); + h.key_press_modifiers(egui::Modifiers::COMMAND | egui::Modifiers::ALT | egui::Modifiers::SHIFT, egui::Key::F); + h.run_steps(4); + assert_eq!(h.state().ui.layer_filter_by, FilterBy::Name); + assert!(h.ctx.memory(|m| m.focused()).is_some(), "the caret is in the Name field"); +} diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 4a3c55d6ec..a4e8d46bb5 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -55,6 +55,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i - `ui.set` also accepts `tileGrid` (boolean), a developer overlay of the active layer's storage tiles: the tile grid over the document, every stored tile filled and labelled `tx,ty`, tiles with identical pixels in a shared colour and unique ones in blue. It has no menu item and View › Extras doesn't hide it. `ui.inspect` reports it as `view.tile_grid`. - `ui.set` also accepts `strokeTrace` (`true`, `false`, `"stderr"` or `"off"`): turn the stroke latency trace on or off at runtime; each stroke's summary is in `ui.inspect` `perf.strokeTrace`. A CSV file of every frame is set only at launch (`PHOTOCRAFT_STROKE_TRACE=` / `--stroke-trace `): the control channel doesn't write files outside the automation write root - `ui.set` also accepts `layerFilter` (#5048), the Layers panel filter row: `{by?, kinds?, name?, effect?, mode?, color?, smart?}`, any subset. `by` is `kind`, `name`, `effect`, `mode`, `color`, `smartObject` or `artboard` (the filter-type dropdown); `kinds` lists the Kind toggles that are on (`pixel`, `adjustment`, `type`, `shape`, `smart`); `name` matches part of a layer name, ignoring case; `effect` (#10880) is `bevelEmboss`, `stroke`, `innerShadow`, `innerGlow`, `satin`, `overlay` (Color, Gradient or Pattern Overlay), `outerGlow` or `dropShadow`, and lists the layers with that effect turned on; `mode` is a blend mode name (`Multiply`, `Pass Through`); `color` is a layer colour label id (`none`, `red`, `orange`, `yellow`, `green`, `seafoam`, `blue`, `indigo`, `magenta`, `fuchsia`, `violet`, `gray`; #5898); `smart` lists the Smart Object toggles that are on (`linked`: linked to a file, `missing`: linked to a file that was not there when the app last looked, `embedded`). Kind, Name and Smart Object filter only once a toggle is on or text is typed; Effect, Mode and Color always filter, by Bevel & Emboss, by Normal and by no colour at first, as in Photoshop. Artboard has no field of its own: it lists the artboards that hold the selected layers, with everything inside them (closed groups stay closed), and does not filter when nothing is selected or a selected layer is in no artboard. Fields left out keep their value; a bad one is an error and changes nothing. +- `select.findLayers` (#10884, Select › Find Layers) filters the Layers panel by Name and does not change the layer selection. With `name` it sets the Name text; without it the text is kept, the Layers panel is shown and its Name field takes the keyboard focus with the text selected. The reply lists the matching layer ids in `selected` and the Name filter applied in `layerFilter` (`{by: "name", name?}`). - `ui.set` also accepts the Histogram panel: `histogramPanel` `{view?, channel?, showChannelsInColor?, showStatistics?, source?}` (any subset, kept with the preferences): `view` is `compact`, `expanded` or `allChannels`; `channel` is `composite`, `red`, `green`, `blue`, `cyan`, `magenta`, `yellow`, `black`, `a`, `b`, `luminosity` or `colors` (one the document's mode lacks shows as its composite); `source` is `entireImage`, `selectedLayer` or `adjustmentComposite` (Entire Image is counted in Compact View, when the document has one layer, or when no adjustment layer is selected for Adjustment Composite). `histogramRange` is `[from, to]` (levels 0..255) or `null`: the dragged tonal range whose Count and Percentile the statistics show. `histogramRefresh: true` is Uncached Refresh: the current state is recounted at cache level 1. `ui.inspect` › `histogram` reports the options, the channel and source as they apply, the channels the document offers, whether the shown histogram is `current` (counted for the document's revision, source and cache level the panel wants now), its `cacheLevel`, `maxCacheLevel` (Preferences › Performance › Cache Levels), `preview` (an adjustment's preview is counted) and `stats` (`mean`, `stdDev`, `median`, `pixels`, `level`, `count`, `percentile`, `clipped` percent at 0 and 255). Histograms are counted while the panel is shown. - Each painting tool keeps its own brush, as in Photoshop: `tools.setBrush` and `ui.set {brushSize}` change the active tool's brush, and switching tools swaps in that tool's own (size, hardness, mode, opacity, flow, dynamics, smoothing). A tool used for the first time starts from the brush in hand. The colours, the erase flag and the stroke seed stay shared. So `ui.set {tool: "eraser", brushSize: 12}` sets the Eraser's size, and `ui.set {tool: "brush"}` afterwards brings the Brush's own size back. - Brush Pose's `pose.overrideTiltX` and `pose.overrideTiltY` are independent booleans. For example, `engine.execute {"command":"tools.setBrush","params":{"pose":{"enabled":true,"tiltX":45,"overrideTiltX":true,"overrideTiltY":false}}}` fixes X at 45° while Y follows the stylus. Pose tilts are degrees (±90); the Brush Settings panel displays percentages (±100). Old stored `overrideTilt` values migrate to both axes. In command patches, `overrideTilt` sets both axes unless an explicit axis field in the same patch overrides it. `brush.get` includes both axis flags and the legacy combined readback (`overrideTilt` is true only when both flags are true). Axis-only journals omit that derived combined key so replay retains the other axis. Present flag values must be booleans; null and other types return an error. From c1d996fb9622c1e0f30d135029f4128d616d43a2 Mon Sep 17 00:00:00 2001 From: NaufalDzz Date: Wed, 4 Nov 2026 13:26:49 +0700 Subject: [PATCH 2/6] Find Layers: focus the Name field after the click on the menu item (#10884) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking Select › Find Layers ran the command in the frame of the click, so the Name field asked for the focus in a frame with a pointer press elsewhere and egui dropped it at the end of that frame. The focus now waits for a frame without a press or release. New tests click the real menu item, and close the Layers panel from Window › Layers before the shortcut. --- .../src/panels/layer_filter_ui/find.rs | 11 +++++-- .../src/panels/layer_filter_ui/find_tests.rs | 32 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find.rs b/crates/ui-egui/src/panels/layer_filter_ui/find.rs index 964b76f056..bfacef6f1e 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find.rs @@ -32,10 +32,17 @@ pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, params: Value) -> Re Ok(reply) } -/// The Name filter's text field, taking the focus with its text selected after [`invoke`]. +/// The Name filter's text field, taking the focus with its text selected after [`invoke`]. The +/// focus waits for a frame without a pointer press or release: egui drops the focus at the end of +/// a frame in which the pointer was clicked elsewhere, as it is when the menu item is clicked. pub fn name_field(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let id = ui.scope_id().with("layer-filter-name"); - if ui.ctx().data_mut(|d| d.remove_temp::(focus_flag())).unwrap_or(false) { + let pending = ui.ctx().data(|d| d.get_temp::(focus_flag())).unwrap_or(false); + let clicking = ui.input(|i| i.pointer.any_pressed() || i.pointer.any_released() || i.pointer.any_down()); + if pending && clicking { + ui.ctx().request_repaint(); + } else if pending { + ui.ctx().data_mut(|d| d.remove_temp::(focus_flag())); ui.memory_mut(|m| m.request_focus(id)); widgets::field_tab::select_all(ui.ctx(), id, &app.ui.layer_filter_name); } diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs index ea1dccd5ab..364bb1d6d1 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs @@ -97,3 +97,35 @@ fn the_shortcut_runs_find_layers() { assert_eq!(h.state().ui.layer_filter_by, FilterBy::Name); assert!(h.ctx.memory(|m| m.focused()).is_some(), "the caret is in the Name field"); } + +#[test] +fn clicking_the_menu_item_leaves_the_caret_in_the_name_field() { + use egui_kittest::kittest::Queryable; + let mut h = harness(); + h.get_by_label("Select").click(); + h.run_steps(4); + h.get_by_label("Find Layers Ctrl+Alt+Shift+F").click(); + h.run_steps(6); + assert_eq!(h.state().ui.layer_filter_by, FilterBy::Name); + h.event(egui::Event::Text("lin".into())); + h.run_steps(4); + assert_eq!(h.state().ui.layer_filter_name, "lin", "typing goes to the Name field"); +} + +#[test] +fn the_shortcut_shows_a_layers_tab_closed_from_the_window_menu() { + let mut h = harness(); + use egui_kittest::kittest::Queryable; + h.get_by_label("Window").click(); + h.run_steps(4); + h.get_by_label("✔ Layers F7").click(); + h.run_steps(4); + assert!(!h.state().ui.panels.layers, "Window › Layers closed the panel"); + h.state_mut().ui.layer_filter_name = "lin".into(); + h.key_press_modifiers(egui::Modifiers::COMMAND | egui::Modifiers::ALT | egui::Modifiers::SHIFT, egui::Key::F); + h.run_steps(6); + assert_eq!(h.state().ui.layer_filter_by, FilterBy::Name); + h.event(egui::Event::Text("other".into())); + h.run_steps(4); + assert_eq!(h.state().ui.layer_filter_name, "other", "the panel is back, focused, with its text selected"); +} From 34dc2c4819b91f050215afd6075cc2c91b09b9bc Mon Sep 17 00:00:00 2001 From: NaufalDzz Date: Wed, 4 Nov 2026 13:38:52 +0700 Subject: [PATCH 3/6] Find Layers: show a Layers panel closed in the panel docking layout (#10884) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the panel docking layout on (any customized workspace), Window › Layers closes the Layers panel in that layout, which the dock group's reveal doesn't reopen. Find Layers now shows it through window.panel.activate there, as a new adjustment layer shows Properties. --- .../ui-egui/src/panels/layer_filter_ui/find.rs | 11 +++++++++-- .../src/panels/layer_filter_ui/find_tests.rs | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find.rs b/crates/ui-egui/src/panels/layer_filter_ui/find.rs index bfacef6f1e..941ebef92d 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find.rs @@ -25,8 +25,15 @@ pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, params: Value) -> Re app.ui.layer_filter_name = name.to_string(); } if !given { - *crate::dock::Group::Layers.tab_mut(&mut app.ui.dock_tabs) = 0; - crate::dock::reveal(app, crate::dock::Group::Layers); + // The panel docking layout (when on) shows the Layers panel itself, else the dock group. + if app.ui.docking.is_some() { + if let Some(shown) = crate::panel_docking::command(app, "window.panel.activate", &json!({"panel": "layers"})) { + shown?; + } + } else { + *crate::dock::Group::Layers.tab_mut(&mut app.ui.dock_tabs) = 0; + crate::dock::reveal(app, crate::dock::Group::Layers); + } ctx.data_mut(|d| d.insert_temp(focus_flag(), true)); } Ok(reply) diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs index 364bb1d6d1..076d5038c8 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs @@ -129,3 +129,19 @@ fn the_shortcut_shows_a_layers_tab_closed_from_the_window_menu() { h.run_steps(4); assert_eq!(h.state().ui.layer_filter_name, "other", "the panel is back, focused, with its text selected"); } + +#[test] +fn the_menu_item_shows_a_layers_panel_closed_in_the_docking_layout() { + let mut h = harness(); + h.state_mut().run("window.panel.move", json!({"panel": "swatches", "anchor": "layers", "zone": "top"})).unwrap(); + h.state_mut().run("window.panel.close", json!({"panel": "layers"})).unwrap(); + h.run_steps(4); + let shown = |h: &Harness<'_, PhotocraftApp>| h.state().ui.docking.as_ref().is_some_and(|w| w.layout.contains(&"layers".to_string())); + assert!(!shown(&h), "the Layers panel is closed"); + h.state_mut().ui.layer_filter_name = "lin".into(); + find(&mut h, json!({})); + assert!(shown(&h), "Find Layers shows the Layers panel again"); + h.event(egui::Event::Text("other".into())); + h.run_steps(4); + assert_eq!(h.state().ui.layer_filter_name, "other", "the Name field has the focus with its text selected"); +} From 2e294450afc6efabf10633cb9962432a0224f781 Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 6 Nov 2026 16:25:36 +0100 Subject: [PATCH 4/6] Find Layers: set the panel filter on every run path; a blank name lists every layer (#11238) Two review findings on #11238 (#10884): - `engine.execute` runs `select.findLayers` through `PhotocraftApp::run`, not `menus::invoke`, so the Layers panel's Name filter was never set on that path. `run` now applies the reply's filter after every Find Layers (menu, shortcut, `engine.execute`, action steps). - A blank or whitespace `name` replied `selected: []`, while the panel doesn't filter by a blank Name and lists every layer. It now lists every layer. Co-Authored-By: NaufalDzz Co-Authored-By: Claude Opus 5.5 --- .../engine/src/cmd/layer_multi_cmds/selection.rs | 5 +++-- crates/engine/src/cmd/layer_multi_cmds/tests.rs | 5 +++++ crates/ui-egui/src/app/commands.rs | 7 +++++++ crates/ui-egui/src/panels/layer_filter_ui/find.rs | 14 ++++++++++---- .../src/panels/layer_filter_ui/find_tests.rs | 14 ++++++++++++++ 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/layer_multi_cmds/selection.rs b/crates/engine/src/cmd/layer_multi_cmds/selection.rs index 80422ce552..f8026cbc6b 100644 --- a/crates/engine/src/cmd/layer_multi_cmds/selection.rs +++ b/crates/engine/src/cmd/layer_multi_cmds/selection.rs @@ -337,14 +337,15 @@ pub(super) fn select_all_layers(s: &mut Session) -> Result { /// Select › Find Layers (#10884): as in Photoshop it filters the Layers panel by Name and leaves the /// layer selection alone. The reply's `layerFilter` is the Name filter the app applies (`name` only /// when one is given) and `selected` lists the layers it matches: part of the name, trimmed and -/// ignoring case, as the panel matches (none without a name). +/// ignoring case, as the panel matches: every layer for a blank name, which the panel doesn't filter +/// by (none without a name). pub(super) fn find_layers(s: &mut Session, p: &Value) -> Result { let name = match p.get("name") { None | Some(Value::Null) => None, Some(v) => Some(v.as_str().ok_or_else(|| bad("select.findLayers", "`name` must be a string"))?), }; let d = s.active().ok_or(EngineError::NoDocument)?; - let needle = name.map(|n| n.trim().to_lowercase()).filter(|n| !n.is_empty()); + let needle = name.map(|n| n.trim().to_lowercase()); let ids: Vec = match &needle { Some(n) => d.doc.walk().into_iter().filter(|(_, _, l)| l.name.to_lowercase().contains(n.as_str())).map(|(_, _, l)| l.id.0).collect(), None => Vec::new(), diff --git a/crates/engine/src/cmd/layer_multi_cmds/tests.rs b/crates/engine/src/cmd/layer_multi_cmds/tests.rs index 3e81988e4d..fc39d25f5d 100644 --- a/crates/engine/src/cmd/layer_multi_cmds/tests.rs +++ b/crates/engine/src/cmd/layer_multi_cmds/tests.rs @@ -594,6 +594,11 @@ fn find_layers_by_name() { assert_eq!(s.active().unwrap().selected_layers(), [a], "the selection is unchanged"); let r = s.execute("select.findLayers", json!({"name": "nothing"})).unwrap(); assert_eq!(r["selected"], json!([]), "no match lists nothing and is no error"); + let all: Vec = doc(&s).walk().into_iter().map(|(_, _, l)| l.id.0).collect(); + for blank in ["", " "] { + let r = s.execute("select.findLayers", json!({"name": blank})).unwrap(); + assert_eq!(r["selected"], json!(all), "a blank name filters nothing, as in the panel: {blank:?}"); + } let r = s.execute("select.findLayers", json!({})).unwrap(); assert_eq!((&r["selected"], &r["layerFilter"]), (&json!([]), &json!({"by": "name"})), "without a name it only switches to Name"); assert_eq!(s.active().unwrap().selected_layers(), [a]); diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index 12f3274046..ed609e75a6 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -31,6 +31,13 @@ impl PhotocraftApp { } self.sync_mask_targets(); } + // Find Layers sets the Layers panel's Name filter however it runs: the menu, the shortcut, + // `engine.execute` or an action step (#10884). + if id == "select.findLayers" + && let Ok(reply) = &result + { + crate::layer_filter_ui::find::apply(self, reply); + } result } diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find.rs b/crates/ui-egui/src/panels/layer_filter_ui/find.rs index 941ebef92d..36c285718c 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find.rs @@ -19,11 +19,8 @@ fn focus_flag() -> egui::Id { pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, params: Value) -> Result { let given = params.get("name").is_some_and(|n| !n.is_null()); let params = if given { params } else { json!({"name": app.ui.layer_filter_name}) }; + // `run` applies the reply's Name filter ([`apply`]). let reply = app.run("select.findLayers", params)?; - app.ui.layer_filter_by = FilterBy::Name; - if let Some(name) = reply["layerFilter"]["name"].as_str() { - app.ui.layer_filter_name = name.to_string(); - } if !given { // The panel docking layout (when on) shows the Layers panel itself, else the dock group. if app.ui.docking.is_some() { @@ -39,6 +36,15 @@ pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, params: Value) -> Re Ok(reply) } +/// Apply the Name filter in a `select.findLayers` reply to the Layers panel: switch to Name and set +/// the text when the reply has one. [`PhotocraftApp::run`] calls it after every Find Layers. +pub(crate) fn apply(app: &mut PhotocraftApp, reply: &Value) { + app.ui.layer_filter_by = FilterBy::Name; + if let Some(name) = reply["layerFilter"]["name"].as_str() { + app.ui.layer_filter_name = name.to_string(); + } +} + /// The Name filter's text field, taking the focus with its text selected after [`invoke`]. The /// focus waits for a frame without a pointer press or release: egui drops the focus at the end of /// a frame in which the pointer was clicked elsewhere, as it is when the menu item is clicked. diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs index 076d5038c8..440d83d7ca 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs @@ -145,3 +145,17 @@ fn the_menu_item_shows_a_layers_panel_closed_in_the_docking_layout() { h.run_steps(4); assert_eq!(h.state().ui.layer_filter_name, "other", "the Name field has the focus with its text selected"); } + +#[test] +fn engine_execute_sets_the_panel_filter_too() { + // `engine.execute` runs engine commands through `PhotocraftApp::run`, not `menus::invoke`. + let mut h = harness(); + h.state_mut().ui.layer_filter_by = FilterBy::Kind; + let before = selected(&h); + h.state_mut().run("select.findLayers", json!({"name": "link"})).unwrap(); + h.run_steps(4); + assert_eq!((h.state().ui.layer_filter_by, h.state().ui.layer_filter_name.as_str()), (FilterBy::Name, "link")); + assert_eq!(listed(&h), ["LinkB", "LinkA"]); + assert_eq!(selected(&h), before); + assert!(h.ctx.memory(|m| m.focused()).is_none(), "a script does not take the keyboard focus"); +} From 9a48ea54a63409cb62fc2006949f3e40921669f4 Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 6 Nov 2026 16:41:29 +0100 Subject: [PATCH 5/6] Find Layers tests: follow #10879 now that it is on main (#11238) Main gained #10879: a Layers panel filter that hides the selected layer deselects it, as in the reference application. Three #11238 tests expected "Other" to stay selected under a "link" Name filter. They now check the combined behaviour: Find Layers selects none of the matches and keeps a selected layer the filter still lists, and the filter deselects what it hides. Also the module order rustfmt wants after the merge. Co-Authored-By: NaufalDzz Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/layer_filter_ui.rs | 4 ++-- .../src/panels/layer_filter_ui/find_tests.rs | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/panels/layer_filter_ui.rs b/crates/ui-egui/src/panels/layer_filter_ui.rs index 15bf6fcc0b..4f2981f261 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui.rs @@ -361,10 +361,10 @@ pub mod attribute; #[cfg(test)] mod attribute_tests; #[cfg(test)] -mod selection_tests; -#[cfg(test)] mod find_tests; #[cfg(test)] +mod selection_tests; +#[cfg(test)] mod tests; #[cfg(test)] diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs index 440d83d7ca..322629b5c9 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs @@ -62,10 +62,11 @@ fn find(h: &mut Harness<'_, PhotocraftApp>, params: serde_json::Value) -> serde_ fn the_menu_item_shows_the_layers_panel_and_focuses_the_name_field() { let mut h = harness(); h.state_mut().ui.panels.layers = false; - h.state_mut().ui.layer_filter_name = "old".into(); + h.state_mut().ui.layer_filter_name = "oth".into(); h.run_steps(4); let before = selected(&h); find(&mut h, json!({})); + assert_eq!(selected(&h), before, "Find Layers does not change the layer selection"); assert!(h.state().ui.panels.layers, "the Layers panel is shown"); assert_eq!(h.state().ui.layer_filter_by, FilterBy::Name); assert!(h.ctx.memory(|m| m.focused()).is_some(), "the caret is in the Name field"); @@ -74,18 +75,20 @@ fn the_menu_item_shows_the_layers_panel_and_focuses_the_name_field() { h.run_steps(4); assert_eq!(h.state().ui.layer_filter_name, "lin"); assert_eq!(listed(&h), ["LinkB", "LinkA"]); - assert_eq!(selected(&h), before, "Find Layers does not change the layer selection"); + assert_eq!(selected(&h), [], "the typed filter hides \"Other\", which is deselected (#10879); no match is selected"); } #[test] fn a_name_param_sets_the_filter_text_without_changing_the_selection() { let mut h = harness(); - let before = selected(&h); + let link_a = id(&h, "LinkA"); + h.state_mut().session.execute("layer.select", json!({"layer": link_a.0})).unwrap(); + h.run_steps(4); let reply = find(&mut h, json!({"name": "link"})); assert_eq!((h.state().ui.layer_filter_by, h.state().ui.layer_filter_name.as_str()), (FilterBy::Name, "link")); assert_eq!(reply["selected"], json!([id(&h, "LinkA").0, id(&h, "LinkB").0]), "the reply lists the matching layers"); assert_eq!(listed(&h), ["LinkB", "LinkA"]); - assert_eq!(selected(&h), before); + assert_eq!(selected(&h), [link_a], "LinkA stays selected; LinkB, also listed, isn't selected"); assert!(h.ctx.memory(|m| m.focused()).is_none(), "a script does not take the keyboard focus"); } @@ -151,11 +154,10 @@ fn engine_execute_sets_the_panel_filter_too() { // `engine.execute` runs engine commands through `PhotocraftApp::run`, not `menus::invoke`. let mut h = harness(); h.state_mut().ui.layer_filter_by = FilterBy::Kind; - let before = selected(&h); h.state_mut().run("select.findLayers", json!({"name": "link"})).unwrap(); h.run_steps(4); assert_eq!((h.state().ui.layer_filter_by, h.state().ui.layer_filter_name.as_str()), (FilterBy::Name, "link")); assert_eq!(listed(&h), ["LinkB", "LinkA"]); - assert_eq!(selected(&h), before); + assert_eq!(selected(&h), [], "the filter hides \"Other\" (#10879) and selects none of the matches"); assert!(h.ctx.memory(|m| m.focused()).is_none(), "a script does not take the keyboard focus"); } From 8bf381f2d930862009bea14cec1a61c857ec666d Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 7 Nov 2026 20:24:22 +0100 Subject: [PATCH 6/6] Find Layers: keep the Name text on every run path; no focus for a hidden filter row (#11238) CodeRabbit found three things after the last fix-up: - `engine.execute` and action steps without `name` replied `selected: []` while the panel listed the layers its kept Name text matches. `run` now fills in the panel's Name text for every path, as the menu did. - With Filter Options > Hide, Find Layers left a focus request that took the caret once the row was shown again. In the reference application the row stays hidden and showing it later does not focus the field, so the request is only made for a drawn row. - The control protocol said the selection never changes; the Name filter deselects a selected layer it hides (#10879). The doc now says so and describes each entry point and the reply. Tests for the first two fail without the fix. Co-Authored-By: NaufalDzz Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/layer_multi_cmds.rs | 2 +- crates/ui-egui/src/app/commands.rs | 1 + .../src/panels/layer_filter_ui/find.rs | 22 ++++++++++++-- .../src/panels/layer_filter_ui/find_tests.rs | 29 +++++++++++++++++++ docs/control-protocol.md | 2 +- 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/layer_multi_cmds.rs b/crates/engine/src/cmd/layer_multi_cmds.rs index ffb1c068c2..5076d665ff 100644 --- a/crates/engine/src/cmd/layer_multi_cmds.rs +++ b/crates/engine/src/cmd/layer_multi_cmds.rs @@ -106,7 +106,7 @@ pub fn specs() -> Vec { "Find Layers", &["Select"], Some("Cmd+Alt+Shift+F"), - r##"{"name":str?} (filters the Layers panel by Name, a case-insensitive substring, without changing the selection; replies with the matching layers)"##, + r##"{"name":str?} (filters the Layers panel by Name, a case-insensitive substring, selecting none of the matches; without `name` the panel's Name text is kept; replies with the matching layers)"##, has_doc, find_layers ), diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index 0dd4c88842..e829a58a2d 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -6,6 +6,7 @@ use super::{ impl PhotocraftApp { /// Run an engine command, reporting errors in the status bar. pub fn run(&mut self, id: &str, params: Value) -> Result { + let params = if id == "select.findLayers" { crate::layer_filter_ui::find::params_for_run(self, params) } else { params }; if let Some(result) = delete_layer_prompt::intercept(self, id, ¶ms) { return result; } diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find.rs b/crates/ui-egui/src/panels/layer_filter_ui/find.rs index 36c285718c..ee437906cf 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find.rs @@ -18,8 +18,8 @@ fn focus_flag() -> egui::Id { /// shown with the field focused. pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, params: Value) -> Result { let given = params.get("name").is_some_and(|n| !n.is_null()); - let params = if given { params } else { json!({"name": app.ui.layer_filter_name}) }; - // `run` applies the reply's Name filter ([`apply`]). + // `run` keeps the Name text when no `name` is given ([`params_for_run`]) and applies the + // reply's Name filter ([`apply`]). let reply = app.run("select.findLayers", params)?; if !given { // The panel docking layout (when on) shows the Layers panel itself, else the dock group. @@ -31,11 +31,27 @@ pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, params: Value) -> Re *crate::dock::Group::Layers.tab_mut(&mut app.ui.dock_tabs) = 0; crate::dock::reveal(app, crate::dock::Group::Layers); } - ctx.data_mut(|d| d.insert_temp(focus_flag(), true)); + // A hidden filter row (Filter Options › Hide) stays hidden, as in Photoshop, and showing it + // later doesn't put the caret in the field: only a drawn row takes the focus. + if app.ui.layers_panel_options.show_filters { + ctx.data_mut(|d| d.insert_temp(focus_flag(), true)); + } } Ok(reply) } +/// The params `select.findLayers` runs with: without a `name` the panel's Name text is kept, so the +/// reply lists the layers the panel lists however the command runs (the menu, the shortcut, +/// `engine.execute` or an action step). +pub(crate) fn params_for_run(app: &PhotocraftApp, params: Value) -> Value { + if params.get("name").is_some_and(|n| !n.is_null()) { + return params; + } + let mut params = if params.is_object() { params } else { json!({}) }; + params["name"] = json!(app.ui.layer_filter_name); + params +} + /// Apply the Name filter in a `select.findLayers` reply to the Layers panel: switch to Name and set /// the text when the reply has one. [`PhotocraftApp::run`] calls it after every Find Layers. pub(crate) fn apply(app: &mut PhotocraftApp, reply: &Value) { diff --git a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs index 322629b5c9..8a7a00d854 100644 --- a/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs +++ b/crates/ui-egui/src/panels/layer_filter_ui/find_tests.rs @@ -149,6 +149,35 @@ fn the_menu_item_shows_a_layers_panel_closed_in_the_docking_layout() { assert_eq!(h.state().ui.layer_filter_name, "other", "the Name field has the focus with its text selected"); } +#[test] +fn a_hidden_filter_row_stays_hidden_and_does_not_take_the_focus_later() { + // Measured in Photoshop: with Filter Options › Hide, Find Layers switches to Name but leaves + // the row hidden, and showing the row afterwards does not put the caret in the field. + let mut h = harness(); + h.state_mut().ui.layers_panel_options.show_filters = false; + h.state_mut().ui.layer_filter_name = "lin".into(); + h.run_steps(4); + find(&mut h, json!({})); + assert_eq!(h.state().ui.layer_filter_by, FilterBy::Name); + assert!(!h.state().ui.layers_panel_options.show_filters, "the filter row stays hidden"); + h.state_mut().ui.layers_panel_options.show_filters = true; + h.run_steps(4); + assert!(h.ctx.memory(|m| m.focused()).is_none(), "showing the row later does not focus the Name field"); + assert_eq!(h.state().ui.layer_filter_name, "lin"); +} + +#[test] +fn engine_execute_without_a_name_lists_what_the_panel_lists() { + let mut h = harness(); + h.state_mut().ui.layer_filter_name = "link".into(); + let reply = h.state_mut().run("select.findLayers", json!({})).unwrap(); + h.run_steps(4); + assert_eq!(h.state().ui.layer_filter_name, "link", "the Name text is kept"); + assert_eq!(reply["selected"], json!([id(&h, "LinkA").0, id(&h, "LinkB").0]), "the reply lists the layers the kept text matches"); + assert_eq!(reply["layerFilter"], json!({"by": "name", "name": "link"})); + assert_eq!(listed(&h), ["LinkB", "LinkA"]); +} + #[test] fn engine_execute_sets_the_panel_filter_too() { // `engine.execute` runs engine commands through `PhotocraftApp::run`, not `menus::invoke`. diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 364b2b20e2..5934696f08 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -56,7 +56,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i - `ui.set` also accepts `tileGrid` (boolean), a developer overlay of the active layer's storage tiles: the tile grid over the document, every stored tile filled and labelled `tx,ty`, tiles with identical pixels in a shared colour and unique ones in blue. It has no menu item and View › Extras doesn't hide it. `ui.inspect` reports it as `view.tile_grid`. - `ui.set` also accepts `strokeTrace` (`true`, `false`, `"stderr"` or `"off"`): turn the stroke latency trace on or off at runtime; each stroke's summary is in `ui.inspect` `perf.strokeTrace`. A CSV file of every frame is set only at launch (`PHOTOCRAFT_STROKE_TRACE=` / `--stroke-trace `): the control channel doesn't write files outside the automation write root - `ui.set` also accepts `layerFilter` (#5048), the Layers panel filter row: `{by?, kinds?, name?, effect?, mode?, attribute?, color?, smart?}`, any subset. `by` is `kind`, `name`, `effect`, `mode`, `attribute`, `color`, `smartObject`, `artboard` or `group` (the filter-type dropdown); `kinds` lists the Kind toggles that are on (`pixel`, `adjustment`, `type`, `shape`, `smart`); `name` matches part of a layer name, ignoring case; `effect` (#10880) is `bevelEmboss`, `stroke`, `innerShadow`, `innerGlow`, `satin`, `overlay` (Color, Gradient or Pattern Overlay), `outerGlow` or `dropShadow`, and lists the layers with that effect turned on; `mode` is one of the 27 layer blend modes (`Multiply`, `Screen`), not Pass Through, which the Mode list doesn't offer (#10878); `attribute` (#10881) is `visible`, `locked`, `empty`, `linked`, `clipped`, `layerMask`, `vectorMask`, `layerEffects` or `advancedBlending`, or one of their opposites `notVisible`, `notLocked`, `notEmpty`, `notLinked`, `notClipped`, `noLayerMask`, `noVectorMask`, `noLayerEffects`, `noAdvancedBlending`; `color` is a layer colour label id (`none`, `red`, `orange`, `yellow`, `green`, `seafoam`, `blue`, `indigo`, `magenta`, `fuchsia`, `violet`, `gray`; #5898); `smart` lists the Smart Object toggles that are on (`linked`: linked to a file, `missing`: linked to a file that was not there when the app last looked, `embedded`). Kind, Name and Smart Object filter only once a toggle is on or text is typed; Effect, Mode, Attribute and Color always filter, by Bevel & Emboss, by Normal, by Visible and by no colour at first, as in Photoshop. Artboard has no field of its own: it lists the artboards that hold the selected layers, with everything inside them (closed groups stay closed), and does not filter when nothing is selected or a selected layer is in no artboard. Group (#10883) has no field of its own either and filters at once: it lists every group that is not an artboard with everything inside it (the groups inside an artboard too), and hides the layers that are in no group; each group stays open or closed as it is. Fields left out keep their value; a bad one is an error and changes nothing. -- `select.findLayers` (#10884, Select › Find Layers) filters the Layers panel by Name and does not change the layer selection. With `name` it sets the Name text; without it the text is kept, the Layers panel is shown and its Name field takes the keyboard focus with the text selected. The reply lists the matching layer ids in `selected` and the Name filter applied in `layerFilter` (`{by: "name", name?}`). +- `select.findLayers` (#10884, Select › Find Layers) filters the Layers panel by Name and selects none of the matches; as with any filter, a selected layer the filter hides is deselected (#10879). With `name` it sets the Name text; without it the text is kept. Through `engine.execute` or an action step that is all; through the menu, the shortcut or `ui.menu.invoke` without `name`, the Layers panel is also shown and its Name field takes the keyboard focus with the text selected (unless Filter Options › Hide hid the filter row, which stays hidden). The reply lists the ids of the layers the Name text matches in `selected` (trimmed, ignoring case: a blank text lists every layer, a text nothing matches none) and the Name filter applied in `layerFilter` (`{by: "name", name}`). - `ui.set` also accepts the Histogram panel: `histogramPanel` `{view?, channel?, showChannelsInColor?, showStatistics?, source?}` (any subset, kept with the preferences): `view` is `compact`, `expanded` or `allChannels`; `channel` is `composite`, `red`, `green`, `blue`, `cyan`, `magenta`, `yellow`, `black`, `a`, `b`, `luminosity` or `colors` (one the document's mode lacks shows as its composite); `source` is `entireImage`, `selectedLayer` or `adjustmentComposite` (Entire Image is counted in Compact View, when the document has one layer, or when no adjustment layer is selected for Adjustment Composite). `histogramRange` is `[from, to]` (levels 0..255) or `null`: the dragged tonal range whose Count and Percentile the statistics show. `histogramRefresh: true` is Uncached Refresh: the current state is recounted at cache level 1. `ui.inspect` › `histogram` reports the options, the channel and source as they apply, the channels the document offers, whether the shown histogram is `current` (counted for the document's revision, source and cache level the panel wants now), its `cacheLevel`, `maxCacheLevel` (Preferences › Performance › Cache Levels), `preview` (an adjustment's preview is counted) and `stats` (`mean`, `stdDev`, `median`, `pixels`, `level`, `count`, `percentile`, `clipped` percent at 0 and 255). Histograms are counted while the panel is shown. - Each painting tool keeps its own brush, as in Photoshop: `tools.setBrush` and `ui.set {brushSize}` change the active tool's brush, and switching tools swaps in that tool's own (size, hardness, mode, opacity, flow, dynamics, smoothing). A tool used for the first time starts from the brush in hand. The colours, the erase flag and the stroke seed stay shared. So `ui.set {tool: "eraser", brushSize: 12}` sets the Eraser's size, and `ui.set {tool: "brush"}` afterwards brings the Brush's own size back. - Brush Pose's `pose.overrideTiltX` and `pose.overrideTiltY` are independent booleans. For example, `engine.execute {"command":"tools.setBrush","params":{"pose":{"enabled":true,"tiltX":45,"overrideTiltX":true,"overrideTiltY":false}}}` fixes X at 45° while Y follows the stylus. Pose tilts are degrees (±90); the Brush Settings panel displays percentages (±100). Old stored `overrideTilt` values migrate to both axes. In command patches, `overrideTilt` sets both axes unless an explicit axis field in the same patch overrides it. `brush.get` includes both axis flags and the legacy combined readback (`overrideTilt` is true only when both flags are true). Axis-only journals omit that derived combined key so replay retains the other axis. Present flag values must be booleans; null and other types return an error.