4
4
html_logo_url = "https://bevyengine.org/assets/icon.png" ,
5
5
html_favicon_url = "https://bevyengine.org/assets/icon.png"
6
6
) ]
7
+ #![ no_std]
7
8
8
9
//! Accessibility for Bevy
9
10
//!
13
14
//!
14
15
//! Make sure to use the same version of `accesskit` as Bevy.
15
16
17
+ #[ cfg( feature = "std" ) ]
18
+ extern crate std;
19
+
16
20
extern crate alloc;
17
21
18
22
use alloc:: sync:: Arc ;
@@ -27,8 +31,21 @@ use bevy_ecs::{
27
31
schedule:: SystemSet ,
28
32
} ;
29
33
34
+ #[ cfg( feature = "bevy_reflect" ) ]
35
+ use {
36
+ bevy_ecs:: reflect:: ReflectResource , bevy_reflect:: std_traits:: ReflectDefault ,
37
+ bevy_reflect:: Reflect ,
38
+ } ;
39
+
40
+ #[ cfg( feature = "serialize" ) ]
41
+ use serde:: { Deserialize , Serialize } ;
42
+
43
+ #[ cfg( all( feature = "bevy_reflect" , feature = "serialize" ) ) ]
44
+ use bevy_reflect:: { ReflectDeserialize , ReflectSerialize } ;
45
+
30
46
/// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`.
31
47
#[ derive( Event , Deref , DerefMut ) ]
48
+ #[ cfg_attr( feature = "serialize" , derive( Serialize , Deserialize ) ) ]
32
49
pub struct ActionRequest ( pub accesskit:: ActionRequest ) ;
33
50
34
51
/// Resource that tracks whether an assistive technology has requested
@@ -37,6 +54,7 @@ pub struct ActionRequest(pub accesskit::ActionRequest);
37
54
/// Useful if a third-party plugin needs to conditionally integrate with
38
55
/// `AccessKit`
39
56
#[ derive( Resource , Default , Clone , Debug , Deref , DerefMut ) ]
57
+ #[ cfg_attr( feature = "bevy_reflect" , derive( Reflect ) , reflect( Default , Resource ) ) ]
40
58
pub struct AccessibilityRequested ( Arc < AtomicBool > ) ;
41
59
42
60
impl AccessibilityRequested {
@@ -59,6 +77,12 @@ impl AccessibilityRequested {
59
77
/// accessibility updates instead. Without this, the external library and ECS
60
78
/// will generate conflicting updates.
61
79
#[ derive( Resource , Clone , Debug , Deref , DerefMut ) ]
80
+ #[ cfg_attr( feature = "serialize" , derive( Serialize , Deserialize ) ) ]
81
+ #[ cfg_attr( feature = "bevy_reflect" , derive( Reflect ) , reflect( Resource ) ) ]
82
+ #[ cfg_attr(
83
+ all( feature = "bevy_reflect" , feature = "serialize" ) ,
84
+ reflect( Serialize , Deserialize )
85
+ ) ]
62
86
pub struct ManageAccessibilityUpdates ( bool ) ;
63
87
64
88
impl Default for ManageAccessibilityUpdates {
@@ -88,6 +112,7 @@ impl ManageAccessibilityUpdates {
88
112
/// If the entity doesn't have a parent, or if the immediate parent doesn't have
89
113
/// an `AccessibilityNode`, its node will be an immediate child of the primary window.
90
114
#[ derive( Component , Clone , Deref , DerefMut ) ]
115
+ #[ cfg_attr( feature = "serialize" , derive( Serialize , Deserialize ) ) ]
91
116
pub struct AccessibilityNode ( pub Node ) ;
92
117
93
118
impl From < Node > for AccessibilityNode {
@@ -98,6 +123,12 @@ impl From<Node> for AccessibilityNode {
98
123
99
124
/// Set enum for the systems relating to accessibility
100
125
#[ derive( Debug , Hash , PartialEq , Eq , Clone , SystemSet ) ]
126
+ #[ cfg_attr( feature = "serialize" , derive( Serialize , Deserialize ) ) ]
127
+ #[ cfg_attr( feature = "bevy_reflect" , derive( Reflect ) ) ]
128
+ #[ cfg_attr(
129
+ all( feature = "bevy_reflect" , feature = "serialize" ) ,
130
+ reflect( Serialize , Deserialize )
131
+ ) ]
101
132
pub enum AccessibilitySystem {
102
133
/// Update the accessibility tree
103
134
Update ,
0 commit comments