pixels_graphics_lib/ui/styles/
mod.rs

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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
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, 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 checkbox: CheckboxStyle,
    pub toggle_icon_button: ToggleIconButtonStyle,
    pub menu: MenuBarStyle,
}

#[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 font: PixelFont,
    pub border: ColorSet,
    pub shadow: ColorSet,
    pub rounding: usize,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct MenuBarStyle {
    pub background: ColorSet,
    pub border: ColorSet,
    pub menu_item: MenuItemStyle,
    pub dropdown_item: DropdownItemStyle,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct MenuItemStyle {
    pub background: FocusColorSet,
    pub text: FocusColorSet,
    pub font: PixelFont,
    pub dropdown_background: Option<Color>,
    pub padding: Padding,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct DropdownItemStyle {
    pub background: FocusColorSet,
    pub text: FocusColorSet,
    pub font: PixelFont,
    pub arrow: IconSet,
    pub padding: Padding,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Padding {
    left: usize,
    top: usize,
    right: usize,
    bottom: 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 CheckboxStyle {
    pub checked_icon: IndexedImage,
    pub check_box: IndexedImage,
    pub text: ColorSet,
    pub icon: ColorSet,
    pub font: PixelFont,
    pub spacing: 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 font: PixelFont,
    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 font: PixelFont,
    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 font: PixelFont,
    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 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 IconSet {
    pub normal: Option<IndexedImage>,
    pub focused: Option<IndexedImage>,
    pub hover: Option<IndexedImage>,
    pub error: Option<IndexedImage>,
    pub disabled: Option<IndexedImage>,
}