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}
16
17#[derive(Clone, Debug)]
19pub struct Semantics {
20 pub role: Role,
22 pub label: Option<String>,
25 pub focused: bool,
27 pub enabled: bool,
30 pub selectable_group: bool,
33 pub checked: Option<bool>,
34 pub selected: Option<bool>,
35 pub value: Option<String>,
36}
37
38impl Semantics {
39 pub fn new(role: Role) -> Self {
40 Self {
41 role,
42 label: None,
43 focused: false,
44 enabled: true,
45 selectable_group: false,
46 checked: None,
47 selected: None,
48 value: None,
49 }
50 }
51 pub fn with_label(mut self, label: impl Into<String>) -> Self {
52 self.label = Some(label.into());
53 self
54 }
55 pub fn with_selectable_group(mut self) -> Self {
56 self.selectable_group = true;
57 self
58 }
59 pub fn with_checked(mut self, checked: bool) -> Self {
60 self.checked = Some(checked);
61 self
62 }
63 pub fn with_selected(mut self, selected: bool) -> Self {
64 self.selected = Some(selected);
65 self
66 }
67 pub fn with_value(mut self, value: impl Into<String>) -> Self {
68 self.value = Some(value.into());
69 self
70 }
71}
72
73impl Default for Semantics {
74 fn default() -> Self {
75 Self::new(Role::default())
76 }
77}