1 /**
2 * @file lv_theme_default.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "../../../lvgl.h" /*To see all the widgets*/
10
11 #if LV_USE_THEME_DEFAULT
12
13 #include "lv_theme_default.h"
14 #include "../../../misc/lv_gc.h"
15
16 /*********************
17 * DEFINES
18 *********************/
19 #define MODE_DARK 1
20 #define RADIUS_DEFAULT (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8))
21
22 /*SCREEN*/
23 #define LIGHT_COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4)
24 #define LIGHT_COLOR_CARD lv_color_white()
25 #define LIGHT_COLOR_TEXT lv_palette_darken(LV_PALETTE_GREY, 4)
26 #define LIGHT_COLOR_GREY lv_palette_lighten(LV_PALETTE_GREY, 2)
27 #define DARK_COLOR_SCR lv_color_hex(0x15171A)
28 #define DARK_COLOR_CARD lv_color_hex(0x282b30)
29 #define DARK_COLOR_TEXT lv_palette_lighten(LV_PALETTE_GREY, 5)
30 #define DARK_COLOR_GREY lv_color_hex(0x2f3237)
31
32 #define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITION_TIME
33 #define BORDER_WIDTH lv_disp_dpx(theme.disp, 2)
34 #define OUTLINE_WIDTH lv_disp_dpx(theme.disp, 3)
35
36 #define PAD_DEF (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 24) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 20) : lv_disp_dpx(theme.disp, 16))
37 #define PAD_SMALL (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 14) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 10))
38 #define PAD_TINY (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 8) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 6) : lv_disp_dpx(theme.disp, 2))
39
40 /**********************
41 * TYPEDEFS
42 **********************/
43 typedef struct {
44 lv_style_t scr;
45 lv_style_t scrollbar;
46 lv_style_t scrollbar_scrolled;
47 lv_style_t card;
48 lv_style_t btn;
49
50 /*Utility*/
51 lv_style_t bg_color_primary;
52 lv_style_t bg_color_primary_muted;
53 lv_style_t bg_color_secondary;
54 lv_style_t bg_color_secondary_muted;
55 lv_style_t bg_color_grey;
56 lv_style_t bg_color_white;
57 lv_style_t pressed;
58 lv_style_t disabled;
59 lv_style_t pad_zero;
60 lv_style_t pad_tiny;
61 lv_style_t pad_small;
62 lv_style_t pad_normal;
63 lv_style_t pad_gap;
64 lv_style_t line_space_large;
65 lv_style_t text_align_center;
66 lv_style_t outline_primary;
67 lv_style_t outline_secondary;
68 lv_style_t circle;
69 lv_style_t no_radius;
70 lv_style_t clip_corner;
71 #if LV_THEME_DEFAULT_GROW
72 lv_style_t grow;
73 #endif
74 lv_style_t transition_delayed;
75 lv_style_t transition_normal;
76 lv_style_t anim;
77 lv_style_t anim_fast;
78
79 /*Parts*/
80 lv_style_t knob;
81 lv_style_t indic;
82
83 #if LV_USE_ARC
84 lv_style_t arc_indic;
85 lv_style_t arc_indic_primary;
86 #endif
87
88 #if LV_USE_CHART
89 lv_style_t chart_series, chart_indic, chart_ticks, chart_bg;
90 #endif
91
92 #if LV_USE_DROPDOWN
93 lv_style_t dropdown_list;
94 #endif
95
96 #if LV_USE_CHECKBOX
97 lv_style_t cb_marker, cb_marker_checked;
98 #endif
99
100 #if LV_USE_SWITCH
101 lv_style_t switch_knob;
102 #endif
103
104 #if LV_USE_LINE
105 lv_style_t line;
106 #endif
107
108 #if LV_USE_TABLE
109 lv_style_t table_cell;
110 #endif
111
112 #if LV_USE_METER
113 lv_style_t meter_marker, meter_indic;
114 #endif
115
116 #if LV_USE_TEXTAREA
117 lv_style_t ta_cursor, ta_placeholder;
118 #endif
119
120 #if LV_USE_CALENDAR
121 lv_style_t calendar_btnm_bg, calendar_btnm_day, calendar_header;
122 #endif
123
124 #if LV_USE_COLORWHEEL
125 lv_style_t colorwheel_main;
126 #endif
127
128 #if LV_USE_MENU
129 lv_style_t menu_bg, menu_cont, menu_sidebar_cont, menu_main_cont, menu_page, menu_header_cont, menu_header_btn,
130 menu_section, menu_pressed, menu_separator;
131 #endif
132
133 #if LV_USE_MSGBOX
134 lv_style_t msgbox_bg, msgbox_btn_bg, msgbox_backdrop_bg;
135 #endif
136
137 #if LV_USE_KEYBOARD
138 lv_style_t keyboard_btn_bg;
139 #endif
140
141 #if LV_USE_LIST
142 lv_style_t list_bg, list_btn, list_item_grow, list_label;
143 #endif
144
145 #if LV_USE_TABVIEW
146 lv_style_t tab_bg_focus, tab_btn;
147 #endif
148 #if LV_USE_LED
149 lv_style_t led;
150 #endif
151 } my_theme_styles_t;
152
153 typedef struct {
154 lv_theme_t base;
155 uint8_t light : 1;
156 } my_theme_t;
157
158 typedef enum {
159 DISP_SMALL = 3,
160 DISP_MEDIUM = 2,
161 DISP_LARGE = 1,
162 } disp_size_t;
163
164 /**********************
165 * STATIC PROTOTYPES
166 **********************/
167 static void theme_apply(lv_theme_t * th, lv_obj_t * obj);
168 static void style_init_reset(lv_style_t * style);
169
170 /**********************
171 * STATIC VARIABLES
172 **********************/
173 static my_theme_styles_t * styles;
174 static lv_theme_t theme;
175 static disp_size_t disp_size;
176 static lv_color_t color_scr;
177 static lv_color_t color_text;
178 static lv_color_t color_card;
179 static lv_color_t color_grey;
180 static bool inited = false;
181
182 /**********************
183 * MACROS
184 **********************/
185
186 /**********************
187 * STATIC FUNCTIONS
188 **********************/
189
dark_color_filter_cb(const lv_color_filter_dsc_t * f,lv_color_t c,lv_opa_t opa)190 static lv_color_t dark_color_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t c, lv_opa_t opa)
191 {
192 LV_UNUSED(f);
193 return lv_color_darken(c, opa);
194 }
195
grey_filter_cb(const lv_color_filter_dsc_t * f,lv_color_t color,lv_opa_t opa)196 static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t color, lv_opa_t opa)
197 {
198 LV_UNUSED(f);
199 if(theme.flags & MODE_DARK) return lv_color_mix(lv_palette_darken(LV_PALETTE_GREY, 2), color, opa);
200 else return lv_color_mix(lv_palette_lighten(LV_PALETTE_GREY, 2), color, opa);
201 }
202
style_init(void)203 static void style_init(void)
204 {
205 static const lv_style_prop_t trans_props[] = {
206 LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR,
207 LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT,
208 LV_STYLE_TRANSLATE_Y, LV_STYLE_TRANSLATE_X,
209 LV_STYLE_TRANSFORM_ZOOM, LV_STYLE_TRANSFORM_ANGLE,
210 LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_DSC,
211 0
212 };
213
214 color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR;
215 color_text = theme.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT;
216 color_card = theme.flags & MODE_DARK ? DARK_COLOR_CARD : LIGHT_COLOR_CARD;
217 color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY;
218
219 style_init_reset(&styles->transition_delayed);
220 style_init_reset(&styles->transition_normal);
221 #if TRANSITION_TIME
222 static lv_style_transition_dsc_t trans_delayed;
223 lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70, NULL);
224
225 static lv_style_transition_dsc_t trans_normal;
226 lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0, NULL);
227
228 lv_style_set_transition(&styles->transition_delayed, &trans_delayed); /*Go back to default state with delay*/
229
230 lv_style_set_transition(&styles->transition_normal, &trans_normal); /*Go back to default state with delay*/
231 #endif
232
233 style_init_reset(&styles->scrollbar);
234 lv_color_t sb_color = (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY,
235 2) : lv_palette_main(LV_PALETTE_GREY);
236 lv_style_set_bg_color(&styles->scrollbar, sb_color);
237
238 lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE);
239 lv_style_set_pad_all(&styles->scrollbar, lv_disp_dpx(theme.disp, 7));
240 lv_style_set_width(&styles->scrollbar, lv_disp_dpx(theme.disp, 5));
241 lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40);
242 #if TRANSITION_TIME
243 lv_style_set_transition(&styles->scrollbar, &trans_normal);
244 #endif
245
246 style_init_reset(&styles->scrollbar_scrolled);
247 lv_style_set_bg_opa(&styles->scrollbar_scrolled, LV_OPA_COVER);
248
249 style_init_reset(&styles->scr);
250 lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER);
251 lv_style_set_bg_color(&styles->scr, color_scr);
252 lv_style_set_text_color(&styles->scr, color_text);
253 lv_style_set_pad_row(&styles->scr, PAD_SMALL);
254 lv_style_set_pad_column(&styles->scr, PAD_SMALL);
255
256 style_init_reset(&styles->card);
257 lv_style_set_radius(&styles->card, RADIUS_DEFAULT);
258 lv_style_set_bg_opa(&styles->card, LV_OPA_COVER);
259 lv_style_set_bg_color(&styles->card, color_card);
260 lv_style_set_border_color(&styles->card, color_grey);
261 lv_style_set_border_width(&styles->card, BORDER_WIDTH);
262 lv_style_set_border_post(&styles->card, true);
263 lv_style_set_text_color(&styles->card, color_text);
264 lv_style_set_pad_all(&styles->card, PAD_DEF);
265 lv_style_set_pad_row(&styles->card, PAD_SMALL);
266 lv_style_set_pad_column(&styles->card, PAD_SMALL);
267 lv_style_set_line_color(&styles->card, lv_palette_main(LV_PALETTE_GREY));
268 lv_style_set_line_width(&styles->card, lv_disp_dpx(theme.disp, 1));
269
270 style_init_reset(&styles->outline_primary);
271 lv_style_set_outline_color(&styles->outline_primary, theme.color_primary);
272 lv_style_set_outline_width(&styles->outline_primary, OUTLINE_WIDTH);
273 lv_style_set_outline_pad(&styles->outline_primary, OUTLINE_WIDTH);
274 lv_style_set_outline_opa(&styles->outline_primary, LV_OPA_50);
275
276 style_init_reset(&styles->outline_secondary);
277 lv_style_set_outline_color(&styles->outline_secondary, theme.color_secondary);
278 lv_style_set_outline_width(&styles->outline_secondary, OUTLINE_WIDTH);
279 lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50);
280
281 style_init_reset(&styles->btn);
282 lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp,
283 16) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8)));
284 lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER);
285 lv_style_set_bg_color(&styles->btn, color_grey);
286 if(!(theme.flags & MODE_DARK)) {
287 lv_style_set_shadow_color(&styles->btn, lv_palette_main(LV_PALETTE_GREY));
288 lv_style_set_shadow_width(&styles->btn, LV_DPX(3));
289 lv_style_set_shadow_opa(&styles->btn, LV_OPA_50);
290 lv_style_set_shadow_ofs_y(&styles->btn, lv_disp_dpx(theme.disp, LV_DPX(4)));
291 }
292 lv_style_set_text_color(&styles->btn, color_text);
293 lv_style_set_pad_hor(&styles->btn, PAD_DEF);
294 lv_style_set_pad_ver(&styles->btn, PAD_SMALL);
295 lv_style_set_pad_column(&styles->btn, lv_disp_dpx(theme.disp, 5));
296 lv_style_set_pad_row(&styles->btn, lv_disp_dpx(theme.disp, 5));
297
298 static lv_color_filter_dsc_t dark_filter;
299 lv_color_filter_dsc_init(&dark_filter, dark_color_filter_cb);
300
301 static lv_color_filter_dsc_t grey_filter;
302 lv_color_filter_dsc_init(&grey_filter, grey_filter_cb);
303
304 style_init_reset(&styles->pressed);
305 lv_style_set_color_filter_dsc(&styles->pressed, &dark_filter);
306 lv_style_set_color_filter_opa(&styles->pressed, 35);
307
308 style_init_reset(&styles->disabled);
309 lv_style_set_color_filter_dsc(&styles->disabled, &grey_filter);
310 lv_style_set_color_filter_opa(&styles->disabled, LV_OPA_50);
311
312 style_init_reset(&styles->clip_corner);
313 lv_style_set_clip_corner(&styles->clip_corner, true);
314 lv_style_set_border_post(&styles->clip_corner, true);
315
316 style_init_reset(&styles->pad_normal);
317 lv_style_set_pad_all(&styles->pad_normal, PAD_DEF);
318 lv_style_set_pad_row(&styles->pad_normal, PAD_DEF);
319 lv_style_set_pad_column(&styles->pad_normal, PAD_DEF);
320
321 style_init_reset(&styles->pad_small);
322 lv_style_set_pad_all(&styles->pad_small, PAD_SMALL);
323 lv_style_set_pad_gap(&styles->pad_small, PAD_SMALL);
324
325 style_init_reset(&styles->pad_gap);
326 lv_style_set_pad_row(&styles->pad_gap, lv_disp_dpx(theme.disp, 10));
327 lv_style_set_pad_column(&styles->pad_gap, lv_disp_dpx(theme.disp, 10));
328
329 style_init_reset(&styles->line_space_large);
330 lv_style_set_text_line_space(&styles->line_space_large, lv_disp_dpx(theme.disp, 20));
331
332 style_init_reset(&styles->text_align_center);
333 lv_style_set_text_align(&styles->text_align_center, LV_TEXT_ALIGN_CENTER);
334
335 style_init_reset(&styles->pad_zero);
336 lv_style_set_pad_all(&styles->pad_zero, 0);
337 lv_style_set_pad_row(&styles->pad_zero, 0);
338 lv_style_set_pad_column(&styles->pad_zero, 0);
339
340 style_init_reset(&styles->pad_tiny);
341 lv_style_set_pad_all(&styles->pad_tiny, PAD_TINY);
342 lv_style_set_pad_row(&styles->pad_tiny, PAD_TINY);
343 lv_style_set_pad_column(&styles->pad_tiny, PAD_TINY);
344
345 style_init_reset(&styles->bg_color_primary);
346 lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary);
347 lv_style_set_text_color(&styles->bg_color_primary, lv_color_white());
348 lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER);
349
350 style_init_reset(&styles->bg_color_primary_muted);
351 lv_style_set_bg_color(&styles->bg_color_primary_muted, theme.color_primary);
352 lv_style_set_text_color(&styles->bg_color_primary_muted, theme.color_primary);
353 lv_style_set_bg_opa(&styles->bg_color_primary_muted, LV_OPA_20);
354
355 style_init_reset(&styles->bg_color_secondary);
356 lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary);
357 lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white());
358 lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER);
359
360 style_init_reset(&styles->bg_color_secondary_muted);
361 lv_style_set_bg_color(&styles->bg_color_secondary_muted, theme.color_secondary);
362 lv_style_set_text_color(&styles->bg_color_secondary_muted, theme.color_secondary);
363 lv_style_set_bg_opa(&styles->bg_color_secondary_muted, LV_OPA_20);
364
365 style_init_reset(&styles->bg_color_grey);
366 lv_style_set_bg_color(&styles->bg_color_grey, color_grey);
367 lv_style_set_bg_opa(&styles->bg_color_grey, LV_OPA_COVER);
368 lv_style_set_text_color(&styles->bg_color_grey, color_text);
369
370 style_init_reset(&styles->bg_color_white);
371 lv_style_set_bg_color(&styles->bg_color_white, color_card);
372 lv_style_set_bg_opa(&styles->bg_color_white, LV_OPA_COVER);
373 lv_style_set_text_color(&styles->bg_color_white, color_text);
374
375 style_init_reset(&styles->circle);
376 lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE);
377
378 style_init_reset(&styles->no_radius);
379 lv_style_set_radius(&styles->no_radius, 0);
380
381 #if LV_THEME_DEFAULT_GROW
382 style_init_reset(&styles->grow);
383 lv_style_set_transform_width(&styles->grow, lv_disp_dpx(theme.disp, 3));
384 lv_style_set_transform_height(&styles->grow, lv_disp_dpx(theme.disp, 3));
385 #endif
386
387 style_init_reset(&styles->knob);
388 lv_style_set_bg_color(&styles->knob, theme.color_primary);
389 lv_style_set_bg_opa(&styles->knob, LV_OPA_COVER);
390 lv_style_set_pad_all(&styles->knob, lv_disp_dpx(theme.disp, 6));
391 lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE);
392
393 style_init_reset(&styles->anim);
394 lv_style_set_anim_time(&styles->anim, 200);
395
396 style_init_reset(&styles->anim_fast);
397 lv_style_set_anim_time(&styles->anim_fast, 120);
398
399 #if LV_USE_ARC
400 style_init_reset(&styles->arc_indic);
401 lv_style_set_arc_color(&styles->arc_indic, color_grey);
402 lv_style_set_arc_width(&styles->arc_indic, lv_disp_dpx(theme.disp, 15));
403 lv_style_set_arc_rounded(&styles->arc_indic, true);
404
405 style_init_reset(&styles->arc_indic_primary);
406 lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary);
407 #endif
408
409 #if LV_USE_DROPDOWN
410 style_init_reset(&styles->dropdown_list);
411 lv_style_set_max_height(&styles->dropdown_list, LV_DPI_DEF * 2);
412 #endif
413 #if LV_USE_CHECKBOX
414 style_init_reset(&styles->cb_marker);
415 lv_style_set_pad_all(&styles->cb_marker, lv_disp_dpx(theme.disp, 3));
416 lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH);
417 lv_style_set_border_color(&styles->cb_marker, theme.color_primary);
418 lv_style_set_bg_color(&styles->cb_marker, color_card);
419 lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER);
420 lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2);
421
422 style_init_reset(&styles->cb_marker_checked);
423 lv_style_set_bg_img_src(&styles->cb_marker_checked, LV_SYMBOL_OK);
424 lv_style_set_text_color(&styles->cb_marker_checked, lv_color_white());
425 lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small);
426 #endif
427
428 #if LV_USE_SWITCH
429 style_init_reset(&styles->switch_knob);
430 lv_style_set_pad_all(&styles->switch_knob, - lv_disp_dpx(theme.disp, 4));
431 lv_style_set_bg_color(&styles->switch_knob, lv_color_white());
432 #endif
433
434 #if LV_USE_LINE
435 style_init_reset(&styles->line);
436 lv_style_set_line_width(&styles->line, 1);
437 lv_style_set_line_color(&styles->line, color_text);
438 #endif
439
440 #if LV_USE_CHART
441 style_init_reset(&styles->chart_bg);
442 lv_style_set_border_post(&styles->chart_bg, false);
443 lv_style_set_pad_column(&styles->chart_bg, lv_disp_dpx(theme.disp, 10));
444 lv_style_set_line_color(&styles->chart_bg, color_grey);
445
446 style_init_reset(&styles->chart_series);
447 lv_style_set_line_width(&styles->chart_series, lv_disp_dpx(theme.disp, 3));
448 lv_style_set_radius(&styles->chart_series, lv_disp_dpx(theme.disp, 3));
449 lv_style_set_size(&styles->chart_series, lv_disp_dpx(theme.disp, 8));
450 lv_style_set_pad_column(&styles->chart_series, lv_disp_dpx(theme.disp, 2));
451
452 style_init_reset(&styles->chart_indic);
453 lv_style_set_radius(&styles->chart_indic, LV_RADIUS_CIRCLE);
454 lv_style_set_size(&styles->chart_indic, lv_disp_dpx(theme.disp, 8));
455 lv_style_set_bg_color(&styles->chart_indic, theme.color_primary);
456 lv_style_set_bg_opa(&styles->chart_indic, LV_OPA_COVER);
457
458 style_init_reset(&styles->chart_ticks);
459 lv_style_set_line_width(&styles->chart_ticks, lv_disp_dpx(theme.disp, 1));
460 lv_style_set_line_color(&styles->chart_ticks, color_text);
461 lv_style_set_pad_all(&styles->chart_ticks, lv_disp_dpx(theme.disp, 2));
462 lv_style_set_text_color(&styles->chart_ticks, lv_palette_main(LV_PALETTE_GREY));
463 #endif
464
465 #if LV_USE_MENU
466 style_init_reset(&styles->menu_bg);
467 lv_style_set_pad_all(&styles->menu_bg, 0);
468 lv_style_set_pad_gap(&styles->menu_bg, 0);
469 lv_style_set_radius(&styles->menu_bg, 0);
470 lv_style_set_clip_corner(&styles->menu_bg, true);
471 lv_style_set_border_side(&styles->menu_bg, LV_BORDER_SIDE_NONE);
472
473 style_init_reset(&styles->menu_section);
474 lv_style_set_radius(&styles->menu_section, RADIUS_DEFAULT);
475 lv_style_set_clip_corner(&styles->menu_section, true);
476 lv_style_set_bg_opa(&styles->menu_section, LV_OPA_COVER);
477 lv_style_set_bg_color(&styles->menu_section, color_card);
478 lv_style_set_text_color(&styles->menu_section, color_text);
479
480 style_init_reset(&styles->menu_cont);
481 lv_style_set_pad_hor(&styles->menu_cont, PAD_SMALL);
482 lv_style_set_pad_ver(&styles->menu_cont, PAD_SMALL);
483 lv_style_set_pad_gap(&styles->menu_cont, PAD_SMALL);
484 lv_style_set_border_width(&styles->menu_cont, lv_disp_dpx(theme.disp, 1));
485 lv_style_set_border_opa(&styles->menu_cont, LV_OPA_10);
486 lv_style_set_border_color(&styles->menu_cont, color_text);
487 lv_style_set_border_side(&styles->menu_cont, LV_BORDER_SIDE_NONE);
488
489 style_init_reset(&styles->menu_sidebar_cont);
490 lv_style_set_pad_all(&styles->menu_sidebar_cont, 0);
491 lv_style_set_pad_gap(&styles->menu_sidebar_cont, 0);
492 lv_style_set_border_width(&styles->menu_sidebar_cont, lv_disp_dpx(theme.disp, 1));
493 lv_style_set_border_opa(&styles->menu_sidebar_cont, LV_OPA_10);
494 lv_style_set_border_color(&styles->menu_sidebar_cont, color_text);
495 lv_style_set_border_side(&styles->menu_sidebar_cont, LV_BORDER_SIDE_RIGHT);
496
497 style_init_reset(&styles->menu_main_cont);
498 lv_style_set_pad_all(&styles->menu_main_cont, 0);
499 lv_style_set_pad_gap(&styles->menu_main_cont, 0);
500
501 style_init_reset(&styles->menu_header_cont);
502 lv_style_set_pad_hor(&styles->menu_header_cont, PAD_SMALL);
503 lv_style_set_pad_ver(&styles->menu_header_cont, PAD_TINY);
504 lv_style_set_pad_gap(&styles->menu_header_cont, PAD_SMALL);
505
506 style_init_reset(&styles->menu_header_btn);
507 lv_style_set_pad_hor(&styles->menu_header_btn, PAD_TINY);
508 lv_style_set_pad_ver(&styles->menu_header_btn, PAD_TINY);
509 lv_style_set_shadow_opa(&styles->menu_header_btn, LV_OPA_TRANSP);
510 lv_style_set_bg_opa(&styles->menu_header_btn, LV_OPA_TRANSP);
511 lv_style_set_text_color(&styles->menu_header_btn, color_text);
512
513 style_init_reset(&styles->menu_page);
514 lv_style_set_pad_hor(&styles->menu_page, 0);
515 lv_style_set_pad_gap(&styles->menu_page, 0);
516
517 style_init_reset(&styles->menu_pressed);
518 lv_style_set_bg_opa(&styles->menu_pressed, LV_OPA_20);
519 lv_style_set_bg_color(&styles->menu_pressed, lv_palette_main(LV_PALETTE_GREY));
520
521 style_init_reset(&styles->menu_separator);
522 lv_style_set_bg_opa(&styles->menu_separator, LV_OPA_TRANSP);
523 lv_style_set_pad_ver(&styles->menu_separator, PAD_TINY);
524 #endif
525
526 #if LV_USE_METER
527 style_init_reset(&styles->meter_marker);
528 lv_style_set_line_width(&styles->meter_marker, lv_disp_dpx(theme.disp, 5));
529 lv_style_set_line_color(&styles->meter_marker, color_text);
530 lv_style_set_size(&styles->meter_marker, lv_disp_dpx(theme.disp, 20));
531 lv_style_set_pad_left(&styles->meter_marker, lv_disp_dpx(theme.disp, 15));
532
533 style_init_reset(&styles->meter_indic);
534 lv_style_set_radius(&styles->meter_indic, LV_RADIUS_CIRCLE);
535 lv_style_set_bg_color(&styles->meter_indic, color_text);
536 lv_style_set_bg_opa(&styles->meter_indic, LV_OPA_COVER);
537 lv_style_set_size(&styles->meter_indic, lv_disp_dpx(theme.disp, 15));
538 #endif
539
540 #if LV_USE_TABLE
541 style_init_reset(&styles->table_cell);
542 lv_style_set_border_width(&styles->table_cell, lv_disp_dpx(theme.disp, 1));
543 lv_style_set_border_color(&styles->table_cell, color_grey);
544 lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
545 #endif
546
547 #if LV_USE_TEXTAREA
548 style_init_reset(&styles->ta_cursor);
549 lv_style_set_border_color(&styles->ta_cursor, color_text);
550 lv_style_set_border_width(&styles->ta_cursor, lv_disp_dpx(theme.disp, 2));
551 lv_style_set_pad_left(&styles->ta_cursor, - lv_disp_dpx(theme.disp, 1));
552 lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT);
553 lv_style_set_anim_time(&styles->ta_cursor, 400);
554
555 style_init_reset(&styles->ta_placeholder);
556 lv_style_set_text_color(&styles->ta_placeholder, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY,
557 2) : lv_palette_lighten(LV_PALETTE_GREY, 1));
558 #endif
559
560 #if LV_USE_CALENDAR
561 style_init_reset(&styles->calendar_btnm_bg);
562 lv_style_set_pad_all(&styles->calendar_btnm_bg, PAD_SMALL);
563 lv_style_set_pad_gap(&styles->calendar_btnm_bg, PAD_SMALL / 2);
564
565 style_init_reset(&styles->calendar_btnm_day);
566 lv_style_set_border_width(&styles->calendar_btnm_day, lv_disp_dpx(theme.disp, 1));
567 lv_style_set_border_color(&styles->calendar_btnm_day, color_grey);
568 lv_style_set_bg_color(&styles->calendar_btnm_day, color_card);
569 lv_style_set_bg_opa(&styles->calendar_btnm_day, LV_OPA_20);
570
571 style_init_reset(&styles->calendar_header);
572 lv_style_set_pad_hor(&styles->calendar_header, PAD_SMALL);
573 lv_style_set_pad_top(&styles->calendar_header, PAD_SMALL);
574 lv_style_set_pad_bottom(&styles->calendar_header, PAD_TINY);
575 lv_style_set_pad_gap(&styles->calendar_header, PAD_SMALL);
576 #endif
577
578 #if LV_USE_COLORWHEEL
579 style_init_reset(&styles->colorwheel_main);
580 lv_style_set_arc_width(&styles->colorwheel_main, lv_disp_dpx(theme.disp, 10));
581 #endif
582
583 #if LV_USE_MSGBOX
584 /*To add space for for the button shadow*/
585 style_init_reset(&styles->msgbox_btn_bg);
586 lv_style_set_pad_all(&styles->msgbox_btn_bg, lv_disp_dpx(theme.disp, 4));
587
588 style_init_reset(&styles->msgbox_bg);
589 lv_style_set_max_width(&styles->msgbox_bg, lv_pct(100));
590
591 style_init_reset(&styles->msgbox_backdrop_bg);
592 lv_style_set_bg_color(&styles->msgbox_backdrop_bg, lv_palette_main(LV_PALETTE_GREY));
593 lv_style_set_bg_opa(&styles->msgbox_backdrop_bg, LV_OPA_50);
594 #endif
595 #if LV_USE_KEYBOARD
596 style_init_reset(&styles->keyboard_btn_bg);
597 lv_style_set_shadow_width(&styles->keyboard_btn_bg, 0);
598 lv_style_set_radius(&styles->keyboard_btn_bg, disp_size == DISP_SMALL ? RADIUS_DEFAULT / 2 : RADIUS_DEFAULT);
599 #endif
600
601 #if LV_USE_TABVIEW
602 style_init_reset(&styles->tab_btn);
603 lv_style_set_border_color(&styles->tab_btn, theme.color_primary);
604 lv_style_set_border_width(&styles->tab_btn, BORDER_WIDTH * 2);
605 lv_style_set_border_side(&styles->tab_btn, LV_BORDER_SIDE_BOTTOM);
606
607 style_init_reset(&styles->tab_bg_focus);
608 lv_style_set_outline_pad(&styles->tab_bg_focus, -BORDER_WIDTH);
609 #endif
610
611 #if LV_USE_LIST
612 style_init_reset(&styles->list_bg);
613 lv_style_set_pad_hor(&styles->list_bg, PAD_DEF);
614 lv_style_set_pad_ver(&styles->list_bg, 0);
615 lv_style_set_pad_gap(&styles->list_bg, 0);
616 lv_style_set_clip_corner(&styles->list_bg, true);
617
618 style_init_reset(&styles->list_btn);
619 lv_style_set_border_width(&styles->list_btn, lv_disp_dpx(theme.disp, 1));
620 lv_style_set_border_color(&styles->list_btn, color_grey);
621 lv_style_set_border_side(&styles->list_btn, LV_BORDER_SIDE_BOTTOM);
622 lv_style_set_pad_all(&styles->list_btn, PAD_SMALL);
623 lv_style_set_pad_column(&styles->list_btn, PAD_SMALL);
624
625 style_init_reset(&styles->list_item_grow);
626 lv_style_set_transform_width(&styles->list_item_grow, PAD_DEF);
627 #endif
628
629 #if LV_USE_LED
630 style_init_reset(&styles->led);
631 lv_style_set_bg_opa(&styles->led, LV_OPA_COVER);
632 lv_style_set_bg_color(&styles->led, lv_color_white());
633 lv_style_set_bg_grad_color(&styles->led, lv_palette_main(LV_PALETTE_GREY));
634 lv_style_set_radius(&styles->led, LV_RADIUS_CIRCLE);
635 lv_style_set_shadow_width(&styles->led, lv_disp_dpx(theme.disp, 15));
636 lv_style_set_shadow_color(&styles->led, lv_color_white());
637 lv_style_set_shadow_spread(&styles->led, lv_disp_dpx(theme.disp, 5));
638 #endif
639 }
640
641 /**********************
642 * GLOBAL FUNCTIONS
643 **********************/
644
lv_theme_default_init(lv_disp_t * disp,lv_color_t color_primary,lv_color_t color_secondary,bool dark,const lv_font_t * font)645 lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark,
646 const lv_font_t * font)
647 {
648
649 /*This trick is required only to avoid the garbage collection of
650 *styles' data if LVGL is used in a binding (e.g. Micropython)
651 *In a general case styles could be in simple `static lv_style_t my_style...` variables*/
652 if(!lv_theme_default_is_inited()) {
653 inited = false;
654 LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t));
655 styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles);
656 }
657
658 if(LV_HOR_RES <= 320) disp_size = DISP_SMALL;
659 else if(LV_HOR_RES < 720) disp_size = DISP_MEDIUM;
660 else disp_size = DISP_LARGE;
661
662 theme.disp = disp;
663 theme.color_primary = color_primary;
664 theme.color_secondary = color_secondary;
665 theme.font_small = font;
666 theme.font_normal = font;
667 theme.font_large = font;
668 theme.apply_cb = theme_apply;
669 theme.flags = dark ? MODE_DARK : 0;
670
671 style_init();
672
673 if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL);
674
675 inited = true;
676
677 return (lv_theme_t *)&theme;
678 }
679
lv_theme_default_get(void)680 lv_theme_t * lv_theme_default_get(void)
681 {
682 if(!lv_theme_default_is_inited()) {
683 return NULL;
684 }
685
686 return (lv_theme_t *)&theme;
687 }
688
lv_theme_default_is_inited(void)689 bool lv_theme_default_is_inited(void)
690 {
691 return LV_GC_ROOT(_lv_theme_default_styles) == NULL ? false : true;
692 }
693
theme_apply(lv_theme_t * th,lv_obj_t * obj)694 static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
695 {
696 LV_UNUSED(th);
697
698 if(lv_obj_get_parent(obj) == NULL) {
699 lv_obj_add_style(obj, &styles->scr, 0);
700 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
701 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
702 return;
703 }
704
705 if(lv_obj_check_type(obj, &lv_obj_class)) {
706 #if LV_USE_TABVIEW
707 lv_obj_t * parent = lv_obj_get_parent(obj);
708 /*Tabview content area*/
709 if(lv_obj_check_type(parent, &lv_tabview_class)) {
710 return;
711 }
712 /*Tabview pages*/
713 else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) {
714 lv_obj_add_style(obj, &styles->pad_normal, 0);
715 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
716 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
717 return;
718 }
719 #endif
720
721 #if LV_USE_WIN
722 /*Header*/
723 if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
724 lv_obj_add_style(obj, &styles->bg_color_grey, 0);
725 lv_obj_add_style(obj, &styles->pad_tiny, 0);
726 return;
727 }
728 /*Content*/
729 else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
730 lv_obj_add_style(obj, &styles->scr, 0);
731 lv_obj_add_style(obj, &styles->pad_normal, 0);
732 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
733 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
734 return;
735 }
736 #endif
737
738 #if LV_USE_CALENDAR
739 if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_calendar_class)) {
740 /*No style*/
741 return;
742 }
743 #endif
744
745 lv_obj_add_style(obj, &styles->card, 0);
746 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
747 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
748 }
749 #if LV_USE_BTN
750 else if(lv_obj_check_type(obj, &lv_btn_class)) {
751 lv_obj_add_style(obj, &styles->btn, 0);
752 lv_obj_add_style(obj, &styles->bg_color_primary, 0);
753 lv_obj_add_style(obj, &styles->transition_delayed, 0);
754 lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED);
755 lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED);
756 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
757 #if LV_THEME_DEFAULT_GROW
758 lv_obj_add_style(obj, &styles->grow, LV_STATE_PRESSED);
759 #endif
760 lv_obj_add_style(obj, &styles->bg_color_secondary, LV_STATE_CHECKED);
761 lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED);
762
763 #if LV_USE_MENU
764 if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_menu_sidebar_header_cont_class) ||
765 lv_obj_check_type(lv_obj_get_parent(obj), &lv_menu_main_header_cont_class)) {
766 lv_obj_add_style(obj, &styles->menu_header_btn, 0);
767 lv_obj_add_style(obj, &styles->menu_pressed, LV_STATE_PRESSED);
768 }
769 #endif
770 }
771 #endif
772
773 #if LV_USE_LINE
774 else if(lv_obj_check_type(obj, &lv_line_class)) {
775 lv_obj_add_style(obj, &styles->line, 0);
776 }
777 #endif
778
779 #if LV_USE_BTNMATRIX
780 else if(lv_obj_check_type(obj, &lv_btnmatrix_class)) {
781 #if LV_USE_MSGBOX
782 if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) {
783 lv_obj_add_style(obj, &styles->msgbox_btn_bg, 0);
784 lv_obj_add_style(obj, &styles->pad_gap, 0);
785 lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS);
786 lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
787 lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
788 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED);
789 lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
790 lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED);
791 return;
792 }
793 #endif
794 #if LV_USE_TABVIEW
795 if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) {
796 lv_obj_add_style(obj, &styles->bg_color_white, 0);
797 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
798 lv_obj_add_style(obj, &styles->tab_bg_focus, LV_STATE_FOCUS_KEY);
799 lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
800 lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_CHECKED);
801 lv_obj_add_style(obj, &styles->tab_btn, LV_PART_ITEMS | LV_STATE_CHECKED);
802 lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
803 lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED);
804 lv_obj_add_style(obj, &styles->tab_bg_focus, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
805 return;
806 }
807 #endif
808
809 #if LV_USE_CALENDAR
810 if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_calendar_class)) {
811 lv_obj_add_style(obj, &styles->calendar_btnm_bg, 0);
812 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
813 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
814 lv_obj_add_style(obj, &styles->calendar_btnm_day, LV_PART_ITEMS);
815 lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
816 lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
817 lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
818 lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED);
819 return;
820 }
821 #endif
822 lv_obj_add_style(obj, &styles->card, 0);
823 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
824 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
825 lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS);
826 lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
827 lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
828 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED);
829 lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
830 lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED);
831 }
832 #endif
833
834 #if LV_USE_BAR
835 else if(lv_obj_check_type(obj, &lv_bar_class)) {
836 lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0);
837 lv_obj_add_style(obj, &styles->circle, 0);
838 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
839 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
840 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR);
841 lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR);
842 }
843 #endif
844
845 #if LV_USE_SLIDER
846 else if(lv_obj_check_type(obj, &lv_slider_class)) {
847 lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0);
848 lv_obj_add_style(obj, &styles->circle, 0);
849 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
850 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
851 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR);
852 lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR);
853 lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB);
854 #if LV_THEME_DEFAULT_GROW
855 lv_obj_add_style(obj, &styles->grow, LV_PART_KNOB | LV_STATE_PRESSED);
856 #endif
857 lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_KNOB);
858 lv_obj_add_style(obj, &styles->transition_normal, LV_PART_KNOB | LV_STATE_PRESSED);
859 }
860 #endif
861
862 #if LV_USE_TABLE
863 else if(lv_obj_check_type(obj, &lv_table_class)) {
864 lv_obj_add_style(obj, &styles->card, 0);
865 lv_obj_add_style(obj, &styles->pad_zero, 0);
866 lv_obj_add_style(obj, &styles->no_radius, 0);
867 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
868 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
869 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
870 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
871 lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS);
872 lv_obj_add_style(obj, &styles->table_cell, LV_PART_ITEMS);
873 lv_obj_add_style(obj, &styles->pad_normal, LV_PART_ITEMS);
874 lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
875 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
876 lv_obj_add_style(obj, &styles->bg_color_secondary, LV_PART_ITEMS | LV_STATE_EDITED);
877 }
878 #endif
879
880 #if LV_USE_CHECKBOX
881 else if(lv_obj_check_type(obj, &lv_checkbox_class)) {
882 lv_obj_add_style(obj, &styles->pad_gap, 0);
883 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
884 lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED);
885 lv_obj_add_style(obj, &styles->cb_marker, LV_PART_INDICATOR);
886 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED);
887 lv_obj_add_style(obj, &styles->cb_marker_checked, LV_PART_INDICATOR | LV_STATE_CHECKED);
888 lv_obj_add_style(obj, &styles->pressed, LV_PART_INDICATOR | LV_STATE_PRESSED);
889 #if LV_THEME_DEFAULT_GROW
890 lv_obj_add_style(obj, &styles->grow, LV_PART_INDICATOR | LV_STATE_PRESSED);
891 #endif
892 lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR | LV_STATE_PRESSED);
893 lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_INDICATOR);
894 }
895 #endif
896
897 #if LV_USE_SWITCH
898 else if(lv_obj_check_type(obj, &lv_switch_class)) {
899 lv_obj_add_style(obj, &styles->bg_color_grey, 0);
900 lv_obj_add_style(obj, &styles->circle, 0);
901 lv_obj_add_style(obj, &styles->anim_fast, 0);
902 lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED);
903 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
904 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED);
905 lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR);
906 lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED);
907 lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB);
908 lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB);
909 lv_obj_add_style(obj, &styles->switch_knob, LV_PART_KNOB);
910 lv_obj_add_style(obj, &styles->disabled, LV_PART_KNOB | LV_STATE_DISABLED);
911
912 lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR | LV_STATE_CHECKED);
913 lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR);
914 }
915 #endif
916
917 #if LV_USE_CHART
918 else if(lv_obj_check_type(obj, &lv_chart_class)) {
919 lv_obj_add_style(obj, &styles->card, 0);
920 lv_obj_add_style(obj, &styles->pad_small, 0);
921 lv_obj_add_style(obj, &styles->chart_bg, 0);
922 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
923 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
924 lv_obj_add_style(obj, &styles->chart_series, LV_PART_ITEMS);
925 lv_obj_add_style(obj, &styles->chart_indic, LV_PART_INDICATOR);
926 lv_obj_add_style(obj, &styles->chart_ticks, LV_PART_TICKS);
927 lv_obj_add_style(obj, &styles->chart_series, LV_PART_CURSOR);
928 }
929 #endif
930
931 #if LV_USE_ROLLER
932 else if(lv_obj_check_type(obj, &lv_roller_class)) {
933 lv_obj_add_style(obj, &styles->card, 0);
934 lv_obj_add_style(obj, &styles->anim, 0);
935 lv_obj_add_style(obj, &styles->line_space_large, 0);
936 lv_obj_add_style(obj, &styles->text_align_center, 0);
937 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
938 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
939 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED);
940 }
941 #endif
942
943 #if LV_USE_DROPDOWN
944 else if(lv_obj_check_type(obj, &lv_dropdown_class)) {
945 lv_obj_add_style(obj, &styles->card, 0);
946 lv_obj_add_style(obj, &styles->pad_small, 0);
947 lv_obj_add_style(obj, &styles->transition_delayed, 0);
948 lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED);
949 lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED);
950 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
951 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
952 lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR);
953 }
954 else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) {
955 lv_obj_add_style(obj, &styles->card, 0);
956 lv_obj_add_style(obj, &styles->clip_corner, 0);
957 lv_obj_add_style(obj, &styles->line_space_large, 0);
958 lv_obj_add_style(obj, &styles->dropdown_list, 0);
959 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
960 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
961 lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_SELECTED);
962 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED | LV_STATE_CHECKED);
963 lv_obj_add_style(obj, &styles->pressed, LV_PART_SELECTED | LV_STATE_PRESSED);
964 }
965 #endif
966
967 #if LV_USE_ARC
968 else if(lv_obj_check_type(obj, &lv_arc_class)) {
969 lv_obj_add_style(obj, &styles->arc_indic, 0);
970 lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR);
971 lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR);
972 lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB);
973 }
974 #endif
975
976 #if LV_USE_SPINNER
977 else if(lv_obj_check_type(obj, &lv_spinner_class)) {
978 lv_obj_add_style(obj, &styles->arc_indic, 0);
979 lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR);
980 lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR);
981 }
982 #endif
983
984 #if LV_USE_METER
985 else if(lv_obj_check_type(obj, &lv_meter_class)) {
986 lv_obj_add_style(obj, &styles->card, 0);
987 lv_obj_add_style(obj, &styles->circle, 0);
988 lv_obj_add_style(obj, &styles->meter_indic, LV_PART_INDICATOR);
989 }
990 #endif
991
992 #if LV_USE_TEXTAREA
993 else if(lv_obj_check_type(obj, &lv_textarea_class)) {
994 lv_obj_add_style(obj, &styles->card, 0);
995 lv_obj_add_style(obj, &styles->pad_small, 0);
996 lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED);
997 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
998 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
999 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
1000 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
1001 lv_obj_add_style(obj, &styles->ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED);
1002 lv_obj_add_style(obj, &styles->ta_placeholder, LV_PART_TEXTAREA_PLACEHOLDER);
1003 }
1004 #endif
1005
1006 #if LV_USE_CALENDAR
1007 else if(lv_obj_check_type(obj, &lv_calendar_class)) {
1008 lv_obj_add_style(obj, &styles->card, 0);
1009 lv_obj_add_style(obj, &styles->pad_zero, 0);
1010 }
1011 #endif
1012
1013 #if LV_USE_CALENDAR_HEADER_ARROW
1014 else if(lv_obj_check_type(obj, &lv_calendar_header_arrow_class)) {
1015 lv_obj_add_style(obj, &styles->calendar_header, 0);
1016 }
1017 #endif
1018
1019 #if LV_USE_CALENDAR_HEADER_DROPDOWN
1020 else if(lv_obj_check_type(obj, &lv_calendar_header_dropdown_class)) {
1021 lv_obj_add_style(obj, &styles->calendar_header, 0);
1022 }
1023 #endif
1024
1025 #if LV_USE_KEYBOARD
1026 else if(lv_obj_check_type(obj, &lv_keyboard_class)) {
1027 lv_obj_add_style(obj, &styles->scr, 0);
1028 lv_obj_add_style(obj, disp_size == DISP_LARGE ? &styles->pad_small : &styles->pad_tiny, 0);
1029 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
1030 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
1031 lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS);
1032 lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
1033 lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS);
1034 lv_obj_add_style(obj, &styles->keyboard_btn_bg, LV_PART_ITEMS);
1035 lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
1036 lv_obj_add_style(obj, &styles->bg_color_grey, LV_PART_ITEMS | LV_STATE_CHECKED);
1037 lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
1038 lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED);
1039 }
1040 #endif
1041 #if LV_USE_LIST
1042 else if(lv_obj_check_type(obj, &lv_list_class)) {
1043 lv_obj_add_style(obj, &styles->card, 0);
1044 lv_obj_add_style(obj, &styles->list_bg, 0);
1045 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
1046 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
1047 return;
1048 }
1049 else if(lv_obj_check_type(obj, &lv_list_text_class)) {
1050 lv_obj_add_style(obj, &styles->bg_color_grey, 0);
1051 lv_obj_add_style(obj, &styles->list_item_grow, 0);
1052 }
1053 else if(lv_obj_check_type(obj, &lv_list_btn_class)) {
1054 lv_obj_add_style(obj, &styles->bg_color_white, 0);
1055 lv_obj_add_style(obj, &styles->list_btn, 0);
1056 lv_obj_add_style(obj, &styles->bg_color_primary, LV_STATE_FOCUS_KEY);
1057 lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_FOCUS_KEY);
1058 lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_PRESSED);
1059 lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED);
1060
1061 }
1062 #endif
1063 #if LV_USE_MENU
1064 else if(lv_obj_check_type(obj, &lv_menu_class)) {
1065 lv_obj_add_style(obj, &styles->card, 0);
1066 lv_obj_add_style(obj, &styles->menu_bg, 0);
1067 }
1068 else if(lv_obj_check_type(obj, &lv_menu_sidebar_cont_class)) {
1069 lv_obj_add_style(obj, &styles->menu_sidebar_cont, 0);
1070 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
1071 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
1072 }
1073 else if(lv_obj_check_type(obj, &lv_menu_main_cont_class)) {
1074 lv_obj_add_style(obj, &styles->menu_main_cont, 0);
1075 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
1076 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
1077 }
1078 else if(lv_obj_check_type(obj, &lv_menu_cont_class)) {
1079 lv_obj_add_style(obj, &styles->menu_cont, 0);
1080 lv_obj_add_style(obj, &styles->menu_pressed, LV_STATE_PRESSED);
1081 lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_STATE_PRESSED | LV_STATE_CHECKED);
1082 lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_STATE_CHECKED);
1083 lv_obj_add_style(obj, &styles->bg_color_primary, LV_STATE_FOCUS_KEY);
1084 }
1085 else if(lv_obj_check_type(obj, &lv_menu_sidebar_header_cont_class) ||
1086 lv_obj_check_type(obj, &lv_menu_main_header_cont_class)) {
1087 lv_obj_add_style(obj, &styles->menu_header_cont, 0);
1088 }
1089 else if(lv_obj_check_type(obj, &lv_menu_page_class)) {
1090 lv_obj_add_style(obj, &styles->menu_page, 0);
1091 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
1092 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
1093 }
1094 else if(lv_obj_check_type(obj, &lv_menu_section_class)) {
1095 lv_obj_add_style(obj, &styles->menu_section, 0);
1096 }
1097 else if(lv_obj_check_type(obj, &lv_menu_separator_class)) {
1098 lv_obj_add_style(obj, &styles->menu_separator, 0);
1099 }
1100 #endif
1101 #if LV_USE_MSGBOX
1102 else if(lv_obj_check_type(obj, &lv_msgbox_class)) {
1103 lv_obj_add_style(obj, &styles->card, 0);
1104 lv_obj_add_style(obj, &styles->msgbox_bg, 0);
1105 return;
1106 }
1107 else if(lv_obj_check_type(obj, &lv_msgbox_backdrop_class)) {
1108 lv_obj_add_style(obj, &styles->msgbox_backdrop_bg, 0);
1109 }
1110 #endif
1111 #if LV_USE_SPINBOX
1112 else if(lv_obj_check_type(obj, &lv_spinbox_class)) {
1113 lv_obj_add_style(obj, &styles->card, 0);
1114 lv_obj_add_style(obj, &styles->pad_small, 0);
1115 lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
1116 lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
1117 lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_CURSOR);
1118 }
1119 #endif
1120 #if LV_USE_TILEVIEW
1121 else if(lv_obj_check_type(obj, &lv_tileview_class)) {
1122 lv_obj_add_style(obj, &styles->scr, 0);
1123 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
1124 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
1125 }
1126 else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) {
1127 lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
1128 lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
1129 }
1130 #endif
1131
1132 #if LV_USE_TABVIEW
1133 else if(lv_obj_check_type(obj, &lv_tabview_class)) {
1134 lv_obj_add_style(obj, &styles->scr, 0);
1135 lv_obj_add_style(obj, &styles->pad_zero, 0);
1136 }
1137 #endif
1138
1139 #if LV_USE_WIN
1140 else if(lv_obj_check_type(obj, &lv_win_class)) {
1141 lv_obj_add_style(obj, &styles->clip_corner, 0);
1142 }
1143 #endif
1144
1145 #if LV_USE_COLORWHEEL
1146 else if(lv_obj_check_type(obj, &lv_colorwheel_class)) {
1147 lv_obj_add_style(obj, &styles->colorwheel_main, 0);
1148 lv_obj_add_style(obj, &styles->pad_normal, 0);
1149 lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB);
1150 lv_obj_add_style(obj, &styles->pad_normal, LV_PART_KNOB);
1151 }
1152 #endif
1153
1154 #if LV_USE_LED
1155 else if(lv_obj_check_type(obj, &lv_led_class)) {
1156 lv_obj_add_style(obj, &styles->led, 0);
1157 }
1158 #endif
1159 }
1160
1161 /**********************
1162 * STATIC FUNCTIONS
1163 **********************/
1164
style_init_reset(lv_style_t * style)1165 static void style_init_reset(lv_style_t * style)
1166 {
1167 if(inited) {
1168 lv_style_reset(style);
1169 }
1170 else {
1171 lv_style_init(style);
1172 }
1173 }
1174
1175 #endif
1176