Skip to content

Commit

Permalink
Add documentation comments to bevy_window (#4333)
Browse files Browse the repository at this point in the history
# Objective
- Add documentation comments and `#![warn(missing_docs)]` to `bevy_window`.
- Part of #3492
  • Loading branch information
arnavc52 committed Jun 16, 2022
1 parent ab72c83 commit 14ed3b3
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 48 deletions.
44 changes: 43 additions & 1 deletion crates/bevy_window/src/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,81 @@
/// The icon to display for a window's cursor
/// The icon to display for a window's cursor.
///
/// Examples of all of these cursors can be found [here](https://www.w3schools.com/cssref/playit.asp?filename=playcss_cursor).
/// This `enum` is simply a copy of a similar `enum` found in [`winit`](https://docs.rs/winit/latest/winit/window/enum.CursorIcon.html).
/// `winit`, in turn, mostly copied cursor types avilable in the browser.
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub enum CursorIcon {
/// The platform-dependent default cursor.
Default,
/// A simple crosshair.
Crosshair,
/// A hand (often used to indicate links in web browsers).
Hand,
/// An arrow. This is the default cursor on most systems.
Arrow,
/// Indicates something is to be moved.
Move,
/// Indicates text that may be selected or edited.
Text,
/// Program busy indicator.
Wait,
/// Help indicator (often rendered as a "?")
Help,
/// Progress indicator. Shows that processing is being done.
///
/// But in contrast with "Wait" the user may still interact with the program.
/// Often rendered as a spinning beach ball, or an arrow with a watch or hourglass.
Progress,
/// Cursor showing that something cannot be done.
NotAllowed,
/// Indicates that a context menu is available.
ContextMenu,
/// Indicates that a cell (or set of cells) may be selected.
Cell,
/// Indicates vertical text that may be selected or edited.
VerticalText,
/// Indicates that an alias of something is to be created.
Alias,
/// Indicates something is to be copied.
Copy,
/// Indicates that the dragged item cannot be dropped here.
NoDrop,
/// Indicates that something can be grabbed.
Grab,
/// Indicates that something is grabbed.
Grabbing,
/// Indicates that the user can scroll by dragging the mouse.
AllScroll,
/// Indicates that the user can zoom in.
ZoomIn,
/// Indicates that the user can zoom out.
ZoomOut,
/// Indicates that an edge of a box is to be moved right (east).
EResize,
/// Indicates that an edge of a box is to be moved up (north).
NResize,
/// Indicates that an edge of a box is to be moved up and right (north/east).
NeResize,
/// indicates that an edge of a box is to be moved up and left (north/west).
NwResize,
/// Indicates that an edge of a box is to be moved down (south).
SResize,
/// The cursor indicates that an edge of a box is to be moved down and right (south/east).
SeResize,
/// The cursor indicates that an edge of a box is to be moved down and left (south/west).
SwResize,
/// Indicates that an edge of a box is to be moved left (west).
WResize,
/// Indicates a bidirectional resize cursor.
EwResize,
/// Indicates a bidirectional resize cursor.
NsResize,
/// Indicates a bidirectional resize cursor.
NeswResize,
/// Indicates a bidirectional resize cursor.
NwseResize,
/// Indicates that a column can be resized horizontally.
ColResize,
/// Indicates that the row can be resized vertically.
RowResize,
}
12 changes: 6 additions & 6 deletions crates/bevy_window/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::path::PathBuf;
use super::{WindowDescriptor, WindowId};
use bevy_math::{IVec2, Vec2};

/// A window event that is sent whenever a windows logical size has changed
/// A window event that is sent whenever a window's logical size has changed.
#[derive(Debug, Clone)]
pub struct WindowResized {
pub id: WindowId,
/// The new logical width of the window
/// The new logical width of the window.
pub width: f32,
/// The new logical height of the window
/// The new logical height of the window.
pub height: f32,
}

Expand Down Expand Up @@ -58,18 +58,18 @@ pub struct WindowCloseRequested {
pub struct WindowClosed {
pub id: WindowId,
}

/// An event that is sent whenenver the user's cursor moves.
#[derive(Debug, Clone)]
pub struct CursorMoved {
pub id: WindowId,
pub position: Vec2,
}

/// An event that is sent whenever the user's cursor enters a window.
#[derive(Debug, Clone)]
pub struct CursorEntered {
pub id: WindowId,
}

/// An event that is sent whenever the user's cursor leaves a window.
#[derive(Debug, Clone)]
pub struct CursorLeft {
pub id: WindowId,
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_window/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[warn(missing_docs)]
mod cursor;
mod event;
mod raw_window_handle;
Expand All @@ -23,13 +24,15 @@ pub mod prelude {
use bevy_app::prelude::*;
use bevy_ecs::{event::Events, schedule::SystemLabel};

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

0 comments on commit 14ed3b3

Please sign in to comment.