feat: Set whether to show decorations (#660)

* feat: Set whether to show decorations

* cargo fmt

* Update comment and changelog
This commit is contained in:
zu1k 2021-08-28 17:18:36 +08:00 committed by GitHub
parent 2ce99f3a12
commit 0db74f3000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View File

@ -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

View File

@ -202,6 +202,7 @@ pub fn run(mut app: Box<dyn epi::App>, 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<dyn epi::App>, 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<dyn epi::App>, 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<dyn epi::App>, 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(

View File

@ -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;
}

View File

@ -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<dyn RepaintSignal> {
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<dyn RepaintSignal>,
/// 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<egui::Vec2>,
/// If the window has decorations
pub decorated: bool,
}
}