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
71#[cfg(feature = "bevy_reflect")]
72use bevy_reflect::{prelude::ReflectDefault, Reflect};
73
74#[cfg(feature = "serialize")]
75use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
76
77/// The icon to display for a window.
78///
79/// Examples of all of these cursors can be found [here](https://www.w3schools.com/cssref/playit.php?filename=playcss_cursor&preval=crosshair).
80/// This `enum` is simply a copy of a similar `enum` found in [`winit`](https://docs.rs/winit/latest/winit/window/enum.CursorIcon.html).
81/// `winit`, in turn, is based upon the [CSS3 UI spec](https://www.w3.org/TR/css-ui-3/#cursor).
82///
83/// See the [`window_settings`] example for usage.
84///
85/// [`window_settings`]: https://github.com/bevyengine/bevy/blob/latest/examples/window/window_settings.rs
86#[derive(Default, Debug, Hash, PartialEq, Eq, Clone, Copy)]
87#[cfg_attr(
88 feature = "bevy_reflect",
89 derive(Reflect),
90 reflect(Debug, PartialEq, Hash, Default, Clone)
91)]
92#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
93#[cfg_attr(
94 all(feature = "serialize", feature = "bevy_reflect"),
95 reflect(Serialize, Deserialize)
96)]
97pub enum SystemCursorIcon {
98 /// The platform-dependent default cursor. Often rendered as arrow.
99 #[default]
100 Default,
101
102 /// A context menu is available for the object under the cursor. Often
103 /// rendered as an arrow with a small menu-like graphic next to it.
104 ContextMenu,
105
106 /// Help is available for the object under the cursor. Often rendered as a
107 /// question mark or a balloon.
108 Help,
109
110 /// The cursor is a pointer that indicates a link. Often rendered as the
111 /// backside of a hand with the index finger extended.
112 Pointer,
113
114 /// A progress indicator. The program is performing some processing, but is
115 /// different from [`SystemCursorIcon::Wait`] in that the user may still interact
116 /// with the program.
117 Progress,
118
119 /// Indicates that the program is busy and the user should wait. Often
120 /// rendered as a watch or hourglass.
121 Wait,
122
123 /// Indicates that a cell or set of cells may be selected. Often rendered as
124 /// a thick plus-sign with a dot in the middle.
125 Cell,
126
127 /// A simple crosshair (e.g., short line segments resembling a "+" sign).
128 /// Often used to indicate a two dimensional bitmap selection mode.
129 Crosshair,
130
131 /// Indicates text that may be selected. Often rendered as an I-beam.
132 Text,
133
134 /// Indicates vertical-text that may be selected. Often rendered as a
135 /// horizontal I-beam.
136 VerticalText,
137
138 /// Indicates an alias of/shortcut to something is to be created. Often
139 /// rendered as an arrow with a small curved arrow next to it.
140 Alias,
141
142 /// Indicates something is to be copied. Often rendered as an arrow with a
143 /// small plus sign next to it.
144 Copy,
145
146 /// Indicates something is to be moved.
147 Move,
148
149 /// Indicates that the dragged item cannot be dropped at the current cursor
150 /// location. Often rendered as a hand or pointer with a small circle with a
151 /// line through it.
152 NoDrop,
153
154 /// Indicates that the requested action will not be carried out. Often
155 /// rendered as a circle with a line through it.
156 NotAllowed,
157
158 /// Indicates that something can be grabbed (dragged to be moved). Often
159 /// rendered as the backside of an open hand.
160 Grab,
161
162 /// Indicates that something is being grabbed (dragged to be moved). Often
163 /// rendered as the backside of a hand with fingers closed mostly out of
164 /// view.
165 Grabbing,
166
167 /// The east border to be moved.
168 EResize,
169
170 /// The north border to be moved.
171 NResize,
172
173 /// The north-east corner to be moved.
174 NeResize,
175
176 /// The north-west corner to be moved.
177 NwResize,
178
179 /// The south border to be moved.
180 SResize,
181
182 /// The south-east corner to be moved.
183 SeResize,
184
185 /// The south-west corner to be moved.
186 SwResize,
187
188 /// The west border to be moved.
189 WResize,
190
191 /// The east and west borders to be moved.
192 EwResize,
193
194 /// The south and north borders to be moved.
195 NsResize,
196
197 /// The north-east and south-west corners to be moved.
198 NeswResize,
199
200 /// The north-west and south-east corners to be moved.
201 NwseResize,
202
203 /// Indicates that the item/column can be resized horizontally. Often
204 /// rendered as arrows pointing left and right with a vertical bar
205 /// separating them.
206 ColResize,
207
208 /// Indicates that the item/row can be resized vertically. Often rendered as
209 /// arrows pointing up and down with a horizontal bar separating them.
210 RowResize,
211
212 /// Indicates that the something can be scrolled in any direction. Often
213 /// rendered as arrows pointing up, down, left, and right with a dot in the
214 /// middle.
215 AllScroll,
216
217 /// Indicates that something can be zoomed in. Often rendered as a
218 /// magnifying glass with a "+" in the center of the glass.
219 ZoomIn,
220
221 /// Indicates that something can be zoomed in. Often rendered as a
222 /// magnifying glass with a "-" in the center of the glass.
223 ZoomOut,
224}