1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 15:13:12 -04:00

Opacity is used to gray out elements.

"fade_out_to_color" was replaced by "fade_out_opacity" for this purpose.
This commit is contained in:
tye-exe
2025-04-25 13:38:40 +01:00
parent 3ceb246c2a
commit 450956f546
2 changed files with 6 additions and 6 deletions

View File

@@ -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())
}
}

View File

@@ -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());
}
}