1 /**
2 * @file lv_theme_material.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "../../lvgl.h" /*To see all the widgets*/
10
11 #if LV_USE_THEME_MATERIAL
12
13 #include "../lv_misc/lv_gc.h"
14
15 #if defined(LV_GC_INCLUDE)
16 #include LV_GC_INCLUDE
17 #endif /* LV_ENABLE_GC */
18
19 /*********************
20 * DEFINES
21 *********************/
22
23 /*SCREEN*/
24
25 #define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xeaeff3) : lv_color_hex(0x444b5a))
26 #define COLOR_SCR_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xe7e9ec))
27
28 /*BUTTON*/
29 #define COLOR_BTN (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0x586273))
30 #define COLOR_BTN_PR (IS_LIGHT ? lv_color_mix(theme.color_primary, COLOR_BTN, LV_OPA_10) : lv_color_mix(theme.color_primary, COLOR_BTN, LV_OPA_30))
31
32 #define COLOR_BTN_CHK (theme.color_primary)
33 #define COLOR_BTN_CHK_PR (lv_color_darken(theme.color_primary, LV_OPA_30))
34 #define COLOR_BTN_DIS (IS_LIGHT ? lv_color_hex3(0xccc) : lv_color_hex3(0x888))
35
36 #define COLOR_BTN_BORDER theme.color_primary
37 #define COLOR_BTN_BORDER_PR theme.color_primary
38 #define COLOR_BTN_BORDER_CHK theme.color_primary
39 #define COLOR_BTN_BORDER_CHK_PR theme.color_primary
40 #define COLOR_BTN_BORDER_INA (IS_LIGHT ? lv_color_hex3(0x888) : lv_color_hex(0x404040))
41
42 /*BACKGROUND*/
43 #define COLOR_BG (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0x586273))
44 #define COLOR_BG_PR (IS_LIGHT ? lv_color_hex(0xeeeeee) : lv_color_hex(0x494f57))
45 #define COLOR_BG_CHK theme.color_primary
46 #define COLOR_BG_PR_CHK lv_color_darken(theme.color_primary, LV_OPA_20)
47 #define COLOR_BG_DIS COLOR_BG
48
49 #define COLOR_BG_BORDER (IS_LIGHT ? lv_color_hex(0xd6dde3) : lv_color_hex(0x808a97)) /*dfe7ed*/
50 #define COLOR_BG_BORDER_PR (IS_LIGHT ? lv_color_hex3(0xccc) : lv_color_hex(0x5f656e))
51 #define COLOR_BG_BORDER_CHK (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0x5f656e))
52 #define COLOR_BG_BORDER_CHK_PR (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0x5f656e))
53 #define COLOR_BG_BORDER_DIS (IS_LIGHT ? lv_color_hex(0xd6dde3) : lv_color_hex(0x5f656e))
54
55 #define COLOR_BG_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xffffff))
56 #define COLOR_BG_TEXT_PR (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xffffff))
57 #define COLOR_BG_TEXT_CHK (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0xffffff))
58 #define COLOR_BG_TEXT_CHK_PR (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0xffffff))
59 #define COLOR_BG_TEXT_DIS (IS_LIGHT ? lv_color_hex3(0xaaa) : lv_color_hex3(0x999))
60
61 /*SECONDARY BACKGROUND*/
62 #define COLOR_BG_SEC (IS_LIGHT ? lv_color_hex(0xd4d7d9) : lv_color_hex(0x45494d))
63 #define COLOR_BG_SEC_BORDER (IS_LIGHT ? lv_color_hex(0xdfe7ed) : lv_color_hex(0x404040))
64 #define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad))
65 #define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad))
66
67 #define TRANSITION_TIME 0/*((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 150)*/
68 #define BORDER_WIDTH LV_DPX(2)
69 #define OUTLINE_WIDTH ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) ? 0 : LV_DPX(2))
70 #define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT)
71
72 #define PAD_DEF (lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(15) : (LV_DPX(30)))
73
74 /**********************
75 * TYPEDEFS
76 **********************/
77 typedef struct {
78 lv_style_t scr;
79 lv_style_t bg;
80 lv_style_t bg_click;
81 lv_style_t bg_sec;
82 lv_style_t btn;
83 lv_style_t pad_inner;
84 lv_style_t pad_small;
85
86 #if LV_USE_ARC
87 lv_style_t arc_indic;
88 lv_style_t arc_bg;
89 lv_style_t arc_knob;
90 #endif
91
92 #if LV_USE_BAR
93 lv_style_t bar_bg;
94 lv_style_t bar_indic;
95 #endif
96
97 #if LV_USE_CALENDAR
98 lv_style_t calendar_date_nums, calendar_header, calendar_daynames;
99 #endif
100
101 #if LV_USE_CPICKER
102 lv_style_t cpicker_bg, cpicker_indic;
103 #endif
104
105 #if LV_USE_CHART
106 lv_style_t chart_bg, chart_series_bg, chart_series;
107 #endif
108
109 #if LV_USE_CHECKBOX
110 lv_style_t cb_bg, cb_bullet;
111 #endif
112
113 #if LV_USE_DROPDOWN
114 lv_style_t ddlist_page, ddlist_sel;
115 #endif
116
117 #if LV_USE_GAUGE
118 lv_style_t gauge_main, gauge_strong, gauge_needle;
119 #endif
120
121 #if LV_USE_KEYBOARD
122 lv_style_t kb_bg;
123 #endif
124
125 #if LV_USE_LED
126 lv_style_t led;
127 #endif
128
129 #if LV_USE_LINEMETER
130 lv_style_t lmeter;
131 #endif
132
133 #if LV_USE_LIST
134 lv_style_t list_bg, list_btn;
135 #endif
136
137 #if LV_USE_MSGBOX
138 lv_style_t mbox_bg;
139 #endif
140
141 #if LV_USE_PAGE
142 lv_style_t sb;
143 #if LV_USE_ANIMATION
144 lv_style_t edge_flash;
145 #endif
146 #endif
147
148 #if LV_USE_ROLLER
149 lv_style_t roller_bg, roller_sel;
150 #endif
151
152 #if LV_USE_SLIDER
153 lv_style_t slider_knob, slider_bg;
154 #endif
155
156 #if LV_USE_SPINBOX
157 lv_style_t spinbox_cursor;
158 #endif
159
160 #if LV_USE_SWITCH
161 lv_style_t sw_knob;
162 #endif
163
164 #if LV_USE_TABLE
165 lv_style_t table_cell;
166 #endif
167
168 #if LV_USE_TABVIEW || LV_USE_WIN
169 lv_style_t tabview_btns, tabview_btns_bg, tabview_indic, tabview_page_scrl;
170 #endif
171
172 #if LV_USE_TEXTAREA
173 lv_style_t ta_cursor, ta_placeholder;
174 #endif
175
176 } theme_styles_t;
177
178 /**********************
179 * STATIC PROTOTYPES
180 **********************/
181 static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
182 static void style_init_reset(lv_style_t * style);
183
184 /**********************
185 * STATIC VARIABLES
186 **********************/
187 static lv_theme_t theme;
188 static theme_styles_t * styles;
189
190 static bool inited;
191
192 /**********************
193 * MACROS
194 **********************/
195
196 /**********************
197 * STATIC FUNCTIONS
198 **********************/
199
basic_init(void)200 static void basic_init(void)
201 {
202 style_init_reset(&styles->scr);
203 lv_style_set_bg_opa(&styles->scr, LV_STATE_DEFAULT, LV_OPA_COVER);
204 lv_style_set_bg_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR);
205 lv_style_set_text_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
206 lv_style_set_value_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
207 lv_style_set_value_font(&styles->scr, LV_STATE_DEFAULT, theme.font_normal);
208
209 style_init_reset(&styles->bg);
210 lv_style_set_radius(&styles->bg, LV_STATE_DEFAULT, LV_DPX(8));
211 lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER);
212 lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG);
213 lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_BORDER);
214 if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED,
215 theme.color_primary);
216 lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary);
217 lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH);
218 lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true);
219 lv_style_set_text_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
220 lv_style_set_value_font(&styles->bg, LV_STATE_DEFAULT, theme.font_normal);
221 lv_style_set_value_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
222 lv_style_set_image_recolor(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
223 lv_style_set_line_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
224 lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, 1);
225 lv_style_set_pad_left(&styles->bg, LV_STATE_DEFAULT, PAD_DEF + BORDER_WIDTH);
226 lv_style_set_pad_right(&styles->bg, LV_STATE_DEFAULT, PAD_DEF + BORDER_WIDTH);
227 lv_style_set_pad_top(&styles->bg, LV_STATE_DEFAULT, PAD_DEF + BORDER_WIDTH);
228 lv_style_set_pad_bottom(&styles->bg, LV_STATE_DEFAULT, PAD_DEF + BORDER_WIDTH);
229 lv_style_set_pad_inner(&styles->bg, LV_STATE_DEFAULT, PAD_DEF);
230 lv_style_set_transition_time(&styles->bg, LV_STATE_DEFAULT, TRANSITION_TIME);
231 lv_style_set_transition_prop_6(&styles->bg, LV_STATE_DEFAULT, LV_STYLE_BORDER_COLOR);
232
233 style_init_reset(&styles->bg_sec);
234 lv_style_copy(&styles->bg_sec, &styles->bg);
235 lv_style_set_bg_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC);
236 lv_style_set_border_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_BORDER);
237 lv_style_set_text_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
238 lv_style_set_value_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
239 lv_style_set_image_recolor(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
240 lv_style_set_line_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
241
242 style_init_reset(&styles->bg_click);
243 lv_style_set_bg_color(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_PR);
244 lv_style_set_bg_color(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_CHK);
245 lv_style_set_bg_color(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_PR_CHK);
246 lv_style_set_bg_color(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_DIS);
247 lv_style_set_border_width(&styles->bg_click, LV_STATE_CHECKED, 0);
248 lv_style_set_border_color(&styles->bg_click, LV_STATE_FOCUSED | LV_STATE_PRESSED, lv_color_darken(theme.color_primary,
249 LV_OPA_20));
250 lv_style_set_border_color(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_BORDER_PR);
251 lv_style_set_border_color(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_BORDER_CHK);
252 lv_style_set_border_color(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_BORDER_CHK_PR);
253 lv_style_set_border_color(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_BORDER_DIS);
254 lv_style_set_text_color(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_TEXT_PR);
255 lv_style_set_text_color(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK);
256 lv_style_set_text_color(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_TEXT_CHK_PR);
257 lv_style_set_text_color(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS);
258 lv_style_set_image_recolor(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_TEXT_PR);
259 lv_style_set_image_recolor(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK);
260 lv_style_set_image_recolor(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_TEXT_CHK_PR);
261 lv_style_set_image_recolor(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS);
262 lv_style_set_transition_prop_5(&styles->bg_click, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
263
264 style_init_reset(&styles->btn);
265 lv_style_set_radius(&styles->btn, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
266 lv_style_set_bg_opa(&styles->btn, LV_STATE_DEFAULT, LV_OPA_COVER);
267 lv_style_set_bg_color(&styles->btn, LV_STATE_DEFAULT, COLOR_BTN);
268 lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, COLOR_BTN_PR);
269 lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED, COLOR_BTN_CHK);
270 lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, COLOR_BTN_CHK_PR);
271 lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED, COLOR_BTN);
272 lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED | LV_STATE_CHECKED, COLOR_BTN_DIS);
273 lv_style_set_border_color(&styles->btn, LV_STATE_DEFAULT, COLOR_BTN_BORDER);
274 lv_style_set_border_color(&styles->btn, LV_STATE_PRESSED, COLOR_BTN_BORDER_PR);
275 lv_style_set_border_color(&styles->btn, LV_STATE_DISABLED, COLOR_BTN_BORDER_INA);
276 lv_style_set_border_width(&styles->btn, LV_STATE_DEFAULT, BORDER_WIDTH);
277 lv_style_set_border_opa(&styles->btn, LV_STATE_CHECKED, LV_OPA_TRANSP);
278
279 lv_style_set_text_color(&styles->btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff));
280 lv_style_set_text_color(&styles->btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff));
281 lv_style_set_text_color(&styles->btn, LV_STATE_CHECKED, lv_color_hex(0xffffff));
282 lv_style_set_text_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff));
283 lv_style_set_text_color(&styles->btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888));
284
285 lv_style_set_image_recolor(&styles->btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff));
286 lv_style_set_image_recolor(&styles->btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff));
287 lv_style_set_image_recolor(&styles->btn, LV_STATE_PRESSED, lv_color_hex(0xffffff));
288 lv_style_set_image_recolor(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff));
289 lv_style_set_image_recolor(&styles->btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888));
290
291 lv_style_set_value_color(&styles->btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff));
292 lv_style_set_value_color(&styles->btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff));
293 lv_style_set_value_color(&styles->btn, LV_STATE_CHECKED, lv_color_hex(0xffffff));
294 lv_style_set_value_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff));
295 lv_style_set_value_color(&styles->btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888));
296
297 lv_style_set_pad_left(&styles->btn, LV_STATE_DEFAULT, LV_DPX(40));
298 lv_style_set_pad_right(&styles->btn, LV_STATE_DEFAULT, LV_DPX(40));
299 lv_style_set_pad_top(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15));
300 lv_style_set_pad_bottom(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15));
301 lv_style_set_pad_inner(&styles->btn, LV_STATE_DEFAULT, LV_DPX(20));
302 lv_style_set_outline_width(&styles->btn, LV_STATE_DEFAULT, OUTLINE_WIDTH);
303 lv_style_set_outline_opa(&styles->btn, LV_STATE_DEFAULT, LV_OPA_0);
304 lv_style_set_outline_opa(&styles->btn, LV_STATE_FOCUSED, LV_OPA_50);
305 lv_style_set_outline_color(&styles->btn, LV_STATE_DEFAULT, theme.color_primary);
306 lv_style_set_outline_color(&styles->btn, LV_STATE_EDITED, theme.color_secondary);
307 lv_style_set_transition_time(&styles->btn, LV_STATE_DEFAULT, TRANSITION_TIME);
308 lv_style_set_transition_prop_4(&styles->btn, LV_STATE_DEFAULT, LV_STYLE_BORDER_OPA);
309 lv_style_set_transition_prop_5(&styles->btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
310 lv_style_set_transition_prop_6(&styles->btn, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA);
311 lv_style_set_transition_delay(&styles->btn, LV_STATE_DEFAULT, TRANSITION_TIME);
312 lv_style_set_transition_delay(&styles->btn, LV_STATE_PRESSED, 0);
313
314 style_init_reset(&styles->pad_inner);
315
316 lv_style_set_pad_inner(&styles->pad_inner, LV_STATE_DEFAULT,
317 lv_disp_get_size_category(NULL) <= LV_DISP_MEDIUM_LIMIT ? LV_DPX(20) : LV_DPX(40));
318
319 style_init_reset(&styles->pad_small);
320 lv_style_int_t pad_small_value = lv_disp_get_size_category(NULL) <= LV_DISP_MEDIUM_LIMIT ? LV_DPX(10) : LV_DPX(20);
321 lv_style_set_pad_left(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
322 lv_style_set_pad_right(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
323 lv_style_set_pad_top(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
324 lv_style_set_pad_bottom(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
325 lv_style_set_pad_inner(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
326 }
327
cont_init(void)328 static void cont_init(void)
329 {
330 #if LV_USE_CONT != 0
331
332 #endif
333 }
334
btn_init(void)335 static void btn_init(void)
336 {
337 #if LV_USE_BTN != 0
338
339 #endif
340 }
341
label_init(void)342 static void label_init(void)
343 {
344 #if LV_USE_LABEL != 0
345
346 #endif
347 }
348
bar_init(void)349 static void bar_init(void)
350 {
351 #if LV_USE_BAR
352 style_init_reset(&styles->bar_bg);
353 lv_style_set_radius(&styles->bar_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
354 lv_style_set_bg_opa(&styles->bar_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
355 lv_style_set_bg_color(&styles->bar_bg, LV_STATE_DEFAULT, COLOR_BG_SEC);
356 lv_style_set_value_color(&styles->bar_bg, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE);
357 lv_style_set_outline_color(&styles->bar_bg, LV_STATE_DEFAULT, theme.color_primary);
358 lv_style_set_outline_color(&styles->bar_bg, LV_STATE_EDITED, theme.color_secondary);
359 lv_style_set_outline_opa(&styles->bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
360 lv_style_set_outline_opa(&styles->bar_bg, LV_STATE_FOCUSED, LV_OPA_50);
361 lv_style_set_outline_width(&styles->bar_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH);
362 lv_style_set_transition_time(&styles->bar_bg, LV_STATE_DEFAULT, TRANSITION_TIME);
363 lv_style_set_transition_prop_6(&styles->bar_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA);
364
365 style_init_reset(&styles->bar_indic);
366 lv_style_set_bg_opa(&styles->bar_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
367 lv_style_set_radius(&styles->bar_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
368 lv_style_set_bg_color(&styles->bar_indic, LV_STATE_DEFAULT, theme.color_primary);
369 lv_style_set_bg_color(&styles->bar_indic, LV_STATE_DISABLED, lv_color_hex3(0x888));
370 lv_style_set_value_color(&styles->bar_indic, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x41404f) : LV_COLOR_WHITE);
371 #endif
372 }
373
img_init(void)374 static void img_init(void)
375 {
376 #if LV_USE_IMG != 0
377
378 #endif
379 }
380
line_init(void)381 static void line_init(void)
382 {
383 #if LV_USE_LINE != 0
384
385 #endif
386 }
387
led_init(void)388 static void led_init(void)
389 {
390 #if LV_USE_LED != 0
391 style_init_reset(&styles->led);
392 lv_style_set_bg_opa(&styles->led, LV_STATE_DEFAULT, LV_OPA_COVER);
393 lv_style_set_bg_color(&styles->led, LV_STATE_DEFAULT, theme.color_primary);
394 lv_style_set_border_width(&styles->led, LV_STATE_DEFAULT, 2);
395 lv_style_set_border_opa(&styles->led, LV_STATE_DEFAULT, LV_OPA_50);
396 lv_style_set_border_color(&styles->led, LV_STATE_DEFAULT, lv_color_lighten(theme.color_primary, LV_OPA_30));
397 lv_style_set_radius(&styles->led, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
398 lv_style_set_shadow_width(&styles->led, LV_STATE_DEFAULT, LV_DPX(15));
399 lv_style_set_shadow_color(&styles->led, LV_STATE_DEFAULT, theme.color_primary);
400 lv_style_set_shadow_spread(&styles->led, LV_STATE_DEFAULT, LV_DPX(5));
401 #endif
402 }
403
slider_init(void)404 static void slider_init(void)
405 {
406 #if LV_USE_SLIDER != 0
407 style_init_reset(&styles->slider_knob);
408 lv_style_set_bg_opa(&styles->slider_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
409 lv_style_set_bg_color(&styles->slider_knob, LV_STATE_DEFAULT, IS_LIGHT ? theme.color_primary : LV_COLOR_WHITE);
410 lv_style_set_value_color(&styles->slider_knob, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE);
411 lv_style_set_radius(&styles->slider_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
412 lv_style_set_pad_left(&styles->slider_knob, LV_STATE_DEFAULT, LV_DPX(7));
413 lv_style_set_pad_right(&styles->slider_knob, LV_STATE_DEFAULT, LV_DPX(7));
414 lv_style_set_pad_top(&styles->slider_knob, LV_STATE_DEFAULT, LV_DPX(7));
415 lv_style_set_pad_bottom(&styles->slider_knob, LV_STATE_DEFAULT, LV_DPX(7));
416
417 style_init_reset(&styles->slider_bg);
418 lv_style_set_margin_left(&styles->slider_bg, LV_STATE_DEFAULT, LV_DPX(10));
419 lv_style_set_margin_right(&styles->slider_bg, LV_STATE_DEFAULT, LV_DPX(10));
420 lv_style_set_margin_top(&styles->slider_bg, LV_STATE_DEFAULT, LV_DPX(10));
421 lv_style_set_margin_bottom(&styles->slider_bg, LV_STATE_DEFAULT, LV_DPX(10));
422
423 #endif
424 }
425
switch_init(void)426 static void switch_init(void)
427 {
428 #if LV_USE_SWITCH != 0
429 style_init_reset(&styles->sw_knob);
430 lv_style_set_bg_opa(&styles->sw_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
431 lv_style_set_bg_color(&styles->sw_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE);
432 lv_style_set_radius(&styles->sw_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
433 lv_style_set_pad_top(&styles->sw_knob, LV_STATE_DEFAULT, - LV_DPX(4));
434 lv_style_set_pad_bottom(&styles->sw_knob, LV_STATE_DEFAULT, - LV_DPX(4));
435 lv_style_set_pad_left(&styles->sw_knob, LV_STATE_DEFAULT, - LV_DPX(4));
436 lv_style_set_pad_right(&styles->sw_knob, LV_STATE_DEFAULT, - LV_DPX(4));
437 #endif
438 }
439
linemeter_init(void)440 static void linemeter_init(void)
441 {
442 #if LV_USE_LINEMETER != 0
443 style_init_reset(&styles->lmeter);
444 lv_style_set_radius(&styles->lmeter, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
445 lv_style_set_pad_left(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(20));
446 lv_style_set_pad_right(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(20));
447 lv_style_set_pad_top(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(20));
448 lv_style_set_pad_inner(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(30));
449 lv_style_set_scale_width(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(25));
450
451 lv_style_set_line_color(&styles->lmeter, LV_STATE_DEFAULT, theme.color_primary);
452 lv_style_set_scale_grad_color(&styles->lmeter, LV_STATE_DEFAULT, theme.color_primary);
453 lv_style_set_scale_end_color(&styles->lmeter, LV_STATE_DEFAULT, lv_color_hex3(0x888));
454 lv_style_set_line_width(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(10));
455 lv_style_set_scale_end_line_width(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(7));
456 #endif
457 }
458
gauge_init(void)459 static void gauge_init(void)
460 {
461 #if LV_USE_GAUGE != 0
462 style_init_reset(&styles->gauge_main);
463 lv_style_set_line_color(&styles->gauge_main, LV_STATE_DEFAULT, lv_color_hex3(0x888));
464 lv_style_set_scale_grad_color(&styles->gauge_main, LV_STATE_DEFAULT, lv_color_hex3(0x888));
465 lv_style_set_scale_end_color(&styles->gauge_main, LV_STATE_DEFAULT, theme.color_primary);
466 lv_style_set_line_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(5));
467 lv_style_set_scale_end_line_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(4));
468 lv_style_set_scale_end_border_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(8));
469 lv_style_set_pad_left(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(20));
470 lv_style_set_pad_right(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(20));
471 lv_style_set_pad_top(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(20));
472 lv_style_set_pad_inner(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(20));
473 lv_style_set_scale_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(15));
474 lv_style_set_radius(&styles->gauge_main, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
475
476 style_init_reset(&styles->gauge_strong);
477 lv_style_set_line_color(&styles->gauge_strong, LV_STATE_DEFAULT, lv_color_hex3(0x888));
478 lv_style_set_scale_grad_color(&styles->gauge_strong, LV_STATE_DEFAULT, lv_color_hex3(0x888));
479 lv_style_set_scale_end_color(&styles->gauge_strong, LV_STATE_DEFAULT, theme.color_primary);
480 lv_style_set_line_width(&styles->gauge_strong, LV_STATE_DEFAULT, LV_DPX(8));
481 lv_style_set_scale_end_line_width(&styles->gauge_strong, LV_STATE_DEFAULT, LV_DPX(8));
482 lv_style_set_scale_width(&styles->gauge_strong, LV_STATE_DEFAULT, LV_DPX(25));
483
484 style_init_reset(&styles->gauge_needle);
485 lv_style_set_line_color(&styles->gauge_needle, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x464b5b) : LV_COLOR_WHITE);
486 lv_style_set_line_width(&styles->gauge_needle, LV_STATE_DEFAULT, LV_DPX(8));
487 lv_style_set_bg_opa(&styles->gauge_needle, LV_STATE_DEFAULT, LV_OPA_COVER);
488 lv_style_set_bg_color(&styles->gauge_needle, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x464b5b) : LV_COLOR_WHITE);
489 lv_style_set_radius(&styles->gauge_needle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
490 lv_style_set_size(&styles->gauge_needle, LV_STATE_DEFAULT, LV_DPX(30));
491 lv_style_set_pad_inner(&styles->gauge_needle, LV_STATE_DEFAULT, LV_DPX(10));
492 #endif
493 }
494
arc_init(void)495 static void arc_init(void)
496 {
497 #if LV_USE_ARC != 0
498 style_init_reset(&styles->arc_indic);
499 lv_style_set_line_color(&styles->arc_indic, LV_STATE_DEFAULT, theme.color_primary);
500 lv_style_set_line_width(&styles->arc_indic, LV_STATE_DEFAULT, LV_DPX(25));
501 lv_style_set_line_rounded(&styles->arc_indic, LV_STATE_DEFAULT, true);
502
503 style_init_reset(&styles->arc_bg);
504 lv_style_set_line_color(&styles->arc_bg, LV_STATE_DEFAULT, COLOR_BG_SEC);
505 lv_style_set_line_width(&styles->arc_bg, LV_STATE_DEFAULT, LV_DPX(25));
506 lv_style_set_line_rounded(&styles->arc_bg, LV_STATE_DEFAULT, true);
507
508 style_init_reset(&styles->arc_knob);
509 lv_style_set_radius(&styles->arc_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
510 lv_style_set_pad_top(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
511 lv_style_set_pad_bottom(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
512 lv_style_set_pad_left(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
513 lv_style_set_pad_right(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
514
515 #endif
516 }
517
spinner_init(void)518 static void spinner_init(void)
519 {
520 #if LV_USE_SPINNER != 0
521 #endif
522 }
523
chart_init(void)524 static void chart_init(void)
525 {
526 #if LV_USE_CHART
527 style_init_reset(&styles->chart_bg);
528 lv_style_set_text_color(&styles->chart_bg, LV_STATE_DEFAULT, IS_LIGHT ? COLOR_BG_TEXT_DIS : lv_color_hex(0xa1adbd));
529
530 style_init_reset(&styles->chart_series_bg);
531 lv_style_set_line_width(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(1));
532 lv_style_set_line_dash_width(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10));
533 lv_style_set_line_dash_gap(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10));
534 lv_style_set_line_color(&styles->chart_series_bg, LV_STATE_DEFAULT, COLOR_BG_BORDER);
535
536 style_init_reset(&styles->chart_series);
537 lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(3));
538 lv_style_set_size(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(4));
539 lv_style_set_pad_inner(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(2)); /*Space between columns*/
540 lv_style_set_radius(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(1));
541
542 #endif
543 }
544
calendar_init(void)545 static void calendar_init(void)
546 {
547 #if LV_USE_CALENDAR
548
549 style_init_reset(&styles->calendar_header);
550 lv_style_set_pad_top(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
551 lv_style_set_pad_left(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
552 lv_style_set_pad_right(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
553 lv_style_set_pad_bottom(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
554 lv_style_set_text_color(&styles->calendar_header, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x888888) : LV_COLOR_WHITE);
555
556 style_init_reset(&styles->calendar_daynames);
557 lv_style_set_text_color(&styles->calendar_daynames, LV_STATE_DEFAULT,
558 IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex3(0xeee));
559 lv_style_set_pad_left(&styles->calendar_daynames, LV_STATE_DEFAULT, PAD_DEF);
560 lv_style_set_pad_right(&styles->calendar_daynames, LV_STATE_DEFAULT, PAD_DEF);
561 lv_style_set_pad_bottom(&styles->calendar_daynames, LV_STATE_DEFAULT, PAD_DEF);
562
563 style_init_reset(&styles->calendar_date_nums);
564 lv_style_set_radius(&styles->calendar_date_nums, LV_STATE_DEFAULT, LV_DPX(4));
565 lv_style_set_text_color(&styles->calendar_date_nums, LV_STATE_CHECKED,
566 IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE);
567 lv_style_set_text_color(&styles->calendar_date_nums, LV_STATE_DISABLED, LV_COLOR_GRAY);
568 lv_style_set_bg_opa(&styles->calendar_date_nums, LV_STATE_CHECKED, IS_LIGHT ? LV_OPA_20 : LV_OPA_40);
569 lv_style_set_bg_opa(&styles->calendar_date_nums, LV_STATE_PRESSED, LV_OPA_20);
570 lv_style_set_bg_opa(&styles->calendar_date_nums, LV_STATE_FOCUSED, LV_OPA_COVER);
571 lv_style_set_text_color(&styles->calendar_date_nums, LV_STATE_FOCUSED, LV_COLOR_WHITE);
572 lv_style_set_bg_color(&styles->calendar_date_nums, LV_STATE_FOCUSED, theme.color_primary);
573 lv_style_set_bg_color(&styles->calendar_date_nums, LV_STATE_DEFAULT,
574 IS_LIGHT ? lv_color_hex(0x666666) : LV_COLOR_WHITE);
575 lv_style_set_bg_color(&styles->calendar_date_nums, LV_STATE_CHECKED, theme.color_primary);
576 lv_style_set_border_width(&styles->calendar_date_nums, LV_STATE_CHECKED, 2);
577 lv_style_set_border_side(&styles->calendar_date_nums, LV_STATE_CHECKED, LV_BORDER_SIDE_LEFT);
578 lv_style_set_border_color(&styles->calendar_date_nums, LV_STATE_CHECKED, theme.color_primary);
579 lv_style_set_pad_inner(&styles->calendar_date_nums, LV_STATE_DEFAULT, LV_DPX(3));
580 lv_style_set_pad_left(&styles->calendar_date_nums, LV_STATE_DEFAULT, PAD_DEF);
581 lv_style_set_pad_right(&styles->calendar_date_nums, LV_STATE_DEFAULT, PAD_DEF);
582 lv_style_set_pad_bottom(&styles->calendar_date_nums, LV_STATE_DEFAULT, PAD_DEF);
583 #endif
584 }
585
cpicker_init(void)586 static void cpicker_init(void)
587 {
588 #if LV_USE_CPICKER
589 style_init_reset(&styles->cpicker_bg);
590 lv_style_set_scale_width(&styles->cpicker_bg, LV_STATE_DEFAULT, LV_DPX(30));
591 lv_style_set_bg_opa(&styles->cpicker_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
592 lv_style_set_bg_color(&styles->cpicker_bg, LV_STATE_DEFAULT, COLOR_SCR);
593 lv_style_set_pad_inner(&styles->cpicker_bg, LV_STATE_DEFAULT, LV_DPX(20));
594 lv_style_set_radius(&styles->cpicker_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
595
596 style_init_reset(&styles->cpicker_indic);
597 lv_style_set_radius(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
598 lv_style_set_bg_color(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_COLOR_WHITE);
599 lv_style_set_bg_opa(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
600 lv_style_set_border_width(&styles->cpicker_indic, LV_STATE_DEFAULT, 2);
601 lv_style_set_border_color(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_COLOR_GRAY);
602 lv_style_set_border_color(&styles->cpicker_indic, LV_STATE_FOCUSED, theme.color_primary);
603 lv_style_set_border_color(&styles->cpicker_indic, LV_STATE_EDITED, theme.color_secondary);
604 lv_style_set_pad_left(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13));
605 lv_style_set_pad_right(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13));
606 lv_style_set_pad_top(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13));
607 lv_style_set_pad_bottom(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13));
608 #endif
609 }
610
checkbox_init(void)611 static void checkbox_init(void)
612 {
613 #if LV_USE_CHECKBOX != 0
614 style_init_reset(&styles->cb_bg);
615 lv_style_set_radius(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(4));
616 lv_style_set_pad_inner(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(10));
617 lv_style_set_outline_color(&styles->cb_bg, LV_STATE_DEFAULT, theme.color_primary);
618 lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
619 lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_FOCUSED, LV_OPA_50);
620 lv_style_set_outline_width(&styles->cb_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH);
621 lv_style_set_outline_pad(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(10));
622 lv_style_set_transition_time(&styles->cb_bg, LV_STATE_DEFAULT, TRANSITION_TIME);
623 lv_style_set_transition_prop_6(&styles->cb_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA);
624
625 style_init_reset(&styles->cb_bullet);
626 lv_style_set_outline_opa(&styles->cb_bullet, LV_STATE_FOCUSED, LV_OPA_TRANSP);
627 lv_style_set_radius(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(4));
628 lv_style_set_pattern_image(&styles->cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK);
629 lv_style_set_pattern_recolor(&styles->cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE);
630 lv_style_set_pattern_opa(&styles->cb_bullet, LV_STATE_DEFAULT, LV_OPA_TRANSP);
631 lv_style_set_pattern_opa(&styles->cb_bullet, LV_STATE_CHECKED, LV_OPA_COVER);
632 lv_style_set_transition_prop_3(&styles->cb_bullet, LV_STATE_DEFAULT, LV_STYLE_PATTERN_OPA);
633 lv_style_set_text_font(&styles->cb_bullet, LV_STATE_CHECKED, theme.font_small);
634 lv_style_set_pad_left(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
635 lv_style_set_pad_right(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
636 lv_style_set_pad_top(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
637 lv_style_set_pad_bottom(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
638 #endif
639 }
640
btnmatrix_init(void)641 static void btnmatrix_init(void)
642 {
643 }
644
keyboard_init(void)645 static void keyboard_init(void)
646 {
647 #if LV_USE_KEYBOARD
648 style_init_reset(&styles->kb_bg);
649 lv_style_set_radius(&styles->kb_bg, LV_STATE_DEFAULT, 0);
650 lv_style_set_border_width(&styles->kb_bg, LV_STATE_DEFAULT, LV_DPX(4));
651 lv_style_set_border_side(&styles->kb_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP);
652 lv_style_set_border_color(&styles->kb_bg, LV_STATE_DEFAULT, IS_LIGHT ? COLOR_BG_TEXT : LV_COLOR_BLACK);
653 lv_style_set_border_color(&styles->kb_bg, LV_STATE_EDITED, theme.color_secondary);
654 lv_style_set_pad_left(&styles->kb_bg, LV_STATE_DEFAULT, LV_DPX(5));
655 lv_style_set_pad_right(&styles->kb_bg, LV_STATE_DEFAULT, LV_DPX(5));
656 lv_style_set_pad_top(&styles->kb_bg, LV_STATE_DEFAULT, LV_DPX(5));
657 lv_style_set_pad_bottom(&styles->kb_bg, LV_STATE_DEFAULT, LV_DPX(5));
658 lv_style_set_pad_inner(&styles->kb_bg, LV_STATE_DEFAULT, LV_DPX(3));
659 #endif
660 }
661
msgbox_init(void)662 static void msgbox_init(void)
663 {
664 #if LV_USE_MSGBOX
665 style_init_reset(&styles->mbox_bg);
666 lv_style_set_shadow_width(&styles->mbox_bg, LV_STATE_DEFAULT, LV_DPX(50));
667 lv_style_set_shadow_color(&styles->mbox_bg, LV_STATE_DEFAULT, IS_LIGHT ? LV_COLOR_SILVER : lv_color_hex3(0x999));
668
669 #endif
670 }
671
page_init(void)672 static void page_init(void)
673 {
674 #if LV_USE_PAGE
675 style_init_reset(&styles->sb);
676 lv_style_set_bg_opa(&styles->sb, LV_STATE_DEFAULT, LV_OPA_COVER);
677 lv_style_set_bg_color(&styles->sb, LV_STATE_DEFAULT, (IS_LIGHT ? lv_color_hex(0xcccfd1) : lv_color_hex(0x777f85)));
678 lv_style_set_radius(&styles->sb, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
679 lv_style_set_size(&styles->sb, LV_STATE_DEFAULT, LV_DPX(7));
680 lv_style_set_pad_right(&styles->sb, LV_STATE_DEFAULT, LV_DPX(7));
681 lv_style_set_pad_bottom(&styles->sb, LV_STATE_DEFAULT, LV_DPX(7));
682
683 #if LV_USE_ANIMATION
684 style_init_reset(&styles->edge_flash);
685 lv_style_set_bg_opa(&styles->edge_flash, LV_STATE_DEFAULT, LV_OPA_COVER);
686 lv_style_set_bg_color(&styles->edge_flash, LV_STATE_DEFAULT, lv_color_hex3(0x888));
687 #endif
688 #endif
689 }
690
textarea_init(void)691 static void textarea_init(void)
692 {
693 #if LV_USE_TEXTAREA
694 style_init_reset(&styles->ta_cursor);
695 lv_style_set_border_color(&styles->ta_cursor, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
696 lv_style_set_border_width(&styles->ta_cursor, LV_STATE_DEFAULT, LV_DPX(2));
697 lv_style_set_pad_left(&styles->ta_cursor, LV_STATE_DEFAULT, LV_DPX(1));
698 lv_style_set_border_side(&styles->ta_cursor, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT);
699
700 style_init_reset(&styles->ta_placeholder);
701 lv_style_set_text_color(&styles->ta_placeholder, LV_STATE_DEFAULT,
702 IS_LIGHT ? COLOR_BG_TEXT_DIS : lv_color_hex(0xa1adbd));
703 #endif
704 }
705
spinbox_init(void)706 static void spinbox_init(void)
707 {
708 #if LV_USE_SPINBOX
709
710 style_init_reset(&styles->spinbox_cursor);
711 lv_style_set_bg_opa(&styles->spinbox_cursor, LV_STATE_DEFAULT, LV_OPA_COVER);
712 lv_style_set_bg_color(&styles->spinbox_cursor, LV_STATE_DEFAULT, theme.color_primary);
713 lv_style_set_text_color(&styles->spinbox_cursor, LV_STATE_DEFAULT, LV_COLOR_WHITE);
714 lv_style_set_pad_top(&styles->spinbox_cursor, LV_STATE_DEFAULT, LV_DPX(100));
715 lv_style_set_pad_bottom(&styles->spinbox_cursor, LV_STATE_DEFAULT, LV_DPX(100));
716
717 #endif
718 }
719
list_init(void)720 static void list_init(void)
721 {
722 #if LV_USE_LIST != 0
723 style_init_reset(&styles->list_bg);
724 lv_style_set_clip_corner(&styles->list_bg, LV_STATE_DEFAULT, true);
725 lv_style_set_pad_left(&styles->list_bg, LV_STATE_DEFAULT, 0);
726 lv_style_set_pad_right(&styles->list_bg, LV_STATE_DEFAULT, 0);
727 lv_style_set_pad_top(&styles->list_bg, LV_STATE_DEFAULT, 0);
728 lv_style_set_pad_bottom(&styles->list_bg, LV_STATE_DEFAULT, 0);
729 lv_style_set_pad_inner(&styles->list_bg, LV_STATE_DEFAULT, 0);
730
731 style_init_reset(&styles->list_btn);
732 lv_style_set_bg_opa(&styles->list_btn, LV_STATE_DEFAULT, LV_OPA_COVER);
733 lv_style_set_bg_color(&styles->list_btn, LV_STATE_DEFAULT, COLOR_BG);
734 lv_style_set_bg_color(&styles->list_btn, LV_STATE_PRESSED, COLOR_BG_PR);
735 lv_style_set_bg_color(&styles->list_btn, LV_STATE_DISABLED, COLOR_BG_DIS);
736 lv_style_set_bg_color(&styles->list_btn, LV_STATE_CHECKED, COLOR_BG_CHK);
737 lv_style_set_bg_color(&styles->list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, COLOR_BG_PR_CHK);
738
739 lv_style_set_text_color(&styles->list_btn, LV_STATE_DEFAULT, COLOR_BG_TEXT);
740 lv_style_set_text_color(&styles->list_btn, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK);
741 lv_style_set_text_color(&styles->list_btn, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS);
742
743 lv_style_set_image_recolor(&styles->list_btn, LV_STATE_DEFAULT, COLOR_BG_TEXT);
744 lv_style_set_image_recolor(&styles->list_btn, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK);
745 lv_style_set_image_recolor(&styles->list_btn, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS);
746
747 lv_style_set_border_side(&styles->list_btn, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM);
748 lv_style_set_border_color(&styles->list_btn, LV_STATE_DEFAULT, COLOR_BG_BORDER);
749 lv_style_set_border_color(&styles->list_btn, LV_STATE_FOCUSED, theme.color_primary);
750 lv_style_set_border_width(&styles->list_btn, LV_STATE_DEFAULT, 1);
751
752 lv_style_set_outline_color(&styles->list_btn, LV_STATE_FOCUSED, theme.color_secondary);
753 lv_style_set_outline_width(&styles->list_btn, LV_STATE_FOCUSED, OUTLINE_WIDTH);
754 lv_style_set_outline_pad(&styles->list_btn, LV_STATE_FOCUSED, -BORDER_WIDTH);
755
756 lv_style_set_pad_left(&styles->list_btn, LV_STATE_DEFAULT, PAD_DEF);
757 lv_style_set_pad_right(&styles->list_btn, LV_STATE_DEFAULT, PAD_DEF);
758 lv_style_set_pad_top(&styles->list_btn, LV_STATE_DEFAULT, PAD_DEF);
759 lv_style_set_pad_bottom(&styles->list_btn, LV_STATE_DEFAULT, PAD_DEF);
760 lv_style_set_pad_inner(&styles->list_btn, LV_STATE_DEFAULT, PAD_DEF);
761
762 lv_style_set_transform_width(&styles->list_btn, LV_STATE_DEFAULT, - PAD_DEF);
763 lv_style_set_transform_width(&styles->list_btn, LV_STATE_PRESSED, -BORDER_WIDTH);
764 lv_style_set_transform_width(&styles->list_btn, LV_STATE_CHECKED, -BORDER_WIDTH);
765 lv_style_set_transform_width(&styles->list_btn, LV_STATE_DISABLED, -BORDER_WIDTH);
766 lv_style_set_transform_width(&styles->list_btn, LV_STATE_FOCUSED, - BORDER_WIDTH);
767
768 lv_style_set_transition_time(&styles->list_btn, LV_STATE_DEFAULT, TRANSITION_TIME);
769 lv_style_set_transition_prop_6(&styles->list_btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
770 lv_style_set_transition_prop_5(&styles->list_btn, LV_STATE_DEFAULT, LV_STYLE_TRANSFORM_WIDTH);
771 #endif
772 }
773
ddlist_init(void)774 static void ddlist_init(void)
775 {
776 #if LV_USE_DROPDOWN != 0
777
778 style_init_reset(&styles->ddlist_page);
779 lv_style_set_text_line_space(&styles->ddlist_page, LV_STATE_DEFAULT, LV_DPX(20));
780 lv_style_set_clip_corner(&styles->ddlist_page, LV_STATE_DEFAULT, true);
781
782 style_init_reset(&styles->ddlist_sel);
783 lv_style_set_bg_opa(&styles->ddlist_sel, LV_STATE_DEFAULT, LV_OPA_COVER);
784 lv_style_set_bg_color(&styles->ddlist_sel, LV_STATE_DEFAULT, theme.color_primary);
785 lv_style_set_text_color(&styles->ddlist_sel, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex3(0xfff) : lv_color_hex3(0xfff));
786 lv_style_set_bg_color(&styles->ddlist_sel, LV_STATE_PRESSED, COLOR_BG_PR);
787 lv_style_set_text_color(&styles->ddlist_sel, LV_STATE_PRESSED, COLOR_BG_TEXT_PR);
788 #endif
789 }
790
roller_init(void)791 static void roller_init(void)
792 {
793 #if LV_USE_ROLLER != 0
794 style_init_reset(&styles->roller_bg);
795 lv_style_set_text_line_space(&styles->roller_bg, LV_STATE_DEFAULT, LV_DPX(25));
796
797 style_init_reset(&styles->roller_sel);
798 lv_style_set_bg_opa(&styles->roller_sel, LV_STATE_DEFAULT, LV_OPA_COVER);
799 lv_style_set_bg_color(&styles->roller_sel, LV_STATE_DEFAULT, theme.color_primary);
800 lv_style_set_text_color(&styles->roller_sel, LV_STATE_DEFAULT, LV_COLOR_WHITE);
801 #endif
802 }
803
tabview_init(void)804 static void tabview_init(void)
805 {
806 #if LV_USE_TABVIEW != 0
807 #endif
808 }
809
tileview_init(void)810 static void tileview_init(void)
811 {
812 #if LV_USE_TILEVIEW != 0
813 #endif
814 }
815
table_init(void)816 static void table_init(void)
817 {
818 #if LV_USE_TABLE != 0
819 style_init_reset(&styles->table_cell);
820 lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER);
821 lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1);
822 lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
823 lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
824 lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
825 lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
826 lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
827
828 #endif
829 }
830
win_init(void)831 static void win_init(void)
832 {
833 #if LV_USE_WIN != 0
834 #endif
835 }
836
tabview_win_shared_init(void)837 static void tabview_win_shared_init(void)
838 {
839 #if LV_USE_TABVIEW || LV_USE_WIN
840 style_init_reset(&styles->tabview_btns_bg);
841 lv_style_set_bg_opa(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
842 lv_style_set_bg_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_BG);
843 lv_style_set_border_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT,
844 IS_LIGHT ? lv_color_hex(0xe4eaf0) : lv_color_hex(0x3b3e42));
845 lv_style_set_border_width(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(5));
846 lv_style_set_border_side(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM);
847 lv_style_set_text_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
848 lv_style_set_image_recolor(&styles->tabview_btns_bg, LV_STATE_DEFAULT, lv_color_hex(0x979a9f));
849 lv_style_set_pad_top(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(7));
850 lv_style_set_pad_left(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(7));
851 lv_style_set_pad_right(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(7));
852
853 style_init_reset(&styles->tabview_btns);
854 lv_style_set_bg_opa(&styles->tabview_btns, LV_STATE_PRESSED, LV_OPA_50);
855 lv_style_set_bg_color(&styles->tabview_btns, LV_STATE_PRESSED, lv_color_hex3(0x888));
856 lv_style_set_text_color(&styles->tabview_btns, LV_STATE_CHECKED, COLOR_SCR_TEXT);
857 lv_style_set_pad_top(&styles->tabview_btns, LV_STATE_DEFAULT, LV_DPX(20));
858 lv_style_set_pad_bottom(&styles->tabview_btns, LV_STATE_DEFAULT, LV_DPX(20));
859 lv_style_set_text_color(&styles->tabview_btns, LV_STATE_FOCUSED, theme.color_primary);
860 lv_style_set_text_color(&styles->tabview_btns, LV_STATE_EDITED, theme.color_secondary);
861
862 style_init_reset(&styles->tabview_indic);
863 lv_style_set_bg_opa(&styles->tabview_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
864 lv_style_set_bg_color(&styles->tabview_indic, LV_STATE_DEFAULT, theme.color_primary);
865 lv_style_set_bg_color(&styles->tabview_indic, LV_STATE_EDITED, theme.color_secondary);
866 lv_style_set_size(&styles->tabview_indic, LV_STATE_DEFAULT, LV_DPX(5));
867 lv_style_set_radius(&styles->tabview_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
868
869 style_init_reset(&styles->tabview_page_scrl);
870 lv_style_set_pad_top(&styles->tabview_page_scrl, LV_STATE_DEFAULT, PAD_DEF);
871 lv_style_set_pad_bottom(&styles->tabview_page_scrl, LV_STATE_DEFAULT, PAD_DEF);
872 lv_style_set_pad_left(&styles->tabview_page_scrl, LV_STATE_DEFAULT, PAD_DEF);
873 lv_style_set_pad_right(&styles->tabview_page_scrl, LV_STATE_DEFAULT, PAD_DEF);
874 lv_style_set_pad_inner(&styles->tabview_page_scrl, LV_STATE_DEFAULT, PAD_DEF);
875 #endif
876 }
877
878
879 /**********************
880 * GLOBAL FUNCTIONS
881 **********************/
882
883 /**
884 * Initialize the default
885 * @param color_primary the primary color of the theme
886 * @param color_secondary the secondary color for the theme
887 * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...`
888 * @param font_small pointer to a small font
889 * @param font_normal pointer to a normal font
890 * @param font_subtitle pointer to a large font
891 * @param font_title pointer to a extra large font
892 * @return a pointer to reference this theme later
893 */
lv_theme_material_init(lv_color_t color_primary,lv_color_t color_secondary,uint32_t flags,const lv_font_t * font_small,const lv_font_t * font_normal,const lv_font_t * font_subtitle,const lv_font_t * font_title)894 lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
895 const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle,
896 const lv_font_t * font_title)
897 {
898
899 /* This trick is required only to avoid the garbage collection of
900 * styles' data if LVGL is used in a binding (e.g. Micropython)
901 * In a general case styles could be simple `static lv_style_t my style` variables*/
902 if(!inited) {
903 LV_GC_ROOT(_lv_theme_material_styles) = lv_mem_alloc(sizeof(theme_styles_t));
904 styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_material_styles);
905 }
906
907 theme.color_primary = color_primary;
908 theme.color_secondary = color_secondary;
909 theme.font_small = font_small;
910 theme.font_normal = font_normal;
911 theme.font_subtitle = font_subtitle;
912 theme.font_title = font_title;
913 theme.flags = flags;
914
915 basic_init();
916 cont_init();
917 btn_init();
918 label_init();
919 bar_init();
920 img_init();
921 line_init();
922 led_init();
923 slider_init();
924 switch_init();
925 linemeter_init();
926 gauge_init();
927 arc_init();
928 spinner_init();
929 chart_init();
930 calendar_init();
931 cpicker_init();
932 checkbox_init();
933 btnmatrix_init();
934 keyboard_init();
935 msgbox_init();
936 page_init();
937 textarea_init();
938 spinbox_init();
939 list_init();
940 ddlist_init();
941 roller_init();
942 tabview_init();
943 tileview_init();
944 table_init();
945 win_init();
946 tabview_win_shared_init();
947
948 theme.apply_xcb = NULL;
949 theme.apply_cb = theme_apply;
950
951 inited = true;
952
953 lv_obj_report_style_mod(NULL);
954
955 return &theme;
956 }
957
958
theme_apply(lv_theme_t * th,lv_obj_t * obj,lv_theme_style_t name)959 static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
960 {
961 LV_UNUSED(th);
962
963 lv_style_list_t * list;
964
965 switch(name) {
966 case LV_THEME_NONE:
967 break;
968
969 case LV_THEME_SCR:
970 list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
971 _lv_style_list_add_style(list, &styles->scr);
972 break;
973 case LV_THEME_OBJ:
974 list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
975 _lv_style_list_add_style(list, &styles->bg);
976 break;
977 #if LV_USE_CONT
978 case LV_THEME_CONT:
979 list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
980 _lv_style_list_add_style(list, &styles->bg);
981 break;
982 #endif
983
984 #if LV_USE_BTN
985 case LV_THEME_BTN:
986 list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
987 _lv_style_list_add_style(list, &styles->btn);
988 break;
989 #endif
990
991 #if LV_USE_BTNMATRIX
992 case LV_THEME_BTNMATRIX:
993 list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
994 _lv_style_list_add_style(list, &styles->bg);
995 _lv_style_list_add_style(list, &styles->pad_small);
996
997 list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
998 _lv_style_list_add_style(list, &styles->bg);
999 _lv_style_list_add_style(list, &styles->bg_click);
1000 break;
1001 #endif
1002
1003 #if LV_USE_KEYBOARD
1004 case LV_THEME_KEYBOARD:
1005 list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
1006 _lv_style_list_add_style(list, &styles->scr);
1007 _lv_style_list_add_style(list, &styles->kb_bg);
1008
1009 list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
1010 _lv_style_list_add_style(list, &styles->bg);
1011 _lv_style_list_add_style(list, &styles->bg_click);
1012 break;
1013 #endif
1014
1015 #if LV_USE_BAR
1016 case LV_THEME_BAR:
1017 list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
1018 _lv_style_list_add_style(list, &styles->bar_bg);
1019
1020 list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
1021 _lv_style_list_add_style(list, &styles->bar_indic);
1022 break;
1023 #endif
1024
1025 #if LV_USE_SWITCH
1026 case LV_THEME_SWITCH:
1027 list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
1028 _lv_style_list_add_style(list, &styles->bar_bg);
1029
1030 list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
1031 _lv_style_list_add_style(list, &styles->bar_indic);
1032
1033 list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
1034 _lv_style_list_add_style(list, &styles->sw_knob);
1035 break;
1036 #endif
1037
1038 #if LV_USE_CANVAS
1039 case LV_THEME_CANVAS:
1040 break;
1041 #endif
1042
1043 #if LV_USE_IMG
1044 case LV_THEME_IMAGE:
1045 break;
1046 #endif
1047
1048 #if LV_USE_IMGBTN
1049 case LV_THEME_IMGBTN:
1050 break;
1051 #endif
1052
1053 #if LV_USE_LABEL
1054 case LV_THEME_LABEL:
1055 break;
1056 #endif
1057
1058 #if LV_USE_LINE
1059 case LV_THEME_LINE:
1060 break;
1061 #endif
1062
1063 #if LV_USE_ARC
1064 case LV_THEME_ARC:
1065 list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
1066 _lv_style_list_add_style(list, &styles->bg);
1067 _lv_style_list_add_style(list, &styles->arc_bg);
1068
1069 list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
1070 _lv_style_list_add_style(list, &styles->arc_indic);
1071
1072 list = lv_obj_get_style_list(obj, LV_ARC_PART_KNOB);
1073 _lv_style_list_add_style(list, &styles->bg);
1074 _lv_style_list_add_style(list, &styles->bg_click);
1075 _lv_style_list_add_style(list, &styles->arc_knob);
1076 break;
1077 #endif
1078
1079 #if LV_USE_SPINNER
1080 case LV_THEME_SPINNER:
1081 list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
1082 _lv_style_list_add_style(list, &styles->arc_bg);
1083
1084 list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC);
1085 _lv_style_list_add_style(list, &styles->arc_indic);
1086 break;
1087 #endif
1088
1089 #if LV_USE_SLIDER
1090 case LV_THEME_SLIDER:
1091 list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
1092 _lv_style_list_add_style(list, &styles->bar_bg);
1093 _lv_style_list_add_style(list, &styles->slider_bg);
1094
1095 list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
1096 _lv_style_list_add_style(list, &styles->bar_indic);
1097
1098 list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
1099 _lv_style_list_add_style(list, &styles->slider_knob);
1100 break;
1101 #endif
1102
1103 #if LV_USE_CHECKBOX
1104 case LV_THEME_CHECKBOX:
1105 list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
1106 _lv_style_list_add_style(list, &styles->cb_bg);
1107
1108 list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
1109 _lv_style_list_add_style(list, &styles->btn);
1110 _lv_style_list_add_style(list, &styles->cb_bullet);
1111 break;
1112 #endif
1113
1114 #if LV_USE_MSGBOX
1115 case LV_THEME_MSGBOX:
1116 list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
1117 _lv_style_list_add_style(list, &styles->bg);
1118 _lv_style_list_add_style(list, &styles->mbox_bg);
1119 break;
1120
1121 case LV_THEME_MSGBOX_BTNS:
1122 list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
1123 _lv_style_list_add_style(list, &styles->pad_small);
1124
1125 list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
1126 _lv_style_list_add_style(list, &styles->btn);
1127 break;
1128
1129 #endif
1130 #if LV_USE_LED
1131 case LV_THEME_LED:
1132 list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN);
1133 _lv_style_list_add_style(list, &styles->led);
1134 break;
1135 #endif
1136 #if LV_USE_PAGE
1137 case LV_THEME_PAGE:
1138 list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
1139 _lv_style_list_add_style(list, &styles->bg);
1140
1141 list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
1142 _lv_style_list_add_style(list, &styles->pad_inner);
1143
1144 list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
1145 _lv_style_list_add_style(list, &styles->sb);
1146
1147 #if LV_USE_ANIMATION
1148 list = lv_obj_get_style_list(obj, LV_PAGE_PART_EDGE_FLASH);
1149 _lv_style_list_add_style(list, &styles->edge_flash);
1150 #endif
1151 break;
1152 #endif
1153 #if LV_USE_TABVIEW
1154 case LV_THEME_TABVIEW:
1155 list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
1156 _lv_style_list_add_style(list, &styles->scr);
1157
1158 list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG);
1159 _lv_style_list_add_style(list, &styles->tabview_btns_bg);
1160
1161 list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC);
1162 _lv_style_list_add_style(list, &styles->tabview_indic);
1163
1164 list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
1165 _lv_style_list_add_style(list, &styles->tabview_btns);
1166 break;
1167
1168 case LV_THEME_TABVIEW_PAGE:
1169 list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
1170 _lv_style_list_add_style(list, &styles->tabview_page_scrl);
1171
1172 break;
1173 #endif
1174
1175 #if LV_USE_TILEVIEW
1176 case LV_THEME_TILEVIEW:
1177 list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG);
1178 _lv_style_list_add_style(list, &styles->scr);
1179
1180 list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
1181 _lv_style_list_add_style(list, &styles->sb);
1182
1183 #if LV_USE_ANIMATION
1184 list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
1185 _lv_style_list_add_style(list, &styles->edge_flash);
1186 #endif
1187 break;
1188 #endif
1189
1190
1191 #if LV_USE_ROLLER
1192 case LV_THEME_ROLLER:
1193 list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
1194 _lv_style_list_add_style(list, &styles->bg);
1195 _lv_style_list_add_style(list, &styles->roller_bg);
1196
1197 list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED);
1198 _lv_style_list_add_style(list, &styles->roller_sel);
1199 break;
1200 #endif
1201
1202 #if LV_USE_OBJMASK
1203 case LV_THEME_OBJMASK:
1204 list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
1205 break;
1206 #endif
1207
1208 #if LV_USE_LIST
1209 case LV_THEME_LIST:
1210 list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
1211 _lv_style_list_add_style(list, &styles->bg);
1212 _lv_style_list_add_style(list, &styles->list_bg);
1213
1214
1215 list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
1216 _lv_style_list_add_style(list, &styles->sb);
1217 break;
1218
1219 case LV_THEME_LIST_BTN:
1220 list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
1221 _lv_style_list_add_style(list, &styles->list_btn);
1222 break;
1223 #endif
1224
1225 #if LV_USE_DROPDOWN
1226 case LV_THEME_DROPDOWN:
1227 list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
1228 _lv_style_list_add_style(list, &styles->bg);
1229 _lv_style_list_add_style(list, &styles->bg_click);
1230 _lv_style_list_add_style(list, &styles->pad_small);
1231
1232 list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
1233 _lv_style_list_add_style(list, &styles->bg);
1234 _lv_style_list_add_style(list, &styles->ddlist_page);
1235
1236 list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
1237 _lv_style_list_add_style(list, &styles->sb);
1238
1239 list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
1240 _lv_style_list_add_style(list, &styles->ddlist_sel);
1241 break;
1242 #endif
1243
1244 #if LV_USE_CHART
1245 case LV_THEME_CHART:
1246 list = lv_obj_get_style_list(obj, LV_CHART_PART_BG);
1247 _lv_style_list_add_style(list, &styles->bg);
1248 _lv_style_list_add_style(list, &styles->chart_bg);
1249 _lv_style_list_add_style(list, &styles->pad_small);
1250
1251 list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
1252 _lv_style_list_add_style(list, &styles->pad_small);
1253 _lv_style_list_add_style(list, &styles->chart_series_bg);
1254
1255 list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
1256 _lv_style_list_add_style(list, &styles->chart_series);
1257 break;
1258 #endif
1259 #if LV_USE_TABLE
1260 case LV_THEME_TABLE:
1261 list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
1262 _lv_style_list_add_style(list, &styles->bg);
1263
1264 list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
1265 _lv_style_list_add_style(list, &styles->table_cell);
1266
1267 list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
1268 _lv_style_list_add_style(list, &styles->table_cell);
1269
1270 list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
1271 _lv_style_list_add_style(list, &styles->table_cell);
1272
1273 list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
1274 _lv_style_list_add_style(list, &styles->table_cell);
1275 break;
1276 #endif
1277
1278 #if LV_USE_WIN
1279 case LV_THEME_WIN:
1280 list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
1281 _lv_style_list_add_style(list, &styles->scr);
1282
1283 list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
1284 _lv_style_list_add_style(list, &styles->sb);
1285
1286 list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
1287 _lv_style_list_add_style(list, &styles->tabview_page_scrl);
1288
1289 list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER);
1290 _lv_style_list_add_style(list, &styles->tabview_btns_bg);
1291 break;
1292
1293 case LV_THEME_WIN_BTN:
1294 list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
1295 _lv_style_list_add_style(list, &styles->tabview_btns);
1296 break;
1297 #endif
1298
1299 #if LV_USE_TEXTAREA
1300 case LV_THEME_TEXTAREA:
1301 list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
1302 _lv_style_list_add_style(list, &styles->bg);
1303 _lv_style_list_add_style(list, &styles->pad_small);
1304
1305 list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
1306 _lv_style_list_add_style(list, &styles->ta_placeholder);
1307
1308 list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
1309 _lv_style_list_add_style(list, &styles->ta_cursor);
1310
1311 list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
1312 _lv_style_list_add_style(list, &styles->sb);
1313 break;
1314
1315 #endif
1316
1317
1318 #if LV_USE_SPINBOX
1319 case LV_THEME_SPINBOX:
1320 list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG);
1321 _lv_style_list_add_style(list, &styles->bg);
1322 _lv_style_list_add_style(list, &styles->pad_small);
1323
1324 list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR);
1325 _lv_style_list_add_style(list, &styles->spinbox_cursor);
1326 break;
1327
1328 case LV_THEME_SPINBOX_BTN:
1329 list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
1330 _lv_style_list_add_style(list, &styles->bg);
1331 _lv_style_list_add_style(list, &styles->bg_click);
1332 break;
1333 #endif
1334
1335 #if LV_USE_CALENDAR
1336 case LV_THEME_CALENDAR:
1337 list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG);
1338 _lv_style_list_add_style(list, &styles->bg);
1339
1340 list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
1341 _lv_style_list_add_style(list, &styles->calendar_date_nums);
1342
1343 list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER);
1344 _lv_style_list_add_style(list, &styles->calendar_header);
1345
1346 list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
1347 _lv_style_list_add_style(list, &styles->calendar_daynames);
1348 break;
1349 #endif
1350 #if LV_USE_CPICKER
1351 case LV_THEME_CPICKER:
1352 list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
1353 _lv_style_list_add_style(list, &styles->cpicker_bg);
1354
1355 list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
1356 _lv_style_list_add_style(list, &styles->cpicker_indic);
1357 break;
1358 #endif
1359
1360 #if LV_USE_LINEMETER
1361 case LV_THEME_LINEMETER:
1362 list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
1363 _lv_style_list_add_style(list, &styles->bg);
1364 _lv_style_list_add_style(list, &styles->lmeter);
1365 break;
1366 #endif
1367 #if LV_USE_GAUGE
1368 case LV_THEME_GAUGE:
1369 list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
1370 _lv_style_list_add_style(list, &styles->bg);
1371 _lv_style_list_add_style(list, &styles->gauge_main);
1372
1373 list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
1374 _lv_style_list_add_style(list, &styles->gauge_strong);
1375
1376 list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
1377 _lv_style_list_add_style(list, &styles->gauge_needle);
1378 break;
1379 #endif
1380 default:
1381 break;
1382 }
1383
1384 lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
1385 }
1386
1387 /**********************
1388 * STATIC FUNCTIONS
1389 **********************/
1390
style_init_reset(lv_style_t * style)1391 static void style_init_reset(lv_style_t * style)
1392 {
1393 if(inited) lv_style_reset(style);
1394 else lv_style_init(style);
1395 }
1396
1397 #endif
1398