From 033884395010575f6fe0f435a6986cc1ccf5c11b Mon Sep 17 00:00:00 2001 From: Julian Date: Thu, 21 Jul 2022 14:16:56 -0400 Subject: [PATCH] (eframe) add Frame.set_visible (#1808) --- eframe/src/epi.rs | 8 ++++++++ eframe/src/native/epi_integration.rs | 5 +++++ eframe/src/web/backend.rs | 1 + 3 files changed, 14 insertions(+) diff --git a/eframe/src/epi.rs b/eframe/src/epi.rs index b7e319b8..805efd4a 100644 --- a/eframe/src/epi.rs +++ b/eframe/src/epi.rs @@ -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, + + /// Set to some bool to change window visibility. + pub visible: Option, } } diff --git a/eframe/src/native/epi_integration.rs b/eframe/src/native/epi_integration.rs index 597e0c85..a6a6d6e0 100644 --- a/eframe/src/native/epi_integration.rs +++ b/eframe/src/native/epi_integration.rs @@ -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); + } } // ---------------------------------------------------------------------------- diff --git a/eframe/src/web/backend.rs b/eframe/src/web/backend.rs index 4416eeaa..ecca55cb 100644 --- a/eframe/src/web/backend.rs +++ b/eframe/src/web/backend.rs @@ -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; }