From 0db74f30006d02fac0feaea601be401269524e9a Mon Sep 17 00:00:00 2001 From: zu1k <42370281+zu1k@users.noreply.github.com> Date: Sat, 28 Aug 2021 17:18:36 +0800 Subject: [PATCH] feat: Set whether to show decorations (#660) * feat: Set whether to show decorations * cargo fmt * Update comment and changelog --- eframe/CHANGELOG.md | 1 + egui_glium/src/backend.rs | 11 ++++++++++- egui_web/src/backend.rs | 3 +++ epi/src/lib.rs | 11 +++++++++++ 4 files changed, 25 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..68878001 100644 --- a/egui_glium/src/backend.rs +++ b/egui_glium/src/backend.rs @@ -202,6 +202,7 @@ pub fn run(mut app: Box, native_options: epi::NativeOptions) { http: http.clone(), output: &mut app_output, repaint_signal: repaint_signal.clone(), + decorated: native_options.decorated, } .build(); app.setup(ctx, &mut frame, storage.as_deref()); @@ -226,6 +227,7 @@ pub fn run(mut app: Box, native_options: epi::NativeOptions) { http: http.clone(), output: &mut app_output, repaint_signal: repaint_signal.clone(), + decorated: native_options.decorated, } .build(); @@ -323,6 +325,7 @@ pub fn run(mut app: Box, native_options: epi::NativeOptions) { http: http.clone(), output: &mut app_output, repaint_signal: repaint_signal.clone(), + decorated: native_options.decorated, } .build(); app.update(ctx, &mut frame); @@ -346,7 +349,13 @@ 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; + + 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..ed036523 100644 --- a/egui_web/src/backend.rs +++ b/egui_web/src/backend.rs @@ -179,6 +179,7 @@ impl AppRunner { http: runner.http.clone(), output: &mut app_output, repaint_signal: runner.needs_repaint.clone(), + decorated: false, } .build(); runner.app.setup( @@ -251,6 +252,7 @@ impl AppRunner { http: self.http.clone(), output: &mut app_output, repaint_signal: self.needs_repaint.clone(), + decorated: false, } .build(); @@ -266,6 +268,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..51bf7f3a 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 = 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() @@ -486,6 +492,8 @@ pub mod backend { pub output: &'a mut AppOutput, /// If you need to request a repaint from another thread, clone this and send it to that other thread. pub repaint_signal: std::sync::Arc, + /// If the window has decorations + pub decorated: bool, } impl<'a> FrameBuilder<'a> { @@ -504,5 +512,8 @@ pub mod backend { /// Set to some size to resize the outer window (e.g. glium window) to this size. pub window_size: Option, + + /// If the window has decorations + pub decorated: bool, } }