1 /**
2  * @file lv_theme_template.c
3  *
4  */
5 
6 /*********************
7  *      INCLUDES
8  *********************/
9 #include "../../lvgl.h" /*To see all the widgets*/
10 
11 #if LV_USE_THEME_TEMPLATE
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 /**********************
24  *      TYPEDEFS
25  **********************/
26 
27 typedef struct {
28     lv_style_t bg;
29     lv_style_t btn;
30     lv_style_t round;
31     lv_style_t color;
32     lv_style_t gray;
33     lv_style_t tick_line;
34     lv_style_t tight;
35 } theme_styles_t;
36 
37 /**********************
38  *  STATIC PROTOTYPES
39  **********************/
40 static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
41 
42 /**********************
43  *  STATIC VARIABLES
44  **********************/
45 static lv_theme_t theme;
46 
47 static lv_theme_t theme;
48 static theme_styles_t * styles;
49 
50 static bool inited;
51 
52 /**********************
53  *      MACROS
54  **********************/
55 
56 /**********************
57  *   STATIC FUNCTIONS
58  **********************/
59 static void style_init_reset(lv_style_t * style);
60 
61 
basic_init(void)62 static void basic_init(void)
63 {
64     style_init_reset(&styles->bg);
65     lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER);
66     lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, 1);
67     lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, 2);
68     lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_secondary);
69     lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, lv_color_darken(theme.color_secondary, LV_OPA_30));
70     lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, 1);
71     lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, 1);
72     lv_style_set_scale_end_color(&styles->bg, LV_STATE_DEFAULT, theme.color_primary);
73     lv_style_set_text_color(&styles->bg, LV_STATE_DEFAULT, LV_COLOR_BLACK);
74     lv_style_set_pad_left(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
75     lv_style_set_pad_right(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
76     lv_style_set_pad_top(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
77     lv_style_set_pad_bottom(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
78     lv_style_set_pad_inner(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
79 
80     style_init_reset(&styles->btn);
81     lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, lv_color_hex3(0xccc));
82     lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED, theme.color_primary);
83     lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_darken(theme.color_primary,
84                                                                                              LV_OPA_30));
85     lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_SILVER);
86     lv_style_set_text_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY);
87     lv_style_set_image_recolor(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY);
88 
89     style_init_reset(&styles->round);
90     lv_style_set_radius(&styles->round, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
91 
92     style_init_reset(&styles->color);
93     lv_style_set_bg_color(&styles->color, LV_STATE_DEFAULT, theme.color_primary);
94     lv_style_set_line_color(&styles->color, LV_STATE_DEFAULT, theme.color_primary);
95 
96     style_init_reset(&styles->gray);
97     lv_style_set_bg_color(&styles->gray, LV_STATE_DEFAULT, LV_COLOR_SILVER);
98     lv_style_set_line_color(&styles->gray, LV_STATE_DEFAULT, LV_COLOR_SILVER);
99     lv_style_set_text_color(&styles->gray, LV_STATE_DEFAULT, LV_COLOR_GRAY);
100 
101     style_init_reset(&styles->tick_line);
102     lv_style_set_line_width(&styles->tick_line, LV_STATE_DEFAULT, 5);
103     lv_style_set_scale_end_line_width(&styles->tick_line, LV_STATE_DEFAULT, 5);
104     lv_style_set_scale_end_color(&styles->tick_line, LV_STATE_DEFAULT, theme.color_primary);
105 
106     style_init_reset(&styles->tight);
107     lv_style_set_pad_left(&styles->tight, LV_STATE_DEFAULT, 0);
108     lv_style_set_pad_right(&styles->tight, LV_STATE_DEFAULT, 0);
109     lv_style_set_pad_top(&styles->tight, LV_STATE_DEFAULT, 0);
110     lv_style_set_pad_bottom(&styles->tight, LV_STATE_DEFAULT, 0);
111     lv_style_set_pad_inner(&styles->tight, LV_STATE_DEFAULT, 0);
112 }
113 
arc_init(void)114 static void arc_init(void)
115 {
116 #if LV_USE_ARC != 0
117 
118 #endif
119 }
120 
bar_init(void)121 static void bar_init(void)
122 {
123 #if LV_USE_BAR
124 
125 #endif
126 }
127 
btn_init(void)128 static void btn_init(void)
129 {
130 #if LV_USE_BTN != 0
131 
132 #endif
133 }
134 
135 
btnmatrix_init(void)136 static void btnmatrix_init(void)
137 {
138 #if LV_USE_BTNMATRIX
139 
140 #endif
141 }
142 
143 
calendar_init(void)144 static void calendar_init(void)
145 {
146 #if LV_USE_CALENDAR
147 
148 #endif
149 }
150 
chart_init(void)151 static void chart_init(void)
152 {
153 #if LV_USE_CHART
154 
155 #endif
156 }
157 
158 
cpicker_init(void)159 static void cpicker_init(void)
160 {
161 #if LV_USE_CPICKER
162 
163 #endif
164 }
165 
checkbox_init(void)166 static void checkbox_init(void)
167 {
168 #if LV_USE_CHECKBOX != 0
169 
170 #endif
171 }
172 
173 
cont_init(void)174 static void cont_init(void)
175 {
176 #if LV_USE_CONT != 0
177 
178 #endif
179 }
180 
181 
gauge_init(void)182 static void gauge_init(void)
183 {
184 #if LV_USE_GAUGE != 0
185 
186 #endif
187 }
188 
img_init(void)189 static void img_init(void)
190 {
191 #if LV_USE_IMG != 0
192 
193 #endif
194 }
195 
label_init(void)196 static void label_init(void)
197 {
198 #if LV_USE_LABEL != 0
199 
200 #endif
201 }
202 
203 
linemeter_init(void)204 static void linemeter_init(void)
205 {
206 #if LV_USE_LINEMETER != 0
207 
208 #endif
209 }
210 
line_init(void)211 static void line_init(void)
212 {
213 #if LV_USE_LINE != 0
214 
215 #endif
216 }
217 
led_init(void)218 static void led_init(void)
219 {
220 #if LV_USE_LED != 0
221 
222 #endif
223 }
224 
page_init(void)225 static void page_init(void)
226 {
227 #if LV_USE_PAGE
228 
229 #endif
230 }
231 
slider_init(void)232 static void slider_init(void)
233 {
234 #if LV_USE_SLIDER != 0
235 
236 #endif
237 }
238 
switch_init(void)239 static void switch_init(void)
240 {
241 #if LV_USE_SWITCH != 0
242 
243 #endif
244 }
245 
246 
spinbox_init(void)247 static void spinbox_init(void)
248 {
249 #if LV_USE_SPINBOX
250 
251 #endif
252 }
253 
254 
spinner_init(void)255 static void spinner_init(void)
256 {
257 #if LV_USE_SPINNER != 0
258 
259 #endif
260 }
261 
keyboard_init(void)262 static void keyboard_init(void)
263 {
264 #if LV_USE_KEYBOARD
265 
266 #endif
267 }
268 
msgbox_init(void)269 static void msgbox_init(void)
270 {
271 #if LV_USE_MSGBOX
272 
273 #endif
274 }
275 
textarea_init(void)276 static void textarea_init(void)
277 {
278 #if LV_USE_TEXTAREA
279 
280 #endif
281 }
282 
list_init(void)283 static void list_init(void)
284 {
285 #if LV_USE_LIST != 0
286 
287 #endif
288 }
289 
ddlist_init(void)290 static void ddlist_init(void)
291 {
292 #if LV_USE_DROPDOWN != 0
293 
294 #endif
295 }
296 
roller_init(void)297 static void roller_init(void)
298 {
299 #if LV_USE_ROLLER != 0
300 
301 #endif
302 }
303 
tabview_init(void)304 static void tabview_init(void)
305 {
306 #if LV_USE_TABVIEW != 0
307 
308 #endif
309 }
310 
tileview_init(void)311 static void tileview_init(void)
312 {
313 #if LV_USE_TILEVIEW != 0
314 #endif
315 }
316 
table_init(void)317 static void table_init(void)
318 {
319 #if LV_USE_TABLE != 0
320 
321 #endif
322 }
323 
win_init(void)324 static void win_init(void)
325 {
326 #if LV_USE_WIN != 0
327 
328 #endif
329 }
330 
331 
332 /**********************
333  *   GLOBAL FUNCTIONS
334  **********************/
335 
336 /**
337  * Initialize the default
338  * @param color_primary the primary color of the theme
339  * @param color_secondary the secondary color for the theme
340  * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...`
341  * @param font_small pointer to a small font
342  * @param font_normal pointer to a normal font
343  * @param font_subtitle pointer to a large font
344  * @param font_title pointer to a extra large font
345  * @return a pointer to reference this theme later
346  */
lv_theme_template_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)347 lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
348                                     const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle,
349                                     const lv_font_t * font_title)
350 {
351 
352     /* This trick is required only to avoid the garbage collection of
353      * styles' data if LVGL is used in a binding (e.g. Micropython)
354      * In a general case styles could be simple `static lv_style_t my style` variables or allocated directly into `styles`*/
355     if(!inited) {
356 #if defined(LV_GC_INCLUDE)
357         LV_GC_ROOT(_lv_theme_template_styles) = lv_mem_alloc(sizeof(theme_styles_t));
358         styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_template_styles);
359 #else
360         styles = lv_mem_alloc(sizeof(theme_styles_t));
361 #endif
362 
363     }
364 
365     theme.color_primary = color_primary;
366     theme.color_secondary = color_secondary;
367     theme.font_small = font_small;
368     theme.font_normal = font_normal;
369     theme.font_subtitle = font_subtitle;
370     theme.font_title = font_title;
371     theme.flags = flags;
372 
373     basic_init();
374     cont_init();
375     btn_init();
376     label_init();
377     bar_init();
378     img_init();
379     line_init();
380     led_init();
381     slider_init();
382     switch_init();
383     linemeter_init();
384     gauge_init();
385     arc_init();
386     spinner_init();
387     chart_init();
388     calendar_init();
389     cpicker_init();
390     checkbox_init();
391     btnmatrix_init();
392     keyboard_init();
393     msgbox_init();
394     page_init();
395     textarea_init();
396     spinbox_init();
397     list_init();
398     ddlist_init();
399     roller_init();
400     tabview_init();
401     tileview_init();
402     table_init();
403     win_init();
404 
405     theme.apply_xcb = NULL;
406     theme.apply_cb = theme_apply;
407 
408     return &theme;
409 }
410 
411 
theme_apply(lv_theme_t * th,lv_obj_t * obj,lv_theme_style_t name)412 void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
413 {
414     LV_UNUSED(th);
415 
416     lv_style_list_t * list;
417 
418     switch(name) {
419         case LV_THEME_NONE:
420             break;
421 
422         case LV_THEME_SCR:
423             list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
424             _lv_style_list_add_style(list, &styles->bg);
425             _lv_style_list_add_style(list, &styles->tight);
426             break;
427         case LV_THEME_OBJ:
428             list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
429             _lv_style_list_add_style(list, &styles->bg);
430             break;
431 #if LV_USE_CONT
432         case LV_THEME_CONT:
433             list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
434             _lv_style_list_add_style(list, &styles->bg);
435             break;
436 #endif
437 
438 #if LV_USE_BTN
439         case LV_THEME_BTN:
440             list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
441             _lv_style_list_add_style(list, &styles->bg);
442             _lv_style_list_add_style(list, &styles->btn);
443             break;
444 #endif
445 
446 #if LV_USE_BTNMATRIX
447         case LV_THEME_BTNMATRIX:
448             list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
449             _lv_style_list_add_style(list, &styles->bg);
450 
451             list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
452             _lv_style_list_add_style(list, &styles->bg);
453             _lv_style_list_add_style(list, &styles->btn);
454             break;
455 #endif
456 
457 #if LV_USE_KEYBOARD
458         case LV_THEME_KEYBOARD:
459             list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
460             _lv_style_list_add_style(list, &styles->bg);
461 
462             list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
463             _lv_style_list_add_style(list, &styles->bg);
464             _lv_style_list_add_style(list, &styles->btn);
465             break;
466 #endif
467 
468 #if LV_USE_BAR
469         case LV_THEME_BAR:
470             list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
471             _lv_style_list_add_style(list, &styles->bg);
472             _lv_style_list_add_style(list, &styles->tight);
473 
474             list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
475             _lv_style_list_add_style(list, &styles->bg);
476             _lv_style_list_add_style(list, &styles->color);
477             break;
478 #endif
479 
480 #if LV_USE_SWITCH
481         case LV_THEME_SWITCH:
482             list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
483             _lv_style_list_add_style(list, &styles->bg);
484             _lv_style_list_add_style(list, &styles->tight);
485             _lv_style_list_add_style(list, &styles->round);
486 
487             list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
488             _lv_style_list_add_style(list, &styles->bg);
489             _lv_style_list_add_style(list, &styles->color);
490 
491             list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
492             _lv_style_list_add_style(list, &styles->bg);
493             _lv_style_list_add_style(list, &styles->tight);
494             _lv_style_list_add_style(list, &styles->round);
495             break;
496 #endif
497 
498 #if LV_USE_CANVAS
499         case LV_THEME_CANVAS:
500             list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN);
501             break;
502 #endif
503 
504 #if LV_USE_IMG
505         case LV_THEME_IMAGE:
506             list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
507             break;
508 #endif
509 
510 #if LV_USE_IMGBTN
511         case LV_THEME_IMGBTN:
512             list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
513             break;
514 #endif
515 
516 #if LV_USE_LABEL
517         case LV_THEME_LABEL:
518             list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
519             break;
520 #endif
521 
522 #if LV_USE_LINE
523         case LV_THEME_LINE:
524             list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
525             break;
526 #endif
527 
528 #if LV_USE_ARC
529         case LV_THEME_ARC:
530             list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
531             _lv_style_list_add_style(list, &styles->bg);
532             _lv_style_list_add_style(list, &styles->tick_line);
533             _lv_style_list_add_style(list, &styles->round);
534 
535             list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
536             _lv_style_list_add_style(list, &styles->bg);
537             _lv_style_list_add_style(list, &styles->color);
538             _lv_style_list_add_style(list, &styles->tick_line);
539             break;
540 #endif
541 
542 #if LV_USE_SPINNER
543         case LV_THEME_SPINNER:
544             list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
545             _lv_style_list_add_style(list, &styles->bg);
546             _lv_style_list_add_style(list, &styles->tick_line);
547 
548             list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC);
549             _lv_style_list_add_style(list, &styles->bg);
550             _lv_style_list_add_style(list, &styles->color);
551             _lv_style_list_add_style(list, &styles->tick_line);
552             break;
553 #endif
554 
555 #if LV_USE_SLIDER
556         case LV_THEME_SLIDER:
557             list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
558             _lv_style_list_add_style(list, &styles->bg);
559 
560             list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
561             _lv_style_list_add_style(list, &styles->bg);
562             _lv_style_list_add_style(list, &styles->color);
563 
564             list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
565             _lv_style_list_add_style(list, &styles->bg);
566             _lv_style_list_add_style(list, &styles->round);
567             break;
568 #endif
569 
570 #if LV_USE_CHECKBOX
571         case LV_THEME_CHECKBOX:
572             list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
573 
574             list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
575             _lv_style_list_add_style(list, &styles->bg);
576             _lv_style_list_add_style(list, &styles->btn);
577             break;
578 #endif
579 
580 #if LV_USE_MSGBOX
581         case LV_THEME_MSGBOX:
582             list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
583             _lv_style_list_add_style(list, &styles->bg);
584             break;
585 
586         case LV_THEME_MSGBOX_BTNS:
587             list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
588             _lv_style_list_add_style(list, &styles->bg);
589 
590             list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
591             _lv_style_list_add_style(list, &styles->bg);
592             _lv_style_list_add_style(list, &styles->btn);
593             break;
594 
595 #endif
596 #if LV_USE_LED
597         case LV_THEME_LED:
598             list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN);
599             _lv_style_list_add_style(list, &styles->bg);
600             _lv_style_list_add_style(list, &styles->color);
601             _lv_style_list_add_style(list, &styles->round);
602             break;
603 #endif
604 #if LV_USE_PAGE
605         case LV_THEME_PAGE:
606             list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
607             _lv_style_list_add_style(list, &styles->bg);
608             _lv_style_list_add_style(list, &styles->gray);
609 
610             list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
611             _lv_style_list_add_style(list, &styles->bg);
612 
613             list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
614             _lv_style_list_add_style(list, &styles->bg);
615             break;
616 #endif
617 #if LV_USE_TABVIEW
618         case LV_THEME_TABVIEW:
619             list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
620             _lv_style_list_add_style(list, &styles->bg);
621 
622             list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
623             _lv_style_list_add_style(list, &styles->bg);
624             _lv_style_list_add_style(list, &styles->color);
625 
626             list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG);
627             _lv_style_list_add_style(list, &styles->bg);
628 
629             list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC);
630             _lv_style_list_add_style(list, &styles->bg);
631             _lv_style_list_add_style(list, &styles->color);
632 
633             list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
634             _lv_style_list_add_style(list, &styles->bg);
635             _lv_style_list_add_style(list, &styles->btn);
636             break;
637 
638         case LV_THEME_TABVIEW_PAGE:
639             list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
640             _lv_style_list_add_style(list, &styles->bg);
641             _lv_style_list_add_style(list, &styles->gray);
642 
643             list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
644             _lv_style_list_add_style(list, &styles->bg);
645 
646             break;
647 #endif
648 
649 #if LV_USE_TILEVIEW
650         case LV_THEME_TILEVIEW:
651             list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG);
652             _lv_style_list_add_style(list, &styles->bg);
653 
654             list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
655             _lv_style_list_add_style(list, &styles->bg);
656 
657             list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
658             _lv_style_list_add_style(list, &styles->bg);
659             break;
660 #endif
661 
662 
663 #if LV_USE_ROLLER
664         case LV_THEME_ROLLER:
665             list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
666             _lv_style_list_add_style(list, &styles->bg);
667 
668             list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED);
669             _lv_style_list_add_style(list, &styles->bg);
670             _lv_style_list_add_style(list, &styles->color);
671             break;
672 #endif
673 
674 
675 #if LV_USE_OBJMASK
676         case LV_THEME_OBJMASK:
677             list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
678             break;
679 #endif
680 
681 #if LV_USE_LIST
682         case LV_THEME_LIST:
683             list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
684             _lv_style_list_add_style(list, &styles->bg);
685 
686             list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE);
687 
688             list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
689             _lv_style_list_add_style(list, &styles->bg);
690             break;
691 
692         case LV_THEME_LIST_BTN:
693             list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
694             _lv_style_list_add_style(list, &styles->bg);
695             _lv_style_list_add_style(list, &styles->btn);
696             break;
697 #endif
698 
699 #if LV_USE_DROPDOWN
700         case LV_THEME_DROPDOWN:
701             list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
702             _lv_style_list_add_style(list, &styles->bg);
703             _lv_style_list_add_style(list, &styles->btn);
704 
705             list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
706             _lv_style_list_add_style(list, &styles->bg);
707 
708             list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
709             _lv_style_list_add_style(list, &styles->bg);
710 
711             list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
712             _lv_style_list_add_style(list, &styles->bg);
713             _lv_style_list_add_style(list, &styles->color);
714             break;
715 #endif
716 
717 #if LV_USE_CHART
718         case LV_THEME_CHART:
719             list = lv_obj_get_style_list(obj, LV_CHART_PART_BG);
720             _lv_style_list_add_style(list, &styles->bg);
721 
722             list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
723             _lv_style_list_add_style(list, &styles->bg);
724 
725             list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
726             _lv_style_list_add_style(list, &styles->bg);
727             _lv_style_list_add_style(list, &styles->tight);
728             break;
729 #endif
730 #if LV_USE_TABLE
731         case LV_THEME_TABLE:
732             list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
733             _lv_style_list_add_style(list, &styles->bg);
734 
735             list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
736             _lv_style_list_add_style(list, &styles->bg);
737 
738             list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
739             _lv_style_list_add_style(list, &styles->bg);
740 
741             list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
742             _lv_style_list_add_style(list, &styles->bg);
743 
744             list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
745             _lv_style_list_add_style(list, &styles->bg);
746             break;
747 #endif
748 
749 #if LV_USE_WIN
750         case LV_THEME_WIN:
751             list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
752             _lv_style_list_add_style(list, &styles->bg);
753 
754             list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
755             _lv_style_list_add_style(list, &styles->bg);
756 
757             list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
758             _lv_style_list_add_style(list, &styles->bg);
759 
760             list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER);
761             _lv_style_list_add_style(list, &styles->bg);
762             break;
763 
764         case LV_THEME_WIN_BTN:
765             list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
766             _lv_style_list_add_style(list, &styles->bg);
767             _lv_style_list_add_style(list, &styles->btn);
768             break;
769 #endif
770 
771 #if LV_USE_TEXTAREA
772         case LV_THEME_TEXTAREA:
773             list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
774             _lv_style_list_add_style(list, &styles->bg);
775 
776             list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
777             _lv_style_list_add_style(list, &styles->gray);
778 
779             list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
780             _lv_style_list_add_style(list, &styles->bg);
781             _lv_style_list_add_style(list, &styles->tight);
782 
783             list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
784             _lv_style_list_add_style(list, &styles->bg);
785             break;
786 #endif
787 
788 
789 #if LV_USE_SPINBOX
790         case LV_THEME_SPINBOX:
791             list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG);
792             _lv_style_list_add_style(list, &styles->bg);
793 
794             list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR);
795             _lv_style_list_add_style(list, &styles->bg);
796             break;
797 
798         case LV_THEME_SPINBOX_BTN:
799             list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
800             _lv_style_list_add_style(list, &styles->bg);
801             _lv_style_list_add_style(list, &styles->btn);
802             break;
803 #endif
804 
805 #if LV_USE_CALENDAR
806         case LV_THEME_CALENDAR:
807             list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG);
808             _lv_style_list_add_style(list, &styles->bg);
809 
810             list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
811             _lv_style_list_add_style(list, &styles->bg);
812             _lv_style_list_add_style(list, &styles->btn);
813             _lv_style_list_add_style(list, &styles->tight);
814 
815             list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER);
816             _lv_style_list_add_style(list, &styles->bg);
817 
818             list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
819             _lv_style_list_add_style(list, &styles->bg);
820             _lv_style_list_add_style(list, &styles->tight);
821             break;
822 #endif
823 #if LV_USE_CPICKER
824         case LV_THEME_CPICKER:
825             list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
826             _lv_style_list_add_style(list, &styles->bg);
827 
828             list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
829             _lv_style_list_add_style(list, &styles->bg);
830             _lv_style_list_add_style(list, &styles->round);
831             break;
832 #endif
833 
834 #if LV_USE_LINEMETER
835         case LV_THEME_LINEMETER:
836             list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
837             _lv_style_list_add_style(list, &styles->bg);
838             _lv_style_list_add_style(list, &styles->round);
839             break;
840 #endif
841 #if LV_USE_GAUGE
842         case LV_THEME_GAUGE:
843             list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
844             _lv_style_list_add_style(list, &styles->bg);
845             _lv_style_list_add_style(list, &styles->round);
846 
847             list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
848             _lv_style_list_add_style(list, &styles->tick_line);
849 
850             list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
851             _lv_style_list_add_style(list, &styles->bg);
852             break;
853 #endif
854         default:
855             break;
856     }
857 
858     lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
859 }
860 
861 /**********************
862  *   STATIC FUNCTIONS
863  **********************/
864 
style_init_reset(lv_style_t * style)865 static void style_init_reset(lv_style_t * style)
866 {
867     if(inited) lv_style_reset(style);
868     else lv_style_init(style);
869 }
870 
871 #endif
872