PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Layers panel: filter-type dropdown with Kind, Name and Mode (#5048) (#5268)
Zach Schneider7833a6cad4dc
diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rsindex ce486f802..207ecbc80 100644--- a/crates/ui-egui/src/control.rs+++ b/crates/ui-egui/src/control.rs@@ -131,7 +131,7 @@ pub enum Outcome {/// field's value is validated before the first one is applied, so a typo, an unknown field, a/// bad value or a bad nested key can't reply with success while nothing — or only half of it —/// changed (#412).-pub const UI_SET_FIELDS: [&str; 35] = [+pub const UI_SET_FIELDS: [&str; 36] = ["tool","panels","dock",@@ -167,6 +167,7 @@ pub const UI_SET_FIELDS: [&str; 35] = ["shapeStroke","camTransformOnDrop","tileGrid",+ "layerFilter",];/// Most clicks one `ui.click` may queue (#982). Each click is a press and a release that the app@@ -511,6 +512,7 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest)let cam_transform_on_drop = bool_field(p, "camTransformOnDrop")?;// Developer overlay of the active layer's storage tiles (tile_overlay.rs).let tile_grid = bool_field(p, "tileGrid")?;+ let layer_filter = p.get("layerFilter").map(|v| crate::layer_filter_ui::patched(&app.ui, v)).transpose()?;// The Crop tool's overlay menu (#1919).let crop_overlay = match p.get("cropOverlay") {Some(v) => Some(v.as_str().and_then(crate::crop_overlay::CropOverlay::from_id).ok_or_else(|| {@@ -672,6 +674,9 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest)if let Some(on) = tile_grid {app.ui.view.tile_grid = on;}+ if let Some(f) = layer_filter {+ crate::layer_filter_ui::apply(&mut app.ui, f);+ }if let Some(k) = crop_overlay {app.ui.tool_options.crop_overlay = k;}@@ -1930,6 +1935,36 @@ mod tests {assert!(app.ui.tool_options.gradient_classic, "invalid mode must not change options");}+ /// #5048: the Layers panel filter is drivable; a bad field changes nothing.+ #[test]+ fn ui_set_drives_the_layers_panel_filter() {+ use crate::layer_filter_ui::FilterBy;+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ let ctx = egui::Context::default();+ let ok = call(&mut app, &ctx, "ui.set", json!({"layerFilter": {"by": "name", "name": "ink"}}));+ assert_eq!(ok["ok"], true, "{ok}");+ assert_eq!((app.ui.layer_filter_by, app.ui.layer_filter_name.as_str()), (FilterBy::Name, "ink"));+ let ok = call(&mut app, &ctx, "ui.set", json!({"layerFilter": {"by": "mode", "mode": "Pass Through", "kinds": ["type", "pixel", "type"]}}));+ assert_eq!(ok["ok"], true, "{ok}");+ assert_eq!((app.ui.layer_filter_by, app.ui.layer_filter_mode), (FilterBy::Mode, photocraft_color::BlendMode::PassThrough));+ assert_eq!(app.ui.layer_filter, ["type", "pixel"], "kinds are kept once each");+ assert_eq!(app.ui.layer_filter_name, "ink", "fields left out keep their value");+ for bad in [+ json!({"layerFilter": "name"}),+ json!({"layerFilter": {"by": "colour"}}),+ json!({"layerFilter": {"kinds": ["pixels"]}}),+ json!({"layerFilter": {"kinds": "pixel"}}),+ json!({"layerFilter": {"name": 3}}),+ json!({"layerFilter": {"mode": "Nonsense"}}),+ json!({"layerFilter": {"by": "kind", "extra": true}}),+ json!({"layerFilter": {"by": "kind"}, "tileGrid": "yes"}),+ ] {+ let r = call(&mut app, &ctx, "ui.set", bad.clone());+ assert_eq!(r["ok"], false, "{bad} → {r}");+ assert_eq!(app.ui.layer_filter_by, FilterBy::Mode, "{bad} changed nothing");+ }+ }+#[test]fn ui_set_toggles_the_developer_tile_grid() {let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());diff --git a/crates/ui-egui/src/layer_filter_ui.rs b/crates/ui-egui/src/layer_filter_ui.rsnew file mode 100644index 000000000..e933d0c16--- /dev/null+++ b/crates/ui-egui/src/layer_filter_ui.rs@@ -0,0 +1,162 @@+//! The Layers panel's filter row (#5048): a filter-type dropdown, as in Photoshop, then the+//! controls for that type. Kind toggles layer kinds, Name matches part of the layer name, Mode+//! picks one blend mode. The criteria live in `UiState` (`layer_filter*`), so the control channel+//! can read and set them.++use photocraft_color::BlendMode;+use photocraft_doc::{Layer, LayerContent};+use serde::{Deserialize, Serialize};++use crate::state::UiState;+use crate::{PhotocraftApp, icons, widgets};++/// What the Layers panel filters by.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub enum FilterBy {+ #[default]+ Kind,+ Name,+ Mode,+}++/// The filter criteria, copied out of `UiState` for one frame of the Layers panel.+#[derive(Clone, Debug, PartialEq)]+pub struct Filter {+ pub by: FilterBy,+ pub kinds: Vec<String>,+ /// As typed; matched trimmed and ignoring case.+ pub name: String,+ pub mode: BlendMode,+}++impl Filter {+ pub fn of(ui: &UiState) -> Self {+ Self { by: ui.layer_filter_by, kinds: ui.layer_filter.clone(), name: ui.layer_filter_name.clone(), mode: ui.layer_filter_mode }+ }++ /// Whether the panel is filtered. Like Photoshop, Mode always filters (by Normal at first);+ /// Kind and Name only once a kind is toggled or some text is typed.+ pub fn active(&self) -> bool {+ match self.by {+ FilterBy::Kind => !self.kinds.is_empty(),+ FilterBy::Name => !self.name.trim().is_empty(),+ FilterBy::Mode => true,+ }+ }++ /// Whether `l` is listed under this filter.+ pub fn shows(&self, l: &Layer) -> bool {+ if !self.active() {+ return true;+ }+ match self.by {+ FilterBy::Kind => self.kinds.iter().any(|k| k == kind(l)),+ FilterBy::Name => l.name.to_lowercase().contains(&self.name.trim().to_lowercase()),+ FilterBy::Mode => l.blend == self.mode,+ }+ }+}++/// The kinds the Kind filter toggles.+pub const KINDS: [&str; 5] = ["pixel", "adjustment", "type", "shape", "smart"];++/// `ui.set {layerFilter: {by?, kinds?, name?, mode?}}`: `current` with the given fields replaced,+/// or an error naming the bad field (nothing changes then). `by` is `kind`, `name` or `mode`;+/// `kinds` a list of [`KINDS`]; `mode` a blend mode name such as `Multiply` or `Pass Through`.+pub fn patched(current: &UiState, v: &serde_json::Value) -> Result<Filter, String> {+ let Some(o) = v.as_object() else { return Err("layerFilter must be an object".into()) };+ if let Some(k) = o.keys().find(|k| !["by", "kinds", "name", "mode"].contains(&k.as_str())) {+ return Err(format!("unknown layerFilter field `{k}` (fields: by, kinds, name, mode)"));+ }+ let mut f =+ Filter { by: current.layer_filter_by, kinds: current.layer_filter.clone(), name: current.layer_filter_name.clone(), mode: current.layer_filter_mode };+ if let Some(by) = o.get("by") {+ f.by = serde_json::from_value(by.clone()).map_err(|_| "layerFilter.by must be kind, name or mode".to_string())?;+ }+ if let Some(kinds) = o.get("kinds") {+ let list = kinds.as_array().ok_or("layerFilter.kinds must be a list")?;+ f.kinds = Vec::new();+ for k in list {+ let Some(k) = k.as_str().filter(|k| KINDS.contains(k)) else {+ return Err(format!("layerFilter.kinds: unknown kind {k} (kinds: {})", KINDS.join(", ")));+ };+ if !f.kinds.iter().any(|have| have == k) {+ f.kinds.push(k.to_string());+ }+ }+ }+ if let Some(name) = o.get("name") {+ f.name = name.as_str().ok_or("layerFilter.name must be a string")?.to_string();+ }+ if let Some(mode) = o.get("mode") {+ let name = mode.as_str().ok_or("layerFilter.mode must be a blend mode name")?;+ f.mode = photocraft_engine::commands::blend_from_str(name)+ .filter(|m| *m == BlendMode::PassThrough || BlendMode::LAYER_MODES.contains(m))+ .ok_or_else(|| format!("layerFilter.mode: unknown blend mode `{name}`"))?;+ }+ Ok(f)+}++/// Store `f` as the Layers panel's filter.+pub fn apply(ui: &mut UiState, f: Filter) {+ ui.layer_filter_by = f.by;+ ui.layer_filter = f.kinds;+ ui.layer_filter_name = f.name;+ ui.layer_filter_mode = f.mode;+}++/// The kind filter's name for `l`'s content ("" for groups, which no kind matches).+fn kind(l: &Layer) -> &'static str {+ match &l.content {+ LayerContent::Raster(_) => "pixel",+ LayerContent::Adjustment(_) | LayerContent::Fill(_) => "adjustment",+ LayerContent::Text(_) => "type",+ LayerContent::Shape(_) => "shape",+ LayerContent::Smart(_) => "smart",+ LayerContent::Group(_) => "",+ }+}++/// Draw the filter row: the type dropdown, then that type's controls.+pub fn bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {+ ui.horizontal(|ui| {+ ui.spacing_mut().item_spacing.x = 2.0;+ let by = [(FilterBy::Kind, tl!("Kind")), (FilterBy::Name, tl!("Name")), (FilterBy::Mode, tl!("Mode"))];+ widgets::dropdown(ui, "layer-filter-by", &mut app.ui.layer_filter_by, &by, 64.0);+ ui.add_space(4.0);+ match app.ui.layer_filter_by {+ FilterBy::Kind => {+ for (kind, icon, tip) in [+ ("pixel", "image", tl!("Filter for pixel layers")),+ ("adjustment", "adjustment-layer", tl!("Filter for adjustment layers")),+ ("type", "type", tl!("Filter for type layers")),+ ("shape", "square", tl!("Filter for shape layers")),+ ("smart", "app-window", tl!("Filter for smart objects")),+ ] {+ let on = app.ui.layer_filter.iter().any(|k| k == kind);+ if icons::button(ui, icon, 22.0, on, tip).clicked() {+ if on {+ app.ui.layer_filter.retain(|k| k != kind);+ } else {+ app.ui.layer_filter.push(kind.to_string());+ }+ }+ }+ }+ FilterBy::Name => {+ let width = ui.available_width().max(48.0);+ widgets::text_field(ui, ui.id().with("layer-filter-name"), &mut app.ui.layer_filter_name, tl!("Search"), width, false);+ }+ FilterBy::Mode => {+ let modes: Vec<(BlendMode, &str)> = std::iter::once(BlendMode::PassThrough).chain(BlendMode::LAYER_MODES).map(|m| (m, m.label())).collect();+ let width = ui.available_width().max(96.0);+ widgets::dropdown(ui, "layer-filter-mode", &mut app.ui.layer_filter_mode, &modes, width);+ }+ }+ });+}++#[cfg(test)]+#[path = "layer_filter_ui_tests.rs"]+mod tests;diff --git a/crates/ui-egui/src/layer_filter_ui_tests.rs b/crates/ui-egui/src/layer_filter_ui_tests.rsnew file mode 100644index 000000000..16400ae12--- /dev/null+++ b/crates/ui-egui/src/layer_filter_ui_tests.rs@@ -0,0 +1,136 @@+//! #5048: the Layers panel's filter-type dropdown (Kind, Name, Mode).++use egui::vec2;+use egui_kittest::Harness;+use egui_kittest::kittest::Queryable;+use photocraft_color::BlendMode;+use photocraft_doc::Document;+use serde_json::json;++use super::{Filter, FilterBy};+use crate::PhotocraftApp;+use crate::state::UiState;++/// Background, "Ink" (Multiply) and "Paper" in a group "Sheets", and "ink notes" (type) on top.+fn session() -> photocraft_engine::Session {+ let mut s = photocraft_engine::Session::new();+ s.execute("file.new", json!({"width": 64, "height": 48})).unwrap();+ s.execute("layer.new.layer", json!({"name": "Paper"})).unwrap();+ s.execute("layer.groupLayers", json!({"name": "Sheets"})).unwrap();+ let paper = layer(&s.active().unwrap().doc, "Paper");+ s.execute("layer.select", json!({"layer": paper})).unwrap();+ let ink = s.execute("layer.new.layer", json!({"name": "Ink"})).unwrap()["layer"].as_u64().unwrap();+ s.execute("layer.setProps", json!({"layer": ink, "blend": "Multiply"})).unwrap();+ let sheets = layer(&s.active().unwrap().doc, "Sheets");+ s.execute("layer.select", json!({"layer": sheets})).unwrap();+ let text = s.execute("type.create", json!({"text": "ink notes", "x": 4, "y": 20, "size": 12})).unwrap()["layer"].as_u64().unwrap();+ s.execute("layer.setProps", json!({"layer": text, "name": "ink notes"})).unwrap();+ s+}++fn layer(doc: &Document, name: &str) -> u64 {+ doc.walk().into_iter().find(|(_, _, l)| l.name == name).map(|(_, _, l)| l.id.0).unwrap_or_else(|| panic!("no layer {name}"))+}++/// The names `filter` lists, top to bottom.+fn listed(doc: &Document, filter: &Filter) -> Vec<String> {+ crate::layer_tree_ui::display_rows(doc, filter.active()).into_iter().filter(|(_, l)| filter.shows(l)).map(|(_, l)| l.name.clone()).collect()+}++fn filter(by: FilterBy, kinds: &[&str], name: &str, mode: BlendMode) -> Filter {+ Filter::of(&UiState {+ layer_filter_by: by,+ layer_filter: kinds.iter().map(|k| k.to_string()).collect(),+ layer_filter_name: name.into(),+ layer_filter_mode: mode,+ ..UiState::default()+ })+}++#[test]+fn each_filter_type_lists_its_matches() {+ let s = session();+ let doc = &s.active().unwrap().doc;+ let all = listed(doc, &Filter::of(&UiState::default()));+ assert_eq!(all, ["ink notes", "Sheets", "Ink", "Paper", "Background"]);+ // Kind: groups match no kind, as before.+ assert_eq!(listed(doc, &filter(FilterBy::Kind, &["pixel"], "", BlendMode::Normal)), ["Ink", "Paper", "Background"]);+ assert_eq!(listed(doc, &filter(FilterBy::Kind, &["type"], "", BlendMode::Normal)), ["ink notes"]);+ // Name: part of the name, ignoring case and surrounding spaces; groups match too.+ assert_eq!(listed(doc, &filter(FilterBy::Name, &[], " INK ", BlendMode::Normal)), ["ink notes", "Ink"]);+ assert_eq!(listed(doc, &filter(FilterBy::Name, &[], "sheet", BlendMode::Normal)), ["Sheets"]);+ assert_eq!(listed(doc, &filter(FilterBy::Name, &[], "nothing like it", BlendMode::Normal)), Vec::<String>::new());+ // Mode: one blend mode; a group's own Pass Through counts.+ assert_eq!(listed(doc, &filter(FilterBy::Mode, &[], "", BlendMode::Multiply)), ["Ink"]);+ assert_eq!(listed(doc, &filter(FilterBy::Mode, &[], "", BlendMode::PassThrough)), ["Sheets"]);+ assert_eq!(listed(doc, &filter(FilterBy::Mode, &[], "", BlendMode::Normal)), ["ink notes", "Paper", "Background"]);+}++#[test]+fn only_a_criterion_turns_kind_and_name_on_while_mode_always_filters() {+ let kinds_left_on = filter(FilterBy::Name, &["pixel"], "", BlendMode::Multiply);+ assert!(!kinds_left_on.active(), "the other types' criteria don't apply");+ assert!(!filter(FilterBy::Name, &[], " ", BlendMode::Normal).active(), "spaces are no criterion");+ assert!(!filter(FilterBy::Kind, &[], "ink", BlendMode::Normal).active());+ assert!(filter(FilterBy::Mode, &[], "", BlendMode::Normal).active(), "Mode filters by Normal at first, like Photoshop");+}++#[test]+fn saved_settings_without_the_new_fields_still_load() {+ let mut saved = serde_json::to_value(UiState::default()).unwrap();+ let fields = saved.as_object_mut().unwrap();+ for key in ["layer_filter_by", "layer_filter_name", "layer_filter_mode"] {+ assert!(fields.remove(key).is_some(), "{key} is saved");+ }+ let ui: UiState = serde_json::from_value(saved).unwrap();+ assert_eq!((ui.layer_filter_by, ui.layer_filter_name.as_str(), ui.layer_filter_mode), (FilterBy::Kind, "", BlendMode::Normal));+ let round = serde_json::to_value(UiState { layer_filter_by: FilterBy::Mode, ..UiState::default() }).unwrap();+ assert_eq!(round["layer_filter_by"], "mode");+}++fn harness() -> Harness<'static, PhotocraftApp> {+ let session = session();+ 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(session, crate::Services::default())+ });+ h.run_steps(8);+ h+}++/// The names of the rows the Layers panel drew, top to bottom.+fn drawn(h: &Harness<'_, PhotocraftApp>) -> Vec<String> {+ let doc = &h.state().session.active().unwrap().doc;+ let mut rows = crate::layer_row_ui::recorded(&h.ctx);+ rows.sort_by(|a, b| a.row.top().total_cmp(&b.row.top()));+ rows.iter().filter_map(|r| doc.walk().into_iter().find(|(_, _, l)| l.id.0 == r.layer).map(|(_, _, l)| l.name.clone())).collect()+}++#[test]+fn the_dropdown_switches_the_panel_between_filter_types() {+ let mut h = harness();+ assert_eq!(drawn(&h), ["ink notes", "Sheets", "Ink", "Paper", "Background"]);+ // The type is a real dropdown now: open it and pick Name.+ // A dropdown shows its choice as the combo box's value.+ h.get_by_value("Kind").click();+ h.run_steps(4);+ h.query_all_by_label("Name").last().expect("Name in the open list").click();+ h.run_steps(4);+ assert_eq!(h.state().ui.layer_filter_by, FilterBy::Name);+ assert_eq!(drawn(&h), ["ink notes", "Sheets", "Ink", "Paper", "Background"], "no text yet: every layer");+ h.state_mut().ui.layer_filter_name = "ink".into();+ h.run_steps(4);+ assert_eq!(drawn(&h), ["ink notes", "Ink"]);+ // Mode starts at Normal; the kind toggles left on under Kind don't leak into it.+ h.state_mut().ui.layer_filter = vec!["type".into()];+ h.state_mut().ui.layer_filter_by = FilterBy::Mode;+ h.run_steps(4);+ assert_eq!(drawn(&h), ["ink notes", "Paper", "Background"]);+ h.state_mut().ui.layer_filter_mode = BlendMode::Multiply;+ h.run_steps(4);+ assert_eq!(drawn(&h), ["Ink"]);+ // Back to Kind: its own criterion applies again.+ h.state_mut().ui.layer_filter_by = FilterBy::Kind;+ h.run_steps(4);+ assert_eq!(drawn(&h), ["ink notes"]);+}diff --git a/crates/ui-egui/src/layer_tree_ui.rs b/crates/ui-egui/src/layer_tree_ui.rsindex 2c1040c24..d00dffb8d 100644--- a/crates/ui-egui/src/layer_tree_ui.rs+++ b/crates/ui-egui/src/layer_tree_ui.rs@@ -39,7 +39,7 @@ pub fn display_rows(doc: &Document, show_all: bool) -> Vec<(usize, &Layer)> {/// Mask session's working text, which is no layer to the user: Photoshop shows only the mask/// overlay while you type (#3036).pub fn panel_rows<'a>(app: &PhotocraftApp, doc: &'a Document) -> Vec<(usize, &'a Layer)> {- let mut rows = display_rows(doc, !app.ui.layer_filter.is_empty());+ let mut rows = display_rows(doc, crate::layer_filter_ui::Filter::of(&app.ui).active());if let Some(working) = app.ui.text_edit.as_ref().filter(|ed| ed.mask).map(|ed| ed.layer) {rows.retain(|(_, l)| l.id.0 != working);}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 3e51aa0ab..ad79a4355 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -108,6 +108,7 @@ pub mod jobs_ui;pub mod kys_import;pub mod lasso_ui;pub(crate) mod last_brush;+pub mod layer_filter_ui;pub mod layer_menu_ui;pub mod layer_pick_ui;pub mod layer_picker;diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rsindex 6fd635e39..c53bc1796 100644--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@ -2198,31 +2198,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());if t.pro {- ui.horizontal(|ui| {- ui.spacing_mut().item_spacing.x = 2.0;- let (r, _) = ui.allocate_exact_size(vec2(64.0, 22.0), Sense::hover());- ui.painter().rect_filled(r, t.radius_sm, t.field);- ui.painter().rect_stroke(r, t.radius_sm, Stroke::new(1.0, t.field_border), StrokeKind::Inside);- icons::paint(ui, Rect::from_center_size(r.left_center() + vec2(11.0, 0.0), vec2(14.0, 14.0)), "search", 11.0, t.text_faint);- ui.painter().text(r.left_center() + vec2(22.0, 0.0), Align2::LEFT_CENTER, tl!("Kind"), egui::FontId::proportional(11.5), t.text_dim);- ui.add_space(4.0);- for (kind, icon, tip) in [- ("pixel", "image", tl!("Filter for pixel layers")),- ("adjustment", "adjustment-layer", tl!("Filter for adjustment layers")),- ("type", "type", tl!("Filter for type layers")),- ("shape", "square", tl!("Filter for shape layers")),- ("smart", "app-window", tl!("Filter for smart objects")),- ] {- let on = app.ui.layer_filter.iter().any(|k| k == kind);- if icons::button(ui, icon, 22.0, on, tip).clicked() {- if on {- app.ui.layer_filter.retain(|k| k != kind);- } else {- app.ui.layer_filter.push(kind.to_string());- }- }- }- });+ crate::layer_filter_ui::bar(app, ui);ui.add_space(4.0);}if let Some(l) = active_layer {@@ -2347,7 +2323,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {ui.scroll_with_delta(vec2(0.0, delta));ctx.request_repaint();}- let filter = app.ui.layer_filter.clone();+ let filter = crate::layer_filter_ui::Filter::of(&app.ui);let fx_collapsed = app.session.active().map(|d| d.fx_collapsed.clone()).unwrap_or_default();crate::layer_row_ui::begin(ui.ctx());// The drawn rows, top to bottom (#1721): the space between them and below the last@@ -2358,18 +2334,8 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {if !photocraft_engine::select_extra_cmds::isolation_shows(&doc, &isolated, l.id) {continue;}- if !filter.is_empty() {- let kind = match &l.content {- LayerContent::Raster(_) => "pixel",- LayerContent::Adjustment(_) | LayerContent::Fill(_) => "adjustment",- LayerContent::Text(_) => "type",- LayerContent::Shape(_) => "shape",- LayerContent::Smart(_) => "smart",- LayerContent::Group(_) => "",- };- if !filter.iter().any(|k| k == kind) {- continue;- }+ if !filter.shows(l) {+ continue;}let row = RowSel { selected: selection.contains(&l.id), primary: active == Some(l.id), multi: selection.len() > 1 };let top = ui.cursor().top();diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rsindex 42997fe62..ae7277160 100644--- a/crates/ui-egui/src/state.rs+++ b/crates/ui-egui/src/state.rs@@ -741,6 +741,10 @@ fn default_brush_tool() -> Tool {Tool::Brush}+fn default_layer_filter_mode() -> photocraft_color::BlendMode {+ photocraft_color::BlendMode::Normal+}+fn one_u32() -> u32 {1}@@ -1140,6 +1144,15 @@ pub struct UiState {/// Layers panel kind filter ("pixel", "adjustment", "type", "shape", "smart"); empty = all.#[serde(default)]pub layer_filter: Vec<String>,+ /// Layers panel filter type (#5048): kind (above), name or blend mode.+ #[serde(default)]+ pub layer_filter_by: crate::layer_filter_ui::FilterBy,+ /// Layers panel name filter: part of a layer name, ignoring case; empty = all.+ #[serde(default)]+ pub layer_filter_name: String,+ /// Layers panel blend-mode filter.+ #[serde(default = "default_layer_filter_mode")]+ pub layer_filter_mode: photocraft_color::BlendMode,/// Actions panel: which row is selected and which are expanded. The list lives on the session.#[serde(default)]pub actions: crate::actions::ActionsUi,@@ -1307,6 +1320,9 @@ impl Default for UiState {artboard_tool: Default::default(),shell: Default::default(),layer_filter: Vec::new(),+ layer_filter_by: Default::default(),+ layer_filter_name: String::new(),+ layer_filter_mode: default_layer_filter_mode(),pen: None,stroke_editor: None,direct_selection: Default::default(),diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 9b49cd9b3..0dcaca2a4 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -53,6 +53,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i- `ui.set` also accepts `gradientBlendMode` (a layer blend mode name, such as `Difference`) and `gradientClassic` (boolean) for the Gradient tool options bar.- `ui.set` also accepts `camTransformOnDrop` (boolean), the Content-Aware Move tool's Transform On Drop checkbox: a drop then puts a scale/rotate box on the patch (`ui.inspect` › `camTransform`: its document/revision, drag `offset` and `frame`), driven with `ui.pointer` (handles as Free Transform's; outside the box rotates), committed with `ui.key Enter` (one `paint.contentAwareMove` with `scaleX`, `scaleY`, `rotate`) or dropped with `Escape`.- `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 `layerFilter` (#5048), the Layers panel filter row: `{by?, kinds?, name?, mode?}`, any subset. `by` is `kind`, `name` or `mode` (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; `mode` is a blend mode name (`Multiply`, `Pass Through`). Kind and Name filter only once a kind is on or text is typed; Mode always filters, by Normal at first, as in Photoshop. Fields left out keep their value; a bad one is an error and changes nothing.- 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.- `ui.set` also accepts the Eyedropper options bar (#1649): `eyedropperSampleSize` (`"point"` or 1, 3, 5, 11, 31, 51, 101: the side of the averaged square, shared by the Eyedropper, a painting tool's Alt-click eyedropper, the Curves/Color Picker eyedroppers and the Info panel), `eyedropperSample` (`current`, `currentAndBelow`, `all`, `allNoAdjustments`, `currentAndBelowNoAdjustments`) and `eyedropperRing` (boolean, Show Sampling Ring). `ui.inspect` reports them under `toolOptions` (`eyedropper_size`, `eyedropper_sample`, `eyedropper_ring`). The engine command `document.sampleColor {x, y, size, sampleLayer}` returns the colour such a sample picks.- `ui.set` also accepts the Crop tool's overlay menu (#1919): `cropOverlay` (`thirds`, `grid`, `diagonal`, `triangle`, `goldenRatio`, `goldenSpiral`), `cropOverlayShow` (`auto`: only while the crop box is dragged, Photoshop's default; `always`; `never`) and `cropOverlayOrientation` (0..3; Triangle has two orientations and Golden Spiral four, the others ignore it). `ui.inspect` reports them under `toolOptions` (`crop_overlay`, `crop_overlay_show`, `crop_overlay_orientation`). In the app, O cycles the overlay and ⇧O its orientation while the Crop tool shows a box.diff --git a/docs/ui-parity.md b/docs/ui-parity.mdindex 41ce47177..4bcd2c413 100644--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@ -1,6 +1,6 @@# UI parity: tools, handles, modifiers and feel-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, thehandles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,@@ -211,6 +211,7 @@ Paragraph; the rest open as in-app floating windows.| Themes: Photoshop's four greys | partial | five themes; #2661 || Document tabs: overflow, context menu, reorder | done | UI-217-6; middle-click close #2570 || Layers panel: wheel steps blend modes, drop on New/Trash | partial | UI-217-14 |+| Layers panel filter-type dropdown (Kind, Name, Effect, Mode, Attribute, Color, Smart Object, Selected, Artboard) | partial | Kind, Name and Mode; the other six missing. `layer_filter_ui.rs`, `ui.set {layerFilter}` (#5048) || Smart filter rows: click selects, drag onto another smart object moves, ⌥-drag copies, drag onto Delete removes | done | `smart_ui.rs`, `layer.smartFilter.transfer` (#4271) || Smart filter rows: drag up or down the stack to reorder (a line marks the drop; the bottom filter is applied first) | done | `smart_ui.rs` `reorder_drop`, `layer.smartFilter.move` |@@ -218,6 +219,7 @@ Paragraph; the rest open as in-app floating windows.| Date | Change | Summary ||---|---|---|+| 2026-10-13 | minor | Layers panel filter row: Kind is a real dropdown with Kind, Name and Mode filters, drivable by `ui.set {layerFilter}` (#5048); row added as partial || 2026-10-13 | minor | Stale "missing tool" rows corrected against main: Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (the P flyout cycle) are live toolbar tools, so only Art History Brush is missing; no percentage or estimate changed || 2026-10-13 | minor | Smart object perspective (non-affine) corrected to done: #426 landed four-corner placements with PSD round trip; scorecard FILE-215-6 flipped || 2026-10-10 | major | First version, from a source audit against Photoshop 2026 27.11.0's shortcuts file and the open issues |