(eframe) add Frame.set_visible (#1808)

This commit is contained in:
Julian 2022-07-21 14:16:56 -04:00 committed by GitHub
parent cbe22a0371
commit 0338843950
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View file

@ -565,6 +565,11 @@ impl Frame {
self.output.drag_window = true;
}
/// Set the visibility of the window.
pub fn set_visible(&mut self, visible: bool) {
self.output.visible = Some(visible);
}
/// for integrations only: call once per frame
#[doc(hidden)]
pub fn take_app_output(&mut self) -> backend::AppOutput {
@ -740,5 +745,8 @@ pub mod backend {
/// Set to some position to move the outer window (e.g. glium window) to this position
pub window_pos: Option<egui::Pos2>,
/// Set to some bool to change window visibility.
pub visible: Option<bool>,
}
}

View file

@ -120,6 +120,7 @@ pub fn handle_app_output(
decorated,
drag_window,
window_pos,
visible,
} = app_output;
if let Some(decorated) = decorated {
@ -150,6 +151,10 @@ pub fn handle_app_output(
if drag_window {
let _ = window.drag_window();
}
if let Some(visible) = visible {
window.set_visible(visible);
}
}
// ----------------------------------------------------------------------------

View file

@ -300,6 +300,7 @@ impl AppRunner {
decorated: _, // Can't toggle decorations
drag_window: _, // Can't be dragged
window_pos: _, // Can't set position of a web page
visible: _, // Can't hide a web page
} = app_output;
}