mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Added documentation to WindowMode to better document what 'use_size' … (#3216)
This pull request aims to solve the issue of a lack of documentation in the enum WindowMode # Objective - Fixes #3136 ## Solution - Added a few lines of documentation that should document what the enum does better
This commit is contained in:
parent
d59a3ddd61
commit
bab4ee962d
3 changed files with 31 additions and 24 deletions
|
@ -183,15 +183,17 @@ pub enum WindowCommand {
|
|||
}
|
||||
|
||||
/// Defines the way a window is displayed
|
||||
/// The use_size option that is used in the Fullscreen variant
|
||||
/// defines whether a videomode is chosen that best fits the width and height
|
||||
/// in the Window structure, or if these are ignored.
|
||||
/// E.g. when use_size is set to false the best video mode possible is chosen.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum WindowMode {
|
||||
/// Creates a window that uses the given size
|
||||
Windowed,
|
||||
/// Creates a borderless window that uses the full size of the screen
|
||||
BorderlessFullscreen,
|
||||
Fullscreen { use_size: bool },
|
||||
/// Creates a fullscreen window that will render at desktop resolution. The app will use the closest supported size
|
||||
/// from the given size and scale it to fit the screen.
|
||||
SizedFullscreen,
|
||||
/// Creates a fullscreen window that uses the maximum supported size
|
||||
Fullscreen,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
|
|
@ -59,16 +59,18 @@ fn change_window(world: &mut World) {
|
|||
bevy_window::WindowMode::BorderlessFullscreen => {
|
||||
window.set_fullscreen(Some(winit::window::Fullscreen::Borderless(None)))
|
||||
}
|
||||
bevy_window::WindowMode::Fullscreen { use_size } => window.set_fullscreen(
|
||||
Some(winit::window::Fullscreen::Exclusive(match use_size {
|
||||
true => get_fitting_videomode(
|
||||
&window.current_monitor().unwrap(),
|
||||
width,
|
||||
height,
|
||||
),
|
||||
false => get_best_videomode(&window.current_monitor().unwrap()),
|
||||
})),
|
||||
),
|
||||
bevy_window::WindowMode::Fullscreen => {
|
||||
window.set_fullscreen(Some(winit::window::Fullscreen::Exclusive(
|
||||
get_best_videomode(&window.current_monitor().unwrap()),
|
||||
)))
|
||||
}
|
||||
bevy_window::WindowMode::SizedFullscreen => window.set_fullscreen(Some(
|
||||
winit::window::Fullscreen::Exclusive(get_fitting_videomode(
|
||||
&window.current_monitor().unwrap(),
|
||||
width,
|
||||
height,
|
||||
)),
|
||||
)),
|
||||
bevy_window::WindowMode::Windowed => window.set_fullscreen(None),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,15 +31,17 @@ impl WinitWindows {
|
|||
WindowMode::BorderlessFullscreen => winit_window_builder.with_fullscreen(Some(
|
||||
winit::window::Fullscreen::Borderless(event_loop.primary_monitor()),
|
||||
)),
|
||||
WindowMode::Fullscreen { use_size } => winit_window_builder.with_fullscreen(Some(
|
||||
winit::window::Fullscreen::Exclusive(match use_size {
|
||||
true => get_fitting_videomode(
|
||||
&event_loop.primary_monitor().unwrap(),
|
||||
window_descriptor.width as u32,
|
||||
window_descriptor.height as u32,
|
||||
),
|
||||
false => get_best_videomode(&event_loop.primary_monitor().unwrap()),
|
||||
}),
|
||||
WindowMode::Fullscreen => {
|
||||
winit_window_builder.with_fullscreen(Some(winit::window::Fullscreen::Exclusive(
|
||||
get_best_videomode(&event_loop.primary_monitor().unwrap()),
|
||||
)))
|
||||
}
|
||||
WindowMode::SizedFullscreen => winit_window_builder.with_fullscreen(Some(
|
||||
winit::window::Fullscreen::Exclusive(get_fitting_videomode(
|
||||
&event_loop.primary_monitor().unwrap(),
|
||||
window_descriptor.width as u32,
|
||||
window_descriptor.height as u32,
|
||||
)),
|
||||
)),
|
||||
_ => {
|
||||
let WindowDescriptor {
|
||||
|
@ -180,6 +182,7 @@ impl WinitWindows {
|
|||
self.winit_to_window_id.get(&id).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_fitting_videomode(
|
||||
monitor: &winit::monitor::MonitorHandle,
|
||||
width: u32,
|
||||
|
|
Loading…
Reference in a new issue