lv_theme: integrate into the library

add lv_theme
This commit is contained in:
Gabor Kiss-Vamosi
2017-11-16 15:32:33 +01:00
parent e3378d23d4
commit b973dd342a
31 changed files with 1809 additions and 116 deletions

304
lv_themes/lv_theme.c Normal file
View File

@@ -0,0 +1,304 @@
/**
* @file lv_theme.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lvgl/lvgl.h"
#include "lv_theme.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void create_tab1(lv_theme_t * th, lv_obj_t *parent);
static void create_tab2(lv_theme_t * th, lv_obj_t *parent);
static void create_tab3(lv_theme_t * th, lv_obj_t *parent);
/**********************
* STATIC VARIABLES
**********************/
static lv_theme_t *current_theme;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Set a theme for the system.
* From now, all the created objects will use styles from this theme by default
* @param th pointer to theme (return value of: 'lv_theme_init_xxx()')
*/
void lv_theme_set_current(lv_theme_t *th)
{
current_theme = th;
}
/**
* Get the current system theme.
* @return pointer to the current system theme. NULL if not set.
*/
lv_theme_t * lv_theme_get_current(void)
{
return current_theme;
}
/**
* Create a test screen with a lot objects and apply the given theme on them
* @param th pointer to a theme
*/
void lv_theme_create_test_screen(lv_theme_t *th)
{
lv_theme_set_current(th);
lv_obj_t *scr = lv_cont_create(NULL, NULL);
lv_scr_load(scr);
lv_cont_set_style(scr, th->bg);
lv_obj_t *tv = lv_tabview_create(scr, NULL);
lv_obj_set_size(tv, LV_HOR_RES, LV_VER_RES);
lv_obj_t *tab1 = lv_tabview_add_tab(tv, "Tab 1");
lv_obj_t *tab2 = lv_tabview_add_tab(tv, "Tab 2");
lv_obj_t *tab3 = lv_tabview_add_tab(tv, "Tab 3");
create_tab1(th, tab1);
create_tab2(th, tab2);
create_tab3(th, tab3);
lv_tabview_set_current_tab(tv, 2, false);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void create_tab1(lv_theme_t * th, lv_obj_t *parent)
{
lv_page_set_scrl_layout(parent, LV_CONT_LAYOUT_PRETTY);
static lv_style_t h_style;
lv_style_copy(&h_style, &lv_style_transp);
h_style.body.padding.inner = LV_DPI / 4;
h_style.body.padding.hor = LV_DPI / 4;
h_style.body.padding.ver = LV_DPI / 6;
lv_obj_t *h = lv_cont_create(parent, NULL);
lv_obj_set_style(h, &h_style);
lv_cont_set_fit(h, true, true);
lv_cont_set_layout(h, LV_CONT_LAYOUT_COL_M);
lv_obj_t *btn = lv_btn_create(h, NULL);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, th->btn.sm.rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, th->btn.sm.pr);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, th->btn.sm.tgl_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, th->btn.sm.tgl_pr);
lv_btn_set_style(btn, LV_BTN_STYLE_INA, th->btn.sm.ina);
lv_btn_set_fit(btn, true, true);
lv_btn_set_toggle(btn, true);
lv_obj_t *btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Small");
btn = lv_btn_create(h, btn);
lv_btn_toggle(btn);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Toggled");
btn = lv_btn_create(h, btn);
lv_btn_set_state(btn, LV_BTN_STATE_INA);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Inactive");
btn = lv_btn_create(h, btn);
lv_btn_set_state(btn, LV_BTN_STATE_REL);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Medium");
btn = lv_btn_create(h, btn);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, th->btn.lg.rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, th->btn.lg.pr);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, th->btn.lg.tgl_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, th->btn.lg.tgl_pr);
lv_btn_set_style(btn, LV_BTN_STYLE_INA, th->btn.lg.ina);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Large");
lv_obj_t *label = lv_label_create(h, NULL);
lv_label_set_text(label, "Small");
lv_obj_set_style(label, th->label.sm);
label = lv_label_create(h, NULL);
lv_label_set_text(label, "Medium");
lv_obj_set_style(label, th->label.md);
label = lv_label_create(h, NULL);
lv_label_set_text(label, "Large");
lv_obj_set_style(label, th->label.lg);
lv_obj_set_protect(label, LV_PROTECT_FOLLOW);
h = lv_cont_create(parent, h);
lv_obj_t *sw_h = lv_cont_create(h, NULL);
lv_cont_set_style(sw_h, &lv_style_transp);
lv_cont_set_fit(sw_h, false, true);
lv_obj_set_width(sw_h, LV_HOR_RES / 4);
lv_cont_set_layout(sw_h, LV_CONT_LAYOUT_PRETTY);
lv_obj_t *sw = lv_sw_create(sw_h, NULL);
sw = lv_sw_create(sw_h, sw);
lv_sw_set_on(sw);
lv_obj_t *bar = lv_bar_create(h, NULL);
lv_bar_set_value(bar, 70);
lv_obj_t *slider = lv_slider_create(h, NULL);
lv_obj_set_height(slider, LV_DPI / 2);
lv_bar_set_value(slider, 70);
lv_obj_t *line = lv_line_create(h, NULL);
static const point_t line_p[] = {{0,0},{LV_HOR_RES / 5, 0}};
lv_line_set_points(line, line_p, 2);
lv_line_set_style(line, th->line.decor);
lv_obj_t *ta = lv_ta_create(h, NULL);
lv_obj_set_style(ta, th->ta.oneline);
lv_ta_set_text(ta, "Some text");
lv_ta_set_one_line(ta, true);
lv_obj_t *cb = lv_cb_create(h, NULL);
cb = lv_cb_create(h, cb);
lv_btn_set_state(cb, LV_BTN_STATE_TGL_REL);
lv_obj_t *ddlist = lv_ddlist_create(h, NULL);
lv_ddlist_open(ddlist, false);
lv_ddlist_set_selected(ddlist, 1);
static const char *btnm_str[] = {"1", "2", "3", SYMBOL_OK, SYMBOL_CLOSE, ""};
lv_obj_t *btnm = lv_btnm_create(h, NULL);
lv_obj_set_size(btnm,LV_HOR_RES / 4, 2 * LV_DPI / 3);
lv_btnm_set_map(btnm, btnm_str);
((lv_btnm_ext_t *) btnm->ext_attr)->btn_id_pr = 3; /*Hack to show a button pressed*/
h = lv_cont_create(parent, h);
lv_obj_t * list = lv_list_create(h, NULL);
lv_list_add(list, SYMBOL_GPS, "GPS", NULL);
lv_list_add(list, SYMBOL_WIFI, "WiFi", NULL);
lv_list_add(list, SYMBOL_CALL, "Call", NULL);
lv_list_add(list, SYMBOL_BELL, "Bell", NULL);
lv_list_add(list, SYMBOL_FILE, "File", NULL);
lv_list_add(list, SYMBOL_EDIT, "Edit", NULL);
lv_list_add(list, SYMBOL_CUT, "Cut", NULL);
lv_list_add(list, SYMBOL_COPY, "Copy", NULL);
lv_obj_t *roller = lv_roller_create(h, NULL);
lv_roller_set_options(roller, "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday");
lv_obj_set_height(roller, LV_DPI);
lv_obj_t *gauge = lv_gauge_create(h, NULL);
lv_gauge_set_value(gauge, 0, 40);
lv_obj_set_size(gauge, 3 * LV_DPI / 2, 3 * LV_DPI / 2);
}
static void create_tab2(lv_theme_t * th, lv_obj_t *parent)
{
cord_t w = lv_page_get_scrl_width(parent);
lv_obj_t *chart = lv_chart_create(parent, NULL);
lv_chart_series_t * s1 = lv_chart_add_series(chart, COLOR_RED);
lv_chart_set_next(chart, s1, 30);
lv_chart_set_next(chart, s1, 20);
lv_chart_set_next(chart, s1, 10);
lv_chart_set_next(chart, s1, 12);
lv_chart_set_next(chart, s1, 20);
lv_chart_set_next(chart, s1, 27);
lv_chart_set_next(chart, s1, 35);
lv_chart_set_next(chart, s1, 55);
lv_chart_set_next(chart, s1, 70);
lv_chart_set_next(chart, s1, 75);
lv_obj_t *ta = lv_ta_create(parent, NULL);
lv_obj_set_size(ta, w / 3, LV_VER_RES / 4);
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
lv_ta_set_cursor_type(ta, LV_TA_CURSOR_BLOCK);
lv_obj_t *kb = lv_kb_create(parent, NULL);
lv_obj_set_size(kb, w / 2, LV_VER_RES / 3);
lv_obj_align(kb, ta, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI / 4);
lv_kb_set_ta(kb, ta);
}
static void create_tab3(lv_theme_t * th, lv_obj_t *parent)
{
lv_obj_t *win = lv_win_create(parent, NULL);
lv_win_add_btn(win, SYMBOL_CLOSE, lv_win_close_action);
lv_win_add_btn(win, SYMBOL_DOWN, NULL);
lv_obj_set_size(win, LV_HOR_RES / 2, LV_VER_RES / 2);
lv_obj_set_top(win, true);
lv_obj_t *label = lv_label_create(win, NULL);
lv_label_set_text(label, "Label in the window");
lv_obj_t *lmeter = lv_lmeter_create(win, NULL);
lv_obj_align(lmeter, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2);
lv_lmeter_set_value(lmeter, 70);
lv_obj_t *led1 = lv_led_create(win, NULL);
lv_obj_align(led1, lmeter, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 2);
lv_led_on(led1);
lv_obj_t *led2 = lv_led_create(win, NULL);
lv_obj_align(led2, led1, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0);
lv_led_off(led2);
lv_obj_t *page = lv_page_create(parent, NULL);
lv_obj_set_size(page, LV_HOR_RES / 3, LV_VER_RES / 2);
lv_obj_set_top(page, true);
lv_obj_align(page, win, LV_ALIGN_IN_TOP_RIGHT, LV_DPI, LV_DPI);
label = lv_label_create(page, NULL);
lv_label_set_text(label, "Lorem ipsum dolor sit amet, repudiare voluptatibus pri cu. "
"Ei mundi pertinax posidonium eum, cum tempor maiorum at, "
"mea fuisset assentior ad. Usu cu suas civibus iudicabit. "
"Eum eu congue tempor facilisi. Tale hinc unum te vim. "
"Te cum populo animal eruditi, labitur inciderint at nec.\n\n"
"Eius corpora et quo. Everti voluptaria instructior est id, "
"vel in falli primis. Mea ei porro essent admodum, "
"his ei malis quodsi, te quis aeterno his. "
"Qui tritani recusabo reprehendunt ne, "
"per duis explicari at. Simul mediocritatem mei et.");
lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK);
lv_obj_set_width(label, lv_page_get_scrl_width(page));
static const char * mbox_btn_map[] = {"\211", "\222Got it!", "\211", ""};
lv_obj_t *mbox = lv_mbox_create(parent, NULL);
lv_mbox_set_text(mbox, "Click on the window or the page to bring it to the foreground");
lv_mbox_set_btns(mbox, mbox_btn_map, NULL);
lv_obj_set_top(mbox, true);
}

287
lv_themes/lv_theme.h Normal file
View File

@@ -0,0 +1,287 @@
/**
*@file lv_themes.h
*
*/
#ifndef LV_THEMES_H
#define LV_THEMES_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#include "lvgl/lv_obj/lv_style.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_style_t *bg;
lv_style_t *panel;
#if USE_LV_CONT != 0
struct {
lv_style_t *filled;
lv_style_t *frame;
}cont;
#endif
#if USE_LV_BTN != 0
struct {
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}sm;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}md;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}lg;
}btn;
#endif
#if USE_LV_LABEL != 0
struct {
lv_style_t *sm;
lv_style_t *md;
lv_style_t *lg;
}label;
#endif
#if USE_LV_IMG != 0
struct {
lv_style_t *light;
lv_style_t *dark;
}img;
#endif
#if USE_LV_LINE != 0
struct {
lv_style_t *decor;
}line;
#endif
#if USE_LV_LED != 0
lv_style_t *led;
#endif
#if USE_LV_BAR != 0
struct {
lv_style_t *bg;
lv_style_t *indic;
}bar;
#endif
#if USE_LV_SLIDER != 0
struct {
lv_style_t *bg;
lv_style_t *indic;
lv_style_t *knob;
}slider;
#endif
#if USE_LV_LMETER != 0
lv_style_t *lmeter;
#endif
#if USE_LV_GAUGE != 0
lv_style_t *gauge;
#endif
#if USE_LV_SW != 0
struct {
lv_style_t *bg;
lv_style_t *indic;
lv_style_t *knob_off;
lv_style_t *knob_on;
}sw;
#endif
#if USE_LV_CHART != 0
lv_style_t *chart;
#endif
#if USE_LV_CB != 0
struct {
lv_style_t *bg;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}box;
}cb;
#endif
#if USE_LV_BTNM != 0
struct {
lv_style_t *bg;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}btn;
}btnm;
#endif
#if USE_LV_KB != 0
struct {
lv_style_t *bg;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
} btn;
}kb;
#endif
#if USE_LV_MBOX != 0
struct {
lv_style_t *bg;
struct {
lv_style_t *bg;
lv_style_t *rel;
lv_style_t *pr;
}btn;
}mbox;
#endif
#if USE_LV_PAGE != 0
struct {
lv_style_t *bg;
lv_style_t *scrl;
lv_style_t *sb;
}page;
#endif
#if USE_LV_TA != 0
struct {
lv_style_t *area;
lv_style_t *oneline;
lv_style_t *sb;
}ta;
#endif
#if USE_LV_LIST
struct {
lv_style_t *bg;
lv_style_t *scrl;
lv_style_t *sb;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}btn;
}list;
#endif
#if USE_LV_DDLIST != 0
struct {
lv_style_t *bg;
lv_style_t *sel;
lv_style_t *sb;
}ddlist;
#endif
#if USE_LV_ROLLER != 0
struct {
lv_style_t *bg;
lv_style_t *sel;
}roller;
#endif
#if USE_LV_TABVIEW != 0
struct {
lv_style_t *bg;
lv_style_t *sb;
lv_style_t *indic;
struct {
lv_style_t *bg;
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
}btn;
}tabview;
#endif
#if USE_LV_WIN != 0
struct {
lv_style_t *bg;
lv_style_t *sb;
lv_style_t *header;
lv_style_t *content;
struct {
lv_style_t *rel;
lv_style_t *pr;
}btn;
}win;
#endif
}lv_theme_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Set a theme for the system.
* From now, all the created objects will use styles from this theme by default
* @param th pointer to theme (return value of: 'lv_theme_init_xxx()')
*/
void lv_theme_set_current(lv_theme_t *th);
/**
* Get the current system theme.
* @return pointer to the current system theme. NULL if not set.
*/
lv_theme_t * lv_theme_get_current(void);
/**
* Create a test screen with a lot objects and apply the given theme on them
* @param th pointer to a theme
*/
void lv_theme_create_test_screen(lv_theme_t *th);
/**********************
* MACROS
**********************/
/**********************
* POST INCLUDE
*********************/
#include "lv_theme_alien.h"
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_THEMES_H*/

816
lv_themes/lv_theme_alien.c Normal file
View File

@@ -0,0 +1,816 @@
/**
* @file lv_theme_alien.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lvgl/lvgl.h"
#include "lv_theme.h"
#include "lv_conf.h"
#if USE_LV_THEME_ALIEN
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
static lv_theme_t theme;
static lv_style_t def;
static lv_style_t bg;
static lv_style_t panel; /*General fancy background (for e.g. chart or ta)*/
static lv_style_t sb;
static lv_style_t label_sm, label_md, label_lg;
static lv_style_t btn_sm_rel, btn_sm_pr, btn_sm_trel, btn_sm_tpr, btn_sm_ina;
static lv_style_t btn_md_rel, btn_md_pr, btn_md_trel, btn_md_tpr, btn_md_ina;
static lv_style_t btn_lg_rel, btn_lg_pr, btn_lg_trel, btn_lg_tpr, btn_lg_ina;
static lv_style_t img_light, img_dark;
static lv_style_t line_decor;
static lv_style_t led;
static lv_style_t bar_bg, bar_indic;
static lv_style_t slider_knob;
static lv_style_t sw_bg, sw_indic, sw_knob;
static lv_style_t lmeter_bg;
static lv_style_t gauge_bg;
static lv_style_t list_bg, list_rel, list_pr, list_trel, list_tpr, list_ina;
static lv_style_t ddlist_bg, ddlist_sel;
static lv_style_t roller_bg, roller_sel;
static lv_style_t cb_bg, cb_rel, cb_pr, cb_trel, cb_tpr, cb_ina;
static lv_style_t btnm_bg, btnm_rel, btnm_pr, btnm_trel, btnm_ina;
static lv_style_t mbox_bg, mbox_btn_rel, mbox_btn_pr;
static lv_style_t tab_rel, tab_pr, tab_trel, tab_tpr, tab_indic;
static lv_style_t win_header;
static uint16_t _hue;
static font_t * _font_sm;
static font_t * _font_md;
static font_t * _font_lg;
/**********************
* MACROS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/
static void basic_init(void)
{
/*Default*/
lv_style_copy(&def, &lv_style_plain);
def.body.opa = OPA_COVER;
def.glass = 0;
def.body.empty = 0;
def.body.color_main = COLOR_HEX3(0x222);
def.body.color_gradient = COLOR_HEX3(0x222);
def.body.radius = 0;
def.body.padding.hor = LV_DPI / 8;
def.body.padding.ver = LV_DPI / 8;
def.body.padding.inner = LV_DPI / 8;
def.body.border.color = COLOR_SILVER;
def.body.border.width = 1 << LV_ANTIALIAS;
def.body.border.opa = OPA_COVER;
def.body.shadow.color = COLOR_SILVER;
def.body.shadow.width = 0;
def.body.shadow.type = LV_SHADOW_FULL;
def.text.color = COLOR_HEX3(0xDDD);
def.text.font = _font_sm;
def.text.letter_space = 1 << LV_ANTIALIAS;
def.text.line_space = 2 << LV_ANTIALIAS;
def.image.color = COLOR_HEX3(0xDDD);
def.image.intense = OPA_TRANSP;
def.line.color = COLOR_HEX3(0xDDD);
def.line.width = 1 << LV_ANTIALIAS;
/*Background*/
lv_style_copy(&bg, &def);
bg.body.color_main = COLOR_HEX3(0x333);
bg.body.color_gradient = COLOR_HEX3(0x333);
bg.body.border.width = 0;
bg.body.border.opa = OPA_70;
bg.body.shadow.color = COLOR_SILVER;
/*Panel*/
lv_style_copy(&panel, &def);
panel.body.radius = LV_DPI / 10;
panel.body.color_main = COLOR_HEX3(0x666);
panel.body.color_gradient = COLOR_HEX3(0x666);
panel.body.border.color = COLOR_HEX3(0xccc);
panel.body.border.width = 2 << LV_ANTIALIAS;
panel.body.border.opa = OPA_60;
panel.text.color = color_hsv_to_rgb(_hue, 8, 96);
panel.line.color = color_hsv_to_rgb(_hue, 20, 70);
/*Scrollbar*/
lv_style_copy(&sb, &def);
sb.body.opa = OPA_50;
sb.body.radius = LV_RADIUS_CIRCLE;
sb.body.border.color = COLOR_SILVER;
sb.body.border.opa = OPA_40;
sb.body.border.width = 1 << LV_ANTIALIAS;
sb.body.color_main = color_hsv_to_rgb(_hue, 33, 92);
sb.body.color_gradient = color_hsv_to_rgb(_hue, 33, 92);
sb.body.padding.hor = 1 << LV_ANTIALIAS;
sb.body.padding.ver = 1 << LV_ANTIALIAS;
sb.body.padding.inner = LV_DPI / 15; /*Scrollbar width*/
theme.bg = &bg;
theme.panel = &panel;
}
static void btn_init(void)
{
#if USE_LV_BTN != 0
lv_style_copy(&btn_sm_rel, &def);
btn_sm_rel.glass = 0;
btn_sm_rel.body.empty = 1;
btn_sm_rel.body.radius = LV_RADIUS_CIRCLE;
btn_sm_rel.body.border.width = 2 << LV_ANTIALIAS;
btn_sm_rel.body.border.color = color_hsv_to_rgb(_hue, 70, 90);
btn_sm_rel.body.border.opa = OPA_80;
btn_sm_rel.body.padding.hor = LV_DPI / 4;
btn_sm_rel.body.padding.ver = LV_DPI / 6;
btn_sm_rel.body.padding.inner = LV_DPI / 10;
btn_sm_rel.text.color = color_hsv_to_rgb(_hue, 8, 96);
btn_sm_rel.text.font = _font_sm;
lv_style_copy(&btn_sm_pr, &btn_sm_rel);
btn_sm_pr.body.opa = OPA_COVER;
btn_sm_pr.body.empty = 0;
btn_sm_pr.body.color_main = color_hsv_to_rgb(_hue, 50, 50);
btn_sm_pr.body.color_gradient = color_hsv_to_rgb(_hue, 50, 50);
btn_sm_pr.body.border.opa = OPA_60;
btn_sm_pr.text.font = _font_sm;
btn_sm_pr.text.color = color_hsv_to_rgb(_hue, 10, 100);
lv_style_copy(&btn_sm_trel, &btn_sm_pr);
btn_sm_trel.body.opa = OPA_COVER;
btn_sm_trel.body.empty = 0;
btn_sm_trel.body.color_main = color_hsv_to_rgb(_hue, 50, 60);
btn_sm_trel.body.color_gradient = color_hsv_to_rgb(_hue, 50, 60);
btn_sm_trel.body.border.opa = OPA_60;
btn_sm_trel.body.border.color = color_hsv_to_rgb(_hue, 80, 90);
btn_sm_trel.text.font = _font_sm;
btn_sm_trel.text.color = color_hsv_to_rgb(_hue, 0, 100);
lv_style_copy(&btn_sm_tpr, &btn_sm_trel);
btn_sm_tpr.body.opa = OPA_COVER;
btn_sm_tpr.body.empty = 0;
btn_sm_tpr.body.color_main = color_hsv_to_rgb(_hue, 50, 50);
btn_sm_tpr.body.color_gradient = color_hsv_to_rgb(_hue, 50, 50);
btn_sm_tpr.body.border.opa = OPA_60;
btn_sm_tpr.body.border.color = color_hsv_to_rgb(_hue, 80, 70);
btn_sm_tpr.text.font = _font_sm;
btn_sm_tpr.text.color = color_hsv_to_rgb(_hue, 10, 90);
lv_style_copy(&btn_sm_ina, &btn_sm_rel);
btn_sm_ina.body.border.opa = OPA_60;
btn_sm_ina.body.border.color = color_hsv_to_rgb(_hue, 10, 50);
btn_sm_ina.text.font = _font_sm;
btn_sm_ina.text.color = color_hsv_to_rgb(_hue, 10, 90);
lv_style_copy(&btn_md_rel, &btn_sm_rel);
btn_md_rel.body.padding.hor = LV_DPI / 3;
btn_md_rel.body.padding.ver = LV_DPI / 5;
btn_md_rel.body.padding.inner = LV_DPI / 8;
btn_md_rel.text.font = _font_md;
lv_style_copy(&btn_md_pr, &btn_sm_pr);
btn_md_pr.body.padding.hor = LV_DPI / 3;
btn_md_pr.body.padding.ver = LV_DPI / 5;
btn_md_pr.body.padding.inner = LV_DPI / 8;
btn_md_pr.text.font = _font_md;
lv_style_copy(&btn_md_trel, &btn_sm_trel);
btn_md_trel.body.padding.hor = LV_DPI / 3;
btn_md_trel.body.padding.ver = LV_DPI / 5;
btn_md_trel.body.padding.inner = LV_DPI / 8;
btn_md_trel.text.font = _font_md;
lv_style_copy(&btn_md_tpr, &btn_sm_tpr);
btn_md_tpr.body.padding.hor = LV_DPI / 3;
btn_md_tpr.body.padding.ver = LV_DPI / 5;
btn_md_tpr.body.padding.inner = LV_DPI / 8;
btn_md_tpr.text.font = _font_md;
lv_style_copy(&btn_md_ina, &btn_sm_ina);
btn_md_ina.body.padding.hor = LV_DPI / 3;
btn_md_ina.body.padding.ver = LV_DPI / 5;
btn_md_ina.body.padding.inner = LV_DPI / 8;
btn_md_ina.text.font = _font_md;
lv_style_copy(&btn_lg_rel, &btn_sm_rel);
btn_lg_rel.body.padding.hor = LV_DPI / 2;
btn_lg_rel.body.padding.ver = LV_DPI / 4;
btn_lg_rel.body.padding.inner = LV_DPI / 6;
btn_lg_rel.text.font = _font_lg;
lv_style_copy(&btn_lg_pr, &btn_sm_pr);
btn_lg_pr.body.padding.hor = LV_DPI / 2;
btn_lg_pr.body.padding.ver = LV_DPI / 4;
btn_lg_pr.body.padding.inner = LV_DPI / 6;
btn_lg_pr.text.font = _font_lg;
lv_style_copy(&btn_lg_trel, &btn_sm_trel);
btn_lg_trel.body.padding.hor = LV_DPI / 2;
btn_lg_trel.body.padding.ver = LV_DPI / 4;
btn_lg_trel.body.padding.inner = LV_DPI / 6;
btn_lg_trel.text.font = _font_lg;
lv_style_copy(&btn_lg_tpr, &btn_sm_tpr);
btn_lg_tpr.body.padding.hor = LV_DPI / 2;
btn_lg_tpr.body.padding.ver = LV_DPI / 4;
btn_lg_tpr.body.padding.inner = LV_DPI / 6;
btn_lg_tpr.text.font = _font_lg;
lv_style_copy(&btn_lg_ina, &btn_sm_ina);
btn_lg_ina.body.padding.hor = LV_DPI / 2;
btn_lg_ina.body.padding.ver = LV_DPI / 4;
btn_lg_ina.body.padding.inner = LV_DPI / 6;
btn_lg_ina.text.font = _font_lg;
theme.btn.sm.rel = &btn_sm_rel;
theme.btn.sm.pr = &btn_sm_pr;
theme.btn.sm.tgl_rel = &btn_sm_trel;
theme.btn.sm.tgl_pr = &btn_sm_tpr;
theme.btn.sm.ina = &btn_sm_ina;
theme.btn.md.rel = &btn_md_rel;
theme.btn.md.pr = &btn_md_pr;
theme.btn.md.tgl_rel = &btn_md_trel;
theme.btn.md.tgl_pr = &btn_md_tpr;
theme.btn.md.ina = &btn_md_ina;
theme.btn.lg.rel = &btn_lg_rel;
theme.btn.lg.pr = &btn_lg_pr;
theme.btn.lg.tgl_rel = &btn_lg_trel;
theme.btn.lg.tgl_pr = &btn_lg_tpr;
theme.btn.lg.ina = &btn_lg_ina;
#endif
}
static void label_init(void)
{
#if USE_LV_LABEL != 0
lv_style_copy(&label_sm, &def);
label_sm.text.font = _font_sm;
label_sm.text.color = color_hsv_to_rgb(_hue, 8, 96);
lv_style_copy(&label_md, &label_sm);
label_md.text.font = _font_md;
lv_style_copy(&label_lg, &label_sm);
label_lg.text.font = _font_lg;
theme.label.sm = &label_sm;
theme.label.md = &label_md;
theme.label.lg = &label_lg;
#endif
}
static void bar_init(void)
{
#if USE_LV_BAR
lv_style_copy(&bar_bg, &def);
bar_bg.body.opa = OPA_30;
bar_bg.body.radius = LV_RADIUS_CIRCLE;
bar_bg.body.color_main = COLOR_WHITE;
bar_bg.body.color_gradient = COLOR_SILVER;
bar_bg.body.border.width = 2 << LV_ANTIALIAS;
bar_bg.body.border.color = COLOR_SILVER;
bar_bg.body.border.opa = OPA_20;
bar_bg.body.padding.hor = 0;
bar_bg.body.padding.ver = LV_DPI / 6;
bar_bg.body.padding.inner = 0;
lv_style_copy(&bar_indic, &def);
bar_indic.body.radius = LV_RADIUS_CIRCLE;
bar_indic.body.border.width = 2 << LV_ANTIALIAS;
bar_indic.body.border.color = COLOR_SILVER;
bar_indic.body.border.opa = OPA_70;
bar_indic.body.padding.hor = 0;
bar_indic.body.padding.ver = 0;
bar_indic.body.shadow.width = LV_DPI / 12;
bar_indic.body.color_main = color_hsv_to_rgb(_hue, 40, 80);
bar_indic.body.color_gradient = color_hsv_to_rgb(_hue, 40, 80);
theme.bar.bg = &bar_bg;
theme.bar.indic = &bar_indic;
#endif
}
static void img_init(void)
{
#if USE_LV_IMG != 0
lv_style_copy(&img_light, &def);
img_light.image.color = color_hsv_to_rgb(_hue, 15, 85);
img_light.image.intense = OPA_80;
lv_style_copy(&img_dark, &def);
img_light.image.color = color_hsv_to_rgb(_hue, 85, 65);
img_light.image.intense = OPA_80;
theme.img.light = &img_light;
theme.img.dark = &img_dark;
#endif
}
static void line_init(void)
{
#if USE_LV_LINE != 0
lv_style_copy(&line_decor, &def);
line_decor.line.color = color_hsv_to_rgb(_hue, 50, 50);
line_decor.line.width = 1 << LV_ANTIALIAS;
theme.line.decor = &line_decor;
#endif
}
static void led_init(void)
{
#if USE_LV_LED != 0
lv_style_copy(&led, &lv_style_pretty_color);
led.body.shadow.width = LV_DPI / 10;
led.body.radius = LV_RADIUS_CIRCLE;
led.body.border.width= LV_DPI / 30;
led.body.border.opa = OPA_30;
led.body.color_main = color_hsv_to_rgb(_hue, 100, 100);
led.body.color_gradient = color_hsv_to_rgb(_hue, 100, 40);
led.body.border.color = color_hsv_to_rgb(_hue, 60, 60);
led.body.shadow.color = color_hsv_to_rgb(_hue, 100, 100);
theme.led = &led;
#endif
}
static void slider_init(void)
{
#if USE_LV_SLIDER != 0
lv_style_copy(&slider_knob, &def);
slider_knob.body.opa = OPA_60;
slider_knob.body.radius = LV_RADIUS_CIRCLE;
slider_knob.body.color_main = COLOR_WHITE;
slider_knob.body.color_gradient = COLOR_SILVER;
slider_knob.body.border.width = 1 << LV_ANTIALIAS;
slider_knob.body.border.color = COLOR_GRAY;
slider_knob.body.border.opa = OPA_50;
theme.slider.bg = &bar_bg;
theme.slider.indic = &bar_indic;
theme.slider.knob = &slider_knob;
#endif
}
static void sw_init(void)
{
#if USE_LV_SW != 0
lv_style_copy(&sw_bg, &bar_bg);
sw_bg.body.opa = OPA_COVER;
sw_bg.body.padding.ver = -2 << LV_ANTIALIAS;
sw_bg.body.padding.hor = -2 << LV_ANTIALIAS;
sw_bg.body.color_main = COLOR_HEX3(0x666);
sw_bg.body.color_gradient = COLOR_HEX3(0x999);
sw_bg.body.border.width = 2 << LV_ANTIALIAS;
sw_bg.body.border.opa = OPA_50;
lv_style_copy(&sw_indic, &bar_indic);
sw_indic.body.shadow .width = LV_DPI / 12;
sw_indic.body.padding.ver = 0;
sw_indic.body.padding.hor = 0;
lv_style_copy(&sw_knob, &slider_knob);
sw_knob.body.opa = OPA_80;
theme.sw.bg = &sw_bg;
theme.sw.indic = &sw_indic;
theme.sw.knob_off = &sw_knob;
theme.sw.knob_on = &sw_knob;
#endif
}
static void lmeter_init(void)
{
#if USE_LV_LMETER != 0
lv_style_copy(&lmeter_bg, &def);
lmeter_bg.body.color_main = color_hsv_to_rgb(_hue, 10, 70);
lmeter_bg.body.color_gradient = color_hsv_to_rgb(_hue, 80, 80);
lmeter_bg.body.padding.hor = LV_DPI / 8; /*Scale line length*/
lmeter_bg.line.color = COLOR_HEX3(0x555);
lmeter_bg.line.width = 2 << LV_ANTIALIAS;
theme.lmeter = &lmeter_bg;
#endif
}
static void gauge_init(void)
{
#if USE_LV_GAUGE != 0
lv_style_copy(&gauge_bg, &def);
gauge_bg.body.color_main = color_hsv_to_rgb(_hue, 10, 70);
gauge_bg.body.color_gradient = color_hsv_to_rgb(_hue, 80, 80);
gauge_bg.body.padding.hor = LV_DPI / 12; /*Scale line length*/
gauge_bg.body.padding.ver = LV_DPI / 10; /*Needle center size*/
gauge_bg.body.padding.inner = LV_DPI / 8; /*Label - scale distance*/
gauge_bg.body.border.color = COLOR_HEX3(0x777);
gauge_bg.line.color = COLOR_HEX3(0x555);
gauge_bg.line.width = 2 << LV_ANTIALIAS;
gauge_bg.text.color = color_hsv_to_rgb(_hue, 10, 90);
gauge_bg.text.font = _font_sm;
theme.gauge = &gauge_bg;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = &panel;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
lv_style_copy(&cb_rel, &bg);
cb_rel.body.radius = LV_DPI / 20;
cb_rel.body.border.width = 1 << LV_ANTIALIAS;
cb_rel.body.border.color = COLOR_GRAY;
cb_rel.body.color_main = COLOR_WHITE;
cb_rel.body.color_gradient = COLOR_SILVER;
lv_style_copy(&cb_bg, &bg);
cb_bg.body.empty = 1;
cb_bg.body.border.width = 0;
cb_bg.body.padding.inner = LV_DPI / 8;
cb_bg.body.padding.hor = 0;
cb_bg.body.padding.ver = 0;
cb_bg.text.font = _font_sm;
lv_style_copy(&cb_pr, &cb_rel);
cb_pr.body.color_main = color_hsv_to_rgb(_hue, 10, 90);
cb_pr.body.color_main = color_hsv_to_rgb(_hue, 10, 82);
lv_style_copy(&cb_trel, &cb_rel);
cb_trel.body.border.width = 4 << LV_ANTIALIAS;
cb_trel.body.border.color = COLOR_WHITE;
cb_trel.body.border.opa = OPA_60;
cb_trel.body.color_main = color_hsv_to_rgb(_hue, 50, 82);
cb_trel.body.color_gradient = color_hsv_to_rgb(_hue, 50, 62);
lv_style_copy(&cb_tpr, &cb_trel);
cb_tpr.body.border.color = COLOR_SILVER;
cb_tpr.body.border.opa = OPA_70;
cb_tpr.body.color_main = color_hsv_to_rgb(_hue, 50, 72);
cb_tpr.body.color_gradient = color_hsv_to_rgb(_hue, 50, 52);
lv_style_copy(&cb_ina, &cb_trel);
cb_ina.body.border.width = 1 << LV_ANTIALIAS;
cb_ina.body.border.color = COLOR_GRAY;
cb_ina.body.color_main = COLOR_SILVER;
cb_ina.body.color_gradient = COLOR_SILVER;
theme.cb.bg = &cb_bg;
theme.cb.box.rel = &cb_rel;
theme.cb.box.pr = &cb_pr;
theme.cb.box.tgl_rel = &cb_trel;
theme.cb.box.tgl_pr = &cb_tpr;
theme.cb.box.ina = &cb_ina;
#endif
}
static void btnm_init(void)
{
#if USE_LV_BTNM
lv_style_copy(&btnm_bg, &lv_style_transp_tight);
btnm_bg.body.border.width = 1 << LV_ANTIALIAS;
btnm_bg.body.border.color = color_hsv_to_rgb(_hue, 60, 80);
btnm_bg.body.border.opa = OPA_COVER;
btnm_bg.body.radius = LV_DPI / 8;
lv_style_copy(&btnm_rel, &lv_style_plain);
btnm_rel.body.empty = 1;
btnm_rel.body.radius = LV_DPI / 8;
btnm_rel.text.color = color_hsv_to_rgb(_hue, 60, 80);
btnm_rel.text.font = _font_md;
lv_style_copy(&btnm_pr, &lv_style_plain);
btnm_pr.body.color_main = color_hsv_to_rgb(_hue, 40, 70);
btnm_pr.body.color_gradient = color_hsv_to_rgb(_hue, 40, 70);
btnm_pr.body.radius = LV_DPI / 8;
btnm_pr.text.color = color_hsv_to_rgb(_hue, 40, 40);
btnm_pr.text.font = _font_md;
lv_style_copy(&btnm_trel, &btnm_rel);
btnm_trel.body.border.color = color_hsv_to_rgb(_hue, 80, 80);
btnm_trel.body.border.width = 3 << LV_ANTIALIAS;
lv_style_copy(&btnm_ina, &btnm_rel);
btnm_ina.text.color = color_hsv_to_rgb(_hue, 10, 60);
theme.btnm.bg = &btnm_bg;
theme.btnm.btn.rel = &btnm_rel;
theme.btnm.btn.pr = &btnm_pr;
theme.btnm.btn.tgl_rel = &btnm_trel;
theme.btnm.btn.tgl_pr = &btnm_pr;
theme.btnm.btn.ina = &btnm_ina;
#endif
}
static void kb_init(void)
{
#if USE_LV_KB
theme.kb.bg = &btnm_bg;
theme.kb.btn.rel = &btnm_rel;
theme.kb.btn.pr = &btnm_pr;
theme.kb.btn.tgl_rel = &btnm_trel;
theme.kb.btn.tgl_pr = &btnm_pr;
theme.kb.btn.ina = &btnm_ina;
#endif
}
static void mbox_init(void)
{
#if USE_LV_MBOX
lv_style_copy(&mbox_bg, &panel);
mbox_bg.body.shadow.width = LV_DPI / 12;
theme.mbox.bg = &mbox_bg;
theme.mbox.btn.bg = &lv_style_transp;
theme.mbox.btn.rel = &btn_sm_trel;
theme.mbox.btn.pr = &btn_sm_tpr;
#endif
}
static void page_init(void)
{
#if USE_LV_PAGE
theme.page.bg = &panel;
theme.page.scrl = &lv_style_transp_fit;
theme.page.sb = &sb;
#endif
}
static void ta_init(void)
{
#if USE_LV_TA
theme.ta.area = &panel;
theme.ta.oneline = &panel;
theme.ta.sb = &sb;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
lv_style_copy(&list_rel, &def);
list_rel.body.empty = 1;
list_rel.body.border.width = 1 << LV_ANTIALIAS;
list_rel.body.border.color = color_hsv_to_rgb(_hue, 50, 85);
list_rel.body.border.opa = OPA_COVER;
list_rel.text.color = color_hsv_to_rgb(_hue, 10, 94);
list_rel.text.font = _font_sm;
lv_style_copy(&list_pr, &list_rel);
list_pr.body.empty = 0;
list_pr.body.opa = OPA_COVER;
list_pr.body.color_main = color_hsv_to_rgb(_hue, 34, 41);
list_pr.body.color_gradient = color_hsv_to_rgb(_hue, 34, 41);
list_pr.text.color = color_hsv_to_rgb(_hue, 7, 96);
lv_style_copy(&list_trel, &list_rel);
lv_style_copy(&list_tpr, &list_pr);
lv_style_copy(&list_ina, &def);
lv_style_copy(&list_bg, &list_rel);
list_bg.body.padding.hor = 0;
list_bg.body.padding.ver = 0;
theme.list.sb = &sb;
theme.list.bg = &list_bg;
theme.list.scrl = &lv_style_transp_tight;
theme.list.btn.rel = &list_rel;
theme.list.btn.pr = &list_pr;
theme.list.btn.tgl_rel = &list_trel;
theme.list.btn.tgl_pr = &list_tpr;
theme.list.btn.ina = &list_ina;
#endif
}
static void ddlist_init(void)
{
#if USE_LV_DDLIST != 0
lv_style_copy(&ddlist_bg, &panel);
ddlist_bg.text.line_space = LV_DPI / 10;
lv_style_copy(&ddlist_sel, &panel);
ddlist_sel.body.color_main = color_hsv_to_rgb(_hue, 45, 70);
ddlist_sel.body.color_gradient = color_hsv_to_rgb(_hue, 45, 70);
ddlist_sel.body.opa = OPA_COVER;
ddlist_sel.body.radius = 0;
theme.ddlist.bg = &ddlist_bg;
theme.ddlist.sel = &ddlist_sel;
theme.ddlist.sb = &sb;
#endif
}
static void roller_init(void)
{
#if USE_LV_ROLLER != 0
lv_style_copy(&roller_bg, &ddlist_bg);
roller_bg.text.line_space = LV_DPI / 6;
roller_bg.body.radius = LV_DPI / 20;
roller_bg.body.color_main = COLOR_HEX3(0x222);
roller_bg.body.color_gradient = COLOR_HEX3(0x999);
roller_bg.body.border.opa = OPA_30;
roller_bg.text.opa = OPA_70;
roller_bg.text.color = color_hsv_to_rgb(_hue, 20, 70);
roller_bg.body.shadow.width = LV_DPI / 20;
roller_bg.body.shadow.color = COLOR_HEX3(0x111);
lv_style_copy(&roller_sel, &panel);
roller_sel.body.empty = 1;
roller_sel.body.radius = 0;
roller_sel.text.color = color_hsv_to_rgb(_hue, 55, 90);
theme.roller.bg = &roller_bg;
theme.roller.sel = &roller_sel;
#endif
}
static void tabview_init(void)
{
#if USE_LV_TABVIEW != 0
lv_style_copy(&tab_rel, &def);
tab_rel.body.color_main = COLOR_HEX3(0x666);
tab_rel.body.color_gradient = COLOR_HEX3(0x666);
tab_rel.body.padding.hor = 0;
tab_rel.body.padding.ver = 0;
tab_rel.body.padding.inner = 0;
tab_rel.body.border.width = 1 << LV_ANTIALIAS;
tab_rel.body.border.color = COLOR_SILVER;
tab_rel.body.border.opa = OPA_40;
tab_rel.text.color = COLOR_HEX3(0xDDD);
tab_rel.text.font = _font_sm;
lv_style_copy(&tab_pr, &tab_rel);
tab_pr.body.color_main = COLOR_HEX3(0x444);
tab_pr.body.color_gradient = COLOR_HEX3(0x444);
lv_style_copy(&tab_trel, &def);
tab_trel.body.empty = 1;
tab_trel.body.padding.hor = 0;
tab_trel.body.padding.ver = 0;
tab_trel.body.padding.inner = 0;
tab_trel.body.border.width = 1 << LV_ANTIALIAS;
tab_trel.body.border.color = COLOR_SILVER;
tab_trel.body.border.opa = OPA_40;
tab_trel.text.color = color_hsv_to_rgb(_hue, 10, 94);
tab_trel.text.font = _font_md;
lv_style_copy(&tab_tpr, &def);
tab_tpr.body.color_main = COLOR_GRAY;
tab_tpr.body.color_gradient = COLOR_GRAY;
tab_tpr.body.padding.hor = 0;
tab_tpr.body.padding.ver = 0;
tab_tpr.body.padding.inner = 0;
tab_tpr.body.border.width = 1 << LV_ANTIALIAS;
tab_tpr.body.border.color = COLOR_SILVER;
tab_tpr.body.border.opa = OPA_40;
tab_tpr.text.color = color_hsv_to_rgb(_hue, 10, 94);
tab_tpr.text.font = _font_md;
lv_style_copy(&tab_indic, &def);
tab_indic.body.border.width = 0;
tab_indic.body.color_main = color_hsv_to_rgb(_hue, 80, 87);
tab_indic.body.color_gradient = color_hsv_to_rgb(_hue, 80, 87);
tab_indic.body.padding.inner = LV_DPI / 10; /*Indicator height*/
theme.tabview.bg = &bg;
theme.tabview.indic = &tab_indic;
theme.tabview.btn.bg = &lv_style_transp_tight;
theme.tabview.btn.rel = &tab_rel;
theme.tabview.btn.pr = &tab_pr;
theme.tabview.btn.tgl_rel = &tab_trel;
theme.tabview.btn.tgl_pr = &tab_tpr;
#endif
}
static void win_init(void)
{
#if USE_LV_WIN != 0
lv_style_copy(&win_header, &def);
win_header.body.radius = panel.body.radius;
win_header.body.padding.hor = LV_DPI / 12;
win_header.body.padding.ver = LV_DPI / 12;
win_header.body.color_main = color_hsv_to_rgb(_hue, 20, 50);
win_header.body.color_gradient = win_header.body.color_main;
win_header.body.border.opa = panel.body.border.opa;
win_header.body.border.width = panel.body.border.width;
win_header.body.border.color = color_hsv_to_rgb(_hue, 20, 80);
win_header.text.color = color_hsv_to_rgb(_hue, 5, 100);
theme.win.bg = &panel;
theme.win.sb = &sb;
theme.win.header = &win_header;
theme.win.content = &lv_style_transp;
theme.win.btn.rel = &btn_sm_rel;
theme.win.btn.pr = &btn_sm_pr;
#endif
}
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Initalize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font_sm pointer to a small font (NULL to use the default)
* @param font_md pointer to a medium font (NULL to use the default)
* @param font_lg pointer to a large font (NULL to use the default)
*/
void lv_theme_alien_init(uint16_t hue, font_t *font_sm, font_t *font_md, font_t *font_lg)
{
if(font_sm == NULL) font_sm = FONT_DEFAULT;
if(font_md == NULL) font_md = FONT_DEFAULT;
if(font_lg == NULL) font_lg = FONT_DEFAULT;
_hue = hue;
_font_sm = font_sm;
_font_md = font_md;
_font_lg = font_lg;
/*For backward compatibility initialize all theme elements with a default style */
uint16_t i;
lv_style_t **style_p = (lv_style_t**) &theme;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
*style_p = &def;
style_p++;
}
basic_init();
btn_init();
label_init();
bar_init();
img_init();
line_init();
led_init();
slider_init();
sw_init();
lmeter_init();
gauge_init();
chart_init();
cb_init();
btnm_init();
kb_init();
mbox_init();
page_init();
ta_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
win_init();
}
/**
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_alien(void)
{
return &theme;
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif

View File

@@ -0,0 +1,56 @@
/**
* @file lv_theme_alien.h
*
*/
#ifndef LV_THEME_ALIEN_H
#define LV_THEME_ALIEN_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_THEME_ALIEN
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initalize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font_sm pointer to a small font (NULL to use the default)
* @param font_md pointer to a medium font (NULL to use the default)
* @param font_lg pointer to a large font (NULL to use the default)
*/
void lv_theme_alien_init(uint16_t hue, font_t *font_sm, font_t *font_md, font_t *font_lg);
/**
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_alien(void);
/**********************
* MACROS
**********************/
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_THEME_ALIEN_H*/