Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(eframe) add Frame.set_visible #1808

Merged
merged 3 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions eframe/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,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 @@ -718,5 +723,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 @@ -299,6 +299,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