#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum Role {
Text,
Button,
Tab,
TextField,
#[default]
Container,
Checkbox,
RadioButton,
Switch,
Slider,
ProgressBar,
}
#[derive(Clone, Debug)]
pub struct Semantics {
pub role: Role,
pub label: Option<String>,
pub focused: bool,
pub enabled: bool,
pub selectable_group: bool,
pub checked: Option<bool>,
pub selected: Option<bool>,
pub value: Option<String>,
}
impl Semantics {
pub fn new(role: Role) -> Self {
Self {
role,
label: None,
focused: false,
enabled: true,
selectable_group: false,
checked: None,
selected: None,
value: None,
}
}
pub fn with_label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn with_selectable_group(mut self) -> Self {
self.selectable_group = true;
self
}
pub fn with_checked(mut self, checked: bool) -> Self {
self.checked = Some(checked);
self
}
pub fn with_selected(mut self, selected: bool) -> Self {
self.selected = Some(selected);
self
}
pub fn with_value(mut self, value: impl Into<String>) -> Self {
self.value = Some(value.into());
self
}
}
impl Default for Semantics {
fn default() -> Self {
Self::new(Role::default())
}
}