bevy_window/
system_cursor.rs

1// This file contains a portion of the CSS Basic User Interface Module Level 3
2// specification. In particular, the names for the cursor from the #cursor
3// section and documentation for some of the variants were taken.
4//
5// The original document is https://www.w3.org/TR/css-ui-3/#cursor.
6// Copyright © 2018 W3C® (MIT, ERCIM, Keio, Beihang)
7//
8// These documents were used under the terms of the following license. This W3C
9// license as well as the W3C short notice apply to the `CursorIcon` enum's
10// variants and documentation attached to them.
11
12// --------- BEGINNING OF W3C LICENSE
13// --------------------------------------------------------------
14//
15// License
16//
17// By obtaining and/or copying this work, you (the licensee) agree that you have
18// read, understood, and will comply with the following terms and conditions.
19//
20// Permission to copy, modify, and distribute this work, with or without
21// modification, for any purpose and without fee or royalty is hereby granted,
22// provided that you include the following on ALL copies of the work or portions
23// thereof, including modifications:
24//
25// - The full text of this NOTICE in a location viewable to users of the
26//   redistributed or derivative work.
27// - Any pre-existing intellectual property disclaimers, notices, or terms and
28//   conditions. If none exist, the W3C Software and Document Short Notice
29//   should be included.
30// - Notice of any changes or modifications, through a copyright statement on
31//   the new code or document such as "This software or document includes
32//   material copied from or derived from [title and URI of the W3C document].
33//   Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)."
34//
35// Disclaimers
36//
37// THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS
38// OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES
39// OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
40// THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
41// COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
42//
43// COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
44// CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
45//
46// The name and trademarks of copyright holders may NOT be used in advertising
47// or publicity pertaining to the work without specific, written prior
48// permission. Title to copyright in this work will at all times remain with
49// copyright holders.
50//
51// --------- END OF W3C LICENSE
52// --------------------------------------------------------------------
53
54// --------- BEGINNING OF W3C SHORT NOTICE
55// ---------------------------------------------------------
56//
57// winit: https://github.com/rust-windowing/cursor-icon
58//
59// Copyright © 2023 World Wide Web Consortium, (Massachusetts Institute of
60// Technology, European Research Consortium for Informatics and Mathematics,
61// Keio University, Beihang). All Rights Reserved. This work is distributed
62// under the W3C® Software License [1] in the hope that it will be useful, but
63// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
64// FITNESS FOR A PARTICULAR PURPOSE.
65//
66// [1] http://www.w3.org/Consortium/Legal/copyright-software
67//
68// --------- END OF W3C SHORT NOTICE
69// --------------------------------------------------------------
70
71use bevy_reflect::{prelude::ReflectDefault, Reflect};
72
73#[cfg(feature = "serialize")]
74use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
75
76/// The icon to display for a window.
77///
78/// Examples of all of these cursors can be found [here](https://www.w3schools.com/cssref/playit.php?filename=playcss_cursor&preval=crosshair).
79/// This `enum` is simply a copy of a similar `enum` found in [`winit`](https://docs.rs/winit/latest/winit/window/enum.CursorIcon.html).
80/// `winit`, in turn, is based upon the [CSS3 UI spec](https://www.w3.org/TR/css-ui-3/#cursor).
81///
82/// See the [`window_settings`] example for usage.
83///
84/// [`window_settings`]: https://github.com/bevyengine/bevy/blob/latest/examples/window/window_settings.rs
85#[derive(Default, Debug, Hash, PartialEq, Eq, Clone, Copy, Reflect)]
86#[cfg_attr(
87    feature = "serialize",
88    derive(serde::Serialize, serde::Deserialize),
89    reflect(Serialize, Deserialize)
90)]
91#[reflect(Debug, PartialEq, Default)]
92pub enum SystemCursorIcon {
93    /// The platform-dependent default cursor. Often rendered as arrow.
94    #[default]
95    Default,
96
97    /// A context menu is available for the object under the cursor. Often
98    /// rendered as an arrow with a small menu-like graphic next to it.
99    ContextMenu,
100
101    /// Help is available for the object under the cursor. Often rendered as a
102    /// question mark or a balloon.
103    Help,
104
105    /// The cursor is a pointer that indicates a link. Often rendered as the
106    /// backside of a hand with the index finger extended.
107    Pointer,
108
109    /// A progress indicator. The program is performing some processing, but is
110    /// different from [`SystemCursorIcon::Wait`] in that the user may still interact
111    /// with the program.
112    Progress,
113
114    /// Indicates that the program is busy and the user should wait. Often
115    /// rendered as a watch or hourglass.
116    Wait,
117
118    /// Indicates that a cell or set of cells may be selected. Often rendered as
119    /// a thick plus-sign with a dot in the middle.
120    Cell,
121
122    /// A simple crosshair (e.g., short line segments resembling a "+" sign).
123    /// Often used to indicate a two dimensional bitmap selection mode.
124    Crosshair,
125
126    /// Indicates text that may be selected. Often rendered as an I-beam.
127    Text,
128
129    /// Indicates vertical-text that may be selected. Often rendered as a
130    /// horizontal I-beam.
131    VerticalText,
132
133    /// Indicates an alias of/shortcut to something is to be created. Often
134    /// rendered as an arrow with a small curved arrow next to it.
135    Alias,
136
137    /// Indicates something is to be copied. Often rendered as an arrow with a
138    /// small plus sign next to it.
139    Copy,
140
141    /// Indicates something is to be moved.
142    Move,
143
144    /// Indicates that the dragged item cannot be dropped at the current cursor
145    /// location. Often rendered as a hand or pointer with a small circle with a
146    /// line through it.
147    NoDrop,
148
149    /// Indicates that the requested action will not be carried out. Often
150    /// rendered as a circle with a line through it.
151    NotAllowed,
152
153    /// Indicates that something can be grabbed (dragged to be moved). Often
154    /// rendered as the backside of an open hand.
155    Grab,
156
157    /// Indicates that something is being grabbed (dragged to be moved). Often
158    /// rendered as the backside of a hand with fingers closed mostly out of
159    /// view.
160    Grabbing,
161
162    /// The east border to be moved.
163    EResize,
164
165    /// The north border to be moved.
166    NResize,
167
168    /// The north-east corner to be moved.
169    NeResize,
170
171    /// The north-west corner to be moved.
172    NwResize,
173
174    /// The south border to be moved.
175    SResize,
176
177    /// The south-east corner to be moved.
178    SeResize,
179
180    /// The south-west corner to be moved.
181    SwResize,
182
183    /// The west border to be moved.
184    WResize,
185
186    /// The east and west borders to be moved.
187    EwResize,
188
189    /// The south and north borders to be moved.
190    NsResize,
191
192    /// The north-east and south-west corners to be moved.
193    NeswResize,
194
195    /// The north-west and south-east corners to be moved.
196    NwseResize,
197
198    /// Indicates that the item/column can be resized horizontally. Often
199    /// rendered as arrows pointing left and right with a vertical bar
200    /// separating them.
201    ColResize,
202
203    /// Indicates that the item/row can be resized vertically. Often rendered as
204    /// arrows pointing up and down with a horizontal bar separating them.
205    RowResize,
206
207    /// Indicates that the something can be scrolled in any direction. Often
208    /// rendered as arrows pointing up, down, left, and right with a dot in the
209    /// middle.
210    AllScroll,
211
212    /// Indicates that something can be zoomed in. Often rendered as a
213    /// magnifying glass with a "+" in the center of the glass.
214    ZoomIn,
215
216    /// Indicates that something can be zoomed in. Often rendered as a
217    /// magnifying glass with a "-" in the center of the glass.
218    ZoomOut,
219}