Skip to content

Commit 3674f10

Browse files
arnavc52james7132
authored andcommitted
Add documentation comments to bevy_window (bevyengine#4333)
# Objective - Add documentation comments and `#![warn(missing_docs)]` to `bevy_window`. - Part of bevyengine#3492
1 parent 0b8c1eb commit 3674f10

File tree

5 files changed

+195
-48
lines changed

5 files changed

+195
-48
lines changed

crates/bevy_window/src/cursor.rs

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,81 @@
1-
/// The icon to display for a window's cursor
1+
/// The icon to display for a window's cursor.
2+
///
3+
/// Examples of all of these cursors can be found [here](https://www.w3schools.com/cssref/playit.asp?filename=playcss_cursor).
4+
/// This `enum` is simply a copy of a similar `enum` found in [`winit`](https://docs.rs/winit/latest/winit/window/enum.CursorIcon.html).
5+
/// `winit`, in turn, mostly copied cursor types avilable in the browser.
26
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
37
pub enum CursorIcon {
8+
/// The platform-dependent default cursor.
49
Default,
10+
/// A simple crosshair.
511
Crosshair,
12+
/// A hand (often used to indicate links in web browsers).
613
Hand,
14+
/// An arrow. This is the default cursor on most systems.
715
Arrow,
16+
/// Indicates something is to be moved.
817
Move,
18+
/// Indicates text that may be selected or edited.
919
Text,
20+
/// Program busy indicator.
1021
Wait,
22+
/// Help indicator (often rendered as a "?")
1123
Help,
24+
/// Progress indicator. Shows that processing is being done.
25+
///
26+
/// But in contrast with "Wait" the user may still interact with the program.
27+
/// Often rendered as a spinning beach ball, or an arrow with a watch or hourglass.
1228
Progress,
29+
/// Cursor showing that something cannot be done.
1330
NotAllowed,
31+
/// Indicates that a context menu is available.
1432
ContextMenu,
33+
/// Indicates that a cell (or set of cells) may be selected.
1534
Cell,
35+
/// Indicates vertical text that may be selected or edited.
1636
VerticalText,
37+
/// Indicates that an alias of something is to be created.
1738
Alias,
39+
/// Indicates something is to be copied.
1840
Copy,
41+
/// Indicates that the dragged item cannot be dropped here.
1942
NoDrop,
43+
/// Indicates that something can be grabbed.
2044
Grab,
45+
/// Indicates that something is grabbed.
2146
Grabbing,
47+
/// Indicates that the user can scroll by dragging the mouse.
2248
AllScroll,
49+
/// Indicates that the user can zoom in.
2350
ZoomIn,
51+
/// Indicates that the user can zoom out.
2452
ZoomOut,
53+
/// Indicates that an edge of a box is to be moved right (east).
2554
EResize,
55+
/// Indicates that an edge of a box is to be moved up (north).
2656
NResize,
57+
/// Indicates that an edge of a box is to be moved up and right (north/east).
2758
NeResize,
59+
/// indicates that an edge of a box is to be moved up and left (north/west).
2860
NwResize,
61+
/// Indicates that an edge of a box is to be moved down (south).
2962
SResize,
63+
/// The cursor indicates that an edge of a box is to be moved down and right (south/east).
3064
SeResize,
65+
/// The cursor indicates that an edge of a box is to be moved down and left (south/west).
3166
SwResize,
67+
/// Indicates that an edge of a box is to be moved left (west).
3268
WResize,
69+
/// Indicates a bidirectional resize cursor.
3370
EwResize,
71+
/// Indicates a bidirectional resize cursor.
3472
NsResize,
73+
/// Indicates a bidirectional resize cursor.
3574
NeswResize,
75+
/// Indicates a bidirectional resize cursor.
3676
NwseResize,
77+
/// Indicates that a column can be resized horizontally.
3778
ColResize,
79+
/// Indicates that the row can be resized vertically.
3880
RowResize,
3981
}

crates/bevy_window/src/event.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use std::path::PathBuf;
33
use super::{WindowDescriptor, WindowId};
44
use bevy_math::{IVec2, Vec2};
55

6-
/// A window event that is sent whenever a windows logical size has changed
6+
/// A window event that is sent whenever a window's logical size has changed.
77
#[derive(Debug, Clone)]
88
pub struct WindowResized {
99
pub id: WindowId,
10-
/// The new logical width of the window
10+
/// The new logical width of the window.
1111
pub width: f32,
12-
/// The new logical height of the window
12+
/// The new logical height of the window.
1313
pub height: f32,
1414
}
1515

@@ -58,18 +58,18 @@ pub struct WindowCloseRequested {
5858
pub struct WindowClosed {
5959
pub id: WindowId,
6060
}
61-
61+
/// An event that is sent whenenver the user's cursor moves.
6262
#[derive(Debug, Clone)]
6363
pub struct CursorMoved {
6464
pub id: WindowId,
6565
pub position: Vec2,
6666
}
67-
67+
/// An event that is sent whenever the user's cursor enters a window.
6868
#[derive(Debug, Clone)]
6969
pub struct CursorEntered {
7070
pub id: WindowId,
7171
}
72-
72+
/// An event that is sent whenever the user's cursor leaves a window.
7373
#[derive(Debug, Clone)]
7474
pub struct CursorLeft {
7575
pub id: WindowId,

crates/bevy_window/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[warn(missing_docs)]
12
mod cursor;
23
mod event;
34
mod raw_window_handle;
@@ -23,13 +24,15 @@ pub mod prelude {
2324
use bevy_app::prelude::*;
2425
use bevy_ecs::{event::Events, schedule::SystemLabel};
2526

27+
/// A [`Plugin`] that defines an interface for windowing support in Bevy.
2628
pub struct WindowPlugin {
2729
/// Whether to create a window when added.
2830
///
2931
/// Note that if there are no windows, by default the App will exit,
3032
/// due to [`exit_on_all_closed`].
3133
pub add_primary_window: bool,
3234
/// Whether to exit the app when there are no open windows.
35+
///
3336
/// If disabling this, ensure that you send the [`bevy_app::AppExit`]
3437
/// event when the app should exit. If this does not occur, you will
3538
/// create 'headless' processes (processes without windows), which may
@@ -38,7 +41,7 @@ pub struct WindowPlugin {
3841
/// If true, this plugin will add [`exit_on_all_closed`] to [`CoreStage::Update`].
3942
pub exit_on_all_closed: bool,
4043
/// Whether to close windows when they are requested to be closed (i.e.
41-
/// when the close button is pressed)
44+
/// when the close button is pressed).
4245
///
4346
/// If true, this plugin will add [`close_when_requested`] to [`CoreStage::Update`].
4447
/// If this system (or a replacement) is not running, the close button will have no effect.

0 commit comments

Comments
 (0)