From 0bfcc35acf5f5aaf6aa95b358388ca32d32bb330 Mon Sep 17 00:00:00 2001 From: zu1k Date: Sat, 28 Aug 2021 20:03:27 +0800 Subject: [PATCH] feat: Set whether to show decorations --- eframe/CHANGELOG.md | 1 + egui_glium/src/backend.rs | 10 +++++++++- egui_web/src/backend.rs | 1 + epi/src/lib.rs | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/eframe/CHANGELOG.md b/eframe/CHANGELOG.md index 87011ed9..b6c98de4 100644 --- a/eframe/CHANGELOG.md +++ b/eframe/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to the `eframe` crate. ## Unreleased +* `Frame` now provides `set_decorations` to set whether to show window decorations. ## 0.14.0 - 2021-08-24 diff --git a/egui_glium/src/backend.rs b/egui_glium/src/backend.rs index 243c1825..f2a1259b 100644 --- a/egui_glium/src/backend.rs +++ b/egui_glium/src/backend.rs @@ -346,7 +346,15 @@ pub fn run(mut app: Box, native_options: epi::NativeOptions) { } { - let epi::backend::AppOutput { quit, window_size } = app_output; + let epi::backend::AppOutput { + quit, + window_size, + decorated, + } = app_output; + + if let Some(decorated) = decorated { + display.gl_window().window().set_decorations(decorated); + } if let Some(window_size) = window_size { display.gl_window().window().set_inner_size( diff --git a/egui_web/src/backend.rs b/egui_web/src/backend.rs index a9d30653..57f36a88 100644 --- a/egui_web/src/backend.rs +++ b/egui_web/src/backend.rs @@ -266,6 +266,7 @@ impl AppRunner { let epi::backend::AppOutput { quit: _, // Can't quit a web page window_size: _, // Can't resize a web page + decorated: _, // Can't show decorations } = app_output; } diff --git a/epi/src/lib.rs b/epi/src/lib.rs index 7c718332..733a5d42 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -251,6 +251,12 @@ impl<'a> Frame<'a> { self.0.output.window_size = Some(size); } + /// Set whether to show window decorations (i.e. a frame around you app). + /// If false it will be difficult to move and resize the app. + pub fn set_decorations(&mut self, decorated: bool) { + self.0.output.decorated = Some(decorated); + } + /// If you need to request a repaint from another thread, clone this and send it to that other thread. pub fn repaint_signal(&self) -> std::sync::Arc { self.0.repaint_signal.clone() @@ -504,5 +510,8 @@ pub mod backend { /// Set to some size to resize the outer window (e.g. glium window) to this size. pub window_size: Option, + + /// Set to some bool to change window decorations + pub decorated: Option, } }