1 /**
2 * @file lv_theme_nemo.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "lv_theme.h"
10
11 #if LV_USE_THEME_NEMO
12
13 /*********************
14 * DEFINES
15 *********************/
16
17 /**********************
18 * TYPEDEFS
19 **********************/
20
21 /**********************
22 * STATIC PROTOTYPES
23 **********************/
24
25 /**********************
26 * STATIC VARIABLES
27 **********************/
28
29 static uint16_t _hue;
30 static lv_font_t * _font;
31 static lv_font_t * _font;
32 static lv_font_t * _font;
33
34 static lv_theme_t theme;
35 static lv_style_t def;
36 static lv_style_t bg;
37 static lv_style_t scr;
38 static lv_style_t panel; /*General fancy background (e.g. to chart or ta)*/
39 static lv_style_t sb;
40 static lv_style_t btn_rel, btn_pr, btn_trel, btn_tpr, btn_ina;
41
42 #if LV_USE_BAR
43 static lv_style_t bar_bg, bar_indic;
44 #endif
45
46 #if LV_USE_SLIDER
47 static lv_style_t slider_knob;
48 #endif
49
50 #if LV_USE_LMETER
51 static lv_style_t lmeter_bg;
52 #endif
53
54 #if LV_USE_DDLIST
55 static lv_style_t ddlist_bg, ddlist_sel;
56 #endif
57
58 #if LV_USE_BTNM
59 static lv_style_t btnm_bg, btnm_rel, btnm_pr, btnm_trel, btnm_ina;
60 #endif
61
62 /**********************
63 * MACROS
64 **********************/
65
66 /**********************
67 * STATIC FUNCTIONS
68 **********************/
69
basic_init(void)70 static void basic_init(void)
71 {
72 /*Default*/
73 lv_style_copy(&def, &lv_style_plain);
74 def.body.opa = LV_OPA_COVER;
75 def.glass = 0;
76
77 def.body.main_color = lv_color_hex3(0x222);
78 def.body.grad_color = lv_color_hex3(0x222);
79 def.body.radius = 0;
80 def.body.padding.left = LV_DPI / 8;
81 def.body.padding.right = LV_DPI / 8;
82 def.body.padding.top = LV_DPI / 8;
83 def.body.padding.bottom = LV_DPI / 8;
84 def.body.padding.inner = LV_DPI / 8;
85 def.body.border.color = LV_COLOR_SILVER;
86 def.body.border.width = 1;
87 def.body.border.opa = LV_OPA_COVER;
88 def.body.shadow.color = LV_COLOR_SILVER;
89 def.body.shadow.width = 0;
90 def.body.shadow.type = LV_SHADOW_FULL;
91
92 def.text.color = lv_color_hex3(0xDDD);
93 def.text.font = _font;
94 def.text.letter_space = 1;
95 def.text.line_space = 2;
96
97 def.image.color = lv_color_hex3(0xDDD);
98 def.image.intense = LV_OPA_TRANSP;
99
100 def.line.color = lv_color_hex3(0xDDD);
101 def.line.width = 1;
102
103 /*Background*/
104 lv_style_copy(&bg, &def);
105 bg.body.main_color = lv_color_hex3(0x005);
106 bg.body.grad_color = lv_color_hex3(0x045);
107 bg.body.border.width = 2;
108 bg.body.border.color = lv_color_hex3(0x666);
109 bg.body.shadow.color = LV_COLOR_SILVER;
110
111 lv_style_copy(&scr, &bg);
112 scr.body.padding.bottom = 0;
113 scr.body.padding.top = 0;
114 scr.body.padding.left = 0;
115 scr.body.padding.right = 0;
116
117 /*Panel*/
118 lv_style_copy(&panel, &def);
119 panel.body.radius = LV_DPI / 10;
120 panel.body.main_color = lv_color_hex3(0x500);
121 panel.body.grad_color = lv_color_hex3(0x505);
122 panel.body.border.color = lv_color_hex3(0xccc);
123 panel.body.border.width = 2;
124 panel.body.border.opa = LV_OPA_60;
125 panel.text.color = lv_color_hsv_to_rgb(_hue, 8, 96);
126 panel.line.color = lv_color_hsv_to_rgb(_hue, 20, 70);
127
128 /*Scrollbar*/
129 lv_style_copy(&sb, &def);
130 sb.body.opa = LV_OPA_50;
131 sb.body.radius = LV_RADIUS_CIRCLE;
132 sb.body.border.color = LV_COLOR_SILVER;
133 sb.body.border.opa = LV_OPA_40;
134 sb.body.border.width = 1;
135 sb.body.main_color = lv_color_hsv_to_rgb(_hue, 33, 92);
136 sb.body.grad_color = lv_color_hsv_to_rgb(_hue, 33, 92);
137 sb.body.padding.left = 1;
138 sb.body.padding.right = 1;
139 sb.body.padding.top = 1;
140 sb.body.padding.bottom = 1;
141 sb.body.padding.inner = LV_DPI / 15; /*Scrollbar width*/
142
143 theme.style.bg = &bg;
144 theme.style.scr = &scr;
145 theme.style.panel = &panel;
146 }
147
btn_init(void)148 static void btn_init(void)
149 {
150 #if LV_USE_BTN != 0
151 lv_style_copy(&btn_rel, &def);
152 btn_rel.glass = 0;
153 btn_rel.body.opa = LV_OPA_TRANSP;
154 btn_rel.body.radius = LV_RADIUS_CIRCLE;
155 btn_rel.body.border.width = 2;
156 btn_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 70, 90);
157 btn_rel.body.border.opa = LV_OPA_80;
158 btn_rel.body.padding.left = LV_DPI / 4;
159 btn_rel.body.padding.right = LV_DPI / 4;
160 btn_rel.body.padding.top = LV_DPI / 6;
161 btn_rel.body.padding.bottom = LV_DPI / 6;
162 btn_rel.body.padding.inner = LV_DPI / 10;
163 btn_rel.text.color = lv_color_hsv_to_rgb(_hue, 8, 96);
164 btn_rel.text.font = _font;
165
166 lv_style_copy(&btn_pr, &btn_rel);
167 btn_pr.body.opa = LV_OPA_COVER;
168 btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50);
169 btn_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50);
170 btn_pr.body.border.opa = LV_OPA_60;
171 btn_pr.text.font = _font;
172 btn_pr.text.color = lv_color_hsv_to_rgb(_hue, 10, 100);
173
174 lv_style_copy(&btn_trel, &btn_pr);
175 btn_trel.body.opa = LV_OPA_COVER;
176 btn_trel.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 60);
177 btn_trel.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 60);
178 btn_trel.body.border.opa = LV_OPA_60;
179 btn_trel.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 90);
180 btn_trel.text.font = _font;
181 btn_trel.text.color = lv_color_hsv_to_rgb(_hue, 0, 100);
182
183 lv_style_copy(&btn_tpr, &btn_trel);
184 btn_tpr.body.opa = LV_OPA_COVER;
185 btn_tpr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50);
186 btn_tpr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50);
187 btn_tpr.body.border.opa = LV_OPA_60;
188 btn_tpr.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 70);
189 btn_tpr.text.font = _font;
190 btn_tpr.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
191
192 lv_style_copy(&btn_ina, &btn_rel);
193 btn_ina.body.border.opa = LV_OPA_60;
194 btn_ina.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 50);
195 btn_ina.text.font = _font;
196 btn_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
197
198 theme.style.btn.rel = &btn_rel;
199 theme.style.btn.pr = &btn_pr;
200 theme.style.btn.tgl_rel = &btn_trel;
201 theme.style.btn.tgl_pr = &btn_tpr;
202 theme.style.btn.ina = &btn_ina;
203 #endif
204 }
205
label_init(void)206 static void label_init(void)
207 {
208 #if LV_USE_LABEL != 0
209 static lv_style_t label_prim, label_sec, label_hint;
210
211 lv_style_copy(&label_prim, &def);
212 label_prim.text.font = _font;
213 label_prim.text.color = lv_color_hsv_to_rgb(_hue, 5, 96);
214
215 lv_style_copy(&label_sec, &label_prim);
216 label_sec.text.color = lv_color_hsv_to_rgb(_hue, 40, 85);
217
218 lv_style_copy(&label_hint, &label_prim);
219 label_hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 70);
220
221 theme.style.label.prim = &label_prim;
222 theme.style.label.sec = &label_sec;
223 theme.style.label.hint = &label_hint;
224 #endif
225 }
226
bar_init(void)227 static void bar_init(void)
228 {
229 #if LV_USE_BAR
230 lv_style_copy(&bar_bg, &def);
231 bar_bg.body.opa = LV_OPA_30;
232 bar_bg.body.radius = LV_RADIUS_CIRCLE;
233 bar_bg.body.main_color = LV_COLOR_WHITE;
234 bar_bg.body.grad_color = LV_COLOR_SILVER;
235 bar_bg.body.border.width = 2;
236 bar_bg.body.border.color = LV_COLOR_SILVER;
237 bar_bg.body.border.opa = LV_OPA_20;
238 bar_bg.body.padding.left = 0;
239 bar_bg.body.padding.right = 0;
240 bar_bg.body.padding.top = LV_DPI / 10;
241 bar_bg.body.padding.bottom = LV_DPI / 10;
242 bar_bg.body.padding.inner = 0;
243
244 lv_style_copy(&bar_indic, &def);
245 bar_indic.body.radius = LV_RADIUS_CIRCLE;
246 bar_indic.body.border.width = 2;
247 bar_indic.body.border.color = LV_COLOR_SILVER;
248 bar_indic.body.border.opa = LV_OPA_70;
249 bar_indic.body.padding.left = 0;
250 bar_indic.body.padding.right = 0;
251 bar_indic.body.padding.top = 0;
252 bar_indic.body.padding.bottom = 0;
253 bar_indic.body.shadow.width = LV_DPI / 20;
254 bar_indic.body.shadow.color = lv_color_hsv_to_rgb(_hue, 20, 90);
255 bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80);
256 bar_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80);
257
258 theme.style.bar.bg = &bar_bg;
259 theme.style.bar.indic = &bar_indic;
260 #endif
261 }
262
img_init(void)263 static void img_init(void)
264 {
265 #if LV_USE_IMG != 0
266 static lv_style_t img_light, img_dark;
267 lv_style_copy(&img_light, &def);
268 img_light.image.color = lv_color_hsv_to_rgb(_hue, 15, 85);
269 img_light.image.intense = LV_OPA_80;
270
271 lv_style_copy(&img_dark, &def);
272 img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 65);
273 img_light.image.intense = LV_OPA_80;
274
275 theme.style.img.light = &img_light;
276 theme.style.img.dark = &img_dark;
277 #endif
278 }
279
line_init(void)280 static void line_init(void)
281 {
282 #if LV_USE_LINE != 0
283 static lv_style_t line_decor;
284 lv_style_copy(&line_decor, &def);
285 line_decor.line.color = lv_color_hsv_to_rgb(_hue, 50, 50);
286 line_decor.line.width = 1;
287
288 theme.style.line.decor = &line_decor;
289 #endif
290 }
291
led_init(void)292 static void led_init(void)
293 {
294 #if LV_USE_LED != 0
295 static lv_style_t led;
296 lv_style_copy(&led, &lv_style_pretty_color);
297 led.body.shadow.width = LV_DPI / 10;
298 led.body.radius = LV_RADIUS_CIRCLE;
299 led.body.border.width = LV_DPI / 30;
300 led.body.border.opa = LV_OPA_30;
301 led.body.main_color = lv_color_hsv_to_rgb(_hue, 100, 100);
302 led.body.grad_color = lv_color_hsv_to_rgb(_hue, 100, 40);
303 led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60);
304 led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100);
305
306 theme.style.led = &led;
307 #endif
308 }
309
slider_init(void)310 static void slider_init(void)
311 {
312 #if LV_USE_SLIDER != 0
313 lv_style_copy(&slider_knob, &def);
314 slider_knob.body.opa = LV_OPA_60;
315 slider_knob.body.radius = LV_RADIUS_CIRCLE;
316 slider_knob.body.main_color = LV_COLOR_PURPLE;
317 slider_knob.body.grad_color = LV_COLOR_SILVER;
318 slider_knob.body.border.width = 2;
319 slider_knob.body.border.color = LV_COLOR_ORANGE;
320 slider_knob.body.border.opa = LV_OPA_50;
321
322 theme.style.slider.bg = &bar_bg;
323 theme.style.slider.indic = &bar_indic;
324 theme.style.slider.knob = &slider_knob;
325 #endif
326 }
327
sw_init(void)328 static void sw_init(void)
329 {
330 #if LV_USE_SW != 0
331 static lv_style_t sw_bg, sw_indic, sw_knob;
332 lv_style_copy(&sw_bg, &bar_bg);
333 sw_bg.body.opa = LV_OPA_COVER;
334 sw_bg.body.padding.left = -2;
335 sw_bg.body.padding.right = -2;
336 sw_bg.body.padding.top = -2;
337 sw_bg.body.padding.bottom = -2;
338 sw_bg.body.main_color = lv_color_hex3(0x666);
339 sw_bg.body.grad_color = lv_color_hex3(0x999);
340 sw_bg.body.border.width = 2;
341 sw_bg.body.border.opa = LV_OPA_50;
342
343 lv_style_copy(&sw_indic, &bar_indic);
344 sw_indic.body.shadow.width = LV_DPI / 20;
345 sw_indic.body.padding.left = 0;
346 sw_indic.body.padding.right = 0;
347 sw_indic.body.padding.top = 0;
348 sw_indic.body.padding.bottom = 0;
349
350 lv_style_copy(&sw_knob, &slider_knob);
351 sw_knob.body.opa = LV_OPA_80;
352
353 theme.style.sw.bg = &sw_bg;
354 theme.style.sw.indic = &sw_indic;
355 theme.style.sw.knob_off = &sw_knob;
356 theme.style.sw.knob_on = &sw_knob;
357 #endif
358 }
359
lmeter_init(void)360 static void lmeter_init(void)
361 {
362 #if LV_USE_LMETER != 0
363 lv_style_copy(&lmeter_bg, &def);
364 lmeter_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 70);
365 lmeter_bg.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 80);
366 lmeter_bg.body.padding.left = LV_DPI / 8; /*Scale line length*/
367 lmeter_bg.line.color = lv_color_hex3(0x500);
368 lmeter_bg.line.width = 2;
369
370 theme.style.lmeter = &lmeter_bg;
371
372 #endif
373 }
374
gauge_init(void)375 static void gauge_init(void)
376 {
377 #if LV_USE_GAUGE != 0
378 static lv_style_t gauge_bg;
379 lv_style_copy(&gauge_bg, &def);
380 gauge_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 20, 100);
381 gauge_bg.body.grad_color = gauge_bg.body.main_color;
382 gauge_bg.body.padding.left = LV_DPI / 16; /*Scale line length*/
383 gauge_bg.body.padding.right = LV_DPI / 16; /*Scale line length*/
384 gauge_bg.body.padding.top = LV_DPI / 20; /*Needle center size*/
385 gauge_bg.body.padding.bottom = LV_DPI / 20; /*Needle center size*/
386 gauge_bg.body.padding.inner = LV_DPI / 12; /*Label - scale distance*/
387 gauge_bg.body.border.color = lv_color_hex3(0x500);
388 gauge_bg.line.color = lv_color_hsv_to_rgb(_hue, 80, 75);
389 gauge_bg.line.width = 2;
390 gauge_bg.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
391 gauge_bg.text.font = _font;
392
393 theme.style.gauge = &gauge_bg;
394 #endif
395 }
396
arc_init(void)397 static void arc_init(void)
398 {
399 #if LV_USE_ARC != 0
400
401 static lv_style_t arc;
402 lv_style_copy(&arc, &def);
403 arc.line.width = 10;
404 arc.line.color = lv_color_hsv_to_rgb(_hue, 70, 90);
405 arc.line.rounded = 1;
406
407 /*For preloader*/
408 arc.body.border.width = 0;
409
410 theme.style.arc = &arc;
411 #endif
412 }
413
preload_init(void)414 static void preload_init(void)
415 {
416 #if LV_USE_PRELOAD != 0
417
418 theme.style.preload = theme.style.arc;
419 #endif
420 }
421
chart_init(void)422 static void chart_init(void)
423 {
424 #if LV_USE_CHART
425 theme.style.chart = &panel;
426 #endif
427 }
428
calendar_init(void)429 static void calendar_init(void)
430 {
431 #if LV_USE_CALENDAR != 0
432 static lv_style_t ina_days;
433 lv_style_copy(&ina_days, &def);
434 ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 50);
435
436 static lv_style_t high_days;
437 lv_style_copy(&high_days, &def);
438 high_days.text.color = lv_color_hsv_to_rgb(_hue, 50, 90);
439
440 static lv_style_t week_box;
441 lv_style_copy(&week_box, &def);
442 week_box.body.opa = LV_OPA_TRANSP;
443 week_box.body.border.color = theme.style.panel->body.border.color;
444 week_box.body.padding.top = LV_DPI / 20;
445 week_box.body.padding.bottom = LV_DPI / 20;
446
447 static lv_style_t today_box;
448 lv_style_copy(&today_box, &def);
449 today_box.body.main_color = LV_COLOR_WHITE;
450 today_box.body.grad_color = LV_COLOR_WHITE;
451 today_box.body.padding.top = LV_DPI / 20;
452 today_box.body.padding.bottom = LV_DPI / 20;
453 today_box.body.radius = 0;
454
455 theme.style.calendar.bg = theme.style.panel;
456 theme.style.calendar.header = theme.style.label.prim;
457 theme.style.calendar.inactive_days = theme.style.label.hint;
458 theme.style.calendar.highlighted_days = theme.style.label.sec;
459 theme.style.calendar.week_box = &week_box;
460 theme.style.calendar.today_box = &week_box;
461 theme.style.calendar.header_pr = theme.style.label.prim;
462 #endif
463 }
464
cb_init(void)465 static void cb_init(void)
466 {
467 #if LV_USE_CB != 0
468 static lv_style_t cb_bg, cb_rel, cb_pr, cb_trel, cb_tpr, cb_ina;
469 lv_style_copy(&cb_rel, &bg);
470 cb_rel.body.radius = LV_DPI / 20;
471 cb_rel.body.border.width = 1;
472 cb_rel.body.border.color = LV_COLOR_ORANGE;
473 cb_rel.body.main_color = LV_COLOR_PURPLE;
474 cb_rel.body.grad_color = LV_COLOR_SILVER;
475
476 lv_style_copy(&cb_bg, &bg);
477 cb_bg.body.opa = LV_OPA_TRANSP;
478 cb_bg.body.border.width = 0;
479 cb_bg.body.padding.inner = LV_DPI / 8;
480 cb_bg.body.padding.left = 0;
481 cb_bg.body.padding.right = 0;
482 cb_bg.body.padding.top = 0;
483 cb_bg.body.padding.bottom = 0;
484 cb_bg.text.font = _font;
485
486 lv_style_copy(&cb_pr, &cb_rel);
487 cb_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 90);
488 cb_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 82);
489
490 lv_style_copy(&cb_trel, &cb_rel);
491 cb_trel.body.border.width = 4;
492 cb_trel.body.border.color = LV_COLOR_WHITE;
493 cb_trel.body.border.opa = LV_OPA_60;
494 cb_trel.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 82);
495 cb_trel.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 62);
496
497 lv_style_copy(&cb_tpr, &cb_trel);
498 cb_tpr.body.border.color = LV_COLOR_SILVER;
499 cb_tpr.body.border.opa = LV_OPA_70;
500 cb_tpr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 72);
501 cb_tpr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 52);
502
503 lv_style_copy(&cb_ina, &cb_trel);
504 cb_ina.body.border.width = 1;
505 cb_ina.body.border.color = LV_COLOR_GRAY;
506 cb_ina.body.main_color = LV_COLOR_PURPLE;
507 cb_ina.body.grad_color = LV_COLOR_SILVER;
508
509 theme.style.cb.bg = &cb_bg;
510 theme.style.cb.box.rel = &cb_rel;
511 theme.style.cb.box.pr = &cb_pr;
512 theme.style.cb.box.tgl_rel = &cb_trel;
513 theme.style.cb.box.tgl_pr = &cb_tpr;
514 theme.style.cb.box.ina = &cb_ina;
515 #endif
516 }
517
btnm_init(void)518 static void btnm_init(void)
519 {
520 #if LV_USE_BTNM
521 lv_style_copy(&btnm_bg, &lv_style_transp_tight);
522 btnm_bg.body.border.width = 1;
523 btnm_bg.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 80);
524 btnm_bg.body.border.opa = LV_OPA_COVER;
525 btnm_bg.body.radius = LV_DPI / 8;
526
527 lv_style_copy(&btnm_rel, &lv_style_plain);
528 btnm_rel.body.opa = LV_OPA_TRANSP;
529 btnm_rel.body.radius = LV_DPI / 8;
530 btnm_rel.text.color = lv_color_hsv_to_rgb(_hue, 60, 80);
531 btnm_rel.text.font = _font;
532
533 lv_style_copy(&btnm_pr, &lv_style_plain);
534 btnm_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 70);
535 btnm_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 70);
536 btnm_pr.body.radius = LV_DPI / 8;
537 btnm_pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 40);
538 btnm_pr.text.font = _font;
539
540 lv_style_copy(&btnm_trel, &btnm_rel);
541 btnm_trel.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 80);
542 btnm_trel.body.border.width = 3;
543
544 lv_style_copy(&btnm_ina, &btnm_rel);
545 btnm_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 60);
546
547 theme.style.btnm.bg = &btnm_bg;
548 theme.style.btnm.btn.rel = &btnm_rel;
549 theme.style.btnm.btn.pr = &btnm_pr;
550 theme.style.btnm.btn.tgl_rel = &btnm_trel;
551 theme.style.btnm.btn.tgl_pr = &btnm_pr;
552 theme.style.btnm.btn.ina = &btnm_ina;
553 #endif
554 }
555
kb_init(void)556 static void kb_init(void)
557 {
558 #if LV_USE_KB
559 theme.style.kb.bg = &btnm_bg;
560 theme.style.kb.btn.rel = &btnm_rel;
561 theme.style.kb.btn.pr = &btnm_pr;
562 theme.style.kb.btn.tgl_rel = &btnm_trel;
563 theme.style.kb.btn.tgl_pr = &btnm_pr;
564 theme.style.kb.btn.ina = &btnm_ina;
565 #endif
566 }
567
mbox_init(void)568 static void mbox_init(void)
569 {
570 #if LV_USE_MBOX
571 static lv_style_t mbox_bg;
572 lv_style_copy(&mbox_bg, &panel);
573 mbox_bg.body.shadow.width = LV_DPI / 12;
574
575 theme.style.mbox.bg = &mbox_bg;
576 theme.style.mbox.btn.bg = &lv_style_transp;
577 theme.style.mbox.btn.rel = &btn_trel;
578 theme.style.mbox.btn.pr = &btn_tpr;
579 #endif
580 }
581
page_init(void)582 static void page_init(void)
583 {
584 #if LV_USE_PAGE
585 theme.style.page.bg = &panel;
586 theme.style.page.scrl = &lv_style_transp_fit;
587 theme.style.page.sb = &sb;
588 #endif
589 }
590
ta_init(void)591 static void ta_init(void)
592 {
593 #if LV_USE_TA
594 theme.style.ta.area = &panel;
595 theme.style.ta.oneline = &panel;
596 theme.style.ta.cursor = NULL;
597 theme.style.ta.sb = &sb;
598 #endif
599 }
600
spinbox_init(void)601 static void spinbox_init(void)
602 {
603 #if LV_USE_SPINBOX
604 theme.style.spinbox.bg = &panel;
605 theme.style.spinbox.cursor = theme.style.ta.cursor;
606 theme.style.spinbox.sb = theme.style.ta.sb;
607 #endif
608 }
609
list_init(void)610 static void list_init(void)
611 {
612 #if LV_USE_LIST != 0
613 static lv_style_t list_bg, list_rel, list_pr, list_trel, list_tpr, list_ina;
614 lv_style_copy(&list_rel, &def);
615 list_rel.body.opa = LV_OPA_TRANSP;
616 list_rel.body.border.width = 1;
617 list_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 50, 85);
618 list_rel.body.border.opa = LV_OPA_COVER;
619 list_rel.text.color = lv_color_hsv_to_rgb(_hue, 10, 94);
620 list_rel.text.font = _font;
621
622 lv_style_copy(&list_pr, &list_rel);
623 list_pr.body.opa = LV_OPA_TRANSP;
624 list_pr.body.opa = LV_OPA_COVER;
625 list_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 34, 41);
626 list_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 34, 41);
627 list_pr.text.color = lv_color_hsv_to_rgb(_hue, 7, 96);
628
629 lv_style_copy(&list_trel, &list_rel);
630 lv_style_copy(&list_tpr, &list_pr);
631 lv_style_copy(&list_ina, &def);
632
633 lv_style_copy(&list_bg, &list_rel);
634 list_bg.body.padding.left = 0;
635 list_bg.body.padding.right = 0;
636 list_bg.body.padding.top = 0;
637 list_bg.body.padding.bottom = 0;
638
639 theme.style.list.sb = &sb;
640 theme.style.list.bg = &list_bg;
641 theme.style.list.scrl = &lv_style_transp_tight;
642 theme.style.list.btn.rel = &list_rel;
643 theme.style.list.btn.pr = &list_pr;
644 theme.style.list.btn.tgl_rel = &list_trel;
645 theme.style.list.btn.tgl_pr = &list_tpr;
646 theme.style.list.btn.ina = &list_ina;
647 #endif
648 }
649
ddlist_init(void)650 static void ddlist_init(void)
651 {
652 #if LV_USE_DDLIST != 0
653 lv_style_copy(&ddlist_bg, &panel);
654 ddlist_bg.text.line_space = LV_DPI / 8;
655 ddlist_bg.body.padding.left = LV_DPI / 6;
656 ddlist_bg.body.padding.right = LV_DPI / 6;
657 ddlist_bg.body.padding.top = LV_DPI / 6;
658 ddlist_bg.body.padding.bottom = LV_DPI / 6;
659
660 lv_style_copy(&ddlist_sel, &panel);
661 ddlist_sel.body.main_color = lv_color_hsv_to_rgb(_hue, 45, 70);
662 ddlist_sel.body.grad_color = lv_color_hsv_to_rgb(_hue, 45, 70);
663 ddlist_sel.body.opa = LV_OPA_COVER;
664 ddlist_sel.body.radius = 0;
665
666 theme.style.ddlist.bg = &ddlist_bg;
667 theme.style.ddlist.sel = &ddlist_sel;
668 theme.style.ddlist.sb = &sb;
669 #endif
670 }
671
roller_init(void)672 static void roller_init(void)
673 {
674 #if LV_USE_ROLLER != 0
675 static lv_style_t roller_bg, roller_sel;
676 lv_style_copy(&roller_bg, &ddlist_bg);
677 roller_bg.text.line_space = LV_DPI / 6;
678 roller_bg.body.radius = LV_DPI / 20;
679 roller_bg.body.main_color = lv_color_hex3(0x500);
680 roller_bg.body.grad_color = lv_color_hex3(0x005);
681 roller_bg.body.border.opa = LV_OPA_30;
682 roller_bg.text.opa = LV_OPA_70;
683 roller_bg.text.color = lv_color_hsv_to_rgb(_hue, 20, 70);
684 roller_bg.body.shadow.width = 0;
685
686 lv_style_copy(&roller_sel, &panel);
687 roller_sel.body.opa = LV_OPA_TRANSP;
688 roller_sel.body.radius = 0;
689 roller_sel.text.opa = LV_OPA_COVER;
690 roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 70, 95);
691
692 theme.style.roller.bg = &roller_bg;
693 theme.style.roller.sel = &roller_sel;
694 #endif
695 }
696
tabview_init(void)697 static void tabview_init(void)
698 {
699 #if LV_USE_TABVIEW != 0
700 static lv_style_t tab_rel, tab_pr, tab_trel, tab_tpr, tab_indic;
701 lv_style_copy(&tab_rel, &def);
702 tab_rel.body.main_color = lv_color_hex3(0x500);
703 tab_rel.body.grad_color = lv_color_hex3(0x005);
704 tab_rel.body.padding.left = 0;
705 tab_rel.body.padding.right = 0;
706 tab_rel.body.padding.top = LV_DPI / 6;
707 tab_rel.body.padding.bottom = LV_DPI / 6;
708 tab_rel.body.padding.inner = 0;
709 tab_rel.body.border.width = 1;
710 tab_rel.body.border.color = LV_COLOR_SILVER;
711 tab_rel.body.border.opa = LV_OPA_40;
712 tab_rel.text.color = lv_color_hex3(0xDDD);
713 tab_rel.text.font = _font;
714
715 lv_style_copy(&tab_pr, &tab_rel);
716 tab_pr.body.main_color = lv_color_hex3(0x005);
717 tab_pr.body.grad_color = lv_color_hex3(0x500);
718
719 lv_style_copy(&tab_trel, &def);
720 tab_trel.body.opa = LV_OPA_TRANSP;
721 tab_trel.body.padding.left = 0;
722 tab_trel.body.padding.right = 0;
723 tab_trel.body.padding.top = LV_DPI / 6;
724 tab_trel.body.padding.bottom = LV_DPI / 6;
725 tab_trel.body.padding.inner = 0;
726 tab_trel.body.border.width = 1;
727 tab_trel.body.border.color = LV_COLOR_SILVER;
728 tab_trel.body.border.opa = LV_OPA_40;
729 tab_trel.text.color = lv_color_hsv_to_rgb(_hue, 10, 94);
730 tab_trel.text.font = _font;
731
732 lv_style_copy(&tab_tpr, &def);
733 tab_tpr.body.main_color = LV_COLOR_GRAY;
734 tab_tpr.body.grad_color = LV_COLOR_GRAY;
735 tab_tpr.body.padding.left = 0;
736 tab_tpr.body.padding.right = 0;
737 tab_tpr.body.padding.top = LV_DPI / 6;
738 tab_tpr.body.padding.bottom = LV_DPI / 6;
739 tab_tpr.body.padding.inner = 0;
740 tab_tpr.body.border.width = 1;
741 tab_tpr.body.border.color = LV_COLOR_SILVER;
742 tab_tpr.body.border.opa = LV_OPA_40;
743 tab_tpr.text.color = lv_color_hsv_to_rgb(_hue, 10, 94);
744 tab_tpr.text.font = _font;
745
746 lv_style_copy(&tab_indic, &def);
747 tab_indic.body.border.width = 0;
748 tab_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 80, 87);
749 tab_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 87);
750 tab_indic.body.padding.inner = LV_DPI / 10; /*Indicator height*/
751
752 theme.style.tabview.bg = &bg;
753 theme.style.tabview.indic = &tab_indic;
754 theme.style.tabview.btn.bg = &lv_style_transp_tight;
755 theme.style.tabview.btn.rel = &tab_rel;
756 theme.style.tabview.btn.pr = &tab_pr;
757 theme.style.tabview.btn.tgl_rel = &tab_trel;
758 theme.style.tabview.btn.tgl_pr = &tab_tpr;
759 #endif
760 }
761
tileview_init(void)762 static void tileview_init(void)
763 {
764 #if LV_USE_TILEVIEW != 0
765 theme.style.tileview.bg = &lv_style_transp_tight;
766 theme.style.tileview.scrl = &lv_style_transp_tight;
767 theme.style.tileview.sb = theme.style.page.sb;
768 #endif
769 }
770
table_init(void)771 static void table_init(void)
772 {
773 #if LV_USE_TABLE != 0
774 static lv_style_t cell;
775 lv_style_copy(&cell, &panel);
776 cell.body.radius = 0;
777 cell.body.border.width = 1;
778
779 theme.style.table.bg = &lv_style_transp_tight;
780 theme.style.table.cell = &cell;
781 #endif
782 }
783
win_init(void)784 static void win_init(void)
785 {
786 #if LV_USE_WIN != 0
787 static lv_style_t win_header;
788
789 lv_style_copy(&win_header, &panel);
790 win_header.body.radius = 0;
791 win_header.body.padding.left = LV_DPI / 12;
792 win_header.body.padding.right = LV_DPI / 12;
793 win_header.body.padding.top = LV_DPI / 20;
794 win_header.body.padding.bottom = LV_DPI / 20;
795 win_header.body.border.opa = panel.body.border.opa;
796 win_header.body.border.width = panel.body.border.width;
797 win_header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
798 win_header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
799
800 theme.style.win.bg = &bg;
801 theme.style.win.sb = &sb;
802 theme.style.win.header = &win_header;
803 theme.style.win.content = &lv_style_transp;
804 theme.style.win.btn.rel = &btn_rel;
805 theme.style.win.btn.pr = &btn_pr;
806 #endif
807 }
808
809 #if LV_USE_GROUP
810
style_mod(lv_group_t * group,lv_style_t * style)811 static void style_mod(lv_group_t * group, lv_style_t * style)
812 {
813 (void)group; /*Unused*/
814 #if LV_COLOR_DEPTH != 1
815 style->body.border.width = 2;
816 style->body.border.color = LV_COLOR_SILVER;
817 style->body.border.opa = LV_OPA_70;
818 style->body.shadow.width = LV_DPI / 20;
819 style->body.shadow.color = lv_color_hsv_to_rgb(_hue, 20, 90);
820 style->body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80);
821 style->body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80);
822 #else
823 style->body.border.opa = LV_OPA_COVER;
824 style->body.border.color = LV_COLOR_BLACK;
825 style->body.border.width = 2;
826 #endif
827 }
828
style_mod_edit(lv_group_t * group,lv_style_t * style)829 static void style_mod_edit(lv_group_t * group, lv_style_t * style)
830 {
831 (void)group; /*Unused*/
832 #if LV_COLOR_DEPTH != 1
833 /*Make the style to be a little bit orange*/
834 style->body.border.opa = LV_OPA_COVER;
835 style->body.border.color = LV_COLOR_GREEN;
836
837 /*If not empty or has border then emphasis the border*/
838 if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
839
840 style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70);
841 style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);
842 style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60);
843
844 style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70);
845 #else
846 style->body.border.opa = LV_OPA_COVER;
847 style->body.border.color = LV_COLOR_BLACK;
848 style->body.border.width = 3;
849 #endif
850 }
851
852 #endif /*LV_USE_GROUP*/
853
854 /**********************
855 * GLOBAL FUNCTIONS
856 **********************/
857
858 /**
859 * Initialize the nemo theme
860 * @param hue [0..360] hue value from HSV color space to define the theme's base color
861 * @param font pointer to a font (NULL to use the default)
862 * @return pointer to the initialized theme
863 */
lv_theme_nemo_init(uint16_t hue,lv_font_t * font)864 lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font)
865 {
866 if(font == NULL) font = LV_FONT_DEFAULT;
867
868 _hue = hue;
869 _font = font;
870
871 /*For backward compatibility initialize all theme elements with a default style */
872 uint16_t i;
873 lv_style_t ** style_p = (lv_style_t **)&theme.style;
874 for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
875 *style_p = &def;
876 style_p++;
877 }
878
879 basic_init();
880 btn_init();
881 label_init();
882 bar_init();
883 img_init();
884 line_init();
885 led_init();
886 slider_init();
887 sw_init();
888 lmeter_init();
889 gauge_init();
890 arc_init();
891 preload_init();
892 chart_init();
893 calendar_init();
894 cb_init();
895 btnm_init();
896 kb_init();
897 mbox_init();
898 page_init();
899 ta_init();
900 spinbox_init();
901 list_init();
902 ddlist_init();
903 roller_init();
904 tabview_init();
905 tileview_init();
906 table_init();
907 win_init();
908
909 #if LV_USE_GROUP
910 theme.group.style_mod_xcb = style_mod;
911 theme.group.style_mod_edit_xcb = style_mod_edit;
912 #endif
913
914 return &theme;
915 }
916
917 /**
918 * Get a pointer to the theme
919 * @return pointer to the theme
920 */
lv_theme_get_nemo(void)921 lv_theme_t * lv_theme_get_nemo(void)
922 {
923 return &theme;
924 }
925
926 /**********************
927 * STATIC FUNCTIONS
928 **********************/
929
930 #endif
931