1#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
3pub enum Role {
4 Text,
5 Button,
6 Tab,
7 TextField,
8 #[default]
9 Container,
10 Checkbox,
11 RadioButton,
12 Switch,
13 Slider,
14 ProgressBar,
15 Dialog,
16}
17
18#[derive(Clone, Debug)]
20pub struct Semantics {
21 pub role: Role,
23 pub label: Option<String>,
26 pub focused: bool,
28 pub enabled: bool,
31 pub selectable_group: bool,
34 pub checked: Option<bool>,
35 pub selected: Option<bool>,
36 pub value: Option<String>,
37}
38
39impl Semantics {
40 pub fn new(role: Role) -> Self {
41 Self {
42 role,
43 label: None,
44 focused: false,
45 enabled: true,
46 selectable_group: false,
47 checked: None,
48 selected: None,
49 value: None,
50 }
51 }
52 pub fn with_label(mut self, label: impl Into<String>) -> Self {
53 self.label = Some(label.into());
54 self
55 }
56 pub fn with_selectable_group(mut self) -> Self {
57 self.selectable_group = true;
58 self
59 }
60 pub fn with_checked(mut self, checked: bool) -> Self {
61 self.checked = Some(checked);
62 self
63 }
64 pub fn with_selected(mut self, selected: bool) -> Self {
65 self.selected = Some(selected);
66 self
67 }
68 pub fn with_value(mut self, value: impl Into<String>) -> Self {
69 self.value = Some(value.into());
70 self
71 }
72}
73
74impl Default for Semantics {
75 fn default() -> Self {
76 Self::new(Role::default())
77 }
78}