Unify fullscreen and fullscreen_windowed APIs
Use the enum to make a single fullscreen API that's much more consistent. Both set_fullscreen() and with_fullscreen() take the same enum and support all the variations so you can build the window however you want and switch between the modes at runtime.
This commit is contained in:
parent
b35c4a5ee5
commit
1382adbf11
4 changed files with 170 additions and 134 deletions
|
|
@ -57,25 +57,12 @@ impl WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Requests fullscreen mode.
|
||||
/// Sets the fullscreen mode.
|
||||
///
|
||||
/// If you don't specify dimensions for the window, it will match the monitor's.
|
||||
/// Disables fullscreen windowed mode if set.
|
||||
#[inline]
|
||||
pub fn with_fullscreen(mut self, monitor: MonitorId) -> WindowBuilder {
|
||||
let MonitorId(monitor) = monitor;
|
||||
self.window.fullscreen = FullScreenState::Exclusive(monitor);
|
||||
self
|
||||
}
|
||||
|
||||
/// Requests fullscreen windowed mode.
|
||||
///
|
||||
/// Disables the non-windowed fullscreen mode if set
|
||||
#[inline]
|
||||
pub fn with_fullscreen_windowed(mut self, fullscreen: bool) -> WindowBuilder {
|
||||
if fullscreen {
|
||||
self.window.fullscreen = FullScreenState::Windowed;
|
||||
}
|
||||
pub fn with_fullscreen(mut self, state: FullScreenState) -> WindowBuilder {
|
||||
self.window.fullscreen = state;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -322,8 +309,8 @@ impl Window {
|
|||
|
||||
/// Sets the window to fullscreen or back
|
||||
#[inline]
|
||||
pub fn set_fullscreen_windowed(&self, fullscreen: bool) {
|
||||
self.window.set_fullscreen_windowed(fullscreen)
|
||||
pub fn set_fullscreen(&self, state: FullScreenState) {
|
||||
self.window.set_fullscreen(state)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -384,7 +371,7 @@ pub fn get_primary_monitor() -> MonitorId {
|
|||
|
||||
/// Identifier for a monitor.
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct MonitorId(platform::MonitorId);
|
||||
pub struct MonitorId(pub platform::MonitorId);
|
||||
|
||||
impl MonitorId {
|
||||
/// Returns a human-readable name of the monitor.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue