Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

fix(ui): dim unchecked layer style effect labels even when selected (#2288) (#2321)

Nigel Ihza Firdausyf8744c6b81aa
diff --git a/crates/ui-egui/src/layer_style.rs b/crates/ui-egui/src/layer_style.rs
index 2aff1608f..f582197bd 100644
--- a/crates/ui-egui/src/layer_style.rs
+++ b/crates/ui-egui/src/layer_style.rs
@@ -680,6 +680,12 @@ fn save_new_style(app: &mut PhotocraftApp, f: &Map<String, Value>) {
}
}
+/// Disabled effects keep their muted labels even when their parameter page stays
+/// selected; selecting a page is distinct from enabling its effect (#2288).
+fn fx_label_color(enabled: bool, t: &Tokens) -> Color32 {
+ if enabled { t.text } else { t.text_dim }
+}
+
/// Dialog body (left list, right parameters).
/// The enable checkbox of an effect row.
fn fx_checkbox_rect(row: egui::Rect) -> egui::Rect {
@@ -774,7 +780,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
egui::Align2::LEFT_CENTER,
tl!(kind_label),
egui::FontId::proportional(12.5),
- if on || is_sel { t.text } else { t.text_dim },
+ fx_label_color(on, &t),
);
// + adds another instance; − removes one once there are several.
if multi(kind) {
@@ -1598,6 +1604,16 @@ mod tests {
}
}
+ /// #2288: the selected effect row must dim again when its checkbox is cleared.
+ #[test]
+ fn disabled_effect_row_uses_muted_text_even_when_selected() {
+ for theme in crate::theme::ThemeKind::ALL {
+ let tokens = Tokens::for_kind(theme);
+ assert_eq!(fx_label_color(true, &tokens), tokens.text, "{theme:?}: checked");
+ assert_eq!(fx_label_color(false, &tokens), tokens.text_dim, "{theme:?}: unchecked");
+ }
+ }
+
#[test]
fn blending_page_renders_for_every_mode_and_odd_fields() {
let ctx = egui::Context::default();