BigW Consortium Gitlab

Commit b973dd34 by Gabor Kiss-Vamosi

lv_theme: integrate into the library

add lv_theme
parent e3378d23
......@@ -73,9 +73,9 @@ void lv_style_init (void)
lv_style_scr.body.color_main = COLOR_WHITE;
lv_style_scr.body.color_gradient = COLOR_WHITE;
lv_style_scr.body.radius = 0;
lv_style_scr.body.padding.ver = LV_DPI / 10;
lv_style_scr.body.padding.hor = LV_DPI / 10;
lv_style_scr.body.padding.inner = LV_DPI / 10;
lv_style_scr.body.padding.ver = LV_DPI / 12;
lv_style_scr.body.padding.hor = LV_DPI / 12;
lv_style_scr.body.padding.inner = LV_DPI / 12;
lv_style_scr.body.empty = 0;
lv_style_scr.body.border.color = COLOR_BLACK;
......
......@@ -13,6 +13,7 @@
#include "lv_bar.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/anim.h"
#include <stdio.h>
......@@ -74,8 +75,15 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy)
if(copy == NULL) {
lv_obj_set_click(new_bar, false);
lv_obj_set_size(new_bar, LV_DPI * 2, LV_DPI / 3);
lv_obj_set_style(new_bar, &lv_style_pretty);
lv_bar_set_value(new_bar, ext->cur_value);
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_bar_set_style(new_bar, LV_BAR_STYLE_BG, th->bar.bg);
lv_bar_set_style(new_bar, LV_BAR_STYLE_INDIC, th->bar.indic);
} else {
lv_obj_set_style(new_bar, &lv_style_pretty);
}
} else {
lv_bar_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
ext->min_value = ext_copy->min_value;
......@@ -222,20 +230,6 @@ int16_t lv_bar_get_max_value(lv_obj_t * bar)
}
/**
* Get the style of bar indicator
* @param bar pointer to a bar object
* @return pointer to the bar indicator style
*/
lv_style_t * lv_bar_get_style_indicator(lv_obj_t * bar)
{
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
if(ext->style_indic == NULL) return lv_obj_get_style(bar);
return ext->style_indic;
}
/**
* Get a style of a bar
* @param bar pointer to a bar object
* @param type which style should be get
......@@ -279,7 +273,7 @@ static bool lv_bar_design(lv_obj_t * bar, const area_t * mask, lv_design_mode_t
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
lv_style_t * style_indic = lv_bar_get_style_indicator(bar);
lv_style_t *style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
area_t indic_area;
area_cpy(&indic_area, &bar->coords);
indic_area.x1 += style_indic->body.padding.hor;
......@@ -320,7 +314,7 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
lv_style_t * style_indic = lv_bar_get_style_indicator(bar);
lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
if(style_indic->body.shadow.width > bar->ext_size) bar->ext_size = style_indic->body.shadow.width;
}
......
......@@ -14,6 +14,7 @@
#include "lv_btn.h"
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/area.h"
#include "misc/gfx/color.h"
......@@ -81,7 +82,18 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
/*If no copy do the basic initialization*/
if(copy == NULL) {
lv_btn_set_layout(new_btn, LV_CONT_LAYOUT_CENTER);
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->btn.md.rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.md.pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->btn.md.tgl_rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->btn.md.tgl_pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->btn.md.ina);
} else {
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
}
}
/*Copy 'copy'*/
else {
......
......@@ -13,6 +13,7 @@
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_obj/lv_refr.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/text.h"
/*********************
......@@ -92,8 +93,20 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new button matrix object*/
if(copy == NULL) {
lv_obj_set_size(new_btnm, LV_HOR_RES, LV_VER_RES / 2);
lv_obj_set_style(new_btnm, &lv_style_pretty);
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->btnm.bg);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->btnm.btn.rel);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_PR, th->btnm.btn.pr);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_REL, th->btnm.btn.tgl_rel);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_PR, th->btnm.btn.tgl_pr);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_INA, th->btnm.btn.ina);
} else {
lv_obj_set_style(new_btnm, &lv_style_pretty);
}
}
/*Copy an existing object*/
else {
......@@ -120,9 +133,9 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
* The first byte can be a control data:
* - bit 7: always 1
* - bit 6: always 0
* - bit 5: inactive (disabled)
* - bit 4: no repeat (on long press)
* - bit 3: hidden
* - bit 5: inactive (disabled) (\24x)
* - bit 4: no repeat (on long press) (\22x)
* - bit 3: hidden (\21x)
* - bit 2..0: button relative width
* Example (practically use octal numbers): "\224abc": "abc" text with 4 width and no long press
*/
......
......@@ -11,6 +11,7 @@
#include "lv_cb.h"
#include "../lv_obj/lv_group.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
......@@ -71,15 +72,24 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_click(ext->bullet, false);
ext->label = lv_label_create(new_cb, NULL);
lv_obj_set_style(ext->label, NULL); /*Inherit the style of the parent*/
lv_cb_set_style(new_cb,LV_CB_STYLE_BG, &lv_style_transp);
lv_cb_set_text(new_cb, "Check box");
lv_cont_set_layout(new_cb, LV_CONT_LAYOUT_ROW_M);
lv_cont_set_fit(new_cb, true, true);
lv_btn_set_layout(new_cb, LV_CONT_LAYOUT_ROW_M);
lv_btn_set_fit(new_cb, true, true);
lv_btn_set_toggle(new_cb, true);
lv_obj_refresh_style(new_cb);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, th->cb.bg);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, th->cb.box.rel);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_PR, th->cb.box.pr);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_REL, th->cb.box.tgl_rel);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_PR, th->cb.box.tgl_pr);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_INA, th->cb.box.ina);
} else {
lv_cb_set_style(new_cb,LV_CB_STYLE_BG, &lv_style_transp);
}
} else {
lv_cb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->bullet = lv_btn_create(new_cb, copy_ext->bullet);
......@@ -127,19 +137,19 @@ void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t *style)
lv_btn_set_style(cb, LV_BTN_STYLE_TGL_PR, style);
lv_btn_set_style(cb, LV_BTN_STYLE_INA, style);
break;
case LV_CB_STYLE_REL:
case LV_CB_STYLE_BOX_REL:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_REL, style);
break;
case LV_CB_STYLE_PR:
case LV_CB_STYLE_BOX_PR:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_PR, style);
break;
case LV_CB_STYLE_TGL_REL:
case LV_CB_STYLE_BOX_TGL_REL:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_REL, style);
break;
case LV_CB_STYLE_TGL_PR:
case LV_CB_STYLE_BOX_TGL_PR:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_PR, style);
break;
case LV_CB_STYLE_INA:
case LV_CB_STYLE_BOX_INA:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_INA, style);
break;
}
......@@ -174,11 +184,11 @@ lv_style_t * lv_cb_get_style(lv_obj_t * cb, lv_cb_style_t type)
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
switch (type) {
case LV_CB_STYLE_REL: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
case LV_CB_STYLE_PR: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
case LV_CB_STYLE_TGL_REL: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
case LV_CB_STYLE_TGL_PR: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
case LV_CB_STYLE_INA: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
case LV_CB_STYLE_BOX_REL: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
case LV_CB_STYLE_BOX_PR: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
case LV_CB_STYLE_BOX_TGL_REL: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
case LV_CB_STYLE_BOX_TGL_PR: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
case LV_CB_STYLE_BOX_INA: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
default: return NULL;
}
......
......@@ -48,11 +48,11 @@ typedef struct
typedef enum {
LV_CB_STYLE_BG,
LV_CB_STYLE_REL,
LV_CB_STYLE_PR,
LV_CB_STYLE_TGL_REL,
LV_CB_STYLE_TGL_PR,
LV_CB_STYLE_INA,
LV_CB_STYLE_BOX_REL,
LV_CB_STYLE_BOX_PR,
LV_CB_STYLE_BOX_TGL_REL,
LV_CB_STYLE_BOX_TGL_PR,
LV_CB_STYLE_BOX_INA,
}lv_cb_style_t;
/**********************
......
......@@ -11,6 +11,7 @@
#include "lv_chart.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
......@@ -84,8 +85,16 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new chart background object*/
if(copy == NULL) {
lv_obj_set_style(new_chart, &lv_style_pretty);
lv_obj_set_size(new_chart, LV_HOR_RES / 2, LV_VER_RES / 2);
lv_obj_set_size(new_chart, LV_HOR_RES / 3, LV_VER_RES / 3);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_chart_set_style(new_chart, th->chart);
} else {
lv_chart_set_style(new_chart, &lv_style_pretty);
}
} else {
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
ext->type = ext_copy->type;
......
......@@ -17,6 +17,7 @@
#include "lv_cont.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_draw/lv_draw_vbasic.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/area.h"
#include "misc/gfx/color.h"
......@@ -79,7 +80,13 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new container*/
if(copy == NULL) {
lv_cont_set_style(new_cont, &lv_style_plain);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_cont_set_style(new_cont, th->cont.filled);
} else {
lv_cont_set_style(new_cont, &lv_style_pretty);
}
}
/*Copy an existing object*/
else {
......
......@@ -14,6 +14,7 @@
#include "../lv_draw/lv_draw.h"
#include "../lv_obj/lv_group.h"
#include "../lv_obj/lv_indev.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/anim.h"
/*********************
......@@ -94,9 +95,20 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
lv_page_set_release_action(new_ddlist, lv_ddlist_release_action);
lv_page_set_sb_mode(new_ddlist, LV_PAGE_SB_MODE_DRAG);
lv_page_set_style(new_ddlist, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, &lv_style_pretty);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, &lv_style_plain_color);
lv_ddlist_set_options(new_ddlist, "Option 1\nOption 2\nOption 3");
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, th->ddlist.bg);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL,th->ddlist.sel);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, th->ddlist.sb);
} else {
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, &lv_style_pretty);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, &lv_style_plain_color);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, &lv_style_pretty_color);
}
}
/*Copy an existing drop down list*/
else {
......
......@@ -12,6 +12,7 @@
#include "lv_gauge.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/text.h"
#include "misc/math/trigo.h"
#include "misc/math/math_base.h"
......@@ -90,7 +91,14 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
lv_gauge_set_scale(new_gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT, LV_GAUGE_DEF_LABEL_COUNT);
lv_gauge_set_needle_count(new_gauge, 1, NULL);
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
lv_obj_set_style(new_gauge, &lv_style_pretty_color);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_gauge_set_style(new_gauge, th->gauge);
} else {
lv_gauge_set_style(new_gauge, &lv_style_pretty_color);
}
}
/*Copy an existing gauge*/
else {
......
......@@ -12,6 +12,7 @@
#include "lv_img.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "misc/fs/fsint.h"
#include "misc/fs/ufs/ufs.h"
#include "misc/gfx/text.h"
......@@ -79,8 +80,8 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
* and must be screen sized*/
if(par != NULL) ext->auto_size = 1;
else ext->auto_size = 0;
if(par != NULL) lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
else lv_obj_set_style(new_img, &lv_style_plain); /*Set style for screens*/
if(par != NULL) lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
else lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/
} else {
lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->auto_size = copy_ext->auto_size;
......
......@@ -12,6 +12,7 @@
#include "lv_kb.h"
#include "lv_ta.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
......@@ -34,21 +35,21 @@ static lv_signal_func_t ancestor_signal;
static const char * kb_map_lc[] = {
"\2051#", "\204q", "\204w", "\204e", "\204r", "\204t", "\204y", "\204u", "\204i", "\204o", "\204p", "\207Del", "\n",
"\206ABC", "\203a", "\203s", "\203d", "\203f", "\203g", "\203h", "\203j", "\203k", "\203l", "\207Enter", "\n",
"\226ABC", "\203a", "\203s", "\203d", "\203f", "\203g", "\203h", "\203j", "\203k", "\203l", "\207Enter", "\n",
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
};
static const char * kb_map_uc[] = {
"\2051#", "\204Q", "\204W", "\204E", "\204R", "\204T", "\204Y", "\204U", "\204I", "\204O", "\204P", "\207Del", "\n",
"\206abc", "\203A", "\203S", "\203D", "\203F", "\203G", "\203H", "\203J", "\203K", "\203L", "\207Enter", "\n",
"\226abc", "\203A", "\203S", "\203D", "\203F", "\203G", "\203H", "\203J", "\203K", "\203L", "\207Enter", "\n",
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
};
static const char * kb_map_spec[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\202Del", "\n",
"\202abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
"\222abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
};
......@@ -101,6 +102,19 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_btnm_set_action(new_kb, lv_app_kb_action);
lv_btnm_set_map(new_kb, kb_map_lc);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->kb.bg);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->kb.btn.rel);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_PR, th->kb.btn.pr);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_REL, th->kb.btn.tgl_rel);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_PR, th->kb.btn.tgl_pr);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_INA, th->kb.btn.ina);
} else {
/*Let the button matrix's styles*/
}
}
/*Copy an existing keyboard*/
else {
......@@ -334,9 +348,18 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt)
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
/*Do the corresponding action according to the text of the button*/
if(strcmp(txt, "abc") == 0) lv_btnm_set_map(kb, kb_map_lc);
else if(strcmp(txt, "ABC") == 0) lv_btnm_set_map(kb, kb_map_uc);
else if(strcmp(txt, "1#") == 0) lv_btnm_set_map(kb, kb_map_spec);
if(strcmp(txt, "abc") == 0) {
lv_btnm_set_map(kb, kb_map_lc);
return LV_RES_OK;
}
else if(strcmp(txt, "ABC") == 0) {
lv_btnm_set_map(kb, kb_map_uc);
return LV_RES_OK;
}
else if(strcmp(txt, "1#") == 0) {
lv_btnm_set_map(kb, kb_map_spec);
return LV_RES_OK;
}
else if(strcmp(txt, SYMBOL_CLOSE) == 0) {
if(ext->close_action) ext->close_action(kb);
else lv_obj_del(kb);
......
......@@ -9,15 +9,15 @@
#include "lv_conf.h"
#if USE_LV_LABEL != 0
#include "misc/gfx/color.h"
#include "misc/gfx/text.h"
#include "misc/math/math_base.h"
#include "lv_label.h"
#include "../lv_obj/lv_obj.h"
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "misc/gfx/color.h"
#include "misc/gfx/text.h"
#include "misc/math/math_base.h"
#include "misc/gfx/text.h"
#include "misc/gfx/anim.h"
#include "../lv_draw/lv_draw.h"
/*********************
* DEFINES
......@@ -93,9 +93,9 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new label*/
if(copy == NULL) {
lv_obj_set_click(new_label, false);
lv_obj_set_style(new_label, NULL);
lv_label_set_long_mode(new_label, LV_LABEL_LONG_EXPAND);
lv_label_set_text(new_label, "Text");
lv_label_set_style(new_label, NULL); /*Inherit parent's style*/
}
/*Copy 'copy' if not NULL*/
else {
......
......@@ -10,6 +10,7 @@
#if USE_LV_LED != 0
#include "lv_led.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_draw/lv_draw.h"
/*********************
......@@ -68,8 +69,15 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new led object*/
if(copy == NULL) {
lv_obj_set_style(new_led, &lv_style_pretty_color);
lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_led_set_style(new_led, th->led);
} else {
lv_led_set_style(new_led, &lv_style_pretty_color);
}
}
/*Copy an existing object*/
else {
......
......@@ -70,8 +70,8 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new line*/
if(copy == NULL) {
lv_obj_set_size(new_line, LV_DPI, LV_DPI);
lv_obj_set_style(new_line, &lv_style_plain);
lv_obj_set_size(new_line, LV_DPI, LV_DPI); /*Auto size is enables, but set default size until no points are added*/
lv_obj_set_style(new_line, NULL); /*Inherit parent's style*/
}
/*Copy an existing object*/
else {
......
......@@ -11,6 +11,7 @@
#include "lv_list.h"
#include "../lv_obj/lv_group.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/anim.h"
#include "misc/math/math_base.h"
......@@ -79,9 +80,23 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
if(copy == NULL) {
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
lv_page_set_sb_mode(new_list, LV_PAGE_SB_MODE_DRAG);
lv_list_set_style(new_list, LV_LIST_STYLE_BG, &lv_style_transp_fit);
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, &lv_style_pretty);
lv_list_set_sb_mode(new_list, LV_PAGE_SB_MODE_DRAG);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_list_set_style(new_list, LV_LIST_STYLE_BG, th->list.bg);
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, th->list.scrl);
lv_list_set_style(new_list, LV_LIST_STYLE_SB, th->list.sb);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, th->list.btn.rel);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, th->list.btn.pr);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, th->list.btn.tgl_rel);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, th->list.btn.tgl_pr);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, th->list.btn.ina);
} else {
lv_list_set_style(new_list, LV_LIST_STYLE_BG, &lv_style_transp_fit);
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, &lv_style_pretty);
}
} else {
lv_list_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
......
......@@ -10,8 +10,9 @@
#if USE_LV_LMETER != 0
#include "lv_lmeter.h"
#include "misc/math/trigo.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "misc/math/trigo.h"
/*********************
* DEFINES
......@@ -70,8 +71,15 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new line meter line meter*/
if(copy == NULL) {
lv_obj_set_size(new_lmeter, 1 * LV_DPI, 1 * LV_DPI);
lv_obj_set_style(new_lmeter, &lv_style_pretty_color);
lv_obj_set_size(new_lmeter, LV_DPI, LV_DPI);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_lmeter_set_style(new_lmeter, th->lmeter);
} else {
lv_lmeter_set_style(new_lmeter, &lv_style_pretty_color);
}
}
/*Copy an existing line meter*/
else {
......
......@@ -12,6 +12,7 @@
#include "lv_mbox.h"
#include "../lv_obj/lv_group.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/anim.h"
#include "misc/math/math_base.h"
......@@ -29,6 +30,7 @@
**********************/
static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param);
static void mbox_realign(lv_obj_t *mbox);
static lv_res_t lv_mbox_close_action(lv_obj_t *btn, const char *txt);
/**********************
* STATIC VARIABLES
......@@ -76,8 +78,16 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
lv_cont_set_layout(new_mbox, LV_CONT_LAYOUT_COL_M);
lv_cont_set_fit(new_mbox, false, true);
lv_obj_set_width(new_mbox, LV_HOR_RES / 3);
lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, th->mbox.bg);
} else {
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, &lv_style_pretty);
}
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, &lv_style_pretty);
}
/*Copy an existing message box*/
else {
......@@ -110,11 +120,21 @@ void lv_mbox_set_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t ac
if(ext->btnm == NULL) {
ext->btnm = lv_btnm_create(mbox, NULL);
lv_obj_set_height(ext->btnm, LV_DPI / 2);
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, &lv_style_transp_fit);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_BG, th->mbox.btn.bg);
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_REL, th->mbox.btn.rel);
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_PR, th->mbox.btn.pr);
} else {
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, &lv_style_transp_fit);
}
}
lv_btnm_set_map(ext->btnm, btn_map);
lv_btnm_set_action(ext->btnm, action);
if(action == NULL) lv_btnm_set_action(ext->btnm, lv_mbox_close_action); /*Set a default action anyway*/
else lv_btnm_set_action(ext->btnm, action);
mbox_realign(mbox);
}
......@@ -346,4 +366,16 @@ static void mbox_realign(lv_obj_t *mbox)
if(ext->text) lv_obj_set_width(ext->text, w);
}
static lv_res_t lv_mbox_close_action(lv_obj_t *btn, const char *txt)
{
lv_obj_t *mbox = lv_mbox_get_from_btn(btn);
if(txt[0] != '\0') {
lv_mbox_start_auto_close(mbox, 0);
return LV_RES_INV;
}
return LV_RES_OK;
}
#endif
......@@ -76,13 +76,6 @@ typedef enum {
lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy);
/**
* A release action which can be assigned to a message box button to close it
* @param btn pointer to the released button
* @return always lv_action_res_t because the button is deleted with the mesage box
*/
lv_res_t lv_mbox_close_action(lv_obj_t * btn);
/**
* Set button to the message box
* @param mbox pointer to message box object
* @param btn_map button descriptor (button matrix map).
......
......@@ -13,6 +13,7 @@
#include "../lv_obj/lv_group.h"
#include "../lv_objx/lv_page.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_obj/lv_refr.h"
#include "misc/gfx/anim.h"
......@@ -88,10 +89,20 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_signal_func(new_page, lv_page_signal);
lv_obj_set_design_func(new_page, lv_page_design);
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, &lv_style_pretty_color);
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_pretty);
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, &lv_style_pretty_color);
lv_page_set_sb_mode(new_page, ext->sb.mode);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->page.bg);
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->page.scrl);
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->page.sb);
} else {
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, &lv_style_pretty_color);
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_pretty);
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, &lv_style_pretty_color);
}
} else {
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
......
......@@ -11,6 +11,7 @@
#include "lv_roller.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
......@@ -78,7 +79,16 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
lv_label_set_align(ext->ddlist.label, LV_LABEL_ALIGN_CENTER);
lv_obj_set_signal_func(scrl, lv_roller_scrl_signal);
lv_obj_refresh_style(new_roller); /*To set scrollable size automatically*/
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_BG, th->roller.bg);
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_SEL, th->roller.sel);
} else {
/*Let the ddlist's style*/
lv_obj_refresh_style(new_roller); /*To set scrollable size automatically*/
}
}
/*Copy an existing roller*/
else {
......
......@@ -12,6 +12,7 @@
#include "lv_slider.h"
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "misc/math/math_base.h"
/*********************
......@@ -75,7 +76,16 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new slider slider*/
if(copy == NULL) {
lv_obj_set_click(new_slider, true);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, ext->style_knob);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_BG, th->slider.bg);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_INDIC, th->slider.indic);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, th->slider.knob);
} else {
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, ext->style_knob);
}
}
/*Copy an existing slider*/
else {
......
......@@ -10,6 +10,7 @@
#if USE_LV_SW != 0
#include "lv_sw.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
......@@ -68,6 +69,18 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy)
lv_slider_set_range(new_sw, 0, 1);
lv_obj_set_size(new_sw, 2 * LV_DPI / 3, LV_DPI / 3);
lv_slider_set_knob_in(new_sw, true);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_slider_set_style(new_sw, LV_SW_STYLE_BG, th->sw.bg);
lv_slider_set_style(new_sw, LV_SW_STYLE_INDIC, th->sw.indic);
lv_slider_set_style(new_sw, LV_SW_STYLE_KNOB_OFF, th->sw.knob_off);
lv_slider_set_style(new_sw, LV_SW_STYLE_KNOB_ON, th->sw.knob_on);
} else {
/*Let the slider' style*/
}
}
/*Copy an existing switch*/
else {
......
......@@ -13,6 +13,7 @@
#include "lv_ta.h"
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/anim.h"
#include "misc/gfx/text.h"
#include "misc/math/math_base.h"
......@@ -103,13 +104,22 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
ext->label = lv_label_create(new_ta, NULL);
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
lv_label_set_text(ext->label, "Text area");
lv_obj_set_click(ext->label, false);
lv_obj_set_style(new_ta, &lv_style_pretty);
lv_obj_set_style(lv_page_get_scrl(new_ta), &lv_style_transp_fit);
lv_obj_set_size(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
lv_ta_set_sb_mode(new_ta, LV_PAGE_SB_MODE_DRAG);
lv_page_set_style(new_ta, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, th->ta.area);
lv_ta_set_style(new_ta, LV_TA_STYLE_SB, th->ta.sb);
} else {
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, &lv_style_pretty);
}
}
/*Copy an existing object*/
else {
......
......@@ -9,8 +9,9 @@
#include "lv_conf.h"
#if USE_LV_TABVIEW != 0
#include <lvgl/lv_objx/lv_tabview.h>
#include "lv_tabview.h"
#include "lv_btnm.h"
#include "../lv_themes/lv_theme.h"
#include "misc/gfx/anim.h"
/*********************
......@@ -107,12 +108,23 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_height(ext->content, LV_VER_RES - lv_obj_get_height(ext->btns));
lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_transp);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, &lv_style_plain_color);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->tabview.bg);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->tabview.indic);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->tabview.btn.bg);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->tabview.btn.rel);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->tabview.btn.pr);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->tabview.btn.tgl_rel);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->tabview.btn.tgl_pr);
} else {
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_transp);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, &lv_style_plain_color);
}
}
/*Copy an existing tab*/
/*Copy an existing tab view*/
else {
lv_tabview_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->point_last.x = 0;
......@@ -194,7 +206,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
lv_obj_set_width(ext->indic, indic_width);
lv_obj_set_x(ext->indic, indic_width * ext->tab_cur + style_tabs->body.padding.inner * ext->tab_cur + style_tabs->body.padding.hor);
/*Set the first tab as active*/
/*Set the first btn as active*/
if(ext->tab_cnt == 1) {
ext->tab_cur = 0;
lv_tabview_set_current_tab(tabview, 0, false);
......@@ -274,7 +286,7 @@ void lv_tabview_set_current_tab(lv_obj_t * tabview, uint16_t id, bool anim_en)
* Set an action to call when a tab is loaded (Good to create content only if required)
* lv_tabview_get_act() still gives the current (old) tab (to remove content from here)
* @param tabview pointer to a tabview object
* @param action pointer to a function to call when a tab is loaded
* @param action pointer to a function to call when a btn is loaded
*/
void lv_tabview_set_tab_load_action(lv_obj_t *tabview, lv_tabview_action_t action)
{
......@@ -346,9 +358,9 @@ void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t
*====================*/
/**
* Get the index of the currently active tab
* Get the index of the currently active btn
* @param tabview pointer to Tab view object
* @return the active tab index
* @return the active btn index
*/
uint16_t lv_tabview_get_current_tab(lv_obj_t * tabview)
{
......@@ -359,7 +371,7 @@ uint16_t lv_tabview_get_current_tab(lv_obj_t * tabview)
/**
* Get the number of tabs
* @param tabview pointer to Tab view object
* @return tab count
* @return btn count
*/
uint16_t lv_tabview_get_tab_count(lv_obj_t * tabview)
{
......@@ -370,7 +382,7 @@ uint16_t lv_tabview_get_tab_count(lv_obj_t * tabview)
/**
* Get the page (content area) of a tab
* @param tabview pointer to Tab view object
* @param id index of the tab (>= 0)
* @param id index of the btn (>= 0)
* @return pointer to page (lv_page) object
*/
lv_obj_t * lv_tabview_get_tab(lv_obj_t * tabview, uint16_t id)
......@@ -392,7 +404,7 @@ lv_obj_t * lv_tabview_get_tab(lv_obj_t * tabview, uint16_t id)
/**
* Get the tab load action
* @param tabview pointer to a tabview object
* @param return the current tab load action
* @param return the current btn load action
*/
lv_tabview_action_t lv_tabview_get_tab_load_action(lv_obj_t *tabview)
{
......@@ -537,8 +549,8 @@ static lv_res_t tabpage_scrl_signal(lv_obj_t * tab_scrl, lv_signal_t sign, void
/**
* Called when a tab's page or scrollable object is pressed
* @param tabview pointer to the tab view object
* @param tabpage pointer to the page of a tab
* @param tabview pointer to the btn view object
* @param tabpage pointer to the page of a btn
*/
static void tabpage_pressed_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
{
......@@ -549,8 +561,8 @@ static void tabpage_pressed_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
/**
* Called when a tab's page or scrollable object is being pressed
* @param tabview pointer to the tab view object
* @param tabpage pointer to the page of a tab
* @param tabview pointer to the btn view object
* @param tabpage pointer to the page of a btn
*/
static void tabpage_pressing_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
{
......@@ -588,8 +600,8 @@ static void tabpage_pressing_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
/**
* Called when a tab's page or scrollable object is released or the press id lost
* @param tabview pointer to the tab view object
* @param tabpage pointer to the page of a tab
* @param tabview pointer to the btn view object
* @param tabpage pointer to the page of a btn
*/
static void tabpage_press_lost_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
{
......
......@@ -10,6 +10,7 @@
#if USE_LV_WIN != 0
#include "lv_win.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
......@@ -71,7 +72,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
ext->page = lv_page_create(new_win, NULL);
lv_obj_set_protect(ext->page, LV_PROTECT_PARENT);
lv_page_set_sb_mode(ext->page, LV_PAGE_SB_MODE_AUTO);
lv_page_set_style(ext->page, LV_PAGE_STYLE_BG, &lv_style_transp_tight);
lv_page_set_style(ext->page, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
/*Create a holder for the header*/
ext->header = lv_obj_create(new_win, NULL);
......@@ -83,9 +84,24 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
ext->title = lv_label_create(ext->header, NULL);
lv_label_set_text(ext->title,"My title");
lv_win_set_style(new_win, LV_WIN_STYLE_BG, &lv_style_pretty);
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT, &lv_style_transp);
lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, &lv_style_plain_color);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_win_set_style(new_win, LV_WIN_STYLE_BG, th->win.bg);
lv_win_set_style(new_win, LV_WIN_STYLE_SB, th->win.sb);
lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, th->win.header);
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT, th->win.content);
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_REL, th->win.btn.rel);
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_PR, th->win.btn.pr);
} else {
lv_win_set_style(new_win, LV_WIN_STYLE_BG, &lv_style_pretty);
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT, &lv_style_transp);
lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, &lv_style_plain_color);
}
lv_obj_set_signal_func(new_win, lv_win_signal);
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
......@@ -212,7 +228,7 @@ void lv_win_set_style(lv_obj_t *win, lv_win_style_t type, lv_style_t *style)
lv_win_realign(win);
break;
case LV_WIN_STYLE_CONTENT:
lv_page_set_style(ext->page, LV_PAGE_STYLE_SCRL, style);
lv_page_set_style(ext->page, LV_PAGE_STYLE_BG, style);
break;
case LV_WIN_STYLE_SB:
lv_page_set_style(ext->page, LV_PAGE_STYLE_SB, style);
......@@ -292,8 +308,7 @@ cord_t lv_win_get_width(lv_obj_t * win)
*/
lv_obj_t * lv_win_get_from_btn(lv_obj_t * ctrl_btn)
{
lv_obj_t * ctrl_holder = lv_obj_get_parent(ctrl_btn);
lv_obj_t * header = lv_obj_get_parent(ctrl_holder);
lv_obj_t * header = lv_obj_get_parent(ctrl_btn);
lv_obj_t * win = lv_obj_get_parent(header);
return win;
......@@ -312,7 +327,7 @@ lv_style_t * lv_win_get_style(lv_obj_t *win, lv_win_style_t type)
switch (type) {
case LV_WIN_STYLE_BG: return lv_obj_get_style(win);
case LV_WIN_STYLE_SB: return lv_page_get_style(ext->page, LV_PAGE_STYLE_SB);
case LV_WIN_STYLE_CONTENT: return lv_page_get_style(ext->page, LV_PAGE_STYLE_SCRL);
case LV_WIN_STYLE_CONTENT: return lv_page_get_style(ext->page, LV_PAGE_STYLE_BG);
case LV_WIN_STYLE_HEADER: return lv_obj_get_style(ext->header);
case LV_WIN_STYLE_BTN_REL: return ext->style_btn_rel;
case LV_WIN_STYLE_BTN_PR: return ext->style_btn_pr;
......
/**
*@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*/
/**
* @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*/
......@@ -17,8 +17,12 @@ extern "C" {
/*Test misc. module version*/
#include "misc/misc.h"
#include "lv_hal/lv_hal.h"
#include "lv_obj/lv_obj.h"
#include "lv_obj/lv_group.h"
#include "lv_themes/lv_theme.h"
#include "lv_objx/lv_btn.h"
#include "lv_objx/lv_img.h"
#include "lv_objx/lv_label.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment