Merge PR #9370: fix(ui): Bevel & Emboss Highlight and Shadow Mode are separate dropdowns (#9368)

This commit is contained in:
David Mann committed 2026-10-25 15:01:05 +01:00
commit 52dc8e09fb
2 files changed
+50 -1

No files matched your search

+4 -1
View File
@@ -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<String, Valu
let mut cur = disp.get(key).and_then(Value::as_str).unwrap_or("Normal").to_string();
let opts: Vec<(String, &str)> =
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);
@@ -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<String, Value>)| {
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<String, Value>)>| 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");
}