Allow windows to maximized. (#1004)

Adds a new `set_maximized` method to allow users to maximize windows.
This commit is contained in:
Corey Farwell 2020-12-04 17:31:17 -05:00 committed by GitHub
parent fcbae57489
commit 1398d78330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -82,6 +82,9 @@ pub enum WindowCommand {
SetCursorPosition {
position: Vec2,
},
SetMaximized {
maximized: bool,
},
}
/// Defines the way a window is displayed
@ -140,6 +143,12 @@ impl Window {
self.height
}
#[inline]
pub fn set_maximized(&mut self, maximized: bool) {
self.command_queue
.push(WindowCommand::SetMaximized { maximized });
}
pub fn set_resolution(&mut self, width: u32, height: u32) {
self.width = width;
self.height = height;

View file

@ -104,6 +104,10 @@ fn change_window(_: &mut World, resources: &mut Resources) {
))
.unwrap_or_else(|e| error!("Unable to set cursor position: {}", e));
}
bevy_window::WindowCommand::SetMaximized { maximized } => {
let window = winit_windows.get_window(id).unwrap();
window.set_maximized(maximized)
}
}
}
}