Skip to content

Commit 6430b56

Browse files
tsujpSelene-Amanita
authored andcommitted
improve documentation relating to WindowPlugin and Window (#9173)
- attempt to clarify with better docstrings the default behaviour of WindowPlugin and the component type it accepts. # Objective - I'm new to Rust and Bevy, I got a bit confused about how to customise some window parameters (title, height, width etc) and while the docs do show the struct code for that field `Option<Window>` I was a bit of a doofus and skipped that to read the docstring entry for `primary_window` and then the `Window` component directly which aren't linked together. This is a minor improvement which I think will help in-case others, like me, have a doofus moment. --------- Co-authored-by: Sélène Amanita <[email protected]>
1 parent bda987d commit 6430b56

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

crates/bevy_window/src/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ impl Default for WindowPlugin {
3838

3939
/// A [`Plugin`] that defines an interface for windowing support in Bevy.
4040
pub struct WindowPlugin {
41-
/// Settings for the primary window. This will be spawned by
42-
/// default, with the marker component [`PrimaryWindow`](PrimaryWindow).
43-
/// If you want to run without a primary window you should set this to `None`.
41+
/// Settings for the primary window.
4442
///
45-
/// Note that if there are no windows, by default the App will exit,
46-
/// due to [`exit_on_all_closed`].
43+
/// `Some(custom_window)` will spawn an entity with `custom_window` and [`PrimaryWindow`] as components.
44+
/// `None` will not spawn a primary window.
45+
///
46+
/// Defaults to `Some(Window::default())`.
47+
///
48+
/// Note that if there are no windows the App will exit (by default) due to
49+
/// [`exit_on_all_closed`].
4750
pub primary_window: Option<Window>,
4851

4952
/// Whether to exit the app when there are no open windows.

crates/bevy_window/src/window.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ use crate::CursorIcon;
1616
///
1717
/// Currently this is assumed to only exist on 1 entity at a time.
1818
///
19-
/// [`WindowPlugin`](crate::WindowPlugin) will spawn a window entity
20-
/// with this component if `primary_window` is `Some`.
19+
/// [`WindowPlugin`](crate::WindowPlugin) will spawn a [`Window`] entity
20+
/// with this component if [`primary_window`](crate::WindowPlugin::primary_window)
21+
/// is `Some`.
2122
#[derive(Default, Debug, Component, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Reflect)]
2223
#[reflect(Component)]
2324
pub struct PrimaryWindow;
@@ -234,16 +235,16 @@ impl Default for Window {
234235
}
235236

236237
impl Window {
237-
/// Setting this to true will attempt to maximize the window.
238+
/// Setting to true will attempt to maximize the window.
238239
///
239-
/// Setting it to false will attempt to un-maximize the window.
240+
/// Setting to false will attempt to un-maximize the window.
240241
pub fn set_maximized(&mut self, maximized: bool) {
241242
self.internal.maximize_request = Some(maximized);
242243
}
243244

244-
/// Setting this to true will attempt to minimize the window.
245+
/// Setting to true will attempt to minimize the window.
245246
///
246-
/// Setting it to false will attempt to un-minimize the window.
247+
/// Setting to false will attempt to un-minimize the window.
247248
pub fn set_minimized(&mut self, minimized: bool) {
248249
self.internal.minimize_request = Some(minimized);
249250
}

0 commit comments

Comments
 (0)