diff --git a/eframe/src/epi.rs b/eframe/src/epi.rs index 5cd070d5..a7c3ece4 100644 --- a/eframe/src/epi.rs +++ b/eframe/src/epi.rs @@ -93,11 +93,13 @@ pub trait App { /// Background color for the app, e.g. what is sent to `gl.clearColor`. /// This is the background of your windows if you don't set a central panel. - fn clear_color(&self) -> egui::Rgba { + fn clear_color(&self, _visuals: &egui::Visuals) -> egui::Rgba { // NOTE: a bright gray makes the shadows of the windows look weird. // We use a bit of transparency so that if the user switches on the // `transparent()` option they get immediate results. egui::Color32::from_rgba_unmultiplied(12, 12, 12, 180).into() + + // _visuals.window_fill() would also be a natural choice } /// Controls whether or not the native window position and size will be diff --git a/eframe/src/native/run.rs b/eframe/src/native/run.rs index 984ea1bd..a2406d07 100644 --- a/eframe/src/native/run.rs +++ b/eframe/src/native/run.rs @@ -95,7 +95,11 @@ pub fn run(app_name: &str, native_options: &epi::NativeOptions, app_creator: epi crate::profile_scope!("frame"); let screen_size_in_pixels: [u32; 2] = gl_window.window().inner_size().into(); - egui_glow::painter::clear(&gl, screen_size_in_pixels, app.clear_color()); + egui_glow::painter::clear( + &gl, + screen_size_in_pixels, + app.clear_color(&integration.egui_ctx.style().visuals), + ); let egui::FullOutput { platform_output, diff --git a/eframe/src/web/backend.rs b/eframe/src/web/backend.rs index 98004eb6..107b7fef 100644 --- a/eframe/src/web/backend.rs +++ b/eframe/src/web/backend.rs @@ -278,7 +278,8 @@ impl AppRunner { } pub fn clear_color_buffer(&self) { - self.painter.clear(self.app.clear_color()); + self.painter + .clear(self.app.clear_color(&self.egui_ctx.style().visuals)); } /// Paint the results of the last call to [`Self::logic`]. diff --git a/egui_demo_app/src/wrap_app.rs b/egui_demo_app/src/wrap_app.rs index b0ce4f37..47277aed 100644 --- a/egui_demo_app/src/wrap_app.rs +++ b/egui_demo_app/src/wrap_app.rs @@ -156,8 +156,8 @@ impl eframe::App for WrapApp { eframe::set_value(storage, eframe::APP_KEY, &self.state); } - fn clear_color(&self) -> egui::Rgba { - egui::Rgba::TRANSPARENT // we set a [`CentralPanel`] fill color in `demo_windows.rs` + fn clear_color(&self, visuals: &egui::Visuals) -> egui::Rgba { + visuals.window_fill().into() } fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { diff --git a/examples/custom_window_frame/src/main.rs b/examples/custom_window_frame/src/main.rs index ef466fa0..9f3f10aa 100644 --- a/examples/custom_window_frame/src/main.rs +++ b/examples/custom_window_frame/src/main.rs @@ -24,7 +24,7 @@ fn main() { struct MyApp {} impl eframe::App for MyApp { - fn clear_color(&self) -> egui::Rgba { + fn clear_color(&self, _visuals: &egui::Visuals) -> egui::Rgba { egui::Rgba::TRANSPARENT // Make sure we don't paint anything behind the rounded corners }