From c5f77cf37a85e56c56531882abe5ac27e225a04e Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 25 Oct 2026 01:48:53 -0600 Subject: [PATCH] fix(ui): Bevel & Emboss Highlight and Shadow Mode are separate dropdowns (#9368) Every blend-mode dropdown in the Layer Style dialog took the id `fx-blend-`, so Bevel & Emboss's two (Highlight Mode and Shadow Mode) shared one: the Shadow Mode list opened over the other and a pick changed the Highlight Mode. Photoshop keeps them independent. The id now includes the parameter, as the other effect dropdowns already do. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/layer_style.rs | 5 +- .../src/layer_style/bevel_modes_tests.rs | 46 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/src/layer_style/bevel_modes_tests.rs diff --git a/crates/ui-egui/src/layer_style.rs b/crates/ui-egui/src/layer_style.rs index 084a48ffa4..8bd559d6f2 100644 --- a/crates/ui-egui/src/layer_style.rs +++ b/crates/ui-egui/src/layer_style.rs @@ -21,6 +21,8 @@ use serde_json::{Map, Value, json}; use crate::theme::Tokens; use crate::{PhotocraftApp, widgets}; +#[cfg(test)] +mod bevel_modes_tests; pub(crate) mod color_picker; mod contour; #[cfg(test)] @@ -1048,7 +1050,8 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map = photocraft_color::BlendMode::LAYER_MODES.iter().map(|m| (m.label().to_string(), m.label())).collect(); - if widgets::dropdown(ui, &format!("fx-blend-{sel_kind}"), &mut cur, &opts, 150.0) { + // One id per mode: Bevel & Emboss has two (Highlight, Shadow), which must not share a list (#9368). + if widgets::dropdown(ui, &format!("fx-blend-{sel_kind}-{key}"), &mut cur, &opts, 150.0) { let value = json!(cur); disp[key] = value.clone(); set_param(f, &selected, key, value); diff --git a/crates/ui-egui/src/layer_style/bevel_modes_tests.rs b/crates/ui-egui/src/layer_style/bevel_modes_tests.rs new file mode 100644 index 0000000000..56bfd35727 --- /dev/null +++ b/crates/ui-egui/src/layer_style/bevel_modes_tests.rs @@ -0,0 +1,46 @@ +//! #9368: Bevel & Emboss's Highlight Mode and Shadow Mode are two dropdowns, each changing its own +//! mode, as in Photoshop. They shared one widget id, so the Shadow Mode list opened both lists and +//! a pick changed the Highlight Mode. +use egui::vec2; +use egui_kittest::kittest::Queryable; + +use super::*; + +#[test] +fn highlight_and_shadow_modes_are_independent_dropdowns() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 32, "height": 32})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("layer.layerStyle.bevelEmboss", json!({})).unwrap(); + let fields = { + let state = app.session.active().unwrap(); + initial_fields(state.doc.layer(state.active_layer.unwrap()).unwrap(), Some("bevelEmboss"), 120.0) + }; + let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 1200.0)).build_ui_state( + |ui, state: &mut (PhotocraftApp, Map)| { + if ui.ctx().fonts(|fonts| fonts.families().contains(&egui::FontFamily::Name("semibold".into()))) { + body(&mut state.0, ui, &mut state.1); + } + }, + (app, fields), + ); + PhotocraftApp::setup_context(&harness.ctx, crate::theme::ThemeKind::ALL[0]); + harness.run_steps(3); + let params = |h: &egui_kittest::Harness<'_, (PhotocraftApp, Map)>| h.state().1["effects"][0]["params"].clone(); + assert_eq!((params(&harness)["highlightBlend"].as_str(), params(&harness)["shadowBlend"].as_str()), (Some("Screen"), Some("Multiply"))); + // Shadow Mode's list: one list opens, and its pick is the Shadow Mode's. + harness.get_by_value("Multiply").click(); + harness.run_steps(3); + assert_eq!(harness.query_all_by_label("Dissolve").count(), 1, "only the Shadow Mode list is open"); + harness.get_by_label("Dissolve").click(); + harness.run_steps(3); + assert_eq!(params(&harness)["shadowBlend"], "Dissolve"); + assert_eq!(params(&harness)["highlightBlend"], "Screen", "the Highlight Mode is unchanged"); + // And the Highlight Mode's list changes the Highlight Mode. + harness.get_by_value("Screen").click(); + harness.run_steps(3); + harness.get_by_label("Overlay").click(); + harness.run_steps(3); + assert_eq!(params(&harness)["highlightBlend"], "Overlay"); + assert_eq!(params(&harness)["shadowBlend"], "Dissolve"); +}