Compare commits
2 commits
master
...
set_decora
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9ae7762029 | ||
![]() |
0bfcc35acf |
5 changed files with 35 additions and 5 deletions
|
@ -3,6 +3,7 @@ All notable changes to the `eframe` crate.
|
||||||
|
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
* `Frame` now provides `set_decorations` to set whether to show window decorations.
|
||||||
|
|
||||||
|
|
||||||
## 0.14.0 - 2021-08-24
|
## 0.14.0 - 2021-08-24
|
||||||
|
|
|
@ -134,14 +134,25 @@ impl BackendPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !frame.is_web()
|
if !frame.is_web() {
|
||||||
&& ui
|
ui.horizontal(|ui| {
|
||||||
|
ui.label("Window decorations:");
|
||||||
|
if ui.button("Show").clicked() {
|
||||||
|
frame.set_decorations(true);
|
||||||
|
}
|
||||||
|
if ui.button("Hide").clicked() {
|
||||||
|
frame.set_decorations(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if ui
|
||||||
.button("📱 Phone Size")
|
.button("📱 Phone Size")
|
||||||
.on_hover_text("Resize the window to be small like a phone.")
|
.on_hover_text("Resize the window to be small like a phone.")
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
frame.set_window_size(egui::Vec2::new(375.0, 812.0)); // iPhone 12 mini
|
frame.set_window_size(egui::Vec2::new(375.0, 812.0)); // iPhone 12 mini
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,15 @@ 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;
|
||||||
|
|
||||||
|
if let Some(decorated) = decorated {
|
||||||
|
display.gl_window().window().set_decorations(decorated);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(window_size) = window_size {
|
if let Some(window_size) = window_size {
|
||||||
display.gl_window().window().set_inner_size(
|
display.gl_window().window().set_inner_size(
|
||||||
|
|
|
@ -266,6 +266,7 @@ impl AppRunner {
|
||||||
let epi::backend::AppOutput {
|
let epi::backend::AppOutput {
|
||||||
quit: _, // Can't quit a web page
|
quit: _, // Can't quit a web page
|
||||||
window_size: _, // Can't resize a web page
|
window_size: _, // Can't resize a web page
|
||||||
|
decorated: _, // Can't show decorations
|
||||||
} = app_output;
|
} = app_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,12 @@ impl<'a> Frame<'a> {
|
||||||
self.0.output.window_size = Some(size);
|
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.
|
/// 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> {
|
pub fn repaint_signal(&self) -> std::sync::Arc<dyn RepaintSignal> {
|
||||||
self.0.repaint_signal.clone()
|
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.
|
/// Set to some size to resize the outer window (e.g. glium window) to this size.
|
||||||
pub window_size: Option<egui::Vec2>,
|
pub window_size: Option<egui::Vec2>,
|
||||||
|
|
||||||
|
/// Set to some bool to change window decorations
|
||||||
|
pub decorated: Option<bool>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue