1 /**
2 * @file lv_theme_templ.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "lv_theme.h"
10
11 #if LV_USE_THEME_MONO
12
13 /*********************
14 * DEFINES
15 *********************/
16
17 /**********************
18 * TYPEDEFS
19 **********************/
20
21 /**********************
22 * STATIC PROTOTYPES
23 **********************/
24
25 /**********************
26 * STATIC VARIABLES
27 **********************/
28 static lv_theme_t theme;
29 static lv_style_t def;
30 static lv_style_t scr;
31
32 /*Static style definitions*/
33 static lv_style_t light_plain;
34 static lv_style_t dark_plain;
35 static lv_style_t light_frame;
36 static lv_style_t dark_frame;
37
38 /*Saved input parameters*/
39 static lv_font_t * _font;
40
41 /**********************
42 * MACROS
43 **********************/
44
45 /**********************
46 * STATIC FUNCTIONS
47 **********************/
48
basic_init(void)49 static void basic_init(void)
50 {
51 lv_style_copy(&def, &lv_style_plain); /*Initialize the default style*/
52 def.body.main_color = LV_COLOR_WHITE;
53 def.body.grad_color = LV_COLOR_WHITE;
54 def.body.radius = 0;
55 def.body.opa = LV_OPA_COVER;
56 def.body.padding.left = LV_DPI / 10;
57 def.body.padding.right = LV_DPI / 10;
58 def.body.padding.top = LV_DPI / 10;
59 def.body.padding.bottom = LV_DPI / 10;
60 def.body.padding.inner = LV_DPI / 10;
61 def.body.border.color = LV_COLOR_BLACK;
62 def.body.border.width = 1;
63 def.body.border.opa = LV_OPA_COVER;
64 def.body.border.part = LV_BORDER_FULL;
65
66 def.text.font = _font;
67 def.text.color = LV_COLOR_BLACK;
68 def.text.letter_space = 1;
69 def.text.line_space = 1;
70
71 def.line.color = LV_COLOR_BLACK;
72 def.line.opa = LV_OPA_COVER;
73 def.line.width = 1;
74
75 def.image.color = LV_COLOR_BLACK;
76 def.image.intense = LV_OPA_TRANSP;
77 def.image.opa = LV_OPA_COVER;
78
79 lv_style_copy(&scr, &light_plain);
80 scr.body.padding.bottom = 0;
81 scr.body.padding.top = 0;
82 scr.body.padding.left = 0;
83 scr.body.padding.right = 0;
84
85 lv_style_copy(&light_plain, &def);
86
87 lv_style_copy(&light_frame, &light_plain);
88 light_frame.body.radius = LV_DPI / 20;
89
90 lv_style_copy(&dark_plain, &light_plain);
91 dark_plain.body.main_color = LV_COLOR_BLACK;
92 dark_plain.body.grad_color = LV_COLOR_BLACK;
93 dark_plain.body.border.color = LV_COLOR_WHITE;
94 dark_plain.text.color = LV_COLOR_WHITE;
95 dark_plain.line.color = LV_COLOR_WHITE;
96 dark_plain.image.color = LV_COLOR_WHITE;
97
98 lv_style_copy(&dark_frame, &dark_plain);
99 dark_frame.body.radius = LV_DPI / 20;
100
101 theme.style.bg = &def;
102 theme.style.scr = &scr;
103 theme.style.panel = &light_frame;
104 }
105
cont_init(void)106 static void cont_init(void)
107 {
108 #if LV_USE_CONT != 0
109
110 theme.style.cont = &def;
111 #endif
112 }
113
btn_init(void)114 static void btn_init(void)
115 {
116 #if LV_USE_BTN != 0
117
118 theme.style.btn.rel = &light_frame;
119 theme.style.btn.pr = &dark_frame;
120 theme.style.btn.tgl_rel = &dark_frame;
121 theme.style.btn.tgl_pr = &light_frame;
122 theme.style.btn.ina = &light_frame;
123 #endif
124 }
125
label_init(void)126 static void label_init(void)
127 {
128 #if LV_USE_LABEL != 0
129
130 theme.style.label.prim = NULL;
131 theme.style.label.sec = NULL;
132 theme.style.label.hint = NULL;
133 #endif
134 }
135
img_init(void)136 static void img_init(void)
137 {
138 #if LV_USE_IMG != 0
139
140 theme.style.img.light = &def;
141 theme.style.img.dark = &def;
142 #endif
143 }
144
line_init(void)145 static void line_init(void)
146 {
147 #if LV_USE_LINE != 0
148 theme.style.line.decor = NULL;
149 #endif
150 }
151
led_init(void)152 static void led_init(void)
153 {
154 #if LV_USE_LED != 0
155 static lv_style_t led;
156 lv_style_copy(&led, &light_frame);
157 led.body.radius = LV_RADIUS_CIRCLE;
158 led.body.shadow.width = LV_DPI / 8;
159 led.body.shadow.color = LV_COLOR_BLACK;
160 led.body.shadow.type = LV_SHADOW_FULL;
161
162 theme.style.led = &led;
163 #endif
164 }
165
bar_init(void)166 static void bar_init(void)
167 {
168 #if LV_USE_BAR
169 static lv_style_t bar_bg;
170 static lv_style_t bar_indic;
171
172 lv_style_copy(&bar_bg, &light_frame);
173 bar_bg.body.padding.left = LV_DPI / 15;
174 bar_bg.body.padding.right = LV_DPI / 15;
175 bar_bg.body.padding.top = LV_DPI / 15;
176 bar_bg.body.padding.bottom = LV_DPI / 15;
177 bar_bg.body.radius = LV_RADIUS_CIRCLE;
178
179 lv_style_copy(&bar_indic, &dark_frame);
180 bar_indic.body.padding.left = LV_DPI / 30;
181 bar_indic.body.padding.right = LV_DPI / 30;
182 bar_indic.body.padding.top = LV_DPI / 30;
183 bar_indic.body.padding.bottom = LV_DPI / 30;
184 bar_indic.body.radius = LV_RADIUS_CIRCLE;
185
186 theme.style.bar.bg = &bar_bg;
187 theme.style.bar.indic = &bar_indic;
188 #endif
189 }
190
slider_init(void)191 static void slider_init(void)
192 {
193 #if LV_USE_SLIDER != 0
194 static lv_style_t slider_knob;
195 lv_style_copy(&slider_knob, &light_frame);
196 slider_knob.body.radius = LV_RADIUS_CIRCLE;
197 slider_knob.body.padding.left = LV_DPI / 30;
198 slider_knob.body.padding.right = LV_DPI / 30;
199 slider_knob.body.padding.top = LV_DPI / 30;
200 slider_knob.body.padding.bottom = LV_DPI / 30;
201
202 theme.style.slider.bg = theme.style.bar.bg;
203 theme.style.slider.indic = theme.style.bar.indic;
204 theme.style.slider.knob = &slider_knob;
205 #endif
206 }
207
sw_init(void)208 static void sw_init(void)
209 {
210 #if LV_USE_SW != 0
211
212 theme.style.sw.bg = theme.style.slider.bg;
213 theme.style.sw.indic = theme.style.slider.indic;
214 theme.style.sw.knob_off = theme.style.slider.knob;
215 theme.style.sw.knob_on = theme.style.slider.knob;
216 #endif
217 }
218
lmeter_init(void)219 static void lmeter_init(void)
220 {
221 #if LV_USE_LMETER != 0
222 static lv_style_t lmeter_bg;
223 lv_style_copy(&lmeter_bg, &light_frame);
224 lmeter_bg.body.opa = LV_OPA_TRANSP;
225 lmeter_bg.body.main_color = LV_COLOR_BLACK;
226 lmeter_bg.body.grad_color = LV_COLOR_BLACK;
227 lmeter_bg.body.padding.left = LV_DPI / 20;
228 lmeter_bg.body.padding.inner = LV_DPI / 8;
229 lmeter_bg.line.color = LV_COLOR_WHITE;
230 lmeter_bg.line.width = 1;
231
232 theme.style.lmeter = &lmeter_bg;
233 #endif
234 }
235
gauge_init(void)236 static void gauge_init(void)
237 {
238 #if LV_USE_GAUGE != 0
239 static lv_style_t gauge_bg;
240 lv_style_copy(&gauge_bg, theme.style.lmeter);
241 gauge_bg.line.color = LV_COLOR_BLACK;
242 gauge_bg.line.width = 1;
243
244 theme.style.gauge = &gauge_bg;
245 #endif
246 }
247
chart_init(void)248 static void chart_init(void)
249 {
250 #if LV_USE_CHART
251 theme.style.chart = &light_frame;
252 #endif
253 }
254
calendar_init(void)255 static void calendar_init(void)
256 {
257 #if LV_USE_CALENDAR
258 static lv_style_t box;
259 lv_style_copy(&box, &light_plain);
260 box.body.padding.top = LV_DPI / 20;
261 box.body.padding.bottom = LV_DPI / 20;
262
263 /*Can't handle highlighted dates in this theme*/
264 theme.style.calendar.week_box = &box;
265 theme.style.calendar.today_box = &box;
266 #endif
267 }
268
cb_init(void)269 static void cb_init(void)
270 {
271 #if LV_USE_CB != 0
272
273 theme.style.cb.bg = &lv_style_transp;
274 theme.style.cb.box.rel = &light_frame;
275 theme.style.cb.box.pr = &dark_frame;
276 theme.style.cb.box.tgl_rel = &dark_frame;
277 theme.style.cb.box.tgl_pr = &light_frame;
278 theme.style.cb.box.ina = &light_frame;
279 #endif
280 }
281
btnm_init(void)282 static void btnm_init(void)
283 {
284 #if LV_USE_BTNM
285
286 theme.style.btnm.bg = &light_frame;
287 theme.style.btnm.btn.rel = &light_frame;
288 theme.style.btnm.btn.pr = &dark_frame;
289 theme.style.btnm.btn.tgl_rel = &dark_frame;
290 theme.style.btnm.btn.tgl_pr = &light_frame;
291 theme.style.btnm.btn.ina = &light_frame;
292 #endif
293 }
294
kb_init(void)295 static void kb_init(void)
296 {
297 #if LV_USE_KB
298 theme.style.kb.bg = &lv_style_transp_fit;
299 theme.style.kb.btn.rel = &light_frame;
300 theme.style.kb.btn.pr = &light_frame;
301 theme.style.kb.btn.tgl_rel = &dark_frame;
302 theme.style.kb.btn.tgl_pr = &dark_frame;
303 theme.style.kb.btn.ina = &light_frame;
304 #endif
305 }
306
mbox_init(void)307 static void mbox_init(void)
308 {
309 #if LV_USE_MBOX
310
311 theme.style.mbox.bg = &dark_frame;
312 theme.style.mbox.btn.bg = &lv_style_transp_fit;
313 theme.style.mbox.btn.rel = &light_frame;
314 theme.style.mbox.btn.pr = &dark_frame;
315 #endif
316 }
317
page_init(void)318 static void page_init(void)
319 {
320 #if LV_USE_PAGE
321
322 theme.style.page.bg = &light_frame;
323 theme.style.page.scrl = &light_frame;
324 theme.style.page.sb = &dark_frame;
325 #endif
326 }
327
ta_init(void)328 static void ta_init(void)
329 {
330 #if LV_USE_TA
331
332 theme.style.ta.area = &light_frame;
333 theme.style.ta.oneline = &light_frame;
334 theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
335 theme.style.ta.sb = &dark_frame;
336 #endif
337 }
338
list_init(void)339 static void list_init(void)
340 {
341 #if LV_USE_LIST != 0
342
343 theme.style.list.sb = &dark_frame;
344 theme.style.list.bg = &light_frame;
345 theme.style.list.scrl = &lv_style_transp_fit;
346 theme.style.list.btn.rel = &light_plain;
347 theme.style.list.btn.pr = &dark_plain;
348 theme.style.list.btn.tgl_rel = &dark_plain;
349 theme.style.list.btn.tgl_pr = &light_plain;
350 theme.style.list.btn.ina = &light_plain;
351 #endif
352 }
353
ddlist_init(void)354 static void ddlist_init(void)
355 {
356 #if LV_USE_DDLIST != 0
357 static lv_style_t bg;
358 lv_style_copy(&bg, &light_frame);
359 bg.text.line_space = LV_DPI / 12;
360
361 theme.style.ddlist.bg = &bg;
362 theme.style.ddlist.sel = &dark_plain;
363 theme.style.ddlist.sb = &dark_frame;
364 #endif
365 }
366
roller_init(void)367 static void roller_init(void)
368 {
369 #if LV_USE_ROLLER != 0
370 static lv_style_t bg;
371 lv_style_copy(&bg, &light_frame);
372 bg.text.line_space = LV_DPI / 12;
373
374 theme.style.roller.bg = &bg;
375 theme.style.roller.sel = &dark_frame;
376 #endif
377 }
378
tabview_init(void)379 static void tabview_init(void)
380 {
381 #if LV_USE_TABVIEW != 0
382
383 theme.style.tabview.bg = &light_frame;
384 theme.style.tabview.indic = &light_plain;
385 theme.style.tabview.btn.bg = &lv_style_transp_fit;
386 theme.style.tabview.btn.rel = &light_frame;
387 theme.style.tabview.btn.pr = &dark_frame;
388 theme.style.tabview.btn.tgl_rel = &dark_frame;
389 theme.style.tabview.btn.tgl_pr = &light_frame;
390 #endif
391 }
392
win_init(void)393 static void win_init(void)
394 {
395 #if LV_USE_WIN != 0
396 static lv_style_t win_header;
397 lv_style_copy(&win_header, &dark_plain);
398 win_header.body.padding.left = LV_DPI / 30;
399 win_header.body.padding.right = LV_DPI / 30;
400 win_header.body.padding.top = LV_DPI / 30;
401 win_header.body.padding.bottom = LV_DPI / 30;
402
403 theme.style.win.bg = &light_frame;
404 theme.style.win.sb = &dark_frame;
405 theme.style.win.header = &win_header;
406 theme.style.win.content = &lv_style_transp;
407 theme.style.win.btn.rel = &light_frame;
408 theme.style.win.btn.pr = &dark_frame;
409 #endif
410 }
411
412 #if LV_USE_GROUP
413
style_mod(lv_group_t * group,lv_style_t * style)414 static void style_mod(lv_group_t * group, lv_style_t * style)
415 {
416 (void)group; /*Unused*/
417 #if LV_COLOR_DEPTH != 1
418 /*Make the style to be a little bit orange*/
419 style->body.border.opa = LV_OPA_COVER;
420 style->body.border.color = LV_COLOR_BLACK;
421
422 /*If not empty or has border then emphasis the border*/
423 if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
424 #else
425 style->body.border.opa = LV_OPA_COVER;
426 style->body.border.color = LV_COLOR_BLACK;
427 style->body.border.width = 2;
428 #endif
429 }
430
style_mod_edit(lv_group_t * group,lv_style_t * style)431 static void style_mod_edit(lv_group_t * group, lv_style_t * style)
432 {
433 (void)group; /*Unused*/
434 #if LV_COLOR_DEPTH != 1
435 /*Make the style to be a little bit orange*/
436 style->body.border.opa = LV_OPA_COVER;
437 style->body.border.color = LV_COLOR_BLACK;
438
439 /*If not empty or has border then emphasis the border*/
440 if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
441 #else
442 style->body.border.opa = LV_OPA_COVER;
443 style->body.border.color = LV_COLOR_BLACK;
444 style->body.border.width = 3;
445 #endif
446 }
447
448 #endif /*LV_USE_GROUP*/
449
450 /**********************
451 * GLOBAL FUNCTIONS
452 **********************/
453
454 /**
455 * Initialize the mono theme
456 * @param hue [0..360] hue value from HSV color space to define the theme's base color; is not used
457 * in lv_theme_mono
458 * @param font pointer to a font (NULL to use the default)
459 * @return pointer to the initialized theme
460 */
lv_theme_mono_init(uint16_t hue,lv_font_t * font)461 lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font)
462 {
463
464 (void)hue; /*Unused*/
465
466 if(font == NULL) font = LV_FONT_DEFAULT;
467
468 _font = font;
469
470 /*For backward compatibility initialize all theme elements with a default style */
471 uint16_t i;
472 lv_style_t ** style_p = (lv_style_t **)&theme.style;
473 for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
474 *style_p = &def;
475 style_p++;
476 }
477
478 basic_init();
479 cont_init();
480 btn_init();
481 label_init();
482 img_init();
483 line_init();
484 led_init();
485 bar_init();
486 slider_init();
487 sw_init();
488 lmeter_init();
489 gauge_init();
490 chart_init();
491 calendar_init();
492 cb_init();
493 btnm_init();
494 kb_init();
495 mbox_init();
496 page_init();
497 ta_init();
498 list_init();
499 ddlist_init();
500 roller_init();
501 tabview_init();
502 win_init();
503
504 #if LV_USE_GROUP
505 theme.group.style_mod_xcb = style_mod;
506 theme.group.style_mod_edit_xcb = style_mod_edit;
507 #endif
508
509 return &theme;
510 }
511
512 /**
513 * Get a pointer to the theme
514 * @return pointer to the theme
515 */
lv_theme_get_mono(void)516 lv_theme_t * lv_theme_get_mono(void)
517 {
518 return &theme;
519 }
520
521 /**********************
522 * STATIC FUNCTIONS
523 **********************/
524
525 #endif
526