1use buffer_graphics_lib::prelude::*;
2#[cfg(feature = "serde")]
3use serde::{Deserialize, Serialize};
4
5pub mod defaults;
6pub mod impls;
7
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9#[derive(Debug, Clone, PartialEq)]
10pub struct UiStyle {
11 pub button: ButtonStyle,
12 pub text_field: TextFieldStyle,
13 pub toggle_button: ToggleButtonStyle,
14 pub alert: AlertStyle,
15 pub dialog: DialogStyle,
16 pub background: Color,
17 pub title_text: TextFormat,
18 pub body_text: TextFormat,
19 pub tooltip: TooltipStyle,
20 pub icon_button: IconButtonStyle,
21 pub checkbox: CheckboxStyle,
22 pub toggle_icon_button: ToggleIconButtonStyle,
23 pub menu: MenuBarStyle,
24}
25
26#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
27#[derive(Debug, Clone, Eq, PartialEq)]
28pub struct ColorSet {
29 pub normal: Option<Color>,
30 pub hover: Option<Color>,
31 pub error: Option<Color>,
32 pub disabled: Option<Color>,
33}
34
35#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
36#[derive(Debug, Clone, Eq, PartialEq)]
37pub struct ToggleColorSet {
38 pub normal: Option<Color>,
39 pub hover: Option<Color>,
40 pub toggled: Option<Color>,
41 pub hover_toggled: Option<Color>,
42 pub error: Option<Color>,
43 pub disabled: Option<Color>,
44}
45
46#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
47#[derive(Debug, Clone, Eq, PartialEq)]
48pub struct FocusColorSet {
49 pub normal: Option<Color>,
50 pub hover: Option<Color>,
51 pub focused: Option<Color>,
52 pub error: Option<Color>,
53 pub disabled: Option<Color>,
54}
55
56#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
57#[derive(Debug, Clone, Eq, PartialEq)]
58pub struct TextFieldStyle {
59 pub text_color: FocusColorSet,
60 pub background_color: FocusColorSet,
61 pub border_color: FocusColorSet,
62 pub cursor: FocusColorSet,
63}
64
65#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
66#[derive(Debug, Clone, Eq, PartialEq)]
67pub struct ButtonStyle {
68 pub text: ColorSet,
69 pub font: PixelFont,
70 pub border: ColorSet,
71 pub shadow: ColorSet,
72 pub rounding: usize,
73}
74
75#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
76#[derive(Debug, Clone, Eq, PartialEq)]
77pub struct MenuBarStyle {
78 pub background: ColorSet,
79 pub border: ColorSet,
80 pub menu_item: MenuItemStyle,
81 pub dropdown_item: DropdownItemStyle,
82}
83
84#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
85#[derive(Debug, Clone, Eq, PartialEq)]
86pub struct MenuItemStyle {
87 pub background: FocusColorSet,
88 pub text: FocusColorSet,
89 pub font: PixelFont,
90 pub dropdown_background: Option<Color>,
91 pub padding: Padding,
92}
93
94#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
95#[derive(Debug, Clone, Eq, PartialEq)]
96pub struct DropdownItemStyle {
97 pub background: FocusColorSet,
98 pub text: FocusColorSet,
99 pub font: PixelFont,
100 pub arrow: IconSet,
101 pub padding: Padding,
102}
103
104#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
105#[derive(Debug, Clone, Eq, PartialEq)]
106pub struct Padding {
107 left: usize,
108 top: usize,
109 right: usize,
110 bottom: usize,
111}
112
113#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
114#[derive(Debug, Clone, Eq, PartialEq)]
115pub struct IconButtonStyle {
116 pub tooltip: TooltipStyle,
117 pub border: ColorSet,
118 pub shadow: ColorSet,
119 pub rounding: usize,
120 pub padding: usize,
121}
122
123#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
124#[derive(Debug, Clone, Eq, PartialEq)]
125pub struct CheckboxStyle {
126 pub checked_icon: IndexedImage,
127 pub check_box: IndexedImage,
128 pub text: ColorSet,
129 pub icon: ColorSet,
130 pub font: PixelFont,
131 pub spacing: usize,
132}
133
134#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
135#[derive(Debug, Clone, Eq, PartialEq)]
136pub struct TooltipStyle {
137 pub text: ColorSet,
138 pub background: ColorSet,
139 pub border: ColorSet,
140 pub shadow: ColorSet,
141 pub font: PixelFont,
142 pub padding: usize,
143}
144
145#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
146#[derive(Debug, Clone, Eq, PartialEq)]
147pub struct ToggleButtonStyle {
148 pub text: ToggleColorSet,
149 pub border: ToggleColorSet,
150 pub shadow: ToggleColorSet,
151 pub font: PixelFont,
152 pub rounding: usize,
153}
154
155#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
156#[derive(Debug, Clone, Eq, PartialEq)]
157pub struct ToggleIconButtonStyle {
158 pub tooltip: TooltipStyle,
159 pub border: ToggleColorSet,
160 pub shadow: ToggleColorSet,
161 pub rounding: usize,
162 pub padding: usize,
163}
164
165#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
166#[derive(Debug, Clone, Eq, PartialEq)]
167pub struct AlertStyle {
168 pub background: Option<Color>,
169 pub text: Color,
170 pub warning_text: Color,
171 pub font: PixelFont,
172 pub button: ButtonStyle,
173 pub border: Option<Color>,
174 pub shadow: Option<Color>,
175 pub shade: Option<Color>,
176}
177
178#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
179#[derive(Debug, Clone, Eq, PartialEq)]
180pub struct DialogStyle {
181 pub bounds: Rect,
182 pub background: Option<Color>,
183 pub text: Color,
184 pub border: Option<Color>,
185 pub shadow: Option<Color>,
186 pub shade: Option<Color>,
187}
188
189#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
190#[derive(Debug, Clone, Eq, PartialEq)]
191pub struct IconSet {
192 pub normal: Option<IndexedImage>,
193 pub focused: Option<IndexedImage>,
194 pub hover: Option<IndexedImage>,
195 pub error: Option<IndexedImage>,
196 pub disabled: Option<IndexedImage>,
197}