repose_core/semantics.rs
1/// High‑level semantic role of a view, similar to ARIA roles.
2#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3pub enum Role {
4 Text,
5 Button,
6 TextField,
7 Container,
8 Checkbox,
9 RadioButton,
10 Switch,
11 Slider,
12 ProgressBar,
13}
14
15/// Semantics attached to a `View`, used to build the accessibility tree.
16#[derive(Clone, Debug)]
17pub struct Semantics {
18 /// Primary role of this node (what kind of thing it is).
19 pub role: Role,
20 /// Human‑readable label for screen readers. For buttons, this is the
21 /// “name” that is announced.
22 pub label: Option<String>,
23 /// Whether this node is currently focused.
24 pub focused: bool,
25 /// Whether this node is actionable; disabled nodes remain in the tree
26 /// but are marked not enabled.
27 pub enabled: bool,
28 // pub value: Option<String>,
29 // pub checked: Option<bool>,
30}
31
32impl Semantics {
33 pub fn new(role: Role) -> Self {
34 Self {
35 role,
36 label: None,
37 focused: false,
38 enabled: true,
39 // value: None,
40 // checked: None,
41 }
42 }
43}