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