Skip to main content

euv_core/system/a11y/
struct.rs

1use super::*;
2
3/// Declarative accessibility metadata attached to any retained `SceneNode`.
4#[derive(Clone, Data, Debug, Default, New, PartialEq)]
5pub struct A11yProps {
6    /// Semantic assistive role.
7    #[get(type(copy))]
8    pub(crate) role: A11yRole,
9    /// Primary accessible name spoken by screen readers.
10    pub(crate) label: String,
11    /// Supplemental usage hint or description.
12    #[new(skip)]
13    pub(crate) hint: String,
14    /// Current human-readable value (e.g. input text or slider percentage).
15    #[new(skip)]
16    pub(crate) value: String,
17    /// Checked or toggled state for checkboxes, switches, and toggle buttons.
18    #[new(skip)]
19    #[get(skip)]
20    pub(crate) checked: Option<bool>,
21    /// Whether the control is currently disabled.
22    #[new(skip)]
23    #[get(type(copy))]
24    pub(crate) disabled: bool,
25    /// Whether the subtree is hidden from assistive technology.
26    #[new(skip)]
27    #[get(type(copy))]
28    pub(crate) hidden: bool,
29    /// Live region announcement policy.
30    #[new(skip)]
31    #[get(type(copy))]
32    pub(crate) live_region: A11yLiveRegion,
33    /// Heading level (`1..=6`) when `role == A11yRole::Heading`.
34    #[new(skip)]
35    #[get(type(copy))]
36    pub(crate) heading_level: u8,
37}
38
39/// Compiled snapshot node in the cross-platform `A11yTree`.
40#[derive(Clone, Data, Debug, New, PartialEq)]
41pub struct A11yNode {
42    /// Corresponding scene node identifier.
43    #[get(type(copy))]
44    pub(crate) id: NodeId,
45    /// Resolved semantic accessibility properties.
46    pub(crate) props: A11yProps,
47    /// Laid-out screen bounds in logical coordinates.
48    #[get(type(copy))]
49    pub(crate) bounds: Rect,
50    /// Whether this node currently holds keyboard focus.
51    #[get(type(copy))]
52    pub(crate) focused: bool,
53    /// Ordered accessible child node handles.
54    pub(crate) children: Vec<NodeId>,
55}
56
57/// Compiled semantic accessibility tree bridging `SceneTree` to OS screen readers.
58#[derive(Clone, Data, Debug, Default, New, PartialEq)]
59pub struct A11yTree {
60    /// Root accessible node handle.
61    #[get(type(copy))]
62    pub(crate) root: NodeId,
63    /// Flat preorder list of exposed accessible nodes.
64    pub(crate) nodes: Vec<A11yNode>,
65    /// Currently focused accessible node handle, if any.
66    #[get(skip)]
67    pub(crate) focused_id: Option<NodeId>,
68}
69
70/// Live accessibility announcement queued for VoiceOver, TalkBack, Narrator, Orca, or ARIA live regions.
71#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
72pub struct A11yAnnouncement {
73    /// Spoken message text.
74    pub(crate) message: String,
75    /// Announcement priority level.
76    #[get(type(copy))]
77    pub(crate) politeness: A11yLiveRegion,
78}