1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
use buffer_graphics_lib::prelude::*;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

pub mod defaults;
pub mod impls;

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct UiStyle {
    pub button: ButtonStyle,
    pub text_field: TextFieldStyle,
    pub toggle_button: ToggleButtonStyle,
    pub alert: AlertStyle,
    pub dialog: DialogStyle,
    pub background: Color,
    pub title_text: TextFormat,
    pub body_text: TextFormat,
    pub tooltip: TooltipStyle,
    pub icon_button: IconButtonStyle,
    pub toggle_icon_button: ToggleIconButtonStyle,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ColorSet {
    pub normal: Option<Color>,
    pub hover: Option<Color>,
    pub error: Option<Color>,
    pub disabled: Option<Color>,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ToggleColorSet {
    pub normal: Option<Color>,
    pub hover: Option<Color>,
    pub toggled: Option<Color>,
    pub hover_toggled: Option<Color>,
    pub error: Option<Color>,
    pub disabled: Option<Color>,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct FocusColorSet {
    pub normal: Option<Color>,
    pub hover: Option<Color>,
    pub focused: Option<Color>,
    pub error: Option<Color>,
    pub disabled: Option<Color>,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct TextFieldStyle {
    pub text_color: FocusColorSet,
    pub background_color: FocusColorSet,
    pub border_color: FocusColorSet,
    pub cursor: FocusColorSet,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ButtonStyle {
    pub text: ColorSet,
    pub text_size: TextSize,
    pub border: ColorSet,
    pub shadow: ColorSet,
    pub rounding: usize,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct IconButtonStyle {
    pub tooltip: TooltipStyle,
    pub border: ColorSet,
    pub shadow: ColorSet,
    pub rounding: usize,
    pub padding: usize,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct TooltipStyle {
    pub text: ColorSet,
    pub background: ColorSet,
    pub border: ColorSet,
    pub shadow: ColorSet,
    pub size: TextSize,
    pub padding: usize,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ToggleButtonStyle {
    pub text: ToggleColorSet,
    pub border: ToggleColorSet,
    pub shadow: ToggleColorSet,
    pub text_size: TextSize,
    pub rounding: usize,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ToggleIconButtonStyle {
    pub tooltip: TooltipStyle,
    pub border: ToggleColorSet,
    pub shadow: ToggleColorSet,
    pub rounding: usize,
    pub padding: usize,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct AlertStyle {
    pub background: Option<Color>,
    pub text: Color,
    pub warning_text: Color,
    pub text_size: TextSize,
    pub button: ButtonStyle,
    pub border: Option<Color>,
    pub shadow: Option<Color>,
    pub shade: Option<Color>,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct DialogStyle {
    pub bounds: Rect,
    pub background: Option<Color>,
    pub text: Color,
    pub button: ButtonStyle,
    pub text_field: TextFieldStyle,
    pub toggle_button: ToggleButtonStyle,
    pub border: Option<Color>,
    pub shadow: Option<Color>,
    pub shade: Option<Color>,
}