From 83a5c0f2b26e137d640fd4db5d04dc1532209e51 Mon Sep 17 00:00:00 2001 From: tye-exe Date: Wed, 30 Apr 2025 17:49:44 +0100 Subject: [PATCH] Customise fade amount The fade amount for UI elements can be customised. --- crates/egui/src/style.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 6025fbdb6..261bd9387 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -1018,6 +1018,9 @@ pub struct Visuals { /// How to display numeric color values. pub numeric_color_space: NumericColorSpace, + + /// Opacity is multiplied by this amount when fading out widgets. + pub fade_out_by: f32, } impl Visuals { @@ -1055,7 +1058,7 @@ impl Visuals { /// When fading out things, we multiply the opacity by this. #[inline(always)] pub fn fade_out_opacity(&self) -> f32 { - 0.5 + self.fade_out_by } /// Returned a "grayed out" version of the given color. @@ -1382,6 +1385,7 @@ impl Visuals { image_loading_spinners: true, numeric_color_space: NumericColorSpace::GammaByte, + fade_out_by: 0.5, } } @@ -2061,6 +2065,7 @@ impl Visuals { image_loading_spinners, numeric_color_space, + fade_out_by, } = self; ui.collapsing("Background Colors", |ui| { @@ -2189,6 +2194,8 @@ impl Visuals { ui.label("Color picker type"); numeric_color_space.toggle_button_ui(ui); }); + + ui.add(Slider::new(fade_out_by, 0.0..=1.0).text("Fades out widgets by")); }); ui.vertical_centered(|ui| reset_button(ui, self, "Reset visuals"));