From 5445aeec541b745e10dbfb828ebc44bb7388b859 Mon Sep 17 00:00:00 2001 From: Ivan Sanchez Date: Wed, 18 Nov 2026 11:46:59 -0800 Subject: [PATCH] Lens Blur: an alpha channel as the depth map runs again Since the move to the craft UI framework, Lens Blur's Depth Map menu names an alpha channel `channel:N`, and that id went to the command as is. The engine takes `channel` with `depthChannel`, so OK failed with "`depthMap` must be one of none|transparency|layerMask|channel" and the preview showed nothing. command_params now sends the `channel` source and the channel's index. Test: a document with two alpha channels, the second chosen as the depth map, reaches the command as `channel` and index 1 and runs (fails before the change: `channel:1` and no depthChannel). --- crates/ui-egui/src/dialogs/filter_dialog.rs | 8 +++++++ .../src/dialogs/filter_dialog/tests.rs | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/crates/ui-egui/src/dialogs/filter_dialog.rs b/crates/ui-egui/src/dialogs/filter_dialog.rs index 4fad587bf05..90e91c42311 100644 --- a/crates/ui-egui/src/dialogs/filter_dialog.rs +++ b/crates/ui-egui/src/dialogs/filter_dialog.rs @@ -610,6 +610,14 @@ pub(crate) fn command_params(command: &str, fields: &DialogFields) -> Value { map.insert("matte".into(), color); } } + // Lens Blur's Source menu names an alpha channel `channel:N` (by index: two channels may share a name); the command + // takes the `channel` source and the channel's index. + if command == rows::LENS_BLUR + && let Some(index) = map.get("depthMap").and_then(Value::as_str).and_then(rows::channel_of_choice) + { + map.insert("depthMap".into(), json!("channel")); + map.insert("depthChannel".into(), json!(index)); + } if command == "filter.blur.radialBlur" && let Some([x, y]) = fields.point("center") { diff --git a/crates/ui-egui/src/dialogs/filter_dialog/tests.rs b/crates/ui-egui/src/dialogs/filter_dialog/tests.rs index d6686353b23..73198949cbf 100644 --- a/crates/ui-egui/src/dialogs/filter_dialog/tests.rs +++ b/crates/ui-egui/src/dialogs/filter_dialog/tests.rs @@ -1835,3 +1835,27 @@ fn indexed_matte_other_shows_the_color_row_and_none_hides_it() { assert_eq!(fields_of(harness.state(), id).text("matte"), Some("none")); assert!(try_set(harness.state_mut(), id, "matteColor", json!([0.0, 0.0, 1.0])).is_err(), "None hides the colour row"); } + +/// An alpha channel chosen as Lens Blur's depth map reaches the command as the `channel` source and its index: the +/// menu's own `channel:N` id was sent as is, and the engine refused it at OK and in the preview. +#[test] +fn lens_blur_alpha_channel_source_runs() { + let mut app = new_app(); + app.run("file.new", json!({"width": 64, "height": 64})).unwrap(); + for name in ["Mask", "Depth"] { + app.run("select.all", json!({})).unwrap(); + app.run("select.saveSelection", json!({"name": name})).unwrap(); + } + app.run("select.deselect", json!({})).unwrap(); + let id = open(&mut app, LENS_BLUR).unwrap(); + passes(&mut app, 2); + set(&mut app, id, "depthMap", json!("channel:1")); + passes(&mut app, 2); + let params = command_params(LENS_BLUR, &fields_of(&app, id)); + assert_eq!((¶ms["depthMap"], ¶ms["depthChannel"]), (&json!("channel"), &json!(1)), "{params}"); + app.run(LENS_BLUR, params).expect("the command takes the channel source"); + // The other sources pass through. + set(&mut app, id, "depthMap", json!("transparency")); + let params = command_params(LENS_BLUR, &fields_of(&app, id)); + assert_eq!((¶ms["depthMap"], params.get("depthChannel")), (&json!("transparency"), None)); +}