mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
egui_glium: add support for transparent windows
Also support non-decorated windows (without border)
This commit is contained in:
@@ -129,12 +129,17 @@ impl DemoWindows {
|
||||
show_menu_bar(ui);
|
||||
});
|
||||
|
||||
// Just get a background to put the windows on instead of using whatever the clear color is
|
||||
let frame = egui::Frame {
|
||||
fill: ctx.style().visuals.extreme_bg_color,
|
||||
..egui::Frame::none()
|
||||
};
|
||||
egui::CentralPanel::default().frame(frame).show(ctx, |_| {});
|
||||
{
|
||||
let mut fill = ctx.style().visuals.extreme_bg_color;
|
||||
if !cfg!(target_arch = "wasm32") {
|
||||
// Native: WrapApp uses a transparent window, so let's show that off:
|
||||
// NOTE: the OS compositor assumes "normal" blending, so we need to hack it:
|
||||
let [r, g, b, _] = fill.to_array();
|
||||
fill = egui::Color32::from_rgba_premultiplied(r, g, b, 180);
|
||||
}
|
||||
let frame = egui::Frame::none().fill(fill);
|
||||
egui::CentralPanel::default().frame(frame).show(ctx, |_| {});
|
||||
}
|
||||
|
||||
self.windows(ctx);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,14 @@ impl epi::App for WrapApp {
|
||||
self.backend_panel.max_size_points_active
|
||||
}
|
||||
|
||||
// Let's show off that we support transparent windows (on native):
|
||||
fn transparent(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn clear_color(&self) -> egui::Rgba {
|
||||
egui::Rgba::TRANSPARENT // we set a `CentralPanel` fill color in `demo_windows.rs`
|
||||
}
|
||||
|
||||
fn warm_up_enabled(&self) -> bool {
|
||||
// The example windows use a lot of emojis. Pre-cache them by running one frame where everything is open
|
||||
#[cfg(debug_assertions)]
|
||||
|
||||
Reference in New Issue
Block a user