Skip to content

Commit bab4ee9

Browse files
committed
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
1 parent d59a3dd commit bab4ee9

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

crates/bevy_window/src/window.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,17 @@ pub enum WindowCommand {
183183
}
184184

185185
/// Defines the way a window is displayed
186-
/// The use_size option that is used in the Fullscreen variant
187-
/// defines whether a videomode is chosen that best fits the width and height
188-
/// in the Window structure, or if these are ignored.
189-
/// E.g. when use_size is set to false the best video mode possible is chosen.
190186
#[derive(Debug, Clone, Copy, PartialEq)]
191187
pub enum WindowMode {
188+
/// Creates a window that uses the given size
192189
Windowed,
190+
/// Creates a borderless window that uses the full size of the screen
193191
BorderlessFullscreen,
194-
Fullscreen { use_size: bool },
192+
/// Creates a fullscreen window that will render at desktop resolution. The app will use the closest supported size
193+
/// from the given size and scale it to fit the screen.
194+
SizedFullscreen,
195+
/// Creates a fullscreen window that uses the maximum supported size
196+
Fullscreen,
195197
}
196198

197199
impl Window {

crates/bevy_winit/src/lib.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,18 @@ fn change_window(world: &mut World) {
5959
bevy_window::WindowMode::BorderlessFullscreen => {
6060
window.set_fullscreen(Some(winit::window::Fullscreen::Borderless(None)))
6161
}
62-
bevy_window::WindowMode::Fullscreen { use_size } => window.set_fullscreen(
63-
Some(winit::window::Fullscreen::Exclusive(match use_size {
64-
true => get_fitting_videomode(
65-
&window.current_monitor().unwrap(),
66-
width,
67-
height,
68-
),
69-
false => get_best_videomode(&window.current_monitor().unwrap()),
70-
})),
71-
),
62+
bevy_window::WindowMode::Fullscreen => {
63+
window.set_fullscreen(Some(winit::window::Fullscreen::Exclusive(
64+
get_best_videomode(&window.current_monitor().unwrap()),
65+
)))
66+
}
67+
bevy_window::WindowMode::SizedFullscreen => window.set_fullscreen(Some(
68+
winit::window::Fullscreen::Exclusive(get_fitting_videomode(
69+
&window.current_monitor().unwrap(),
70+
width,
71+
height,
72+
)),
73+
)),
7274
bevy_window::WindowMode::Windowed => window.set_fullscreen(None),
7375
}
7476
}

crates/bevy_winit/src/winit_windows.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ impl WinitWindows {
3131
WindowMode::BorderlessFullscreen => winit_window_builder.with_fullscreen(Some(
3232
winit::window::Fullscreen::Borderless(event_loop.primary_monitor()),
3333
)),
34-
WindowMode::Fullscreen { use_size } => winit_window_builder.with_fullscreen(Some(
35-
winit::window::Fullscreen::Exclusive(match use_size {
36-
true => get_fitting_videomode(
37-
&event_loop.primary_monitor().unwrap(),
38-
window_descriptor.width as u32,
39-
window_descriptor.height as u32,
40-
),
41-
false => get_best_videomode(&event_loop.primary_monitor().unwrap()),
42-
}),
34+
WindowMode::Fullscreen => {
35+
winit_window_builder.with_fullscreen(Some(winit::window::Fullscreen::Exclusive(
36+
get_best_videomode(&event_loop.primary_monitor().unwrap()),
37+
)))
38+
}
39+
WindowMode::SizedFullscreen => winit_window_builder.with_fullscreen(Some(
40+
winit::window::Fullscreen::Exclusive(get_fitting_videomode(
41+
&event_loop.primary_monitor().unwrap(),
42+
window_descriptor.width as u32,
43+
window_descriptor.height as u32,
44+
)),
4345
)),
4446
_ => {
4547
let WindowDescriptor {
@@ -180,6 +182,7 @@ impl WinitWindows {
180182
self.winit_to_window_id.get(&id).cloned()
181183
}
182184
}
185+
183186
pub fn get_fitting_videomode(
184187
monitor: &winit::monitor::MonitorHandle,
185188
width: u32,

0 commit comments

Comments
 (0)