uzor_core/widgets/
checkbox.rs1use crate::types::{WidgetState, Rect};
7use serde::{Deserialize, Serialize};
8
9#[derive(Clone, Debug, Serialize, Deserialize)]
11#[derive(Default)]
12pub struct CheckboxConfig {
13 pub label: String,
15 pub checked: bool,
17 pub disabled: bool,
19}
20
21
22impl CheckboxConfig {
23 pub fn new(label: &str) -> Self {
24 Self {
25 label: label.to_string(),
26 ..Default::default()
27 }
28 }
29
30 pub fn with_checked(mut self, checked: bool) -> Self {
31 self.checked = checked;
32 self
33 }
34
35 pub fn with_disabled(mut self, disabled: bool) -> Self {
36 self.disabled = disabled;
37 self
38 }
39}
40
41#[derive(Clone, Debug, Default, Serialize, Deserialize)]
43pub struct CheckboxResponse {
44 pub toggled: bool,
46 pub new_checked: bool,
48 pub hovered: bool,
50 pub state: WidgetState,
52 pub rect: Rect,
54}