From 450956f546a3609beb4f537f3ededb76797b2320 Mon Sep 17 00:00:00 2001 From: tye-exe Date: Fri, 25 Apr 2025 13:38:40 +0100 Subject: [PATCH] Opacity is used to gray out elements. "fade_out_to_color" was replaced by "fade_out_opacity" for this purpose. --- crates/egui/src/style.rs | 9 ++++----- crates/egui/src/ui.rs | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 38d403749..6025fbdb6 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -1052,18 +1052,17 @@ impl Visuals { self.window_stroke } - /// When fading out things, we fade the colors towards this. - // TODO(emilk): replace with an alpha + /// When fading out things, we multiply the opacity by this. #[inline(always)] - pub fn fade_out_to_color(&self) -> Color32 { - self.widgets.noninteractive.weak_bg_fill + pub fn fade_out_opacity(&self) -> f32 { + 0.5 } /// Returned a "grayed out" version of the given color. #[doc(alias = "grey_out")] #[inline(always)] pub fn gray_out(&self, color: Color32) -> Color32 { - crate::ecolor::tint_color_towards(color, self.fade_out_to_color()) + color.gamma_multiply(self.fade_out_opacity()) } } diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 32d6a5f37..64affddaa 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -521,7 +521,8 @@ impl Ui { pub fn disable(&mut self) { self.enabled = false; if self.is_visible() { - self.painter.multiply_opacity(0.5); + self.painter + .multiply_opacity(self.visuals().fade_out_opacity()); } }