Skip to content

Commit

Permalink
(eframe) add Frame.set_visible (#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNite authored Jul 21, 2022
1 parent cbe22a0 commit 0338843
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions eframe/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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>,
}
}
5 changes: 5 additions & 0 deletions eframe/src/native/epi_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub fn handle_app_output(
decorated,
drag_window,
window_pos,
visible,
} = app_output;

if let Some(decorated) = decorated {
Expand Down Expand Up @@ -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);
}
}

// ----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions eframe/src/web/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0338843

Please sign in to comment.