Skip to content

Commit

Permalink
feat: Set whether to show decorations (emilk#660)
Browse files Browse the repository at this point in the history
* feat: Set whether to show decorations

* cargo fmt

* Update comment and changelog
  • Loading branch information
zu1k authored Aug 28, 2021
1 parent 2ce99f3 commit 0db74f3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions eframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion egui_glium/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions egui_web/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -251,6 +252,7 @@ impl AppRunner {
http: self.http.clone(),
output: &mut app_output,
repaint_signal: self.needs_repaint.clone(),
decorated: false,
}
.build();

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

Expand Down
11 changes: 11 additions & 0 deletions epi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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> {
Expand All @@ -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,
}
}

0 comments on commit 0db74f3

Please sign in to comment.