@@ -15,7 +15,7 @@ use crate::{
15
15
} ;
16
16
use bevy_app:: { App , Last , Plugin } ;
17
17
#[ cfg( feature = "custom_cursor" ) ]
18
- use bevy_asset:: { Assets , Handle } ;
18
+ use bevy_asset:: Assets ;
19
19
#[ cfg( feature = "custom_cursor" ) ]
20
20
use bevy_ecs:: system:: Res ;
21
21
use bevy_ecs:: {
@@ -29,15 +29,16 @@ use bevy_ecs::{
29
29
world:: { OnRemove , Ref } ,
30
30
} ;
31
31
#[ cfg( feature = "custom_cursor" ) ]
32
- use bevy_image:: { Image , TextureAtlas , TextureAtlasLayout } ;
33
- #[ cfg( feature = "custom_cursor" ) ]
34
- use bevy_math:: URect ;
32
+ use bevy_image:: { Image , TextureAtlasLayout } ;
35
33
use bevy_reflect:: { std_traits:: ReflectDefault , Reflect } ;
36
34
use bevy_utils:: HashSet ;
37
35
use bevy_window:: { SystemCursorIcon , Window } ;
38
36
#[ cfg( feature = "custom_cursor" ) ]
39
37
use tracing:: warn;
40
38
39
+ #[ cfg( feature = "custom_cursor" ) ]
40
+ pub use crate :: custom_cursor:: CustomCursor ;
41
+
41
42
pub ( crate ) struct CursorPlugin ;
42
43
43
44
impl Plugin for CursorPlugin {
@@ -75,51 +76,6 @@ impl From<SystemCursorIcon> for CursorIcon {
75
76
}
76
77
}
77
78
78
- #[ cfg( feature = "custom_cursor" ) ]
79
- impl From < CustomCursor > for CursorIcon {
80
- fn from ( cursor : CustomCursor ) -> Self {
81
- CursorIcon :: Custom ( cursor)
82
- }
83
- }
84
-
85
- #[ cfg( feature = "custom_cursor" ) ]
86
- /// Custom cursor image data.
87
- #[ derive( Debug , Clone , Reflect , PartialEq , Eq , Hash ) ]
88
- pub enum CustomCursor {
89
- /// Image to use as a cursor.
90
- Image {
91
- /// The image must be in 8 bit int or 32 bit float rgba. PNG images
92
- /// work well for this.
93
- handle : Handle < Image > ,
94
- /// The (optional) texture atlas used to render the image.
95
- texture_atlas : Option < TextureAtlas > ,
96
- /// Whether the image should be flipped along its x-axis.
97
- flip_x : bool ,
98
- /// Whether the image should be flipped along its y-axis.
99
- flip_y : bool ,
100
- /// An optional rectangle representing the region of the image to
101
- /// render, instead of rendering the full image. This is an easy one-off
102
- /// alternative to using a [`TextureAtlas`].
103
- ///
104
- /// When used with a [`TextureAtlas`], the rect is offset by the atlas's
105
- /// minimal (top-left) corner position.
106
- rect : Option < URect > ,
107
- /// X and Y coordinates of the hotspot in pixels. The hotspot must be
108
- /// within the image bounds.
109
- hotspot : ( u16 , u16 ) ,
110
- } ,
111
- #[ cfg( all( target_family = "wasm" , target_os = "unknown" ) ) ]
112
- /// A URL to an image to use as the cursor.
113
- Url {
114
- /// Web URL to an image to use as the cursor. PNGs preferred. Cursor
115
- /// creation can fail if the image is invalid or not reachable.
116
- url : String ,
117
- /// X and Y coordinates of the hotspot in pixels. The hotspot must be
118
- /// within the image bounds.
119
- hotspot : ( u16 , u16 ) ,
120
- } ,
121
- }
122
-
123
79
fn update_cursors (
124
80
mut commands : Commands ,
125
81
windows : Query < ( Entity , Ref < CursorIcon > ) , With < Window > > ,
0 commit comments