App::clear_color: give egui::Visuals as argument
This commit is contained in:
parent
8303523ccf
commit
e1bcaeebe5
5 changed files with 13 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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`].
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue