use crate::Id;
use crate::rect::Rect;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Role {
Window,
Button,
Link,
CheckBox,
RadioButton,
TextInput,
TextArea,
Slider,
Label,
Heading,
List,
ListItem,
Image,
Container,
ScrollRegion,
Menu,
Switch,
}
#[derive(Debug, Clone, PartialEq)]
pub struct SemanticNode {
pub id: Id,
pub role: Role,
pub label: Option<String>,
pub rect: Rect,
pub children: Vec<Id>,
pub focused: bool,
pub disabled: bool,
pub value: Option<f32>,
pub min_value: Option<f32>,
pub max_value: Option<f32>,
}
impl SemanticNode {
pub fn new(id: Id, role: Role, rect: Rect) -> Self {
Self {
id,
role,
label: None,
rect,
children: Vec::new(),
focused: false,
disabled: false,
value: None,
min_value: None,
max_value: None,
}
}
pub fn with_label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn with_focus(mut self, focused: bool) -> Self {
self.focused = focused;
self
}
pub fn with_value(mut self, value: f32) -> Self {
self.value = Some(value);
self
}
pub fn with_min_value(mut self, min: f32) -> Self {
self.min_value = Some(min);
self
}
pub fn with_max_value(mut self, max: f32) -> Self {
self.max_value = Some(max);
self
}
}