From 86b34460dd80d6c3e35d903a6ee29ab943137704 Mon Sep 17 00:00:00 2001 From: MiSimon Date: Fri, 1 Feb 2019 23:53:09 +0100 Subject: [PATCH 01/33] Added POS1 and END support to lv_ta --- lv_core/lv_group.h | 2 ++ lv_objx/lv_ta.c | 19 ++++++++++++++----- lv_objx/lv_ta.h | 6 ++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lv_core/lv_group.h b/lv_core/lv_group.h index 6be9b5cca..7aac83d60 100644 --- a/lv_core/lv_group.h +++ b/lv_core/lv_group.h @@ -36,6 +36,8 @@ extern "C" { #define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/ #define LV_GROUP_KEY_NEXT 9 /*0x09, '\t'*/ #define LV_GROUP_KEY_PREV 11 /*0x0B, '*/ +#define LV_GROUP_KEY_POS1 2 /*0x02, STX*/ +#define LV_GROUP_KEY_END 3 /*0x03, ETX*/ #if USE_LV_GROUP != 0 /********************** diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 69c12ce03..f6d3a4614 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -351,6 +351,17 @@ void lv_ta_del_char(lv_obj_t * ta) lv_ta_set_cursor_pos(ta, ext->cursor.pos - 1); } +/** + * Delete the right character from the current cursor position + * @param ta pointer to a text area object + */ +void lv_ta_del_char_forward(lv_obj_t * ta) +{ + uint16_t cp = lv_ta_get_cursor_pos(ta); + lv_ta_set_cursor_pos(ta, cp + 1); + if(cp != lv_ta_get_cursor_pos(ta)) lv_ta_del_char(ta); +} + /*===================== * Setter functions *====================*/ @@ -1051,11 +1062,9 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) else if(c == LV_GROUP_KEY_UP) lv_ta_cursor_up(ta); else if(c == LV_GROUP_KEY_DOWN) lv_ta_cursor_down(ta); else if(c == LV_GROUP_KEY_BACKSPACE) lv_ta_del_char(ta); - else if(c == LV_GROUP_KEY_DEL) { - uint16_t cp = lv_ta_get_cursor_pos(ta); - lv_ta_set_cursor_pos(ta, cp + 1); - if(cp != lv_ta_get_cursor_pos(ta)) lv_ta_del_char(ta); - } + else if(c == LV_GROUP_KEY_DEL) lv_ta_del_char_forward(ta); + else if(c == LV_GROUP_KEY_POS1) lv_ta_set_cursor_pos(ta, 0); + else if(c == LV_GROUP_KEY_END) lv_ta_set_cursor_pos(ta, LV_TA_CURSOR_LAST); else { lv_ta_add_char(ta, c); } diff --git a/lv_objx/lv_ta.h b/lv_objx/lv_ta.h index 3227873a7..dd38cc857 100644 --- a/lv_objx/lv_ta.h +++ b/lv_objx/lv_ta.h @@ -122,6 +122,12 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt); */ void lv_ta_del_char(lv_obj_t * ta); +/** + * Delete the right character from the current cursor position + * @param ta pointer to a text area object + */ +void lv_ta_del_char_forward(lv_obj_t * ta); + /*===================== * Setter functions *====================*/ From dc9cffec5d316c4c19a062f732abdf479359d314 Mon Sep 17 00:00:00 2001 From: MiSimon Date: Sat, 2 Feb 2019 00:19:18 +0100 Subject: [PATCH 02/33] Position cursor at the position at which lv_ta was clicked --- lv_objx/lv_ta.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 69c12ce03..521ca61ad 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -53,6 +53,7 @@ static void pwd_char_hider(lv_obj_t * ta); static bool char_is_accepted(lv_obj_t * ta, uint32_t c); static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res); static void refr_cursor_area(lv_obj_t * ta); +static lv_res_t label_signal_wrapper(lv_obj_t * ta, lv_signal_t sign, void * param); /********************** * STATIC VARIABLES @@ -61,6 +62,7 @@ static lv_design_func_t ancestor_design; static lv_design_func_t scrl_design; static lv_signal_func_t ancestor_signal; static lv_signal_func_t scrl_signal; +static lv_signal_func_t label_signal_original; /********************** * MACROS @@ -153,6 +155,11 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_refresh_style(new_ta); } + /*Wrap the labels signal function and make it clickable*/ + if(label_signal_original) label_signal_original = lv_obj_get_signal_func(ext->label); + lv_obj_set_signal_func(ext->label, label_signal_wrapper); + lv_obj_set_click(ext->label, true); + #if USE_LV_ANIMATION /*Create a cursor blinker animation*/ lv_anim_t a; @@ -1090,7 +1097,36 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) lv_ta_set_cursor_type(ta, cur_type & (~LV_CURSOR_HIDDEN)); } #endif + } else if(sign == LV_SIGNAL_PRESSED) { + lv_indev_t * indev = (lv_indev_t *)param; + lv_area_t label_coords; + uint16_t index_of_char_at_position; + + lv_obj_get_coords(ext->label, &label_coords); + + lv_point_t relative_position = { + indev->proc.act_point.x - label_coords.x1, + indev->proc.act_point.y - label_coords.y1 + }; + + lv_coord_t label_width = lv_obj_get_width(ext->label); + + /*Check if the click happend on the left side of the area ouside the label*/ + if (relative_position.x < 0) { + index_of_char_at_position = 0; + } + /*Check if the click happend on the right side of the area ouside the label*/ + else if (relative_position.x >= label_width) { + index_of_char_at_position = LV_TA_CURSOR_LAST; + } + else { + index_of_char_at_position = lv_label_get_letter_on(ext->label, &relative_position); + + } + + lv_ta_set_cursor_pos(ta, index_of_char_at_position); } + return res; } @@ -1345,4 +1381,27 @@ static void refr_cursor_area(lv_obj_t * ta) lv_inv_area(&area_tmp); } +static lv_res_t label_signal_wrapper(lv_obj_t * label, lv_signal_t sign, void * param) +{ + if(sign == LV_SIGNAL_PRESSED) { + lv_obj_t * parent; + + parent = lv_obj_get_parent(label); + /*Get the parent (ta) of the parent (scrl part)*/ + parent = parent ? lv_obj_get_parent(parent) : NULL; + + /*Forward the pressed event to the parent, which is the ta*/ + if(parent) { + lv_signal_func_t parent_signal = lv_obj_get_signal_func(parent); + + if(parent_signal) { + if(parent_signal(parent, sign, param) != LV_RES_OK) return LV_RES_INV; + } + } + } + + if(label_signal_original) return label_signal_original(label, sign, param); + + return LV_RES_OK; +} #endif From 4e61a2da338818914aa3b3c544c9a483a1702b41 Mon Sep 17 00:00:00 2001 From: MiSimon Date: Sat, 2 Feb 2019 00:21:50 +0100 Subject: [PATCH 03/33] Fixed missing NULL check --- lv_objx/lv_ta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 521ca61ad..4518bfd6c 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -156,7 +156,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) } /*Wrap the labels signal function and make it clickable*/ - if(label_signal_original) label_signal_original = lv_obj_get_signal_func(ext->label); + if(label_signal_original == NULL) label_signal_original = lv_obj_get_signal_func(ext->label); lv_obj_set_signal_func(ext->label, label_signal_wrapper); lv_obj_set_click(ext->label, true); From 8acc122ab0569710e9a1e83a097974e839a93ef6 Mon Sep 17 00:00:00 2001 From: MiSimon Date: Sat, 2 Feb 2019 01:26:52 +0100 Subject: [PATCH 04/33] Added placeholder label to text area --- lv_objx/lv_ta.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ lv_objx/lv_ta.h | 16 ++++++++++ 2 files changed, 100 insertions(+) diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 69c12ce03..e89caaced 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -53,6 +53,7 @@ static void pwd_char_hider(lv_obj_t * ta); static bool char_is_accepted(lv_obj_t * ta, uint32_t c); static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res); static void refr_cursor_area(lv_obj_t * ta); +static void placeholder_update(lv_obj_t * ta); /********************** * STATIC VARIABLES @@ -247,6 +248,8 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c) /*Revert the original edge flash state*/ lv_ta_set_edge_flash(ta, edge_flash_en); + + placeholder_update(ta); } /** @@ -310,6 +313,8 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt) /*Revert the original edge flash state*/ lv_ta_set_edge_flash(ta, edge_flash_en); + + placeholder_update(ta); } /** @@ -349,6 +354,8 @@ void lv_ta_del_char(lv_obj_t * ta) /*Move the cursor to the place of the deleted character*/ lv_ta_set_cursor_pos(ta, ext->cursor.pos - 1); + + placeholder_update(ta); } /*===================== @@ -411,6 +418,29 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt) pwd_char_hider(ta); #endif } + + placeholder_update(ta); +} + +/** +* Set the placeholder text of a text area +* @param ta pointer to a text area +* @param txt pointer to the text +*/ +void lv_ta_set_placeholder_text(lv_obj_t * ta, const char * txt) +{ + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + + /*Create the placeholder label only when it is needed*/ + if (ext->placeholder == NULL) { + ext->placeholder = lv_label_create(ta, NULL); + + lv_label_set_long_mode(ext->placeholder, LV_LABEL_LONG_CROP); + } + + lv_label_set_text(ext->placeholder, txt); + + placeholder_update(ta); } /** @@ -663,6 +693,9 @@ void lv_ta_set_style(lv_obj_t * ta, lv_ta_style_t type, lv_style_t * style) lv_obj_refresh_ext_size(lv_page_get_scrl(ta)); /*Refresh ext. size because of cursor drawing*/ refr_cursor_area(ta); break; + case LV_TA_STYLE_PLACEHOLDER: + if(ext->placeholder) lv_label_set_style(ext->placeholder, style); + break; } } @@ -689,6 +722,21 @@ const char * lv_ta_get_text(const lv_obj_t * ta) return txt; } +/** +* Get the placeholder text of a text area +* @param ta pointer to a text area object +* @return pointer to the text +*/ +const char * lv_ta_get_placeholder_text(lv_obj_t * ta) +{ + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + + const char * txt = NULL; + + if (ext->placeholder) txt = lv_label_get_text(ext->label); + + return txt; +} /** * Get the label of a text area @@ -793,6 +841,9 @@ lv_style_t * lv_ta_get_style(const lv_obj_t * ta, lv_ta_style_t type) case LV_TA_STYLE_CURSOR: style = ext->cursor.style; break; + case LV_TA_STYLE_PLACEHOLDER: + if (ext->placeholder) style = lv_label_get_style(ext->placeholder); + break; default: style = NULL; break; @@ -1026,6 +1077,11 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) /*In not one line mode refresh the Label width because 'hpad' can modify it*/ lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->body.padding.hor); lv_obj_set_pos(ext->label, style_scrl->body.padding.hor, style_scrl->body.padding.ver); /*Be sure the Label is in the correct position*/ + + if(ext->placeholder) { + lv_obj_set_width(ext->placeholder, lv_obj_get_width(scrl) - 2 * style_scrl->body.padding.hor); + lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.hor, style_scrl->body.padding.ver); /*Be sure the Label is in the correct position*/ + } } lv_label_set_text(ext->label, NULL); @@ -1041,6 +1097,19 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) lv_obj_set_pos(ext->label, style_scrl->body.padding.hor, style_scrl->body.padding.ver); lv_label_set_text(ext->label, NULL); /*Refresh the label*/ + refr_cursor_area(ta); + } + } + /*Set the placeholder width according to the text area width*/ + if (ext->placeholder) { + if (lv_obj_get_width(ta) != lv_area_get_width(param) || + lv_obj_get_height(ta) != lv_area_get_height(param)) { + lv_obj_t * scrl = lv_page_get_scrl(ta); + lv_style_t * style_scrl = lv_obj_get_style(scrl); + lv_obj_set_width(ext->placeholder, lv_obj_get_width(scrl) - 2 * style_scrl->body.padding.hor); + lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.hor, style_scrl->body.padding.ver); + lv_label_set_text(ext->placeholder, NULL); /*Refresh the label*/ + refr_cursor_area(ta); } } @@ -1345,4 +1414,19 @@ static void refr_cursor_area(lv_obj_t * ta) lv_inv_area(&area_tmp); } +static void placeholder_update(lv_obj_t * ta) +{ + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + const char *ta_text; + + if (ext->placeholder == NULL) return; + + ta_text = lv_ta_get_text(ta); + + uint32_t len = ta_text == NULL ? 0 : strlen(ta_text); + + if(len == 0) lv_obj_set_hidden(ext->placeholder, false); + else lv_obj_set_hidden(ext->placeholder, true); +} + #endif diff --git a/lv_objx/lv_ta.h b/lv_objx/lv_ta.h index 3227873a7..f9c082790 100644 --- a/lv_objx/lv_ta.h +++ b/lv_objx/lv_ta.h @@ -59,6 +59,7 @@ typedef struct lv_page_ext_t page; /*Ext. of ancestor*/ /*New data for this type */ lv_obj_t * label; /*Label of the text area*/ + lv_obj_t * placeholder; /*Place holder label of the text area, only visible if text is an empty string*/ char * pwd_tmp; /*Used to store the original text in password mode*/ const char * accapted_chars;/*Only these characters will be accepted. NULL: accept all*/ uint16_t max_length; /*The max. number of characters. 0: no limit*/ @@ -80,6 +81,7 @@ enum { LV_TA_STYLE_SB, LV_TA_STYLE_EDGE_FLASH, LV_TA_STYLE_CURSOR, + LV_TA_STYLE_PLACEHOLDER, }; typedef uint8_t lv_ta_style_t; @@ -133,6 +135,13 @@ void lv_ta_del_char(lv_obj_t * ta); */ void lv_ta_set_text(lv_obj_t * ta, const char * txt); +/** +* Set the placeholder text of a text area +* @param ta pointer to a text area +* @param txt pointer to the text +*/ +void lv_ta_set_placeholder_text(lv_obj_t * ta, const char * txt); + /** * Set the cursor position * @param obj pointer to a text area object @@ -245,6 +254,13 @@ void lv_ta_set_style(lv_obj_t *ta, lv_ta_style_t type, lv_style_t *style); */ const char * lv_ta_get_text(const lv_obj_t * ta); +/** +* Get the placeholder text of a text area +* @param ta pointer to a text area object +* @return pointer to the text +*/ +const char * lv_ta_get_placeholder_text(lv_obj_t * ta); + /** * Get the label of a text area * @param ta pointer to a text area object From 1e6dc74c5a76bafe541490cd75ec3f0d88eaea1c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 2 Feb 2019 05:00:59 +0100 Subject: [PATCH 05/33] lv_ta click simplification --- lv_objx/lv_ta.c | 85 ++++++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 57 deletions(-) diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 4518bfd6c..3b5510cac 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -53,7 +53,6 @@ static void pwd_char_hider(lv_obj_t * ta); static bool char_is_accepted(lv_obj_t * ta, uint32_t c); static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res); static void refr_cursor_area(lv_obj_t * ta); -static lv_res_t label_signal_wrapper(lv_obj_t * ta, lv_signal_t sign, void * param); /********************** * STATIC VARIABLES @@ -62,7 +61,6 @@ static lv_design_func_t ancestor_design; static lv_design_func_t scrl_design; static lv_signal_func_t ancestor_signal; static lv_signal_func_t scrl_signal; -static lv_signal_func_t label_signal_original; /********************** * MACROS @@ -155,11 +153,6 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_refresh_style(new_ta); } - /*Wrap the labels signal function and make it clickable*/ - if(label_signal_original == NULL) label_signal_original = lv_obj_get_signal_func(ext->label); - lv_obj_set_signal_func(ext->label, label_signal_wrapper); - lv_obj_set_click(ext->label, true); - #if USE_LV_ANIMATION /*Create a cursor blinker animation*/ lv_anim_t a; @@ -1097,7 +1090,34 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) lv_ta_set_cursor_type(ta, cur_type & (~LV_CURSOR_HIDDEN)); } #endif - } else if(sign == LV_SIGNAL_PRESSED) { + } + return res; +} + +/** + * Signal function of the scrollable part of the text area + * @param scrl pointer to scrollable part of a text area object + * @param sign a signal type from lv_signal_t enum + * @param param pointer to a signal specific variable + * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted + */ +static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param) +{ + lv_res_t res; + + /* Include the ancient signal function */ + res = scrl_signal(scrl, sign, param); + if(res != LV_RES_OK) return res; + + lv_obj_t * ta = lv_obj_get_parent(scrl); + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + if(sign == LV_SIGNAL_REFR_EXT_SIZE) { + /*Set ext. size because the cursor might be out of this object*/ + lv_style_t * style_label = lv_obj_get_style(ext->label); + lv_coord_t font_h = lv_font_get_height(style_label->text.font); + scrl->ext_size = LV_MATH_MAX(scrl->ext_size, style_label->text.line_space + font_h); + } + else if(sign == LV_SIGNAL_PRESSED) { lv_indev_t * indev = (lv_indev_t *)param; lv_area_t label_coords; uint16_t index_of_char_at_position; @@ -1127,32 +1147,6 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) lv_ta_set_cursor_pos(ta, index_of_char_at_position); } - return res; -} - -/** - * Signal function of the scrollable part of the text area - * @param scrl pointer to scrollable part of a text area object - * @param sign a signal type from lv_signal_t enum - * @param param pointer to a signal specific variable - * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted - */ -static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param) -{ - lv_res_t res; - - /* Include the ancient signal function */ - res = scrl_signal(scrl, sign, param); - if(res != LV_RES_OK) return res; - - if(sign == LV_SIGNAL_REFR_EXT_SIZE) { - /*Set ext. size because the cursor might be out of this object*/ - lv_obj_t * ta = lv_obj_get_parent(scrl); - lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); - lv_style_t * style_label = lv_obj_get_style(ext->label); - lv_coord_t font_h = lv_font_get_height(style_label->text.font); - scrl->ext_size = LV_MATH_MAX(scrl->ext_size, style_label->text.line_space + font_h); - } return res; } @@ -1381,27 +1375,4 @@ static void refr_cursor_area(lv_obj_t * ta) lv_inv_area(&area_tmp); } -static lv_res_t label_signal_wrapper(lv_obj_t * label, lv_signal_t sign, void * param) -{ - if(sign == LV_SIGNAL_PRESSED) { - lv_obj_t * parent; - - parent = lv_obj_get_parent(label); - /*Get the parent (ta) of the parent (scrl part)*/ - parent = parent ? lv_obj_get_parent(parent) : NULL; - - /*Forward the pressed event to the parent, which is the ta*/ - if(parent) { - lv_signal_func_t parent_signal = lv_obj_get_signal_func(parent); - - if(parent_signal) { - if(parent_signal(parent, sign, param) != LV_RES_OK) return LV_RES_INV; - } - } - } - - if(label_signal_original) return label_signal_original(label, sign, param); - - return LV_RES_OK; -} #endif From cfe0c14e56a7fd369d8703fa3155afa79a7f2851 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 2 Feb 2019 05:11:18 +0100 Subject: [PATCH 06/33] ta click: add to lv_ta_signal too --- lv_objx/lv_ta.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 3b5510cac..1b322c6bb 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -1091,6 +1091,30 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) } #endif } + else if(sign == LV_SIGNAL_PRESSED) { + lv_indev_t * indev = (lv_indev_t *)param; + lv_area_t label_coords; + uint16_t index_of_char_at_position; + + lv_obj_get_coords(ext->label, &label_coords); + + lv_point_t relative_position; + relative_position.x = indev->proc.act_point.x - label_coords.x1; + relative_position.y = indev->proc.act_point.y - label_coords.y1; + + lv_coord_t label_width = lv_obj_get_width(ext->label); + + /*Check if the click happened on the left side of the area outside the label*/ + if (relative_position.x < label_width / 2) { + index_of_char_at_position = 0; + } + /*Check if the click happened on the right side of the area outside the label*/ + else if (relative_position.x >= label_width / 2) { + index_of_char_at_position = LV_TA_CURSOR_LAST; + } + + lv_ta_set_cursor_pos(ta, index_of_char_at_position); + } return res; } @@ -1124,18 +1148,18 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_obj_get_coords(ext->label, &label_coords); - lv_point_t relative_position = { - indev->proc.act_point.x - label_coords.x1, - indev->proc.act_point.y - label_coords.y1 - }; + lv_point_t relative_position; + relative_position.x = indev->proc.act_point.x - label_coords.x1; + relative_position.y = indev->proc.act_point.y - label_coords.y1; + lv_coord_t label_width = lv_obj_get_width(ext->label); - /*Check if the click happend on the left side of the area ouside the label*/ + /*Check if the click happened on the left side of the area outside the label*/ if (relative_position.x < 0) { index_of_char_at_position = 0; } - /*Check if the click happend on the right side of the area ouside the label*/ + /*Check if the click happened on the right side of the area outside the label*/ else if (relative_position.x >= label_width) { index_of_char_at_position = LV_TA_CURSOR_LAST; } From 0d76cc4ef3b707bcad82827a26502fcf042f60ef Mon Sep 17 00:00:00 2001 From: MiSimon Date: Sat, 2 Feb 2019 22:45:02 +0100 Subject: [PATCH 07/33] Changed POS1 to HOME --- lv_core/lv_group.h | 2 +- lv_objx/lv_ta.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lv_core/lv_group.h b/lv_core/lv_group.h index 7aac83d60..133d5954e 100644 --- a/lv_core/lv_group.h +++ b/lv_core/lv_group.h @@ -36,7 +36,7 @@ extern "C" { #define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/ #define LV_GROUP_KEY_NEXT 9 /*0x09, '\t'*/ #define LV_GROUP_KEY_PREV 11 /*0x0B, '*/ -#define LV_GROUP_KEY_POS1 2 /*0x02, STX*/ +#define LV_GROUP_KEY_HOME 2 /*0x02, STX*/ #define LV_GROUP_KEY_END 3 /*0x03, ETX*/ #if USE_LV_GROUP != 0 diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index f6d3a4614..951f32049 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -1063,7 +1063,7 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) else if(c == LV_GROUP_KEY_DOWN) lv_ta_cursor_down(ta); else if(c == LV_GROUP_KEY_BACKSPACE) lv_ta_del_char(ta); else if(c == LV_GROUP_KEY_DEL) lv_ta_del_char_forward(ta); - else if(c == LV_GROUP_KEY_POS1) lv_ta_set_cursor_pos(ta, 0); + else if(c == LV_GROUP_KEY_HOME) lv_ta_set_cursor_pos(ta, 0); else if(c == LV_GROUP_KEY_END) lv_ta_set_cursor_pos(ta, LV_TA_CURSOR_LAST); else { lv_ta_add_char(ta, c); From 43b20179ed4c678e5bb7e705dfa4893051fd0195 Mon Sep 17 00:00:00 2001 From: MiSimon Date: Sat, 2 Feb 2019 22:59:28 +0100 Subject: [PATCH 08/33] removed code duplication --- lv_objx/lv_ta.c | 82 ++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 49 deletions(-) diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 1b322c6bb..9c1fd3abc 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -53,6 +53,7 @@ static void pwd_char_hider(lv_obj_t * ta); static bool char_is_accepted(lv_obj_t * ta, uint32_t c); static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res); static void refr_cursor_area(lv_obj_t * ta); +static void update_cursor_position_on_click(lv_obj_t * ta, lv_indev_t * click_source); /********************** * STATIC VARIABLES @@ -1092,28 +1093,7 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) #endif } else if(sign == LV_SIGNAL_PRESSED) { - lv_indev_t * indev = (lv_indev_t *)param; - lv_area_t label_coords; - uint16_t index_of_char_at_position; - - lv_obj_get_coords(ext->label, &label_coords); - - lv_point_t relative_position; - relative_position.x = indev->proc.act_point.x - label_coords.x1; - relative_position.y = indev->proc.act_point.y - label_coords.y1; - - lv_coord_t label_width = lv_obj_get_width(ext->label); - - /*Check if the click happened on the left side of the area outside the label*/ - if (relative_position.x < label_width / 2) { - index_of_char_at_position = 0; - } - /*Check if the click happened on the right side of the area outside the label*/ - else if (relative_position.x >= label_width / 2) { - index_of_char_at_position = LV_TA_CURSOR_LAST; - } - - lv_ta_set_cursor_pos(ta, index_of_char_at_position); + update_cursor_position_on_click(ta, (lv_indev_t *) param); } return res; } @@ -1142,33 +1122,7 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void scrl->ext_size = LV_MATH_MAX(scrl->ext_size, style_label->text.line_space + font_h); } else if(sign == LV_SIGNAL_PRESSED) { - lv_indev_t * indev = (lv_indev_t *)param; - lv_area_t label_coords; - uint16_t index_of_char_at_position; - - lv_obj_get_coords(ext->label, &label_coords); - - lv_point_t relative_position; - relative_position.x = indev->proc.act_point.x - label_coords.x1; - relative_position.y = indev->proc.act_point.y - label_coords.y1; - - - lv_coord_t label_width = lv_obj_get_width(ext->label); - - /*Check if the click happened on the left side of the area outside the label*/ - if (relative_position.x < 0) { - index_of_char_at_position = 0; - } - /*Check if the click happened on the right side of the area outside the label*/ - else if (relative_position.x >= label_width) { - index_of_char_at_position = LV_TA_CURSOR_LAST; - } - else { - index_of_char_at_position = lv_label_get_letter_on(ext->label, &relative_position); - - } - - lv_ta_set_cursor_pos(ta, index_of_char_at_position); + update_cursor_position_on_click(ta, (lv_indev_t *)param); } @@ -1399,4 +1353,34 @@ static void refr_cursor_area(lv_obj_t * ta) lv_inv_area(&area_tmp); } +static void update_cursor_position_on_click(lv_obj_t * ta, lv_indev_t * click_source) +{ + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + + lv_area_t label_coords; + uint16_t index_of_char_at_position; + + lv_obj_get_coords(ext->label, &label_coords); + + lv_point_t relative_position; + relative_position.x = click_source->proc.act_point.x - label_coords.x1; + relative_position.y = click_source->proc.act_point.y - label_coords.y1; + + lv_coord_t label_width = lv_obj_get_width(ext->label); + + /*Check if the click happened on the left side of the area outside the label*/ + if (relative_position.x < 0) { + index_of_char_at_position = 0; + } + /*Check if the click happened on the right side of the area outside the label*/ + else if (relative_position.x >= label_width) { + index_of_char_at_position = LV_TA_CURSOR_LAST; + } + else { + index_of_char_at_position = lv_label_get_letter_on(ext->label, &relative_position); + } + + lv_ta_set_cursor_pos(ta, index_of_char_at_position); +} + #endif From a71964f0b266c36412dfb17c7202745b765db288 Mon Sep 17 00:00:00 2001 From: MiSimon Date: Sat, 2 Feb 2019 23:25:11 +0100 Subject: [PATCH 09/33] Removed some spaces --- lv_objx/lv_ta.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index e89caaced..971a3beef 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -432,7 +432,7 @@ void lv_ta_set_placeholder_text(lv_obj_t * ta, const char * txt) lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); /*Create the placeholder label only when it is needed*/ - if (ext->placeholder == NULL) { + if(ext->placeholder == NULL) { ext->placeholder = lv_label_create(ta, NULL); lv_label_set_long_mode(ext->placeholder, LV_LABEL_LONG_CROP); @@ -733,7 +733,7 @@ const char * lv_ta_get_placeholder_text(lv_obj_t * ta) const char * txt = NULL; - if (ext->placeholder) txt = lv_label_get_text(ext->label); + if(ext->placeholder) txt = lv_label_get_text(ext->label); return txt; } @@ -842,7 +842,7 @@ lv_style_t * lv_ta_get_style(const lv_obj_t * ta, lv_ta_style_t type) style = ext->cursor.style; break; case LV_TA_STYLE_PLACEHOLDER: - if (ext->placeholder) style = lv_label_get_style(ext->placeholder); + if(ext->placeholder) style = lv_label_get_style(ext->placeholder); break; default: style = NULL; @@ -1101,8 +1101,8 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) } } /*Set the placeholder width according to the text area width*/ - if (ext->placeholder) { - if (lv_obj_get_width(ta) != lv_area_get_width(param) || + if(ext->placeholder) { + if(lv_obj_get_width(ta) != lv_area_get_width(param) || lv_obj_get_height(ta) != lv_area_get_height(param)) { lv_obj_t * scrl = lv_page_get_scrl(ta); lv_style_t * style_scrl = lv_obj_get_style(scrl); @@ -1417,9 +1417,9 @@ static void refr_cursor_area(lv_obj_t * ta) static void placeholder_update(lv_obj_t * ta) { lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); - const char *ta_text; + const char * ta_text; - if (ext->placeholder == NULL) return; + if(ext->placeholder == NULL) return; ta_text = lv_ta_get_text(ta); From 44e5cc446c9a82043acc3cbaa963d8b409a3c4dc Mon Sep 17 00:00:00 2001 From: manison Date: Mon, 11 Feb 2019 09:35:06 +0100 Subject: [PATCH 10/33] moved theme styles into substructure within lv_theme_t https://github.com/littlevgl/lvgl/issues/806 --- lv_core/lv_obj.c | 4 +- lv_objx/lv_arc.c | 2 +- lv_objx/lv_bar.c | 4 +- lv_objx/lv_btn.c | 10 +- lv_objx/lv_btnm.c | 12 +- lv_objx/lv_calendar.c | 16 +- lv_objx/lv_cb.c | 12 +- lv_objx/lv_chart.c | 2 +- lv_objx/lv_cont.c | 2 +- lv_objx/lv_ddlist.c | 6 +- lv_objx/lv_gauge.c | 2 +- lv_objx/lv_kb.c | 12 +- lv_objx/lv_led.c | 2 +- lv_objx/lv_list.c | 16 +- lv_objx/lv_lmeter.c | 2 +- lv_objx/lv_mbox.c | 8 +- lv_objx/lv_page.c | 8 +- lv_objx/lv_preload.c | 2 +- lv_objx/lv_roller.c | 4 +- lv_objx/lv_slider.c | 6 +- lv_objx/lv_spinbox.c | 6 +- lv_objx/lv_sw.c | 8 +- lv_objx/lv_ta.c | 4 +- lv_objx/lv_table.c | 10 +- lv_objx/lv_tabview.c | 14 +- lv_objx/lv_tileview.c | 6 +- lv_objx/lv_win.c | 14 +- lv_themes/lv_theme.c | 6 +- lv_themes/lv_theme.h | 376 +++++++++++++++++----------------- lv_themes/lv_theme_alien.c | 200 +++++++++--------- lv_themes/lv_theme_default.c | 164 +++++++-------- lv_themes/lv_theme_material.c | 228 ++++++++++----------- lv_themes/lv_theme_mono.c | 172 ++++++++-------- lv_themes/lv_theme_nemo.c | 200 +++++++++--------- lv_themes/lv_theme_night.c | 200 +++++++++--------- lv_themes/lv_theme_templ.c | 196 +++++++++--------- lv_themes/lv_theme_zen.c | 228 ++++++++++----------- 37 files changed, 1083 insertions(+), 1081 deletions(-) diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index a58ead8c2..23330e592 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -160,7 +160,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - new_obj->style_p = th->bg; + new_obj->style_p = th->style.bg; } else { new_obj->style_p = &lv_style_scr; } @@ -227,7 +227,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) /*Set appearance*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - new_obj->style_p = th->panel; + new_obj->style_p = th->style.panel; } else { new_obj->style_p = &lv_style_plain_color; } diff --git a/lv_objx/lv_arc.c b/lv_objx/lv_arc.c index 683d34345..8f5ed9a6c 100644 --- a/lv_objx/lv_arc.c +++ b/lv_objx/lv_arc.c @@ -80,7 +80,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->arc); + lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->style.arc); } else { lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color); } diff --git a/lv_objx/lv_bar.c b/lv_objx/lv_bar.c index d83a60934..656225eb4 100644 --- a/lv_objx/lv_bar.c +++ b/lv_objx/lv_bar.c @@ -84,8 +84,8 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy) 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); + lv_bar_set_style(new_bar, LV_BAR_STYLE_BG, th->style.bar.bg); + lv_bar_set_style(new_bar, LV_BAR_STYLE_INDIC, th->style.bar.indic); } else { lv_obj_set_style(new_bar, &lv_style_pretty); } diff --git a/lv_objx/lv_btn.c b/lv_objx/lv_btn.c index 2bf8314b3..f96607683 100644 --- a/lv_objx/lv_btn.c +++ b/lv_objx/lv_btn.c @@ -123,11 +123,11 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy) /*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.rel); - lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.pr); - lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->btn.tgl_rel); - lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->btn.tgl_pr); - lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->btn.ina); + lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->style.btn.rel); + lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->style.btn.pr); + lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->style.btn.tgl_rel); + lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->style.btn.tgl_pr); + lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->style.btn.ina); } else { lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]); } diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 07e6a72b2..0128614f7 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -103,12 +103,12 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->style.btnm.bg); + lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->style.btnm.btn.rel); + lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_PR, th->style.btnm.btn.pr); + lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_REL, th->style.btnm.btn.tgl_rel); + lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_PR, th->style.btnm.btn.tgl_pr); + lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_INA, th->style.btnm.btn.ina); } else { lv_obj_set_style(new_btnm, &lv_style_pretty); } diff --git a/lv_objx/lv_calendar.c b/lv_objx/lv_calendar.c index 217c08d56..f8260cf4c 100644 --- a/lv_objx/lv_calendar.c +++ b/lv_objx/lv_calendar.c @@ -130,14 +130,14 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->calendar.bg); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->calendar.header); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->calendar.header_pr); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->calendar.day_names); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->calendar.week_box); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->calendar.today_box); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->calendar.highlighted_days); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->calendar.inactive_days); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->style.calendar.bg); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->style.calendar.header); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->style.calendar.header_pr); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->style.calendar.day_names); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->style.calendar.week_box); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->style.calendar.today_box); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->style.calendar.highlighted_days); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->style.calendar.inactive_days); } else { lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty); lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header); diff --git a/lv_objx/lv_cb.c b/lv_objx/lv_cb.c index 6b0277e14..7943ba6b2 100644 --- a/lv_objx/lv_cb.c +++ b/lv_objx/lv_cb.c @@ -88,12 +88,12 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_cb_set_style(new_cb, LV_CB_STYLE_BG, th->style.cb.bg); + lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, th->style.cb.box.rel); + lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_PR, th->style.cb.box.pr); + lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_REL, th->style.cb.box.tgl_rel); + lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_PR, th->style.cb.box.tgl_pr); + lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_INA, th->style.cb.box.ina); } else { lv_cb_set_style(new_cb, LV_CB_STYLE_BG, &lv_style_transp); lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, &lv_style_pretty); diff --git a/lv_objx/lv_chart.c b/lv_objx/lv_chart.c index 1dedaa7a4..3e581382c 100644 --- a/lv_objx/lv_chart.c +++ b/lv_objx/lv_chart.c @@ -95,7 +95,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_chart_set_style(new_chart, th->chart); + lv_chart_set_style(new_chart, th->style.chart); } else { lv_chart_set_style(new_chart, &lv_style_pretty); } diff --git a/lv_objx/lv_cont.c b/lv_objx/lv_cont.c index 304852a22..b6bbe0128 100644 --- a/lv_objx/lv_cont.c +++ b/lv_objx/lv_cont.c @@ -89,7 +89,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_cont_set_style(new_cont, th->cont); + lv_cont_set_style(new_cont, th->style.cont); } else { lv_cont_set_style(new_cont, &lv_style_pretty); } diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index c8805d591..11867e15b 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -118,9 +118,9 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, th->style.ddlist.bg); + lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, th->style.ddlist.sel); + lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, th->style.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); diff --git a/lv_objx/lv_gauge.c b/lv_objx/lv_gauge.c index ad2ef8d92..bdc6a179a 100644 --- a/lv_objx/lv_gauge.c +++ b/lv_objx/lv_gauge.c @@ -95,7 +95,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_gauge_set_style(new_gauge, th->gauge); + lv_gauge_set_style(new_gauge, th->style.gauge); } else { lv_gauge_set_style(new_gauge, &lv_style_pretty_color); } diff --git a/lv_objx/lv_kb.c b/lv_objx/lv_kb.c index 395fc8d5d..3259ffe59 100644 --- a/lv_objx/lv_kb.c +++ b/lv_objx/lv_kb.c @@ -110,12 +110,12 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->style.kb.bg); + lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->style.kb.btn.rel); + lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_PR, th->style.kb.btn.pr); + lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_REL, th->style.kb.btn.tgl_rel); + lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_PR, th->style.kb.btn.tgl_pr); + lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_INA, th->style.kb.btn.ina); } else { /*Let the button matrix's styles*/ } diff --git a/lv_objx/lv_led.c b/lv_objx/lv_led.c index 29fc967ee..3529eb545 100644 --- a/lv_objx/lv_led.c +++ b/lv_objx/lv_led.c @@ -79,7 +79,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_led_set_style(new_led, th->led); + lv_led_set_style(new_led, th->style.led); } else { lv_led_set_style(new_led, &lv_style_pretty_color); } diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index 8accb665a..275519c11 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -109,14 +109,14 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_list_set_style(new_list, LV_LIST_STYLE_BG, th->style.list.bg); + lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, th->style.list.scrl); + lv_list_set_style(new_list, LV_LIST_STYLE_SB, th->style.list.sb); + lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, th->style.list.btn.rel); + lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, th->style.list.btn.pr); + lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, th->style.list.btn.tgl_rel); + lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, th->style.list.btn.tgl_pr); + lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, th->style.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); diff --git a/lv_objx/lv_lmeter.c b/lv_objx/lv_lmeter.c index 4d78d8ee2..e86e4aa54 100644 --- a/lv_objx/lv_lmeter.c +++ b/lv_objx/lv_lmeter.c @@ -84,7 +84,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_lmeter_set_style(new_lmeter, th->lmeter); + lv_lmeter_set_style(new_lmeter, th->style.lmeter); } else { lv_lmeter_set_style(new_lmeter, &lv_style_pretty_color); } diff --git a/lv_objx/lv_mbox.c b/lv_objx/lv_mbox.c index af53ddd4d..06f15d015 100644 --- a/lv_objx/lv_mbox.c +++ b/lv_objx/lv_mbox.c @@ -97,7 +97,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, th->style.mbox.bg); } else { lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, &lv_style_pretty); } @@ -144,9 +144,9 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char ** btn_map, lv_btnm_action_t a /*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); + lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_BG, th->style.mbox.btn.bg); + lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_REL, th->style.mbox.btn.rel); + lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_PR, th->style.mbox.btn.pr); } else { lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, &lv_style_transp_fit); } diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index f01418d10..47647cc30 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -116,14 +116,14 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) lv_theme_t * th = lv_theme_get_current(); if(th) { if(par == NULL) { /*Different styles if it is screen*/ - lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->bg); + lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.bg); lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_transp); } else { - 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_BG, th->style.page.bg); + lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->style.page.scrl); } - lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->page.sb); + lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->style.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); diff --git a/lv_objx/lv_preload.c b/lv_objx/lv_preload.c index 1700a4dab..9532e53c8 100644 --- a/lv_objx/lv_preload.c +++ b/lv_objx/lv_preload.c @@ -93,7 +93,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_preload_set_style(new_preload, LV_PRELOAD_STYLE_MAIN, th->preload); + lv_preload_set_style(new_preload, LV_PRELOAD_STYLE_MAIN, th->style.preload); } else { lv_obj_set_style(new_preload, &lv_style_pretty_color); } diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index ae3419ddb..5eaafaeea 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -96,8 +96,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_roller_set_style(new_roller, LV_ROLLER_STYLE_BG, th->style.roller.bg); + lv_roller_set_style(new_roller, LV_ROLLER_STYLE_SEL, th->style.roller.sel); } else { /*Let the ddlist's style*/ lv_obj_refresh_style(new_roller); /*To set scrollable size automatically*/ diff --git a/lv_objx/lv_slider.c b/lv_objx/lv_slider.c index eaf04e8c2..d75f84bd1 100644 --- a/lv_objx/lv_slider.c +++ b/lv_objx/lv_slider.c @@ -86,9 +86,9 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_slider_set_style(new_slider, LV_SLIDER_STYLE_BG, th->style.slider.bg); + lv_slider_set_style(new_slider, LV_SLIDER_STYLE_INDIC, th->style.slider.indic); + lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, th->style.slider.knob); } else { lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, ext->style_knob); } diff --git a/lv_objx/lv_spinbox.c b/lv_objx/lv_spinbox.c index dc4c6086b..720286b36 100644 --- a/lv_objx/lv_spinbox.c +++ b/lv_objx/lv_spinbox.c @@ -87,9 +87,9 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_BG, th->spinbox.bg); - lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_CURSOR, th->spinbox.cursor); - lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_SB, th->spinbox.sb); + lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_BG, th->style.spinbox.bg); + lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_CURSOR, th->style.spinbox.cursor); + lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_SB, th->style.spinbox.sb); } } /*Copy an existing spinbox*/ diff --git a/lv_objx/lv_sw.c b/lv_objx/lv_sw.c index 2b09354ae..35fe47674 100644 --- a/lv_objx/lv_sw.c +++ b/lv_objx/lv_sw.c @@ -88,10 +88,10 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_sw_set_style(new_sw, LV_SW_STYLE_BG, th->sw.bg); - lv_sw_set_style(new_sw, LV_SW_STYLE_INDIC, th->sw.indic); - lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_OFF, th->sw.knob_off); - lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_ON, th->sw.knob_on); + lv_sw_set_style(new_sw, LV_SW_STYLE_BG, th->style.sw.bg); + lv_sw_set_style(new_sw, LV_SW_STYLE_INDIC, th->style.sw.indic); + lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_OFF, th->style.sw.knob_off); + lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_ON, th->style.sw.knob_on); } else { /*Let the slider' style*/ } diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 8199cd3e3..6ec094b7d 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -129,8 +129,8 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_ta_set_style(new_ta, LV_TA_STYLE_BG, th->style.ta.area); + lv_ta_set_style(new_ta, LV_TA_STYLE_SB, th->style.ta.sb); } else { lv_ta_set_style(new_ta, LV_TA_STYLE_BG, &lv_style_pretty); } diff --git a/lv_objx/lv_table.c b/lv_objx/lv_table.c index f1446ce33..55cb12896 100644 --- a/lv_objx/lv_table.c +++ b/lv_objx/lv_table.c @@ -89,11 +89,11 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_table_set_style(new_table, LV_TABLE_STYLE_BG, th->table.bg); - lv_table_set_style(new_table, LV_TABLE_STYLE_CELL1, th->table.cell); - lv_table_set_style(new_table, LV_TABLE_STYLE_CELL2, th->table.cell); - lv_table_set_style(new_table, LV_TABLE_STYLE_CELL3, th->table.cell); - lv_table_set_style(new_table, LV_TABLE_STYLE_CELL4, th->table.cell); + lv_table_set_style(new_table, LV_TABLE_STYLE_BG, th->style.table.bg); + lv_table_set_style(new_table, LV_TABLE_STYLE_CELL1, th->style.table.cell); + lv_table_set_style(new_table, LV_TABLE_STYLE_CELL2, th->style.table.cell); + lv_table_set_style(new_table, LV_TABLE_STYLE_CELL3, th->style.table.cell); + lv_table_set_style(new_table, LV_TABLE_STYLE_CELL4, th->style.table.cell); } else { lv_table_set_style(new_table, LV_TABLE_STYLE_BG, &lv_style_plain_color); } diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index 8b16ec878..774c7a7a3 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -129,13 +129,13 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) /*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); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->style.tabview.bg); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->style.tabview.indic); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->style.tabview.btn.bg); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->style.tabview.btn.rel); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->style.tabview.btn.pr); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->style.tabview.btn.tgl_rel); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->style.tabview.btn.tgl_pr); } else { lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, &lv_style_plain); lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_transp); diff --git a/lv_objx/lv_tileview.c b/lv_objx/lv_tileview.c index c80cfecad..c6c0ed98a 100644 --- a/lv_objx/lv_tileview.c +++ b/lv_objx/lv_tileview.c @@ -95,9 +95,9 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy) /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); if(th) { - lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, th->tileview.bg); - lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, th->tileview.scrl); - lv_page_set_style(new_tileview, LV_PAGE_STYLE_SB, th->tileview.sb); + lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, th->style.tileview.bg); + lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, th->style.tileview.scrl); + lv_page_set_style(new_tileview, LV_PAGE_STYLE_SB, th->style.tileview.sb); } else { lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, &lv_style_transp_tight); lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight); diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index 3bc968dda..db7205ae9 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -92,13 +92,13 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) /*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_BG, th->win.content.bg); - lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_SCRL, th->win.content.scrl); - 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); + lv_win_set_style(new_win, LV_WIN_STYLE_BG, th->style.win.bg); + lv_win_set_style(new_win, LV_WIN_STYLE_SB, th->style.win.sb); + lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, th->style.win.header); + lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, th->style.win.content.bg); + lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_SCRL, th->style.win.content.scrl); + lv_win_set_style(new_win, LV_WIN_STYLE_BTN_REL, th->style.win.btn.rel); + lv_win_set_style(new_win, LV_WIN_STYLE_BTN_PR, th->style.win.btn.pr); } else { lv_win_set_style(new_win, LV_WIN_STYLE_BG, &lv_style_plain); lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, &lv_style_plain); diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index 59a048991..2090529f6 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -60,7 +60,7 @@ void lv_theme_set_current(lv_theme_t * th) #if LV_THEME_LIVE_UPDATE == 0 current_theme = th; #else - uint32_t style_num = sizeof(lv_theme_t) / sizeof(lv_style_t *); /*Number of styles in a theme*/ + uint32_t style_num = sizeof(th->style) / sizeof(lv_style_t *); /*Number of styles in a theme*/ if(!inited) { /*It's not sure `th_styles` is big enough. Check it now!*/ @@ -71,7 +71,7 @@ void lv_theme_set_current(lv_theme_t * th) /*Initialize the style pointers `current_theme` to point to the `th_styles` style array */ uint16_t i; - lv_style_t ** cur_th_style_p = (lv_style_t **) ¤t_theme; + lv_style_t ** cur_th_style_p = (lv_style_t **) ¤t_theme.style; for(i = 0; i < style_num; i++) { uintptr_t adr = (uintptr_t)&th_styles[i]; memcpy(&cur_th_style_p[i], &adr, sizeof(lv_style_t *)); @@ -82,7 +82,7 @@ void lv_theme_set_current(lv_theme_t * th) /*Copy the styles pointed by the new theme to the `th_styles` style array*/ uint16_t i; - lv_style_t ** th_style = (lv_style_t **) th; + lv_style_t ** th_style = (lv_style_t **) &th->style; for(i = 0; i < style_num; i++) { uintptr_t s = (uintptr_t)th_style[i]; if(s) memcpy(&th_styles[i], (void *)s, sizeof(lv_style_t)); diff --git a/lv_themes/lv_theme.h b/lv_themes/lv_theme.h index 72c40aec5..cdb0771f8 100644 --- a/lv_themes/lv_theme.h +++ b/lv_themes/lv_theme.h @@ -30,265 +30,267 @@ extern "C" { **********************/ typedef struct { - lv_style_t *bg; - lv_style_t *panel; + struct { + lv_style_t *bg; + lv_style_t *panel; #if USE_LV_CONT != 0 - lv_style_t *cont; + lv_style_t *cont; #endif #if USE_LV_BTN != 0 - struct { - lv_style_t *rel; - lv_style_t *pr; - lv_style_t *tgl_rel; - lv_style_t *tgl_pr; - lv_style_t *ina; - } btn; + struct { + lv_style_t *rel; + lv_style_t *pr; + lv_style_t *tgl_rel; + lv_style_t *tgl_pr; + lv_style_t *ina; + } btn; #endif #if USE_LV_IMGBTN != 0 - struct { - lv_style_t *rel; - lv_style_t *pr; - lv_style_t *tgl_rel; - lv_style_t *tgl_pr; - lv_style_t *ina; - } imgbtn; + struct { + lv_style_t *rel; + lv_style_t *pr; + lv_style_t *tgl_rel; + lv_style_t *tgl_pr; + lv_style_t *ina; + } imgbtn; #endif #if USE_LV_LABEL != 0 - struct { - lv_style_t *prim; - lv_style_t *sec; - lv_style_t *hint; - } label; + struct { + lv_style_t *prim; + lv_style_t *sec; + lv_style_t *hint; + } label; #endif #if USE_LV_IMG != 0 - struct { - lv_style_t *light; - lv_style_t *dark; - } img; + struct { + lv_style_t *light; + lv_style_t *dark; + } img; #endif #if USE_LV_LINE != 0 - struct { - lv_style_t *decor; - } line; + struct { + lv_style_t *decor; + } line; #endif #if USE_LV_LED != 0 - lv_style_t *led; + lv_style_t *led; #endif #if USE_LV_BAR != 0 - struct { - lv_style_t *bg; - lv_style_t *indic; - } bar; + 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; + struct { + lv_style_t *bg; + lv_style_t *indic; + lv_style_t *knob; + } slider; #endif #if USE_LV_LMETER != 0 - lv_style_t *lmeter; + lv_style_t *lmeter; #endif #if USE_LV_GAUGE != 0 - lv_style_t *gauge; + lv_style_t *gauge; #endif #if USE_LV_ARC != 0 - lv_style_t *arc; + lv_style_t *arc; #endif #if USE_LV_PRELOAD != 0 - lv_style_t *preload; + lv_style_t *preload; #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; + 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; + lv_style_t *chart; #endif #if USE_LV_CALENDAR != 0 - struct { - lv_style_t *bg; - lv_style_t *header; - lv_style_t *header_pr; - lv_style_t *day_names; - lv_style_t *highlighted_days; - lv_style_t *inactive_days; - lv_style_t *week_box; - lv_style_t *today_box; - } calendar; + struct { + lv_style_t *bg; + lv_style_t *header; + lv_style_t *header_pr; + lv_style_t *day_names; + lv_style_t *highlighted_days; + lv_style_t *inactive_days; + lv_style_t *week_box; + lv_style_t *today_box; + } calendar; #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; + 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; + 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; + 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; + 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 *cursor; - lv_style_t *sb; - } ta; -#endif - -#if USE_LV_SPINBOX != 0 - struct { - lv_style_t *bg; - lv_style_t *cursor; - lv_style_t *sb; - } spinbox; -#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 *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_TILEVIEW != 0 - struct { - lv_style_t *bg; - lv_style_t *scrl; - lv_style_t *sb; - } tileview; -#endif - -#if USE_LV_TABLE != 0 - struct { - lv_style_t *bg; - lv_style_t *cell; - } table; -#endif - -#if USE_LV_WIN != 0 - struct { - lv_style_t *bg; - lv_style_t *sb; - lv_style_t *header; struct { lv_style_t *bg; lv_style_t *scrl; - } content; - struct { - lv_style_t *rel; - lv_style_t *pr; - } btn; - } win; + lv_style_t *sb; + } page; #endif + +#if USE_LV_TA != 0 + struct { + lv_style_t *area; + lv_style_t *oneline; + lv_style_t *cursor; + lv_style_t *sb; + } ta; +#endif + +#if USE_LV_SPINBOX != 0 + struct { + lv_style_t *bg; + lv_style_t *cursor; + lv_style_t *sb; + } spinbox; +#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 *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_TILEVIEW != 0 + struct { + lv_style_t *bg; + lv_style_t *scrl; + lv_style_t *sb; + } tileview; +#endif + +#if USE_LV_TABLE != 0 + struct { + lv_style_t *bg; + lv_style_t *cell; + } table; +#endif + +#if USE_LV_WIN != 0 + struct { + lv_style_t *bg; + lv_style_t *sb; + lv_style_t *header; + struct { + lv_style_t *bg; + lv_style_t *scrl; + } content; + struct { + lv_style_t *rel; + lv_style_t *pr; + } btn; + } win; +#endif + } style; } lv_theme_t; /********************** diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index 7b4ea6026..8b5f469a9 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -129,15 +129,15 @@ static void basic_init(void) sb.body.padding.ver = 1; sb.body.padding.inner = LV_DPI / 15; /*Scrollbar width*/ - theme.bg = &bg; - theme.panel = &panel; + theme.style.bg = &bg; + theme.style.panel = &panel; } static void cont_init(void) { #if USE_LV_CONT != 0 - theme.cont = &panel; + theme.style.cont = &panel; #endif } @@ -192,11 +192,11 @@ static void btn_init(void) btn_ina.text.font = _font; btn_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 90); - theme.btn.rel = &btn_rel; - theme.btn.pr = &btn_pr; - theme.btn.tgl_rel = &btn_trel; - theme.btn.tgl_pr = &btn_tpr; - theme.btn.ina = &btn_ina; + theme.style.btn.rel = &btn_rel; + theme.style.btn.pr = &btn_pr; + theme.style.btn.tgl_rel = &btn_trel; + theme.style.btn.tgl_pr = &btn_tpr; + theme.style.btn.ina = &btn_ina; #endif } @@ -216,9 +216,9 @@ static void label_init(void) lv_style_copy(&label_hint, &label_prim); label_hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 70); - theme.label.prim = &label_prim; - theme.label.sec = &label_sec; - theme.label.hint = &label_hint; + theme.style.label.prim = &label_prim; + theme.style.label.sec = &label_sec; + theme.style.label.hint = &label_hint; #endif } @@ -250,8 +250,8 @@ static void bar_init(void) bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80); bar_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80); - theme.bar.bg = &bar_bg; - theme.bar.indic = &bar_indic; + theme.style.bar.bg = &bar_bg; + theme.style.bar.indic = &bar_indic; #endif } @@ -267,8 +267,8 @@ static void img_init(void) img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 65); img_light.image.intense = LV_OPA_80; - theme.img.light = &img_light; - theme.img.dark = &img_dark; + theme.style.img.light = &img_light; + theme.style.img.dark = &img_dark; #endif } @@ -280,7 +280,7 @@ static void line_init(void) line_decor.line.color = lv_color_hsv_to_rgb(_hue, 50, 50); line_decor.line.width = 1; - theme.line.decor = &line_decor; + theme.style.line.decor = &line_decor; #endif } @@ -298,7 +298,7 @@ static void led_init(void) led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60); led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100); - theme.led = &led; + theme.style.led = &led; #endif } @@ -314,9 +314,9 @@ static void slider_init(void) slider_knob.body.border.color = LV_COLOR_GRAY; slider_knob.body.border.opa = LV_OPA_50; - theme.slider.bg = &bar_bg; - theme.slider.indic = &bar_indic; - theme.slider.knob = &slider_knob; + theme.style.slider.bg = &bar_bg; + theme.style.slider.indic = &bar_indic; + theme.style.slider.knob = &slider_knob; #endif } @@ -341,10 +341,10 @@ static void sw_init(void) lv_style_copy(&sw_knob, &slider_knob); sw_knob.body.opa = LV_OPA_80; - theme.sw.bg = &sw_bg; - theme.sw.indic = &sw_indic; - theme.sw.knob_off = &sw_knob; - theme.sw.knob_on = &sw_knob; + theme.style.sw.bg = &sw_bg; + theme.style.sw.indic = &sw_indic; + theme.style.sw.knob_off = &sw_knob; + theme.style.sw.knob_on = &sw_knob; #endif } @@ -359,7 +359,7 @@ static void lmeter_init(void) lmeter_bg.line.color = LV_COLOR_HEX3(0x222); lmeter_bg.line.width = 2; - theme.lmeter = &lmeter_bg; + theme.style.lmeter = &lmeter_bg; #endif } @@ -380,7 +380,7 @@ static void gauge_init(void) gauge_bg.text.color = lv_color_hsv_to_rgb(_hue, 10, 90); gauge_bg.text.font = _font; - theme.gauge = &gauge_bg; + theme.style.gauge = &gauge_bg; #endif } @@ -400,7 +400,7 @@ static void arc_init(void) arc.body.padding.hor = 3; arc.body.padding.ver = 3; - theme.arc = &arc; + theme.style.arc = &arc; #endif } @@ -408,14 +408,14 @@ static void preload_init(void) { #if USE_LV_PRELOAD != 0 - theme.preload = theme.arc; + theme.style.preload = theme.style.arc; #endif } static void chart_init(void) { #if USE_LV_CHART - theme.chart = &panel; + theme.style.chart = &panel; #endif } @@ -449,13 +449,13 @@ static void calendar_init(void) lv_style_copy(&gray_text, &def); gray_text.text.color = lv_color_hsv_to_rgb(_hue, 10, 65); - theme.calendar.bg = &panel; - theme.calendar.header = &header; - theme.calendar.week_box = &header; - theme.calendar.today_box = &today_box; - theme.calendar.day_names = &color_text; - theme.calendar.highlighted_days = &color_text; - theme.calendar.inactive_days = &gray_text; + theme.style.calendar.bg = &panel; + theme.style.calendar.header = &header; + theme.style.calendar.week_box = &header; + theme.style.calendar.today_box = &today_box; + theme.style.calendar.day_names = &color_text; + theme.style.calendar.highlighted_days = &color_text; + theme.style.calendar.inactive_days = &gray_text; #endif } @@ -501,12 +501,12 @@ static void cb_init(void) cb_ina.body.main_color = LV_COLOR_SILVER; cb_ina.body.grad_color = LV_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; + theme.style.cb.bg = &cb_bg; + theme.style.cb.box.rel = &cb_rel; + theme.style.cb.box.pr = &cb_pr; + theme.style.cb.box.tgl_rel = &cb_trel; + theme.style.cb.box.tgl_pr = &cb_tpr; + theme.style.cb.box.ina = &cb_ina; #endif } @@ -540,24 +540,24 @@ static void btnm_init(void) lv_style_copy(&btnm_ina, &btnm_rel); btnm_ina.text.color = lv_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; + theme.style.btnm.bg = &btnm_bg; + theme.style.btnm.btn.rel = &btnm_rel; + theme.style.btnm.btn.pr = &btnm_pr; + theme.style.btnm.btn.tgl_rel = &btnm_trel; + theme.style.btnm.btn.tgl_pr = &btnm_pr; + theme.style.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; + theme.style.kb.bg = &btnm_bg; + theme.style.kb.btn.rel = &btnm_rel; + theme.style.kb.btn.pr = &btnm_pr; + theme.style.kb.btn.tgl_rel = &btnm_trel; + theme.style.kb.btn.tgl_pr = &btnm_pr; + theme.style.kb.btn.ina = &btnm_ina; #endif } @@ -569,38 +569,38 @@ static void mbox_init(void) 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_trel; - theme.mbox.btn.pr = &btn_tpr; + theme.style.mbox.bg = &mbox_bg; + theme.style.mbox.btn.bg = &lv_style_transp; + theme.style.mbox.btn.rel = &btn_trel; + theme.style.mbox.btn.pr = &btn_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; + theme.style.page.bg = &panel; + theme.style.page.scrl = &lv_style_transp_fit; + theme.style.page.sb = &sb; #endif } static void ta_init(void) { #if USE_LV_TA - theme.ta.area = &panel; - theme.ta.oneline = &panel; - theme.ta.cursor = NULL; - theme.ta.sb = &sb; + theme.style.ta.area = &panel; + theme.style.ta.oneline = &panel; + theme.style.ta.cursor = NULL; + theme.style.ta.sb = &sb; #endif } static void spinbox_init(void) { #if USE_LV_SPINBOX - theme.spinbox.bg= &panel; - theme.spinbox.cursor = theme.ta.cursor; - theme.spinbox.sb = theme.ta.sb; + theme.style.spinbox.bg= &panel; + theme.style.spinbox.cursor = theme.style.ta.cursor; + theme.style.spinbox.sb = theme.style.ta.sb; #endif } @@ -631,14 +631,14 @@ static void list_init(void) 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; + theme.style.list.sb = &sb; + theme.style.list.bg = &list_bg; + theme.style.list.scrl = &lv_style_transp_tight; + theme.style.list.btn.rel = &list_rel; + theme.style.list.btn.pr = &list_pr; + theme.style.list.btn.tgl_rel = &list_trel; + theme.style.list.btn.tgl_pr = &list_tpr; + theme.style.list.btn.ina = &list_ina; #endif } @@ -656,9 +656,9 @@ static void ddlist_init(void) ddlist_sel.body.opa = LV_OPA_COVER; ddlist_sel.body.radius = 0; - theme.ddlist.bg = &ddlist_bg; - theme.ddlist.sel = &ddlist_sel; - theme.ddlist.sb = &sb; + theme.style.ddlist.bg = &ddlist_bg; + theme.style.ddlist.sel = &ddlist_sel; + theme.style.ddlist.sb = &sb; #endif } @@ -682,8 +682,8 @@ static void roller_init(void) roller_sel.text.opa = LV_OPA_COVER; roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 70, 95); - theme.roller.bg = &roller_bg; - theme.roller.sel = &roller_sel; + theme.style.roller.bg = &roller_bg; + theme.style.roller.sel = &roller_sel; #endif } @@ -736,22 +736,22 @@ static void tabview_init(void) tab_indic.body.grad_color = lv_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; + theme.style.tabview.bg = &bg; + theme.style.tabview.indic = &tab_indic; + theme.style.tabview.btn.bg = &lv_style_transp_tight; + theme.style.tabview.btn.rel = &tab_rel; + theme.style.tabview.btn.pr = &tab_pr; + theme.style.tabview.btn.tgl_rel = &tab_trel; + theme.style.tabview.btn.tgl_pr = &tab_tpr; #endif } static void tileview_init(void) { #if USE_LV_TILEVIEW != 0 - theme.tileview.bg = &lv_style_transp_tight; - theme.tileview.scrl = &lv_style_transp_tight; - theme.tileview.sb = theme.page.sb; + theme.style.tileview.bg = &lv_style_transp_tight; + theme.style.tileview.scrl = &lv_style_transp_tight; + theme.style.tileview.sb = theme.style.page.sb; #endif } @@ -766,8 +766,8 @@ static void table_init(void) cell.body.padding.ver = LV_DPI / 12; - theme.table.bg = &lv_style_transp_tight; - theme.table.cell = &cell; + theme.style.table.bg = &lv_style_transp_tight; + theme.style.table.cell = &cell; #endif } @@ -788,13 +788,13 @@ static void win_init(void) header.body.border.part = LV_BORDER_BOTTOM; header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100); - theme.win.bg = &bg; - theme.win.sb = &sb; - theme.win.header = &header; - theme.win.content.bg = &lv_style_transp; - theme.win.content.scrl = &lv_style_transp; - theme.win.btn.rel = &btn_rel; - theme.win.btn.pr = &btn_pr; + theme.style.win.bg = &bg; + theme.style.win.sb = &sb; + theme.style.win.header = &header; + theme.style.win.content.bg = &lv_style_transp; + theme.style.win.content.scrl = &lv_style_transp; + theme.style.win.btn.rel = &btn_rel; + theme.style.win.btn.pr = &btn_pr; #endif } diff --git a/lv_themes/lv_theme_default.c b/lv_themes/lv_theme_default.c index a6ddb7276..9a972571a 100644 --- a/lv_themes/lv_theme_default.c +++ b/lv_themes/lv_theme_default.c @@ -63,19 +63,19 @@ static void basic_init(void) plain_bordered.body.border.width = 2; plain_bordered.body.border.color = LV_COLOR_HEX3(0xbbb); - theme.bg = &lv_style_plain; - theme.panel = &lv_style_pretty; + theme.style.bg = &lv_style_plain; + theme.style.panel = &lv_style_pretty; } static void btn_init(void) { #if USE_LV_BTN != 0 - theme.btn.rel = &lv_style_btn_rel; - theme.btn.pr = &lv_style_btn_pr; - theme.btn.tgl_rel = &lv_style_btn_tgl_rel; - theme.btn.tgl_pr = &lv_style_btn_tgl_pr; - theme.btn.ina = &lv_style_btn_ina; + theme.style.btn.rel = &lv_style_btn_rel; + theme.style.btn.pr = &lv_style_btn_pr; + theme.style.btn.tgl_rel = &lv_style_btn_tgl_rel; + theme.style.btn.tgl_pr = &lv_style_btn_tgl_pr; + theme.style.btn.ina = &lv_style_btn_ina; #endif } @@ -92,9 +92,9 @@ static void label_init(void) label_hint.text.color = LV_COLOR_HEX3(0xaaa); - theme.label.prim = &label_prim; - theme.label.sec = &label_sec; - theme.label.hint = &label_hint; + theme.style.label.prim = &label_prim; + theme.style.label.sec = &label_sec; + theme.style.label.hint = &label_hint; #endif } @@ -104,8 +104,8 @@ static void img_init(void) #if USE_LV_IMG != 0 - theme.img.light = &def; - theme.img.dark = &def; + theme.style.img.light = &def; + theme.style.img.dark = &def; #endif } @@ -113,7 +113,7 @@ static void line_init(void) { #if USE_LV_LINE != 0 - theme.line.decor = &def; + theme.style.line.decor = &def; #endif } @@ -130,7 +130,7 @@ static void led_init(void) led.body.shadow.color = led.body.main_color; - theme.led = &led; + theme.style.led = &led; #endif } @@ -138,8 +138,8 @@ static void bar_init(void) { #if USE_LV_BAR - theme.bar.bg = &lv_style_pretty; - theme.bar.indic = &lv_style_pretty_color; + theme.style.bar.bg = &lv_style_pretty; + theme.style.bar.indic = &lv_style_pretty_color; #endif } @@ -150,9 +150,9 @@ static void slider_init(void) slider_bg.body.padding.hor = LV_DPI / 20; slider_bg.body.padding.ver = LV_DPI / 20; - theme.slider.bg = &slider_bg; - theme.slider.indic = &lv_style_pretty_color; - theme.slider.knob = &lv_style_pretty; + theme.style.slider.bg = &slider_bg; + theme.style.slider.indic = &lv_style_pretty_color; + theme.style.slider.knob = &lv_style_pretty; #endif } @@ -163,10 +163,10 @@ static void sw_init(void) sw_bg.body.padding.hor = 3; sw_bg.body.padding.ver = 3; - theme.sw.bg = &sw_bg; - theme.sw.indic = &lv_style_pretty_color; - theme.sw.knob_off = &lv_style_pretty; - theme.sw.knob_on = &lv_style_pretty; + theme.style.sw.bg = &sw_bg; + theme.style.sw.indic = &lv_style_pretty_color; + theme.style.sw.knob_off = &lv_style_pretty; + theme.style.sw.knob_on = &lv_style_pretty; #endif } @@ -181,7 +181,7 @@ static void lmeter_init(void) lmeter.body.main_color = lv_color_mix(lmeter.body.main_color, LV_COLOR_WHITE, LV_OPA_50); lmeter.body.grad_color = lv_color_mix(lmeter.body.grad_color, LV_COLOR_BLACK, LV_OPA_50); - theme.lmeter = &lmeter; + theme.style.lmeter = &lmeter; #endif } @@ -196,7 +196,7 @@ static void gauge_init(void) gauge.body.grad_color = lmeter.body.main_color; gauge.text.color = LV_COLOR_HEX3(0x888); - theme.gauge = &gauge; + theme.style.gauge = &gauge; #endif } @@ -205,7 +205,7 @@ static void chart_init(void) #if USE_LV_CHART - theme.chart = &lv_style_pretty; + theme.style.chart = &lv_style_pretty; #endif } @@ -214,12 +214,12 @@ static void cb_init(void) #if USE_LV_CB != 0 - theme.cb.bg = &lv_style_transp; - theme.cb.box.rel = &lv_style_pretty; - theme.cb.box.pr = &lv_style_btn_pr; - theme.cb.box.tgl_rel = &lv_style_btn_tgl_rel; - theme.cb.box.tgl_pr = &lv_style_btn_tgl_pr; - theme.cb.box.ina = &lv_style_btn_ina; + theme.style.cb.bg = &lv_style_transp; + theme.style.cb.box.rel = &lv_style_pretty; + theme.style.cb.box.pr = &lv_style_btn_pr; + theme.style.cb.box.tgl_rel = &lv_style_btn_tgl_rel; + theme.style.cb.box.tgl_pr = &lv_style_btn_tgl_pr; + theme.style.cb.box.ina = &lv_style_btn_ina; #endif } @@ -229,12 +229,12 @@ static void btnm_init(void) #if USE_LV_BTNM - theme.btnm.bg = &lv_style_pretty; - theme.btnm.btn.rel = &lv_style_btn_rel; - theme.btnm.btn.pr = &lv_style_btn_pr; - theme.btnm.btn.tgl_rel = &lv_style_btn_tgl_rel; - theme.btnm.btn.tgl_pr = &lv_style_btn_tgl_pr; - theme.btnm.btn.ina = &lv_style_btn_ina; + theme.style.btnm.bg = &lv_style_pretty; + theme.style.btnm.btn.rel = &lv_style_btn_rel; + theme.style.btnm.btn.pr = &lv_style_btn_pr; + theme.style.btnm.btn.tgl_rel = &lv_style_btn_tgl_rel; + theme.style.btnm.btn.tgl_pr = &lv_style_btn_tgl_pr; + theme.style.btnm.btn.ina = &lv_style_btn_ina; #endif } @@ -243,12 +243,12 @@ static void kb_init(void) #if USE_LV_KB - theme.kb.bg = &lv_style_pretty; - theme.kb.btn.rel = &lv_style_btn_rel; - theme.kb.btn.pr = &lv_style_btn_pr; - theme.kb.btn.tgl_rel = &lv_style_btn_tgl_rel; - theme.kb.btn.tgl_pr = &lv_style_btn_tgl_pr; - theme.kb.btn.ina = &lv_style_btn_ina; + theme.style.kb.bg = &lv_style_pretty; + theme.style.kb.btn.rel = &lv_style_btn_rel; + theme.style.kb.btn.pr = &lv_style_btn_pr; + theme.style.kb.btn.tgl_rel = &lv_style_btn_tgl_rel; + theme.style.kb.btn.tgl_pr = &lv_style_btn_tgl_pr; + theme.style.kb.btn.ina = &lv_style_btn_ina; #endif } @@ -258,10 +258,10 @@ static void mbox_init(void) #if USE_LV_MBOX - theme.mbox.bg = &lv_style_pretty; - theme.mbox.btn.bg = &lv_style_transp; - theme.mbox.btn.rel = &lv_style_btn_rel; - theme.mbox.btn.pr = &lv_style_btn_tgl_pr; + theme.style.mbox.bg = &lv_style_pretty; + theme.style.mbox.btn.bg = &lv_style_transp; + theme.style.mbox.btn.rel = &lv_style_btn_rel; + theme.style.mbox.btn.pr = &lv_style_btn_tgl_pr; #endif } @@ -270,9 +270,9 @@ static void page_init(void) #if USE_LV_PAGE - theme.page.bg = &lv_style_pretty; - theme.page.scrl = &lv_style_transp_tight; - theme.page.sb = &sb; + theme.style.page.bg = &lv_style_pretty; + theme.style.page.scrl = &lv_style_transp_tight; + theme.style.page.sb = &sb; #endif } @@ -281,10 +281,10 @@ static void ta_init(void) #if USE_LV_TA - theme.ta.area = &lv_style_pretty; - theme.ta.oneline = &lv_style_pretty; - theme.ta.cursor = NULL; - theme.ta.sb = &sb; + theme.style.ta.area = &lv_style_pretty; + theme.style.ta.oneline = &lv_style_pretty; + theme.style.ta.cursor = NULL; + theme.style.ta.sb = &sb; #endif } @@ -292,14 +292,14 @@ static void list_init(void) { #if USE_LV_LIST != 0 - theme.list.bg = &lv_style_pretty; - theme.list.scrl = &lv_style_transp_fit; - theme.list.sb = &sb; - theme.list.btn.rel = &lv_style_btn_rel; - theme.list.btn.pr = &lv_style_btn_pr; - theme.list.btn.tgl_rel = &lv_style_btn_tgl_rel; - theme.list.btn.tgl_pr = &lv_style_btn_tgl_pr; - theme.list.btn.ina = &lv_style_btn_ina; + theme.style.list.bg = &lv_style_pretty; + theme.style.list.scrl = &lv_style_transp_fit; + theme.style.list.sb = &sb; + theme.style.list.btn.rel = &lv_style_btn_rel; + theme.style.list.btn.pr = &lv_style_btn_pr; + theme.style.list.btn.tgl_rel = &lv_style_btn_tgl_rel; + theme.style.list.btn.tgl_pr = &lv_style_btn_tgl_pr; + theme.style.list.btn.ina = &lv_style_btn_ina; #endif } @@ -308,9 +308,9 @@ static void ddlist_init(void) #if USE_LV_DDLIST != 0 - theme.ddlist.bg = &lv_style_pretty; - theme.ddlist.sel = &lv_style_plain_color; - theme.ddlist.sb = &sb; + theme.style.ddlist.bg = &lv_style_pretty; + theme.style.ddlist.sel = &lv_style_plain_color; + theme.style.ddlist.sb = &sb; #endif } @@ -319,8 +319,8 @@ static void roller_init(void) #if USE_LV_ROLLER != 0 - theme.roller.bg = &lv_style_pretty; - theme.roller.sel = &lv_style_plain_color; + theme.style.roller.bg = &lv_style_pretty; + theme.style.roller.sel = &lv_style_plain_color; #endif } @@ -329,13 +329,13 @@ static void tabview_init(void) #if USE_LV_TABVIEW != 0 - theme.tabview.bg = &plain_bordered; - theme.tabview.indic = &lv_style_plain_color; - theme.tabview.btn.bg = &lv_style_transp; - theme.tabview.btn.rel = &lv_style_btn_rel; - theme.tabview.btn.pr = &lv_style_btn_pr; - theme.tabview.btn.tgl_rel = &lv_style_btn_tgl_rel; - theme.tabview.btn.tgl_pr = &lv_style_btn_tgl_pr; + theme.style.tabview.bg = &plain_bordered; + theme.style.tabview.indic = &lv_style_plain_color; + theme.style.tabview.btn.bg = &lv_style_transp; + theme.style.tabview.btn.rel = &lv_style_btn_rel; + theme.style.tabview.btn.pr = &lv_style_btn_pr; + theme.style.tabview.btn.tgl_rel = &lv_style_btn_tgl_rel; + theme.style.tabview.btn.tgl_pr = &lv_style_btn_tgl_pr; #endif } @@ -345,13 +345,13 @@ static void win_init(void) #if USE_LV_WIN != 0 - theme.win.bg = &plain_bordered; - theme.win.sb = &sb; - theme.win.header = &lv_style_plain_color; - theme.win.content.bg = &lv_style_transp; - theme.win.content.scrl = &lv_style_transp; - theme.win.btn.rel = &lv_style_btn_rel; - theme.win.btn.pr = &lv_style_btn_pr; + theme.style.win.bg = &plain_bordered; + theme.style.win.sb = &sb; + theme.style.win.header = &lv_style_plain_color; + theme.style.win.content.bg = &lv_style_transp; + theme.style.win.content.scrl = &lv_style_transp; + theme.style.win.btn.rel = &lv_style_btn_rel; + theme.style.win.btn.pr = &lv_style_btn_pr; #endif } diff --git a/lv_themes/lv_theme_material.c b/lv_themes/lv_theme_material.c index e46c94391..6cfe50104 100644 --- a/lv_themes/lv_theme_material.c +++ b/lv_themes/lv_theme_material.c @@ -79,8 +79,8 @@ static void basic_init(void) sb.body.opa = LV_OPA_40; sb.body.padding.hor = LV_DPI / 25; - theme.bg = &bg; - theme.panel = &panel; + theme.style.bg = &bg; + theme.style.panel = &panel; } @@ -89,7 +89,7 @@ static void cont_init(void) #if USE_LV_CONT != 0 - theme.cont = theme.panel; + theme.style.cont = theme.style.panel; #endif } @@ -132,11 +132,11 @@ static void btn_init(void) ina.body.shadow.width = 0; ina.text.color = lv_color_hsv_to_rgb(_hue, 95, 5); - theme.btn.rel = &rel; - theme.btn.pr = ≺ - theme.btn.tgl_rel = &tgl_rel; - theme.btn.tgl_pr = &tgl_pr; - theme.btn.ina = &ina; + theme.style.btn.rel = &rel; + theme.style.btn.pr = ≺ + theme.style.btn.tgl_rel = &tgl_rel; + theme.style.btn.tgl_pr = &tgl_pr; + theme.style.btn.ina = &ina; #endif } @@ -156,9 +156,9 @@ static void label_init(void) lv_style_copy(&hint, &prim); hint.text.color = lv_color_hsv_to_rgb(_hue, 40, 90); - theme.label.prim = &prim; - theme.label.sec = &sec; - theme.label.hint = &hint; + theme.style.label.prim = &prim; + theme.style.label.sec = &sec; + theme.style.label.hint = &hint; #endif } @@ -175,8 +175,8 @@ static void img_init(void) img_light.image.intense = LV_OPA_80; - theme.img.light = &def; - theme.img.dark = &def; + theme.style.img.light = &def; + theme.style.img.dark = &def; #endif } @@ -185,7 +185,7 @@ static void line_init(void) #if USE_LV_LINE != 0 - theme.line.decor = &def; + theme.style.line.decor = &def; #endif } @@ -204,7 +204,7 @@ static void led_init(void) led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100); - theme.led = &led; + theme.style.led = &led; #endif } @@ -227,8 +227,8 @@ static void bar_init(void) bar_indic.body.padding.hor = 0; bar_indic.body.padding.ver = 0; - theme.bar.bg = &bar_bg; - theme.bar.indic = &bar_indic; + theme.style.bar.bg = &bar_bg; + theme.style.bar.indic = &bar_indic; #endif } @@ -240,12 +240,12 @@ static void slider_init(void) lv_style_copy(&knob, &def); knob.body.radius = LV_RADIUS_CIRCLE; knob.body.border.width = 0; - knob.body.main_color = theme.bar.indic->body.main_color; + knob.body.main_color = theme.style.bar.indic->body.main_color; knob.body.grad_color = knob.body.main_color; - theme.slider.bg = theme.bar.bg; - theme.slider.indic = theme.bar.indic; - theme.slider.knob = &knob; + theme.style.slider.bg = theme.style.bar.bg; + theme.style.slider.indic = theme.style.bar.indic; + theme.style.slider.knob = &knob; #endif } @@ -253,13 +253,13 @@ static void sw_init(void) { #if USE_LV_SW != 0 static lv_style_t sw_bg, sw_indic, sw_knob_off, sw_knob_on; - lv_style_copy(&sw_bg, theme.slider.bg); + lv_style_copy(&sw_bg, theme.style.slider.bg); sw_bg.body.radius = LV_RADIUS_CIRCLE; - lv_style_copy(&sw_indic, theme.slider.bg); + lv_style_copy(&sw_indic, theme.style.slider.bg); sw_indic.body.radius = LV_RADIUS_CIRCLE; - lv_style_copy(&sw_knob_on, theme.slider.knob); + lv_style_copy(&sw_knob_on, theme.style.slider.knob); sw_knob_on.body.shadow.width = 3; sw_knob_on.body.shadow.type = LV_SHADOW_BOTTOM; sw_knob_on.body.shadow.color = DEF_SHADOW_COLOR; @@ -272,10 +272,10 @@ static void sw_init(void) sw_knob_off.body.border.color = LV_COLOR_HEX3(0x999); sw_knob_off.body.border.opa = LV_OPA_COVER; - theme.sw.bg = &sw_bg; - theme.sw.indic = &sw_indic; - theme.sw.knob_off = &sw_knob_off; - theme.sw.knob_on = &sw_knob_on; + theme.style.sw.bg = &sw_bg; + theme.style.sw.indic = &sw_indic; + theme.style.sw.knob_off = &sw_knob_off; + theme.style.sw.knob_on = &sw_knob_on; #endif } @@ -291,7 +291,7 @@ static void lmeter_init(void) lmeter.line.color = LV_COLOR_HEX3(0x999); lmeter.line.width = 2; - theme.lmeter = &lmeter; + theme.style.lmeter = &lmeter; #endif } @@ -310,7 +310,7 @@ static void gauge_init(void) gauge.line.width = 3; gauge.line.color = lv_color_hsv_to_rgb(_hue, 95, 70); - theme.gauge = &gauge; + theme.style.gauge = &gauge; #endif } @@ -329,7 +329,7 @@ static void arc_init(void) arc.body.padding.hor = 0; arc.body.padding.ver = 0; - theme.arc = &arc; + theme.style.arc = &arc; #endif } @@ -337,14 +337,14 @@ static void preload_init(void) { #if USE_LV_PRELOAD != 0 - theme.preload = theme.arc; + theme.style.preload = theme.style.arc; #endif } static void chart_init(void) { #if USE_LV_CHART - theme.chart = theme.panel; + theme.style.chart = theme.style.panel; #endif } @@ -364,9 +364,9 @@ static void calendar_init(void) week_box.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 100); week_box.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 100); week_box.body.padding.ver = LV_DPI / 20; - week_box.body.padding.hor = theme.panel->body.padding.hor; - week_box.body.border.color = theme.panel->body.border.color; - week_box.body.border.width = theme.panel->body.border.width; + week_box.body.padding.hor = theme.style.panel->body.padding.hor; + week_box.body.border.color = theme.style.panel->body.border.color; + week_box.body.border.width = theme.style.panel->body.border.width; week_box.body.border.part = LV_BORDER_LEFT | LV_BORDER_RIGHT; week_box.body.radius = 0; @@ -377,12 +377,12 @@ static void calendar_init(void) today_box.body.padding.ver = LV_DPI / 20; today_box.body.radius = 0; - theme.calendar.bg = theme.panel; - theme.calendar.header = &lv_style_transp; - theme.calendar.inactive_days = &ina_days; - theme.calendar.highlighted_days = &high_days; - theme.calendar.week_box = &week_box; - theme.calendar.today_box = &today_box; + theme.style.calendar.bg = theme.style.panel; + theme.style.calendar.header = &lv_style_transp; + theme.style.calendar.inactive_days = &ina_days; + theme.style.calendar.highlighted_days = &high_days; + theme.style.calendar.week_box = &week_box; + theme.style.calendar.today_box = &today_box; #endif } @@ -390,7 +390,7 @@ static void cb_init(void) { #if USE_LV_CB != 0 static lv_style_t rel, pr, tgl_rel, tgl_pr, ina; - lv_style_copy(&rel, theme.panel); + lv_style_copy(&rel, theme.style.panel); rel.body.shadow.type = LV_SHADOW_BOTTOM; rel.body.shadow.width = 3; @@ -410,14 +410,14 @@ static void cb_init(void) tgl_pr.body.grad_color = tgl_pr.body.main_color; tgl_pr.body.shadow.width = 0; - lv_style_copy(&ina, theme.btn.ina); + lv_style_copy(&ina, theme.style.btn.ina); - theme.cb.bg = &lv_style_transp; - theme.cb.box.rel = &rel; - theme.cb.box.pr = ≺ - theme.cb.box.tgl_rel = &tgl_rel; - theme.cb.box.tgl_pr = &tgl_pr; - theme.cb.box.ina = &ina; + theme.style.cb.bg = &lv_style_transp; + theme.style.cb.box.rel = &rel; + theme.style.cb.box.pr = ≺ + theme.style.cb.box.tgl_rel = &tgl_rel; + theme.style.cb.box.tgl_pr = &tgl_pr; + theme.style.cb.box.ina = &ina; #endif } @@ -427,13 +427,13 @@ static void btnm_init(void) #if USE_LV_BTNM static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina; - lv_style_copy(&bg, theme.panel); + lv_style_copy(&bg, theme.style.panel); bg.body.padding.hor = 0; bg.body.padding.ver = 0; bg.body.padding.inner = 0; bg.text.color = LV_COLOR_HEX3(0x555); - lv_style_copy(&rel, theme.panel); + lv_style_copy(&rel, theme.style.panel); rel.body.border.part = LV_BORDER_FULL | LV_BORDER_INTERNAL; rel.body.border.width = 1; rel.body.border.color = LV_COLOR_HEX3(0xbbb); @@ -462,12 +462,12 @@ static void btnm_init(void) ina.body.main_color = LV_COLOR_HEX3(0xccc); ina.body.grad_color = ina.body.main_color; - theme.btnm.bg = &bg; - theme.btnm.btn.rel = &rel; - theme.btnm.btn.pr = ≺ - theme.btnm.btn.tgl_rel = &tgl_rel; - theme.btnm.btn.tgl_pr = &tgl_pr; - theme.btnm.btn.ina = &def; + theme.style.btnm.bg = &bg; + theme.style.btnm.btn.rel = &rel; + theme.style.btnm.btn.pr = ≺ + theme.style.btnm.btn.tgl_rel = &tgl_rel; + theme.style.btnm.btn.tgl_pr = &tgl_pr; + theme.style.btnm.btn.ina = &def; #endif } @@ -479,12 +479,12 @@ static void kb_init(void) lv_style_copy(&rel, &lv_style_transp); rel.text.font = _font; - theme.kb.bg = theme.btnm.bg; - theme.kb.btn.rel = &rel; - theme.kb.btn.pr = theme.btnm.btn.pr; - theme.kb.btn.tgl_rel = theme.btnm.btn.tgl_rel; - theme.kb.btn.tgl_pr = theme.btnm.btn.tgl_pr; - theme.kb.btn.ina = theme.btnm.btn.ina; + theme.style.kb.bg = theme.style.btnm.bg; + theme.style.kb.btn.rel = &rel; + theme.style.kb.btn.pr = theme.style.btnm.btn.pr; + theme.style.kb.btn.tgl_rel = theme.style.btnm.btn.tgl_rel; + theme.style.kb.btn.tgl_pr = theme.style.btnm.btn.tgl_pr; + theme.style.kb.btn.ina = theme.style.btnm.btn.ina; #endif } @@ -499,13 +499,13 @@ static void mbox_init(void) rel.text.font = _font; rel.text.color = lv_color_hsv_to_rgb(_hue, 85, 75); - lv_style_copy(&pr, theme.btnm.btn.pr); + lv_style_copy(&pr, theme.style.btnm.btn.pr); pr.text.color = lv_color_hsv_to_rgb(_hue, 85, 60); - theme.mbox.bg = theme.panel; - theme.mbox.btn.bg = &lv_style_transp; - theme.mbox.btn.rel = &rel; - theme.mbox.btn.pr = ≺ + theme.style.mbox.bg = theme.style.panel; + theme.style.mbox.btn.bg = &lv_style_transp; + theme.style.mbox.btn.rel = &rel; + theme.style.mbox.btn.pr = ≺ #endif } @@ -514,9 +514,9 @@ static void page_init(void) #if USE_LV_PAGE - theme.page.bg = theme.panel; - theme.page.scrl = &lv_style_transp; - theme.page.sb = &sb; + theme.style.page.bg = theme.style.panel; + theme.style.page.scrl = &lv_style_transp; + theme.style.page.sb = &sb; #endif } @@ -534,19 +534,19 @@ static void ta_init(void) oneline.body.border.opa = LV_OPA_COVER; oneline.text.color = LV_COLOR_HEX3(0x333); - theme.ta.area = theme.panel; - theme.ta.oneline = &oneline; - theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/ - theme.ta.sb = &sb; + theme.style.ta.area = theme.style.panel; + theme.style.ta.oneline = &oneline; + theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/ + theme.style.ta.sb = &sb; #endif } static void spinbox_init(void) { #if USE_LV_SPINBOX - theme.spinbox.bg= theme.panel; - theme.spinbox.cursor = theme.ta.cursor; - theme.spinbox.sb = theme.ta.sb; + theme.style.spinbox.bg= theme.style.panel; + theme.style.spinbox.cursor = theme.style.ta.cursor; + theme.style.spinbox.sb = theme.style.ta.sb; #endif } @@ -556,7 +556,7 @@ static void list_init(void) static lv_style_t list_bg, rel, pr, tgl_rel, tgl_pr, ina; - lv_style_copy(&list_bg, theme.panel); + lv_style_copy(&list_bg, theme.style.panel); list_bg.body.padding.hor = 0; list_bg.body.padding.ver = 0; list_bg.body.padding.inner = 0; @@ -594,14 +594,14 @@ static void list_init(void) ina.body.grad_color = ina.body.main_color; - theme.list.sb = &sb; - theme.list.bg = &list_bg; - theme.list.scrl = &lv_style_transp_tight; - theme.list.btn.rel = &rel; - theme.list.btn.pr = ≺ - theme.list.btn.tgl_rel = &tgl_rel; - theme.list.btn.tgl_pr = &tgl_pr; - theme.list.btn.ina = &ina; + theme.style.list.sb = &sb; + theme.style.list.bg = &list_bg; + theme.style.list.scrl = &lv_style_transp_tight; + theme.style.list.btn.rel = &rel; + theme.style.list.btn.pr = ≺ + theme.style.list.btn.tgl_rel = &tgl_rel; + theme.style.list.btn.tgl_pr = &tgl_pr; + theme.style.list.btn.ina = &ina; #endif } @@ -609,7 +609,7 @@ static void ddlist_init(void) { #if USE_LV_DDLIST != 0 static lv_style_t bg, sel; - lv_style_copy(&bg, theme.panel); + lv_style_copy(&bg, theme.style.panel); bg.body.padding.hor = LV_DPI / 6; bg.body.padding.ver = LV_DPI / 6; bg.text.line_space = LV_DPI / 8; @@ -623,9 +623,9 @@ static void ddlist_init(void) sel.text.color = lv_color_hsv_to_rgb(_hue, 5, 95); - theme.ddlist.bg = &bg; - theme.ddlist.sel = &sel; - theme.ddlist.sb = &sb; + theme.style.ddlist.bg = &bg; + theme.style.ddlist.sel = &sel; + theme.style.ddlist.sb = &sb; #endif } @@ -645,8 +645,8 @@ static void roller_init(void) roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 90, 70); - theme.roller.bg = &roller_bg; - theme.roller.sel = &roller_sel; + theme.style.roller.bg = &roller_bg; + theme.style.roller.sel = &roller_sel; #endif } @@ -708,22 +708,22 @@ static void tabview_init(void) tgl_pr.body.radius = 0; tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 90, 60); - theme.tabview.bg = theme.bg; - theme.tabview.indic = &indic; - theme.tabview.btn.bg = &btn_bg; - theme.tabview.btn.rel = &rel; - theme.tabview.btn.pr = ≺ - theme.tabview.btn.tgl_rel = &tgl_rel; - theme.tabview.btn.tgl_pr = &tgl_pr; + theme.style.tabview.bg = theme.style.bg; + theme.style.tabview.indic = &indic; + theme.style.tabview.btn.bg = &btn_bg; + theme.style.tabview.btn.rel = &rel; + theme.style.tabview.btn.pr = ≺ + theme.style.tabview.btn.tgl_rel = &tgl_rel; + theme.style.tabview.btn.tgl_pr = &tgl_pr; #endif } static void tileview_init(void) { #if USE_LV_TILEVIEW != 0 - theme.tileview.bg = &lv_style_transp_tight; - theme.tileview.scrl = &lv_style_transp_tight; - theme.tileview.sb = theme.page.sb; + theme.style.tileview.bg = &lv_style_transp_tight; + theme.style.tileview.scrl = &lv_style_transp_tight; + theme.style.tileview.sb = theme.style.page.sb; #endif } @@ -731,15 +731,15 @@ static void table_init(void) { #if USE_LV_TABLE != 0 static lv_style_t cell; - lv_style_copy(&cell, theme.panel); + lv_style_copy(&cell, theme.style.panel); cell.body.radius = 0; cell.body.border.width = 1; cell.body.padding.hor = LV_DPI / 12; cell.body.padding.ver = LV_DPI / 12; - theme.table.bg = &lv_style_transp_tight; - theme.table.cell = &cell; + theme.style.table.bg = &lv_style_transp_tight; + theme.style.table.cell = &cell; #endif } @@ -770,13 +770,13 @@ static void win_init(void) pr.text.color = LV_COLOR_HEX3(0x111); - theme.win.bg = theme.panel; - theme.win.sb = &sb; - theme.win.header = &header; - theme.win.content.bg = &lv_style_transp; - theme.win.content.scrl = &lv_style_transp; - theme.win.btn.rel = &lv_style_transp; - theme.win.btn.pr = ≺ + theme.style.win.bg = theme.style.panel; + theme.style.win.sb = &sb; + theme.style.win.header = &header; + theme.style.win.content.bg = &lv_style_transp; + theme.style.win.content.scrl = &lv_style_transp; + theme.style.win.btn.rel = &lv_style_transp; + theme.style.win.btn.pr = ≺ #endif } diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index af18f8a5d..44c02754f 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -91,8 +91,8 @@ static void basic_init(void) lv_style_copy(&dark_frame, &dark_plain); dark_frame.body.radius = LV_DPI / 20; - theme.bg = &def; - theme.panel = &light_frame; + theme.style.bg = &def; + theme.style.panel = &light_frame; } @@ -101,7 +101,7 @@ static void cont_init(void) #if USE_LV_CONT != 0 - theme.cont = &def; + theme.style.cont = &def; #endif } @@ -110,11 +110,11 @@ static void btn_init(void) #if USE_LV_BTN != 0 - theme.btn.rel = &light_frame; - theme.btn.pr = &dark_frame; - theme.btn.tgl_rel = &dark_frame; - theme.btn.tgl_pr = &light_frame; - theme.btn.ina = &light_frame; + theme.style.btn.rel = &light_frame; + theme.style.btn.pr = &dark_frame; + theme.style.btn.tgl_rel = &dark_frame; + theme.style.btn.tgl_pr = &light_frame; + theme.style.btn.ina = &light_frame; #endif } @@ -124,9 +124,9 @@ static void label_init(void) #if USE_LV_LABEL != 0 - theme.label.prim = NULL; - theme.label.sec = NULL; - theme.label.hint = NULL; + theme.style.label.prim = NULL; + theme.style.label.sec = NULL; + theme.style.label.hint = NULL; #endif } @@ -135,15 +135,15 @@ static void img_init(void) #if USE_LV_IMG != 0 - theme.img.light = &def; - theme.img.dark = &def; + theme.style.img.light = &def; + theme.style.img.dark = &def; #endif } static void line_init(void) { #if USE_LV_LINE != 0 - theme.line.decor = NULL; + theme.style.line.decor = NULL; #endif } @@ -157,7 +157,7 @@ static void led_init(void) led.body.shadow.color = LV_COLOR_BLACK; led.body.shadow.type = LV_SHADOW_FULL; - theme.led = &led; + theme.style.led = &led; #endif } @@ -177,8 +177,8 @@ static void bar_init(void) bar_indic.body.padding.ver = LV_DPI / 30; bar_indic.body.radius = LV_RADIUS_CIRCLE; - theme.bar.bg = &bar_bg; - theme.bar.indic = &bar_indic; + theme.style.bar.bg = &bar_bg; + theme.style.bar.indic = &bar_indic; #endif } @@ -191,9 +191,9 @@ static void slider_init(void) slider_knob.body.padding.hor = LV_DPI / 30; slider_knob.body.padding.ver = LV_DPI / 30; - theme.slider.bg = theme.bar.bg; - theme.slider.indic = theme.bar.indic; - theme.slider.knob = &slider_knob; + theme.style.slider.bg = theme.style.bar.bg; + theme.style.slider.indic = theme.style.bar.indic; + theme.style.slider.knob = &slider_knob; #endif } @@ -202,10 +202,10 @@ static void sw_init(void) #if USE_LV_SW != 0 - theme.sw.bg = theme.slider.bg; - theme.sw.indic = theme.slider.indic; - theme.sw.knob_off = theme.slider.knob; - theme.sw.knob_on = theme.slider.knob; + theme.style.sw.bg = theme.style.slider.bg; + theme.style.sw.indic = theme.style.slider.indic; + theme.style.sw.knob_off = theme.style.slider.knob; + theme.style.sw.knob_on = theme.style.slider.knob; #endif } @@ -223,7 +223,7 @@ static void lmeter_init(void) lmeter_bg.line.color = LV_COLOR_WHITE; lmeter_bg.line.width = 1; - theme.lmeter = &lmeter_bg; + theme.style.lmeter = &lmeter_bg; #endif } @@ -231,19 +231,19 @@ static void gauge_init(void) { #if USE_LV_GAUGE != 0 static lv_style_t gauge_bg; - lv_style_copy(&gauge_bg, theme.lmeter); + lv_style_copy(&gauge_bg, theme.style.lmeter); gauge_bg.line.color = LV_COLOR_BLACK; gauge_bg.line.width = 1; - theme.gauge = &gauge_bg; + theme.style.gauge = &gauge_bg; #endif } static void chart_init(void) { #if USE_LV_CHART - theme.chart = &light_frame; + theme.style.chart = &light_frame; #endif } @@ -255,8 +255,8 @@ static void calendar_init(void) box.body.padding.ver = LV_DPI / 20; /*Can't handle highlighted dates in this theme*/ - theme.calendar.week_box = &box; - theme.calendar.today_box = &box; + theme.style.calendar.week_box = &box; + theme.style.calendar.today_box = &box; #endif } @@ -265,12 +265,12 @@ static void cb_init(void) #if USE_LV_CB != 0 - theme.cb.bg = &lv_style_transp; - theme.cb.box.rel = &light_frame; - theme.cb.box.pr = &dark_frame; - theme.cb.box.tgl_rel = &dark_frame; - theme.cb.box.tgl_pr = &light_frame; - theme.cb.box.ina = &light_frame; + theme.style.cb.bg = &lv_style_transp; + theme.style.cb.box.rel = &light_frame; + theme.style.cb.box.pr = &dark_frame; + theme.style.cb.box.tgl_rel = &dark_frame; + theme.style.cb.box.tgl_pr = &light_frame; + theme.style.cb.box.ina = &light_frame; #endif } @@ -280,24 +280,24 @@ static void btnm_init(void) #if USE_LV_BTNM - theme.btnm.bg = &light_frame; - theme.btnm.btn.rel = &light_frame; - theme.btnm.btn.pr = &dark_frame; - theme.btnm.btn.tgl_rel = &dark_frame; - theme.btnm.btn.tgl_pr = &light_frame; - theme.btnm.btn.ina = &light_frame; + theme.style.btnm.bg = &light_frame; + theme.style.btnm.btn.rel = &light_frame; + theme.style.btnm.btn.pr = &dark_frame; + theme.style.btnm.btn.tgl_rel = &dark_frame; + theme.style.btnm.btn.tgl_pr = &light_frame; + theme.style.btnm.btn.ina = &light_frame; #endif } static void kb_init(void) { #if USE_LV_KB - theme.kb.bg = &lv_style_transp_fit; - theme.kb.btn.rel = &light_frame; - theme.kb.btn.pr = &light_frame; - theme.kb.btn.tgl_rel = &dark_frame; - theme.kb.btn.tgl_pr = &dark_frame; - theme.kb.btn.ina = &light_frame; + theme.style.kb.bg = &lv_style_transp_fit; + theme.style.kb.btn.rel = &light_frame; + theme.style.kb.btn.pr = &light_frame; + theme.style.kb.btn.tgl_rel = &dark_frame; + theme.style.kb.btn.tgl_pr = &dark_frame; + theme.style.kb.btn.ina = &light_frame; #endif } @@ -307,10 +307,10 @@ static void mbox_init(void) #if USE_LV_MBOX - theme.mbox.bg = &dark_frame; - theme.mbox.btn.bg = &lv_style_transp_fit; - theme.mbox.btn.rel = &light_frame; - theme.mbox.btn.pr = &dark_frame; + theme.style.mbox.bg = &dark_frame; + theme.style.mbox.btn.bg = &lv_style_transp_fit; + theme.style.mbox.btn.rel = &light_frame; + theme.style.mbox.btn.pr = &dark_frame; #endif } @@ -319,9 +319,9 @@ static void page_init(void) #if USE_LV_PAGE - theme.page.bg = &light_frame; - theme.page.scrl = &light_frame; - theme.page.sb = &dark_frame; + theme.style.page.bg = &light_frame; + theme.style.page.scrl = &light_frame; + theme.style.page.sb = &dark_frame; #endif } @@ -330,10 +330,10 @@ static void ta_init(void) #if USE_LV_TA - theme.ta.area = &light_frame; - theme.ta.oneline = &light_frame; - theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/ - theme.ta.sb = &dark_frame; + theme.style.ta.area = &light_frame; + theme.style.ta.oneline = &light_frame; + theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/ + theme.style.ta.sb = &dark_frame; #endif } @@ -342,14 +342,14 @@ static void list_init(void) #if USE_LV_LIST != 0 - theme.list.sb = &dark_frame; - theme.list.bg = &light_frame; - theme.list.scrl = &lv_style_transp_fit; - theme.list.btn.rel = &light_plain; - theme.list.btn.pr = &dark_plain; - theme.list.btn.tgl_rel = &dark_plain; - theme.list.btn.tgl_pr = &light_plain; - theme.list.btn.ina = &light_plain; + theme.style.list.sb = &dark_frame; + theme.style.list.bg = &light_frame; + theme.style.list.scrl = &lv_style_transp_fit; + theme.style.list.btn.rel = &light_plain; + theme.style.list.btn.pr = &dark_plain; + theme.style.list.btn.tgl_rel = &dark_plain; + theme.style.list.btn.tgl_pr = &light_plain; + theme.style.list.btn.ina = &light_plain; #endif } @@ -360,9 +360,9 @@ static void ddlist_init(void) lv_style_copy(&bg, &light_frame); bg.text.line_space = LV_DPI / 12; - theme.ddlist.bg = &bg; - theme.ddlist.sel = &dark_plain; - theme.ddlist.sb = &dark_frame; + theme.style.ddlist.bg = &bg; + theme.style.ddlist.sel = &dark_plain; + theme.style.ddlist.sb = &dark_frame; #endif } @@ -373,8 +373,8 @@ static void roller_init(void) lv_style_copy(&bg, &light_frame); bg.text.line_space = LV_DPI / 12; - theme.roller.bg = &bg; - theme.roller.sel = &dark_frame; + theme.style.roller.bg = &bg; + theme.style.roller.sel = &dark_frame; #endif } @@ -383,13 +383,13 @@ static void tabview_init(void) #if USE_LV_TABVIEW != 0 - theme.tabview.bg = &light_frame; - theme.tabview.indic = &light_plain; - theme.tabview.btn.bg = &lv_style_transp_fit; - theme.tabview.btn.rel = &light_frame; - theme.tabview.btn.pr = &dark_frame; - theme.tabview.btn.tgl_rel = &dark_frame; - theme.tabview.btn.tgl_pr = &light_frame; + theme.style.tabview.bg = &light_frame; + theme.style.tabview.indic = &light_plain; + theme.style.tabview.btn.bg = &lv_style_transp_fit; + theme.style.tabview.btn.rel = &light_frame; + theme.style.tabview.btn.pr = &dark_frame; + theme.style.tabview.btn.tgl_rel = &dark_frame; + theme.style.tabview.btn.tgl_pr = &light_frame; #endif } @@ -402,13 +402,13 @@ static void win_init(void) win_header.body.padding.hor = LV_DPI / 30; win_header.body.padding.ver = LV_DPI / 30; - theme.win.bg = &light_frame; - theme.win.sb = &dark_frame; - theme.win.header = &win_header; - theme.win.content.bg = &lv_style_transp; - theme.win.content.scrl = &lv_style_transp; - theme.win.btn.rel = &light_frame; - theme.win.btn.pr = &dark_frame; + theme.style.win.bg = &light_frame; + theme.style.win.sb = &dark_frame; + theme.style.win.header = &win_header; + theme.style.win.content.bg = &lv_style_transp; + theme.style.win.content.scrl = &lv_style_transp; + theme.style.win.btn.rel = &light_frame; + theme.style.win.btn.pr = &dark_frame; #endif } diff --git a/lv_themes/lv_theme_nemo.c b/lv_themes/lv_theme_nemo.c index 0e6cb0a88..339682ad2 100644 --- a/lv_themes/lv_theme_nemo.c +++ b/lv_themes/lv_theme_nemo.c @@ -132,8 +132,8 @@ static void basic_init(void) sb.body.padding.ver = 1; sb.body.padding.inner = LV_DPI / 15; /*Scrollbar width*/ - theme.bg = &bg; - theme.panel = &panel; + theme.style.bg = &bg; + theme.style.panel = &panel; } @@ -188,11 +188,11 @@ static void btn_init(void) btn_ina.text.font = _font; btn_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 90); - theme.btn.rel = &btn_rel; - theme.btn.pr = &btn_pr; - theme.btn.tgl_rel = &btn_trel; - theme.btn.tgl_pr = &btn_tpr; - theme.btn.ina = &btn_ina; + theme.style.btn.rel = &btn_rel; + theme.style.btn.pr = &btn_pr; + theme.style.btn.tgl_rel = &btn_trel; + theme.style.btn.tgl_pr = &btn_tpr; + theme.style.btn.ina = &btn_ina; #endif } @@ -214,9 +214,9 @@ static void label_init(void) lv_style_copy(&label_hint, &label_prim); label_hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 70); - theme.label.prim = &label_prim; - theme.label.sec = &label_sec; - theme.label.hint = &label_hint; + theme.style.label.prim = &label_prim; + theme.style.label.sec = &label_sec; + theme.style.label.hint = &label_hint; #endif } @@ -248,8 +248,8 @@ static void bar_init(void) bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80); bar_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80); - theme.bar.bg = &bar_bg; - theme.bar.indic = &bar_indic; + theme.style.bar.bg = &bar_bg; + theme.style.bar.indic = &bar_indic; #endif } @@ -265,8 +265,8 @@ static void img_init(void) img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 65); img_light.image.intense = LV_OPA_80; - theme.img.light = &img_light; - theme.img.dark = &img_dark; + theme.style.img.light = &img_light; + theme.style.img.dark = &img_dark; #endif } @@ -278,7 +278,7 @@ static void line_init(void) line_decor.line.color = lv_color_hsv_to_rgb(_hue, 50, 50); line_decor.line.width = 1; - theme.line.decor = &line_decor; + theme.style.line.decor = &line_decor; #endif } @@ -296,7 +296,7 @@ static void led_init(void) led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60); led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100); - theme.led = &led; + theme.style.led = &led; #endif } @@ -312,9 +312,9 @@ static void slider_init(void) slider_knob.body.border.color = LV_COLOR_ORANGE; slider_knob.body.border.opa = LV_OPA_50; - theme.slider.bg = &bar_bg; - theme.slider.indic = &bar_indic; - theme.slider.knob = &slider_knob; + theme.style.slider.bg = &bar_bg; + theme.style.slider.indic = &bar_indic; + theme.style.slider.knob = &slider_knob; #endif } @@ -339,10 +339,10 @@ static void sw_init(void) lv_style_copy(&sw_knob, &slider_knob); sw_knob.body.opa = LV_OPA_80; - theme.sw.bg = &sw_bg; - theme.sw.indic = &sw_indic; - theme.sw.knob_off = &sw_knob; - theme.sw.knob_on = &sw_knob; + theme.style.sw.bg = &sw_bg; + theme.style.sw.indic = &sw_indic; + theme.style.sw.knob_off = &sw_knob; + theme.style.sw.knob_on = &sw_knob; #endif } @@ -357,7 +357,7 @@ static void lmeter_init(void) lmeter_bg.line.color = LV_COLOR_HEX3(0x500); lmeter_bg.line.width = 2; - theme.lmeter = &lmeter_bg; + theme.style.lmeter = &lmeter_bg; #endif } @@ -378,7 +378,7 @@ static void gauge_init(void) gauge_bg.text.color = lv_color_hsv_to_rgb(_hue, 10, 90); gauge_bg.text.font = _font; - theme.gauge = &gauge_bg; + theme.style.gauge = &gauge_bg; #endif } @@ -395,7 +395,7 @@ static void arc_init(void) /*For preloader*/ arc.body.border.width = 0; - theme.arc = &arc; + theme.style.arc = &arc; #endif } @@ -403,14 +403,14 @@ static void preload_init(void) { #if USE_LV_PRELOAD != 0 - theme.preload = theme.arc; + theme.style.preload = theme.style.arc; #endif } static void chart_init(void) { #if USE_LV_CHART - theme.chart = &panel; + theme.style.chart = &panel; #endif } @@ -428,7 +428,7 @@ static void calendar_init(void) static lv_style_t week_box; lv_style_copy(&week_box, &def); week_box.body.empty = 1; - week_box.body.border.color = theme.panel->body.border.color; + week_box.body.border.color = theme.style.panel->body.border.color; week_box.body.padding.ver = LV_DPI / 20; static lv_style_t today_box; @@ -438,13 +438,13 @@ static void calendar_init(void) today_box.body.padding.ver = LV_DPI / 20; today_box.body.radius = 0; - theme.calendar.bg = theme.panel; - theme.calendar.header = theme.label.prim; - theme.calendar.inactive_days = theme.label.hint; - theme.calendar.highlighted_days = theme.label.sec; - theme.calendar.week_box = &week_box; - theme.calendar.today_box = &week_box; - theme.calendar.header_pr = theme.label.prim; + theme.style.calendar.bg = theme.style.panel; + theme.style.calendar.header = theme.style.label.prim; + theme.style.calendar.inactive_days = theme.style.label.hint; + theme.style.calendar.highlighted_days = theme.style.label.sec; + theme.style.calendar.week_box = &week_box; + theme.style.calendar.today_box = &week_box; + theme.style.calendar.header_pr = theme.style.label.prim; #endif } @@ -490,12 +490,12 @@ static void cb_init(void) cb_ina.body.main_color = LV_COLOR_PURPLE; cb_ina.body.grad_color = LV_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; + theme.style.cb.bg = &cb_bg; + theme.style.cb.box.rel = &cb_rel; + theme.style.cb.box.pr = &cb_pr; + theme.style.cb.box.tgl_rel = &cb_trel; + theme.style.cb.box.tgl_pr = &cb_tpr; + theme.style.cb.box.ina = &cb_ina; #endif } @@ -529,24 +529,24 @@ static void btnm_init(void) lv_style_copy(&btnm_ina, &btnm_rel); btnm_ina.text.color = lv_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; + theme.style.btnm.bg = &btnm_bg; + theme.style.btnm.btn.rel = &btnm_rel; + theme.style.btnm.btn.pr = &btnm_pr; + theme.style.btnm.btn.tgl_rel = &btnm_trel; + theme.style.btnm.btn.tgl_pr = &btnm_pr; + theme.style.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; + theme.style.kb.bg = &btnm_bg; + theme.style.kb.btn.rel = &btnm_rel; + theme.style.kb.btn.pr = &btnm_pr; + theme.style.kb.btn.tgl_rel = &btnm_trel; + theme.style.kb.btn.tgl_pr = &btnm_pr; + theme.style.kb.btn.ina = &btnm_ina; #endif } @@ -558,38 +558,38 @@ static void mbox_init(void) 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_trel; - theme.mbox.btn.pr = &btn_tpr; + theme.style.mbox.bg = &mbox_bg; + theme.style.mbox.btn.bg = &lv_style_transp; + theme.style.mbox.btn.rel = &btn_trel; + theme.style.mbox.btn.pr = &btn_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; + theme.style.page.bg = &panel; + theme.style.page.scrl = &lv_style_transp_fit; + theme.style.page.sb = &sb; #endif } static void ta_init(void) { #if USE_LV_TA - theme.ta.area = &panel; - theme.ta.oneline = &panel; - theme.ta.cursor = NULL; - theme.ta.sb = &sb; + theme.style.ta.area = &panel; + theme.style.ta.oneline = &panel; + theme.style.ta.cursor = NULL; + theme.style.ta.sb = &sb; #endif } static void spinbox_init(void) { #if USE_LV_SPINBOX - theme.spinbox.bg= &panel; - theme.spinbox.cursor = theme.ta.cursor; - theme.spinbox.sb = theme.ta.sb; + theme.style.spinbox.bg= &panel; + theme.style.spinbox.cursor = theme.style.ta.cursor; + theme.style.spinbox.sb = theme.style.ta.sb; #endif } @@ -620,14 +620,14 @@ static void list_init(void) 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; + theme.style.list.sb = &sb; + theme.style.list.bg = &list_bg; + theme.style.list.scrl = &lv_style_transp_tight; + theme.style.list.btn.rel = &list_rel; + theme.style.list.btn.pr = &list_pr; + theme.style.list.btn.tgl_rel = &list_trel; + theme.style.list.btn.tgl_pr = &list_tpr; + theme.style.list.btn.ina = &list_ina; #endif } @@ -645,9 +645,9 @@ static void ddlist_init(void) ddlist_sel.body.opa = LV_OPA_COVER; ddlist_sel.body.radius = 0; - theme.ddlist.bg = &ddlist_bg; - theme.ddlist.sel = &ddlist_sel; - theme.ddlist.sb = &sb; + theme.style.ddlist.bg = &ddlist_bg; + theme.style.ddlist.sel = &ddlist_sel; + theme.style.ddlist.sb = &sb; #endif } @@ -671,8 +671,8 @@ static void roller_init(void) roller_sel.text.opa = LV_OPA_COVER; roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 70, 95); - theme.roller.bg = &roller_bg; - theme.roller.sel = &roller_sel; + theme.style.roller.bg = &roller_bg; + theme.style.roller.sel = &roller_sel; #endif } @@ -725,22 +725,22 @@ static void tabview_init(void) tab_indic.body.grad_color = lv_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; + theme.style.tabview.bg = &bg; + theme.style.tabview.indic = &tab_indic; + theme.style.tabview.btn.bg = &lv_style_transp_tight; + theme.style.tabview.btn.rel = &tab_rel; + theme.style.tabview.btn.pr = &tab_pr; + theme.style.tabview.btn.tgl_rel = &tab_trel; + theme.style.tabview.btn.tgl_pr = &tab_tpr; #endif } static void tileview_init(void) { #if USE_LV_TILEVIEW != 0 - theme.tileview.bg = &lv_style_transp_tight; - theme.tileview.scrl = &lv_style_transp_tight; - theme.tileview.sb = theme.page.sb; + theme.style.tileview.bg = &lv_style_transp_tight; + theme.style.tileview.scrl = &lv_style_transp_tight; + theme.style.tileview.sb = theme.style.page.sb; #endif } @@ -752,8 +752,8 @@ static void table_init(void) cell.body.radius = 0; cell.body.border.width = 1; - theme.table.bg = &lv_style_transp_tight; - theme.table.cell = &cell; + theme.style.table.bg = &lv_style_transp_tight; + theme.style.table.cell = &cell; #endif } @@ -771,13 +771,13 @@ static void win_init(void) win_header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80); win_header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100); - theme.win.bg = &bg; - theme.win.sb = &sb; - theme.win.header = &win_header; - theme.win.content.bg = &lv_style_transp; - theme.win.content.scrl = &lv_style_transp; - theme.win.btn.rel = &btn_rel; - theme.win.btn.pr = &btn_pr; + theme.style.win.bg = &bg; + theme.style.win.sb = &sb; + theme.style.win.header = &win_header; + theme.style.win.content.bg = &lv_style_transp; + theme.style.win.content.scrl = &lv_style_transp; + theme.style.win.btn.rel = &btn_rel; + theme.style.win.btn.pr = &btn_pr; #endif } diff --git a/lv_themes/lv_theme_night.c b/lv_themes/lv_theme_night.c index ed3823fdc..4f86bd032 100644 --- a/lv_themes/lv_theme_night.c +++ b/lv_themes/lv_theme_night.c @@ -81,8 +81,8 @@ static void basic_init(void) panel.body.padding.hor = LV_DPI / 10; panel.line.color = lv_color_hsv_to_rgb(_hue, 20, 40); panel.line.width = 1; - theme.bg = &bg; - theme.panel = &def; + theme.style.bg = &bg; + theme.style.panel = &def; } static void cont_init(void) @@ -90,7 +90,7 @@ static void cont_init(void) #if USE_LV_CONT != 0 - theme.cont = &panel; + theme.style.cont = &panel; #endif } static void btn_init(void) @@ -132,11 +132,11 @@ static void btn_init(void) btn_ina.text.color = LV_COLOR_HEX3(0xaaa); btn_ina.body.shadow.width = 0; - theme.btn.rel = &btn_rel; - theme.btn.pr = &btn_pr; - theme.btn.tgl_rel = &btn_tgl_rel; - theme.btn.tgl_pr = &btn_tgl_pr; - theme.btn.ina = &btn_ina; + theme.style.btn.rel = &btn_rel; + theme.style.btn.pr = &btn_pr; + theme.style.btn.tgl_rel = &btn_tgl_rel; + theme.style.btn.tgl_pr = &btn_tgl_pr; + theme.style.btn.ina = &btn_ina; #endif } @@ -154,9 +154,9 @@ static void label_init(void) lv_style_copy(&hint, &bg); hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 55); - theme.label.prim = &prim; - theme.label.sec = &sec; - theme.label.hint = &hint; + theme.style.label.prim = &prim; + theme.style.label.sec = &sec; + theme.style.label.hint = &hint; #endif } @@ -165,7 +165,7 @@ static void line_init(void) #if USE_LV_LINE != 0 - theme.line.decor = &def; + theme.style.line.decor = &def; #endif } @@ -183,7 +183,7 @@ static void led_init(void) led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60); led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100); - theme.led = &led; + theme.style.led = &led; #endif } @@ -192,8 +192,8 @@ static void img_init(void) #if USE_LV_IMG != 0 - theme.img.light = &def; - theme.img.dark = &def; + theme.style.img.light = &def; + theme.style.img.dark = &def; #endif } @@ -215,8 +215,8 @@ static void bar_init(void) bar_indic.body.padding.hor = 0; bar_indic.body.padding.ver = 0; - theme.bar.bg = &bar_bg; - theme.bar.indic = &bar_indic; + theme.style.bar.bg = &bar_bg; + theme.style.bar.indic = &bar_indic; #endif } @@ -227,9 +227,9 @@ static void slider_init(void) lv_style_copy(&slider_knob, &btn_rel); slider_knob.body.radius = LV_RADIUS_CIRCLE; - theme.slider.bg = &bar_bg; - theme.slider.indic = &bar_indic; - theme.slider.knob = &slider_knob; + theme.style.slider.bg = &bar_bg; + theme.style.slider.indic = &bar_indic; + theme.style.slider.knob = &slider_knob; #endif } @@ -238,10 +238,10 @@ static void sw_init(void) #if USE_LV_SW != 0 - theme.sw.bg = &bar_bg; - theme.sw.indic = &bar_indic; - theme.sw.knob_off = &slider_knob; - theme.sw.knob_on = &slider_knob; + theme.style.sw.bg = &bar_bg; + theme.style.sw.indic = &bar_indic; + theme.style.sw.knob_off = &slider_knob; + theme.style.sw.knob_on = &slider_knob; #endif } @@ -259,7 +259,7 @@ static void lmeter_init(void) lmeter_bg.line.width = 1; lmeter_bg.text.color = LV_COLOR_HEX3(0xddd); - theme.lmeter = &lmeter_bg; + theme.style.lmeter = &lmeter_bg; #endif } @@ -274,7 +274,7 @@ static void gauge_init(void) gauge_bg.line.width = 1; gauge_bg.text.color = LV_COLOR_HEX3(0xddd); - theme.gauge = &gauge_bg; + theme.style.gauge = &gauge_bg; #endif } @@ -294,7 +294,7 @@ static void arc_init(void) arc.body.padding.hor = 1; arc.body.padding.ver = 1; - theme.arc = &arc; + theme.style.arc = &arc; #endif } @@ -302,14 +302,14 @@ static void preload_init(void) { #if USE_LV_PRELOAD != 0 - theme.preload = theme.arc; + theme.style.preload = theme.style.arc; #endif } static void chart_init(void) { #if USE_LV_CHART - theme.chart = &panel; + theme.style.chart = &panel; #endif } @@ -361,13 +361,13 @@ static void calendar_init(void) lv_style_copy(&ina_days, &bg); ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 60); - theme.calendar.bg = &cal_bg; - theme.calendar.header = &cal_header; - theme.calendar.week_box = &week_box; - theme.calendar.today_box = &today_box; - theme.calendar.highlighted_days = &highlighted_days; - theme.calendar.day_names = &cal_bg; - theme.calendar.inactive_days = &ina_days; + theme.style.calendar.bg = &cal_bg; + theme.style.calendar.header = &cal_header; + theme.style.calendar.week_box = &week_box; + theme.style.calendar.today_box = &today_box; + theme.style.calendar.highlighted_days = &highlighted_days; + theme.style.calendar.day_names = &cal_bg; + theme.style.calendar.inactive_days = &ina_days; #endif } @@ -407,12 +407,12 @@ static void cb_init(void) ina.body.grad_color = LV_COLOR_HEX3(0x777); ina.body.border.width = 0; - theme.cb.bg = &lv_style_transp; - theme.cb.box.rel = &rel; - theme.cb.box.pr = ≺ - theme.cb.box.tgl_rel = &tgl_rel; - theme.cb.box.tgl_pr = &tgl_pr; - theme.cb.box.ina = &def; + theme.style.cb.bg = &lv_style_transp; + theme.style.cb.box.rel = &rel; + theme.style.cb.box.pr = ≺ + theme.style.cb.box.tgl_rel = &tgl_rel; + theme.style.cb.box.tgl_pr = &tgl_pr; + theme.style.cb.box.ina = &def; #endif } @@ -453,24 +453,24 @@ static void btnm_init(void) ina.body.border.width = rel.body.border.width; ina.body.radius = rel.body.radius; - theme.btnm.bg = &btnm_bg; - theme.btnm.btn.rel = &rel; - theme.btnm.btn.pr = ≺ - theme.btnm.btn.tgl_rel = &tgl_rel; - theme.btnm.btn.tgl_pr = &tgl_pr; - theme.btnm.btn.ina = &ina; + theme.style.btnm.bg = &btnm_bg; + theme.style.btnm.btn.rel = &rel; + theme.style.btnm.btn.pr = ≺ + theme.style.btnm.btn.tgl_rel = &tgl_rel; + theme.style.btnm.btn.tgl_pr = &tgl_pr; + theme.style.btnm.btn.ina = &ina; #endif } static void kb_init(void) { #if USE_LV_KB - theme.kb.bg = &bg; - theme.kb.btn.rel = &btn_rel; - theme.kb.btn.pr = &btn_pr; - theme.kb.btn.tgl_rel = &btn_tgl_rel; - theme.kb.btn.tgl_pr = &btn_tgl_pr; - theme.kb.btn.ina = &btn_ina; + theme.style.kb.bg = &bg; + theme.style.kb.btn.rel = &btn_rel; + theme.style.kb.btn.pr = &btn_pr; + theme.style.kb.btn.tgl_rel = &btn_tgl_rel; + theme.style.kb.btn.tgl_pr = &btn_tgl_pr; + theme.style.kb.btn.ina = &btn_ina; #endif } @@ -487,10 +487,10 @@ static void mbox_init(void) mbox_bg.body.shadow.width = LV_DPI / 10; mbox_bg.body.shadow.color = LV_COLOR_HEX3(0x222); mbox_bg.body.radius = LV_DPI / 20; - theme.mbox.bg = &mbox_bg; - theme.mbox.btn.bg = &lv_style_transp; - theme.mbox.btn.rel = &btn_rel; - theme.mbox.btn.pr = &btn_pr; + theme.style.mbox.bg = &mbox_bg; + theme.style.mbox.btn.bg = &lv_style_transp; + theme.style.mbox.btn.rel = &btn_rel; + theme.style.mbox.btn.pr = &btn_pr; #endif } @@ -506,28 +506,28 @@ static void page_init(void) page_scrl.body.border.width = 1; page_scrl.body.radius = LV_DPI / 20; - theme.page.bg = &panel; - theme.page.scrl = &page_scrl; - theme.page.sb = &sb; + theme.style.page.bg = &panel; + theme.style.page.scrl = &page_scrl; + theme.style.page.sb = &sb; #endif } static void ta_init(void) { #if USE_LV_TA - theme.ta.area = &panel; - theme.ta.oneline = &panel; - theme.ta.cursor = NULL; - theme.ta.sb = &def; + theme.style.ta.area = &panel; + theme.style.ta.oneline = &panel; + theme.style.ta.cursor = NULL; + theme.style.ta.sb = &def; #endif } static void spinbox_init(void) { #if USE_LV_SPINBOX - theme.spinbox.bg= &panel; - theme.spinbox.cursor = theme.ta.cursor; - theme.spinbox.sb = theme.ta.sb; + theme.style.spinbox.bg= &panel; + theme.style.spinbox.cursor = theme.style.ta.cursor; + theme.style.spinbox.sb = theme.style.ta.sb; #endif } @@ -571,14 +571,14 @@ static void list_init(void) list_btn_tgl_pr.body.main_color = btn_tgl_pr.body.main_color; list_btn_tgl_pr.body.grad_color = btn_tgl_pr.body.grad_color; - theme.list.sb = &sb; - theme.list.bg = &list_bg; - theme.list.scrl = &lv_style_transp_tight; - theme.list.btn.rel = &list_btn_rel; - theme.list.btn.pr = &list_btn_pr; - theme.list.btn.tgl_rel = &list_btn_tgl_rel; - theme.list.btn.tgl_pr = &list_btn_tgl_pr; - theme.list.btn.ina = &def; + theme.style.list.sb = &sb; + theme.style.list.bg = &list_bg; + theme.style.list.scrl = &lv_style_transp_tight; + theme.style.list.btn.rel = &list_btn_rel; + theme.style.list.btn.pr = &list_btn_pr; + theme.style.list.btn.tgl_rel = &list_btn_tgl_rel; + theme.style.list.btn.tgl_pr = &list_btn_tgl_pr; + theme.style.list.btn.ina = &def; #endif } @@ -596,9 +596,9 @@ static void ddlist_init(void) ddlist_sel.body.grad_color = lv_color_hsv_to_rgb(_hue, 20, 50); ddlist_sel.body.radius = 0; - theme.ddlist.bg = &ddlist_bg; - theme.ddlist.sel = &ddlist_sel; - theme.ddlist.sb = &def; + theme.style.ddlist.bg = &ddlist_bg; + theme.style.ddlist.sel = &ddlist_sel; + theme.style.ddlist.sb = &def; #endif } @@ -613,30 +613,30 @@ static void roller_init(void) roller_bg.text.color = lv_color_hsv_to_rgb(_hue, 5, 70); roller_bg.text.opa = LV_OPA_60; - theme.roller.bg = &roller_bg; - theme.roller.sel = &ddlist_sel; + theme.style.roller.bg = &roller_bg; + theme.style.roller.sel = &ddlist_sel; #endif } static void tabview_init(void) { #if USE_LV_TABVIEW != 0 - theme.tabview.bg = &bg; - theme.tabview.indic = &lv_style_transp; - theme.tabview.btn.bg = &lv_style_transp; - theme.tabview.btn.rel = &btn_rel; - theme.tabview.btn.pr = &btn_pr; - theme.tabview.btn.tgl_rel = &btn_tgl_rel; - theme.tabview.btn.tgl_pr = &btn_tgl_pr; + theme.style.tabview.bg = &bg; + theme.style.tabview.indic = &lv_style_transp; + theme.style.tabview.btn.bg = &lv_style_transp; + theme.style.tabview.btn.rel = &btn_rel; + theme.style.tabview.btn.pr = &btn_pr; + theme.style.tabview.btn.tgl_rel = &btn_tgl_rel; + theme.style.tabview.btn.tgl_pr = &btn_tgl_pr; #endif } static void tileview_init(void) { #if USE_LV_TILEVIEW != 0 - theme.tileview.bg = &lv_style_transp_tight; - theme.tileview.scrl = &lv_style_transp_tight; - theme.tileview.sb = theme.page.sb; + theme.style.tileview.bg = &lv_style_transp_tight; + theme.style.tileview.scrl = &lv_style_transp_tight; + theme.style.tileview.sb = theme.style.page.sb; #endif } @@ -651,8 +651,8 @@ static void table_init(void) cell.body.padding.ver = LV_DPI / 12; - theme.table.bg = &lv_style_transp_tight; - theme.table.cell = &cell; + theme.style.table.bg = &lv_style_transp_tight; + theme.style.table.cell = &cell; #endif } @@ -679,13 +679,13 @@ static void win_init(void) win_btn_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 10); win_btn_pr.text.color = LV_COLOR_HEX3(0xaaa); - theme.win.bg = &win_bg; - theme.win.sb = &sb; - theme.win.header = &win_header; - theme.win.content.bg = &lv_style_transp; - theme.win.content.scrl = &lv_style_transp; - theme.win.btn.rel = &lv_style_transp; - theme.win.btn.pr = &win_btn_pr; + theme.style.win.bg = &win_bg; + theme.style.win.sb = &sb; + theme.style.win.header = &win_header; + theme.style.win.content.bg = &lv_style_transp; + theme.style.win.content.scrl = &lv_style_transp; + theme.style.win.btn.rel = &lv_style_transp; + theme.style.win.btn.pr = &win_btn_pr; #endif } diff --git a/lv_themes/lv_theme_templ.c b/lv_themes/lv_theme_templ.c index b9359d4bc..eb2e0747c 100644 --- a/lv_themes/lv_theme_templ.c +++ b/lv_themes/lv_theme_templ.c @@ -47,8 +47,8 @@ static void basic_init(void) lv_style_copy(&def, &lv_style_pretty); /*Initialize the default style*/ def.text.font = _font; - theme.bg = &def; - theme.panel = &def; + theme.style.bg = &def; + theme.style.panel = &def; } @@ -57,7 +57,7 @@ static void cont_init(void) #if USE_LV_CONT != 0 - theme.cont = &def; + theme.style.cont = &def; #endif } @@ -66,22 +66,22 @@ static void btn_init(void) #if USE_LV_BTN != 0 - theme.btn.rel = &def; - theme.btn.pr = &def; - theme.btn.tgl_rel = &def; - theme.btn.tgl_pr = &def; - theme.btn.ina = &def; + theme.style.btn.rel = &def; + theme.style.btn.pr = &def; + theme.style.btn.tgl_rel = &def; + theme.style.btn.tgl_pr = &def; + theme.style.btn.ina = &def; #endif } static void imgbtn_init(void) { #if USE_LV_IMGBTN != 0 - theme.imgbtn.rel = &def; - theme.imgbtn.pr = &def; - theme.imgbtn.tgl_rel = &def; - theme.imgbtn.tgl_pr = &def; - theme.imgbtn.ina = &def; + theme.style.imgbtn.rel = &def; + theme.style.imgbtn.pr = &def; + theme.style.imgbtn.tgl_rel = &def; + theme.style.imgbtn.tgl_pr = &def; + theme.style.imgbtn.ina = &def; #endif } @@ -90,9 +90,9 @@ static void label_init(void) #if USE_LV_LABEL != 0 - theme.label.prim = &def; - theme.label.sec = &def; - theme.label.hint = &def; + theme.style.label.prim = &def; + theme.style.label.sec = &def; + theme.style.label.hint = &def; #endif } @@ -101,8 +101,8 @@ static void img_init(void) #if USE_LV_IMG != 0 - theme.img.light = &def; - theme.img.dark = &def; + theme.style.img.light = &def; + theme.style.img.dark = &def; #endif } @@ -111,7 +111,7 @@ static void line_init(void) #if USE_LV_LINE != 0 - theme.line.decor = &def; + theme.style.line.decor = &def; #endif } @@ -120,7 +120,7 @@ static void led_init(void) #if USE_LV_LED != 0 - theme.led = &def; + theme.style.led = &def; #endif } @@ -129,8 +129,8 @@ static void bar_init(void) #if USE_LV_BAR - theme.bar.bg = &def; - theme.bar.indic = &def; + theme.style.bar.bg = &def; + theme.style.bar.indic = &def; #endif } @@ -139,9 +139,9 @@ static void slider_init(void) #if USE_LV_SLIDER != 0 - theme.slider.bg = &def; - theme.slider.indic = &def; - theme.slider.knob = &def; + theme.style.slider.bg = &def; + theme.style.slider.indic = &def; + theme.style.slider.knob = &def; #endif } @@ -150,10 +150,10 @@ static void sw_init(void) #if USE_LV_SW != 0 - theme.sw.bg = &def; - theme.sw.indic = &def; - theme.sw.knob_off = &def; - theme.sw.knob_on = &def; + theme.style.sw.bg = &def; + theme.style.sw.indic = &def; + theme.style.sw.knob_off = &def; + theme.style.sw.knob_on = &def; #endif } @@ -163,7 +163,7 @@ static void lmeter_init(void) #if USE_LV_LMETER != 0 - theme.lmeter = &def; + theme.style.lmeter = &def; #endif } @@ -172,7 +172,7 @@ static void gauge_init(void) #if USE_LV_GAUGE != 0 - theme.gauge = &def; + theme.style.gauge = &def; #endif } @@ -181,7 +181,7 @@ static void arc_init(void) #if USE_LV_ARC != 0 - theme.arc = &def; + theme.style.arc = &def; #endif } @@ -190,7 +190,7 @@ static void preload_init(void) #if USE_LV_PRELOAD != 0 - theme.preload = &def; + theme.style.preload = &def; #endif } @@ -198,7 +198,7 @@ static void chart_init(void) { #if USE_LV_CHART - theme.chart = &def; + theme.style.chart = &def; #endif } @@ -206,14 +206,14 @@ static void calendar_init(void) { #if USE_LV_CALENDAR - theme.calendar.bg = theme.panel; - theme.calendar.header = &def; - theme.calendar.inactive_days = &def; - theme.calendar.highlighted_days = &def; - theme.calendar.week_box = &def; - theme.calendar.today_box = &def; - theme.calendar.header_pr = &def; - theme.calendar.day_names = &def; + theme.style.calendar.bg = theme.style.panel; + theme.style.calendar.header = &def; + theme.style.calendar.inactive_days = &def; + theme.style.calendar.highlighted_days = &def; + theme.style.calendar.week_box = &def; + theme.style.calendar.today_box = &def; + theme.style.calendar.header_pr = &def; + theme.style.calendar.day_names = &def; #endif } @@ -222,12 +222,12 @@ static void cb_init(void) #if USE_LV_CB != 0 - theme.cb.bg = &def; - theme.cb.box.rel = &def; - theme.cb.box.pr = &def; - theme.cb.box.tgl_rel = &def; - theme.cb.box.tgl_pr = &def; - theme.cb.box.ina = &def; + theme.style.cb.bg = &def; + theme.style.cb.box.rel = &def; + theme.style.cb.box.pr = &def; + theme.style.cb.box.tgl_rel = &def; + theme.style.cb.box.tgl_pr = &def; + theme.style.cb.box.ina = &def; #endif } @@ -237,12 +237,12 @@ static void btnm_init(void) #if USE_LV_BTNM - theme.btnm.bg = &def; - theme.btnm.btn.rel = &def; - theme.btnm.btn.pr = &def; - theme.btnm.btn.tgl_rel = &def; - theme.btnm.btn.tgl_pr = &def; - theme.btnm.btn.ina = &def; + theme.style.btnm.bg = &def; + theme.style.btnm.btn.rel = &def; + theme.style.btnm.btn.pr = &def; + theme.style.btnm.btn.tgl_rel = &def; + theme.style.btnm.btn.tgl_pr = &def; + theme.style.btnm.btn.ina = &def; #endif } @@ -251,12 +251,12 @@ static void kb_init(void) #if USE_LV_KB - theme.kb.bg = &def; - theme.kb.btn.rel = &def; - theme.kb.btn.pr = &def; - theme.kb.btn.tgl_rel = &def; - theme.kb.btn.tgl_pr = &def; - theme.kb.btn.ina = &def; + theme.style.kb.bg = &def; + theme.style.kb.btn.rel = &def; + theme.style.kb.btn.pr = &def; + theme.style.kb.btn.tgl_rel = &def; + theme.style.kb.btn.tgl_pr = &def; + theme.style.kb.btn.ina = &def; #endif } @@ -266,10 +266,10 @@ static void mbox_init(void) #if USE_LV_MBOX - theme.mbox.bg = &def; - theme.mbox.btn.bg = &def; - theme.mbox.btn.rel = &def; - theme.mbox.btn.pr = &def; + theme.style.mbox.bg = &def; + theme.style.mbox.btn.bg = &def; + theme.style.mbox.btn.rel = &def; + theme.style.mbox.btn.pr = &def; #endif } @@ -278,9 +278,9 @@ static void page_init(void) #if USE_LV_PAGE - theme.page.bg = &def; - theme.page.scrl = &def; - theme.page.sb = &def; + theme.style.page.bg = &def; + theme.style.page.scrl = &def; + theme.style.page.sb = &def; #endif } @@ -289,10 +289,10 @@ static void ta_init(void) #if USE_LV_TA - theme.ta.area = &def; - theme.ta.oneline = &def; - theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/ - theme.ta.sb = &def; + theme.style.ta.area = &def; + theme.style.ta.oneline = &def; + theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/ + theme.style.ta.sb = &def; #endif } @@ -301,14 +301,14 @@ static void list_init(void) #if USE_LV_LIST != 0 - theme.list.sb = &def; - theme.list.bg = &def; - theme.list.scrl = &def; - theme.list.btn.rel = &def; - theme.list.btn.pr = &def; - theme.list.btn.tgl_rel = &def; - theme.list.btn.tgl_pr = &def; - theme.list.btn.ina = &def; + theme.style.list.sb = &def; + theme.style.list.bg = &def; + theme.style.list.scrl = &def; + theme.style.list.btn.rel = &def; + theme.style.list.btn.pr = &def; + theme.style.list.btn.tgl_rel = &def; + theme.style.list.btn.tgl_pr = &def; + theme.style.list.btn.ina = &def; #endif } @@ -317,9 +317,9 @@ static void ddlist_init(void) #if USE_LV_DDLIST != 0 - theme.ddlist.bg = &def; - theme.ddlist.sel = &def; - theme.ddlist.sb = &def; + theme.style.ddlist.bg = &def; + theme.style.ddlist.sel = &def; + theme.style.ddlist.sb = &def; #endif } @@ -328,8 +328,8 @@ static void roller_init(void) #if USE_LV_ROLLER != 0 - theme.roller.bg = &def; - theme.roller.sel = &def; + theme.style.roller.bg = &def; + theme.style.roller.sel = &def; #endif } @@ -338,13 +338,13 @@ static void tabview_init(void) #if USE_LV_TABVIEW != 0 - theme.tabview.bg = &def; - theme.tabview.indic = &def; - theme.tabview.btn.bg = &def; - theme.tabview.btn.rel = &def; - theme.tabview.btn.pr = &def; - theme.tabview.btn.tgl_rel = &def; - theme.tabview.btn.tgl_pr = &def; + theme.style.tabview.bg = &def; + theme.style.tabview.indic = &def; + theme.style.tabview.btn.bg = &def; + theme.style.tabview.btn.rel = &def; + theme.style.tabview.btn.pr = &def; + theme.style.tabview.btn.tgl_rel = &def; + theme.style.tabview.btn.tgl_pr = &def; #endif } @@ -354,13 +354,13 @@ static void win_init(void) #if USE_LV_WIN != 0 - theme.win.bg = &def; - theme.win.sb = &def; - theme.win.header = &def; - theme.win.content.bg = &def; - theme.win.content.scrl = &def; - theme.win.btn.rel = &def; - theme.win.btn.pr = &def; + theme.style.win.bg = &def; + theme.style.win.sb = &def; + theme.style.win.header = &def; + theme.style.win.content.bg = &def; + theme.style.win.content.scrl = &def; + theme.style.win.btn.rel = &def; + theme.style.win.btn.pr = &def; #endif } diff --git a/lv_themes/lv_theme_zen.c b/lv_themes/lv_theme_zen.c index 7cdf5a10c..f04be7bcc 100644 --- a/lv_themes/lv_theme_zen.c +++ b/lv_themes/lv_theme_zen.c @@ -78,8 +78,8 @@ static void basic_init(void) sb.body.radius = LV_RADIUS_CIRCLE; sb.body.padding.inner = LV_DPI / 10; - theme.bg = &bg; - theme.panel = &panel; + theme.style.bg = &bg; + theme.style.panel = &panel; } static void cont_init(void) @@ -87,7 +87,7 @@ static void cont_init(void) #if USE_LV_CONT != 0 - theme.cont = theme.panel; + theme.style.cont = theme.style.panel; #endif } @@ -120,11 +120,11 @@ static void btn_init(void) ina.body.border.color = LV_COLOR_HEX3(0xbbb); ina.text.color = LV_COLOR_HEX3(0xbbb); - theme.btn.rel = &rel; - theme.btn.pr = ≺ - theme.btn.tgl_rel = ≺ - theme.btn.tgl_pr = &tgl_pr; - theme.btn.ina = &ina; + theme.style.btn.rel = &rel; + theme.style.btn.pr = ≺ + theme.style.btn.tgl_rel = ≺ + theme.style.btn.tgl_pr = &tgl_pr; + theme.style.btn.ina = &ina; #endif } @@ -140,9 +140,9 @@ static void label_init(void) sec.text.color = lv_color_hsv_to_rgb(_hue, 50, 80); hint.text.color = lv_color_hsv_to_rgb(_hue, 25, 85); - theme.label.prim = &prim; - theme.label.sec = &sec; - theme.label.hint = &hint; + theme.style.label.prim = &prim; + theme.style.label.sec = &sec; + theme.style.label.hint = &hint; #endif } @@ -158,8 +158,8 @@ static void img_init(void) img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 55); img_light.image.intense = LV_OPA_80; - theme.img.light = &img_light; - theme.img.dark = &img_dark; + theme.style.img.light = &img_light; + theme.style.img.dark = &img_dark; #endif } @@ -168,7 +168,7 @@ static void line_init(void) #if USE_LV_LINE != 0 - theme.line.decor = &def; + theme.style.line.decor = &def; #endif } @@ -187,7 +187,7 @@ static void led_init(void) led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60); led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 80, 100); - theme.led = &led; + theme.style.led = &led; #endif } @@ -212,8 +212,8 @@ static void bar_init(void) indic.body.padding.ver = LV_DPI / 20; - theme.bar.bg = &bg; - theme.bar.indic = &indic; + theme.style.bar.bg = &bg; + theme.style.bar.indic = &indic; #endif } @@ -223,14 +223,14 @@ static void slider_init(void) static lv_style_t knob; lv_style_copy(&knob, &def); - knob.body.main_color = theme.bar.indic->body.main_color; + knob.body.main_color = theme.style.bar.indic->body.main_color; knob.body.grad_color = knob.body.main_color; knob.body.radius = LV_RADIUS_CIRCLE; knob.body.border.width = 0; - theme.slider.bg = theme.bar.bg; - theme.slider.indic = theme.bar.indic; - theme.slider.knob = &knob; + theme.style.slider.bg = theme.style.bar.bg; + theme.style.slider.indic = theme.style.bar.indic; + theme.style.slider.knob = &knob; #endif } @@ -239,22 +239,22 @@ static void sw_init(void) #if USE_LV_SW != 0 static lv_style_t indic; - lv_style_copy(&indic, theme.slider.indic); + lv_style_copy(&indic, theme.style.slider.indic); indic.body.radius = LV_RADIUS_CIRCLE; indic.body.main_color = lv_color_hsv_to_rgb(_hue, 15, 95); indic.body.grad_color = indic.body.main_color; - indic.body.border.width = theme.slider.bg->body.border.width; - indic.body.border.color = theme.slider.bg->body.border.color; - indic.body.border.opa = theme.slider.bg->body.border.opa; + indic.body.border.width = theme.style.slider.bg->body.border.width; + indic.body.border.color = theme.style.slider.bg->body.border.color; + indic.body.border.opa = theme.style.slider.bg->body.border.opa; indic.body.padding.hor = 0; indic.body.padding.ver = 0; - theme.sw.bg = theme.slider.bg; - theme.sw.indic = &indic; - theme.sw.knob_off = theme.slider.knob; - theme.sw.knob_on = theme.slider.knob; + theme.style.sw.bg = theme.style.slider.bg; + theme.style.sw.indic = &indic; + theme.style.sw.knob_off = theme.style.slider.knob; + theme.style.sw.knob_on = theme.style.slider.knob; #endif } @@ -271,7 +271,7 @@ static void lmeter_init(void) lmeter.body.grad_color = lmeter.body.main_color; lmeter.body.padding.hor = LV_DPI / 8; - theme.lmeter = &lmeter; + theme.style.lmeter = &lmeter; #endif } @@ -288,7 +288,7 @@ static void gauge_init(void) gauge.body.padding.hor = LV_DPI / 16; gauge.body.border.color = LV_COLOR_HEX3(0x666); /*Needle middle color*/ - theme.gauge = &gauge; + theme.style.gauge = &gauge; #endif } @@ -305,7 +305,7 @@ static void arc_init(void) /*For preloader*/ arc.body.border.width = 0; - theme.arc = &arc; + theme.style.arc = &arc; #endif } @@ -313,14 +313,14 @@ static void preload_init(void) { #if USE_LV_PRELOAD != 0 - theme.preload = theme.arc; + theme.style.preload = theme.style.arc; #endif } static void chart_init(void) { #if USE_LV_CHART - theme.chart = theme.panel; + theme.style.chart = theme.style.panel; #endif } @@ -338,16 +338,16 @@ static void calendar_init(void) static lv_style_t today_box; lv_style_copy(&today_box, &def); today_box.body.empty = 1; - today_box.body.border.color = theme.panel->body.border.color; + today_box.body.border.color = theme.style.panel->body.border.color; today_box.body.padding.ver = LV_DPI / 20; today_box.body.radius = LV_RADIUS_CIRCLE; - theme.calendar.bg = theme.panel; - theme.calendar.header = &lv_style_transp; - theme.calendar.inactive_days = &ina_days; - theme.calendar.highlighted_days = &high_days; - theme.calendar.week_box = &lv_style_transp_fit; - theme.calendar.today_box = &today_box; + theme.style.calendar.bg = theme.style.panel; + theme.style.calendar.header = &lv_style_transp; + theme.style.calendar.inactive_days = &ina_days; + theme.style.calendar.highlighted_days = &high_days; + theme.style.calendar.week_box = &lv_style_transp_fit; + theme.style.calendar.today_box = &today_box; #endif } @@ -384,12 +384,12 @@ static void cb_init(void) ina.body.border.color = LV_COLOR_HEX3(0xaaa); - theme.cb.bg = &lv_style_transp; - theme.cb.box.rel = &rel; - theme.cb.box.pr = ≺ - theme.cb.box.tgl_rel = &tgl_rel; - theme.cb.box.tgl_pr = &tgl_pr; - theme.cb.box.ina = &ina; + theme.style.cb.bg = &lv_style_transp; + theme.style.cb.box.rel = &rel; + theme.style.cb.box.pr = ≺ + theme.style.cb.box.tgl_rel = &tgl_rel; + theme.style.cb.box.tgl_pr = &tgl_pr; + theme.style.cb.box.ina = &ina; #endif } @@ -434,12 +434,12 @@ static void btnm_init(void) ina.body.grad_color = tgl_pr.body.main_color; ina.text.color = LV_COLOR_HEX3(0x888);; - theme.btnm.bg = &bg; - theme.btnm.btn.rel = &rel; - theme.btnm.btn.pr = ≺ - theme.btnm.btn.tgl_rel = &tgl_rel; - theme.btnm.btn.tgl_pr = &tgl_pr; - theme.btnm.btn.ina = &ina; + theme.style.btnm.bg = &bg; + theme.style.btnm.btn.rel = &rel; + theme.style.btnm.btn.pr = ≺ + theme.style.btnm.btn.tgl_rel = &tgl_rel; + theme.style.btnm.btn.tgl_pr = &tgl_pr; + theme.style.btnm.btn.ina = &ina; #endif } @@ -489,12 +489,12 @@ static void kb_init(void) ina.body.grad_color = ina.body.main_color; ina.text.color = LV_COLOR_HEX3(0xbbb); - theme.kb.bg = &bg; - theme.kb.btn.rel = &rel; - theme.kb.btn.pr = ≺ - theme.kb.btn.tgl_rel = &tgl_rel; - theme.kb.btn.tgl_pr = &tgl_pr; - theme.kb.btn.ina = &ina; + theme.style.kb.bg = &bg; + theme.style.kb.btn.rel = &rel; + theme.style.kb.btn.pr = ≺ + theme.style.kb.btn.tgl_rel = &tgl_rel; + theme.style.kb.btn.tgl_pr = &tgl_pr; + theme.style.kb.btn.ina = &ina; #endif } @@ -503,7 +503,7 @@ static void mbox_init(void) { #if USE_LV_MBOX static lv_style_t bg, rel, pr; - lv_style_copy(&bg, theme.panel); + lv_style_copy(&bg, theme.style.panel); bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 95); bg.body.grad_color = bg.body.main_color; bg.text.color = lv_color_hsv_to_rgb(_hue, 40, 25); @@ -525,10 +525,10 @@ static void mbox_init(void) pr.body.grad_color = pr.body.main_color; - theme.mbox.bg = &bg; - theme.mbox.btn.bg = &lv_style_transp; - theme.mbox.btn.rel = &rel; - theme.mbox.btn.pr = ≺ + theme.style.mbox.bg = &bg; + theme.style.mbox.btn.bg = &lv_style_transp; + theme.style.mbox.btn.rel = &rel; + theme.style.mbox.btn.pr = ≺ #endif } @@ -537,9 +537,9 @@ static void page_init(void) #if USE_LV_PAGE - theme.page.bg = theme.panel; - theme.page.scrl = &lv_style_transp; - theme.page.sb = &sb; + theme.style.page.bg = theme.style.panel; + theme.style.page.scrl = &lv_style_transp; + theme.style.page.sb = &sb; #endif } @@ -547,25 +547,25 @@ static void ta_init(void) { #if USE_LV_TA static lv_style_t oneline; - lv_style_copy(&oneline, theme.panel); + lv_style_copy(&oneline, theme.style.panel); oneline.body.radius = LV_RADIUS_CIRCLE; oneline.body.padding.ver = LV_DPI / 10; oneline.body.shadow.width = 0; - theme.ta.area = theme.panel; - theme.ta.oneline = &oneline; - theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/ - theme.ta.sb = &def; + theme.style.ta.area = theme.style.panel; + theme.style.ta.oneline = &oneline; + theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/ + theme.style.ta.sb = &def; #endif } static void spinbox_init(void) { #if USE_LV_SPINBOX - theme.spinbox.bg= theme.panel; - theme.spinbox.cursor = theme.ta.cursor; - theme.spinbox.sb = theme.ta.sb; + theme.style.spinbox.bg= theme.style.panel; + theme.style.spinbox.cursor = theme.style.ta.cursor; + theme.style.spinbox.sb = theme.style.ta.sb; #endif } @@ -574,7 +574,7 @@ static void list_init(void) #if USE_LV_LIST != 0 static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina; - lv_style_copy(&bg, theme.panel); + lv_style_copy(&bg, theme.style.panel); bg.body.padding.hor = 0; bg.body.padding.ver = 0; @@ -586,25 +586,25 @@ static void list_init(void) rel.text.color = LV_COLOR_HEX3(0x666); lv_style_copy(&pr, &rel); - pr.text.color = theme.btn.pr->text.color; + pr.text.color = theme.style.btn.pr->text.color; lv_style_copy(&tgl_rel, &rel); tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 50, 90); lv_style_copy(&tgl_pr, &rel); - tgl_pr.text.color = theme.btn.tgl_pr->text.color; + tgl_pr.text.color = theme.style.btn.tgl_pr->text.color; lv_style_copy(&ina, &rel); - ina.text.color = theme.btn.ina->text.color; + ina.text.color = theme.style.btn.ina->text.color; - theme.list.sb = &sb; - theme.list.bg = &bg; - theme.list.scrl = &lv_style_transp_tight; - theme.list.btn.rel = &rel; - theme.list.btn.pr = ≺ - theme.list.btn.tgl_rel = &tgl_rel; - theme.list.btn.tgl_pr = &tgl_pr; - theme.list.btn.ina = &ina; + theme.style.list.sb = &sb; + theme.style.list.bg = &bg; + theme.style.list.scrl = &lv_style_transp_tight; + theme.style.list.btn.rel = &rel; + theme.style.list.btn.pr = ≺ + theme.style.list.btn.tgl_rel = &tgl_rel; + theme.style.list.btn.tgl_pr = &tgl_pr; + theme.style.list.btn.ina = &ina; #endif } @@ -612,7 +612,7 @@ static void ddlist_init(void) { #if USE_LV_DDLIST != 0 static lv_style_t bg, sel; - lv_style_copy(&bg, theme.panel); + lv_style_copy(&bg, theme.style.panel); bg.text.line_space = LV_DPI / 8; bg.body.padding.hor = LV_DPI / 6; bg.body.padding.ver = LV_DPI / 8; @@ -623,9 +623,9 @@ static void ddlist_init(void) sel.body.border.width = 0; sel.text.color = lv_color_hsv_to_rgb(_hue, 50, 80); - theme.ddlist.bg = &bg; - theme.ddlist.sel = &sel; - theme.ddlist.sb = &def; + theme.style.ddlist.bg = &bg; + theme.style.ddlist.sel = &sel; + theme.style.ddlist.sb = &def; #endif } @@ -639,12 +639,12 @@ static void roller_init(void) bg.text.line_space = LV_DPI / 6; bg.text.color = LV_COLOR_HEX3(0x999); - lv_style_copy(&sel, theme.panel); + lv_style_copy(&sel, theme.style.panel); sel.body.radius = LV_RADIUS_CIRCLE; sel.body.empty = 1; - theme.roller.bg = &bg; - theme.roller.sel = &sel; + theme.style.roller.bg = &bg; + theme.style.roller.sel = &sel; #endif } @@ -681,22 +681,22 @@ static void tabview_init(void) lv_style_copy(&tgl_pr, &rel); tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 50, 70); - theme.tabview.bg = theme.bg; - theme.tabview.indic = &indic; - theme.tabview.btn.bg = &btn_bg; - theme.tabview.btn.rel = &rel; - theme.tabview.btn.pr = ≺ - theme.tabview.btn.tgl_rel = &tgl_rel; - theme.tabview.btn.tgl_pr = &tgl_pr; + theme.style.tabview.bg = theme.style.bg; + theme.style.tabview.indic = &indic; + theme.style.tabview.btn.bg = &btn_bg; + theme.style.tabview.btn.rel = &rel; + theme.style.tabview.btn.pr = ≺ + theme.style.tabview.btn.tgl_rel = &tgl_rel; + theme.style.tabview.btn.tgl_pr = &tgl_pr; #endif } static void tileview_init(void) { #if USE_LV_TILEVIEW != 0 - theme.tileview.bg = &lv_style_transp_tight; - theme.tileview.scrl = &lv_style_transp_tight; - theme.tileview.sb = theme.page.sb; + theme.style.tileview.bg = &lv_style_transp_tight; + theme.style.tileview.scrl = &lv_style_transp_tight; + theme.style.tileview.sb = theme.style.page.sb; #endif } @@ -704,15 +704,15 @@ static void table_init(void) { #if USE_LV_TABLE != 0 static lv_style_t cell; - lv_style_copy(&cell, theme.panel); + lv_style_copy(&cell, theme.style.panel); cell.body.radius = 0; cell.body.border.width = 1; cell.body.shadow.width = 0; cell.body.padding.hor = LV_DPI / 12; cell.body.padding.ver = LV_DPI / 12; - theme.table.bg = &lv_style_transp_tight; - theme.table.cell = &cell; + theme.style.table.bg = &lv_style_transp_tight; + theme.style.table.cell = &cell; #endif } @@ -736,13 +736,13 @@ static void win_init(void) lv_style_copy(&pr, &rel); pr.text.color = LV_COLOR_HEX3(0x333); - theme.win.bg = theme.panel; - theme.win.sb = &sb; - theme.win.header = &header; - theme.win.content.bg = &lv_style_transp; - theme.win.content.scrl = &lv_style_transp; - theme.win.btn.rel = &rel; - theme.win.btn.pr = ≺ + theme.style.win.bg = theme.style.panel; + theme.style.win.sb = &sb; + theme.style.win.header = &header; + theme.style.win.content.bg = &lv_style_transp; + theme.style.win.content.scrl = &lv_style_transp; + theme.style.win.btn.rel = &rel; + theme.style.win.btn.pr = ≺ #endif } From 728cd172752a5b123353e1c0cdc5c6b455b3b04a Mon Sep 17 00:00:00 2001 From: manison Date: Tue, 12 Feb 2019 09:04:24 +0100 Subject: [PATCH 11/33] determine required size of the th_styles array at compile time and remove runtime assertion https://github.com/littlevgl/lvgl/issues/806 --- lv_themes/lv_theme.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index 2090529f6..bbdca6e4c 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -34,10 +34,8 @@ static lv_theme_t * current_theme; * This way the theme styles will always point to the same memory address even after theme is change. * (The pointers in the theme points to the styles declared by the theme itself) */ -/* Store the styles in this array. - * Can't determine the size in compile time because sizeof is not evaluated (should be `sizeof(lv_theme_t) / sizeof(lv_style_t*)`). - * Error will be generated in run time if too small.*/ -static lv_style_t th_styles[120]; +/* Store the styles in this array. */ +static lv_style_t th_styles[sizeof(((lv_theme_t *)0)->style) / sizeof(lv_style_t *)]; static bool inited = false; static lv_theme_t current_theme; #endif @@ -63,12 +61,6 @@ void lv_theme_set_current(lv_theme_t * th) uint32_t style_num = sizeof(th->style) / sizeof(lv_style_t *); /*Number of styles in a theme*/ if(!inited) { - /*It's not sure `th_styles` is big enough. Check it now!*/ - if(style_num > sizeof(th_styles) / sizeof(lv_style_t)) { - LV_LOG_ERROR("Themes: th_styles array is too small. Increase it's size!"); - while(1); - } - /*Initialize the style pointers `current_theme` to point to the `th_styles` style array */ uint16_t i; lv_style_t ** cur_th_style_p = (lv_style_t **) ¤t_theme.style; From 44c239780479017179e16371a97fab84ceb5b2b2 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 12 Feb 2019 07:01:04 -0500 Subject: [PATCH 12/33] Add LV_INDEV_DRAG_THROW checker to lv_conf_templ.h --- lv_conf_templ.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lv_conf_templ.h b/lv_conf_templ.h index f946864b2..a4712fea6 100644 --- a/lv_conf_templ.h +++ b/lv_conf_templ.h @@ -382,6 +382,13 @@ /************************* * Non-user section *************************/ + +#if LV_INDEV_DRAG_THROW <= 0 +#warning "LV_INDEV_DRAG_THROW must be greater than 0" +#undef LV_INDEV_DRAG_THROW +#define LV_INDEV_DRAG_THROW 1 +#endif + #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ # define _CRT_SECURE_NO_WARNINGS #endif From 9ac933fb9e59acf90e73581d008955f466fbf800 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 12 Feb 2019 07:04:34 -0500 Subject: [PATCH 13/33] Fix image source not being copied in lv_imgbtn --- lv_objx/lv_imgbtn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_objx/lv_imgbtn.c b/lv_objx/lv_imgbtn.c index 75e545343..abae278f3 100644 --- a/lv_objx/lv_imgbtn.c +++ b/lv_objx/lv_imgbtn.c @@ -82,7 +82,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) /*Copy an existing image button*/ else { #if LV_IMGBTN_TILED == 0 - memset(ext->img_src, 0, sizeof(ext->img_src)); + memcpy(ext->img_src, copy_ext->img_src, sizeof(ext->img_src)); #else lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy); From c94fb96bb257dfdd38ab86660b3398b599613e62 Mon Sep 17 00:00:00 2001 From: manison Date: Tue, 12 Feb 2019 15:02:43 +0100 Subject: [PATCH 14/33] fix theme initialization --- lv_themes/lv_theme.c | 2 +- lv_themes/lv_theme.h | 3 +++ lv_themes/lv_theme_alien.c | 4 ++-- lv_themes/lv_theme_default.c | 4 ++-- lv_themes/lv_theme_material.c | 4 ++-- lv_themes/lv_theme_mono.c | 4 ++-- lv_themes/lv_theme_nemo.c | 4 ++-- lv_themes/lv_theme_night.c | 4 ++-- lv_themes/lv_theme_templ.c | 4 ++-- lv_themes/lv_theme_zen.c | 4 ++-- 10 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index bbdca6e4c..4b76c8b78 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -35,7 +35,7 @@ static lv_theme_t * current_theme; * (The pointers in the theme points to the styles declared by the theme itself) */ /* Store the styles in this array. */ -static lv_style_t th_styles[sizeof(((lv_theme_t *)0)->style) / sizeof(lv_style_t *)]; +static lv_style_t th_styles[LV_THEME_STYLE_COUNT]; static bool inited = false; static lv_theme_t current_theme; #endif diff --git a/lv_themes/lv_theme.h b/lv_themes/lv_theme.h index cdb0771f8..24db3d5e6 100644 --- a/lv_themes/lv_theme.h +++ b/lv_themes/lv_theme.h @@ -314,6 +314,9 @@ lv_theme_t * lv_theme_get_current(void); * MACROS **********************/ +/* Returns number of styles within the `lv_theme_t` structure. */ +#define LV_THEME_STYLE_COUNT (sizeof(((lv_theme_t *)0)->style) / sizeof(lv_style_t *)) + /********************** * POST INCLUDE *********************/ diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index 8b5f469a9..c3dc48dac 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -817,8 +817,8 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font) /*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++) { + lv_style_t ** style_p = (lv_style_t **) &theme.style; + for(i = 0; i < LV_THEME_STYLE_COUNT; i++) { *style_p = &def; style_p++; } diff --git a/lv_themes/lv_theme_default.c b/lv_themes/lv_theme_default.c index 9a972571a..f16e47a9d 100644 --- a/lv_themes/lv_theme_default.c +++ b/lv_themes/lv_theme_default.c @@ -376,8 +376,8 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font) /*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++) { + lv_style_t ** style_p = (lv_style_t **) &theme.style; + for(i = 0; i < LV_THEME_STYLE_COUNT; i++) { *style_p = &def; style_p++; } diff --git a/lv_themes/lv_theme_material.c b/lv_themes/lv_theme_material.c index 6cfe50104..e5d5d5d42 100644 --- a/lv_themes/lv_theme_material.c +++ b/lv_themes/lv_theme_material.c @@ -801,8 +801,8 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font) /*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++) { + lv_style_t ** style_p = (lv_style_t **) &theme.style; + for(i = 0; i < LV_THEME_STYLE_COUNT; i++) { *style_p = &def; style_p++; } diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index 44c02754f..babfc4998 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -435,8 +435,8 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font) /*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++) { + lv_style_t ** style_p = (lv_style_t **) &theme.style; + for(i = 0; i < LV_THEME_STYLE_COUNT; i++) { *style_p = &def; style_p++; } diff --git a/lv_themes/lv_theme_nemo.c b/lv_themes/lv_theme_nemo.c index 339682ad2..c10fc303f 100644 --- a/lv_themes/lv_theme_nemo.c +++ b/lv_themes/lv_theme_nemo.c @@ -800,8 +800,8 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font) /*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++) { + lv_style_t ** style_p = (lv_style_t **) &theme.style; + for(i = 0; i < LV_THEME_STYLE_COUNT; i++) { *style_p = &def; style_p++; } diff --git a/lv_themes/lv_theme_night.c b/lv_themes/lv_theme_night.c index 4f86bd032..c65efba97 100644 --- a/lv_themes/lv_theme_night.c +++ b/lv_themes/lv_theme_night.c @@ -710,8 +710,8 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font) /*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++) { + lv_style_t ** style_p = (lv_style_t **) &theme.style; + for(i = 0; i < LV_THEME_STYLE_COUNT; i++) { *style_p = &def; style_p++; } diff --git a/lv_themes/lv_theme_templ.c b/lv_themes/lv_theme_templ.c index eb2e0747c..906ec52a2 100644 --- a/lv_themes/lv_theme_templ.c +++ b/lv_themes/lv_theme_templ.c @@ -385,8 +385,8 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font) /*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++) { + lv_style_t ** style_p = (lv_style_t **) &theme.style; + for(i = 0; i < LV_THEME_STYLE_COUNT; i++) { *style_p = &def; style_p++; } diff --git a/lv_themes/lv_theme_zen.c b/lv_themes/lv_theme_zen.c index f04be7bcc..3f3f29923 100644 --- a/lv_themes/lv_theme_zen.c +++ b/lv_themes/lv_theme_zen.c @@ -767,8 +767,8 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font) /*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++) { + lv_style_t ** style_p = (lv_style_t **) &theme.style; + for(i = 0; i < LV_THEME_STYLE_COUNT; i++) { *style_p = &def; style_p++; } From 327d7c84caea08a3b2a15e5657104c3058fd974e Mon Sep 17 00:00:00 2001 From: manison Date: Tue, 12 Feb 2019 16:35:17 +0100 Subject: [PATCH 15/33] added style modification callbacks to lv_theme_t struct https://github.com/littlevgl/lvgl/issues/806 --- lv_core/lv_group.c | 23 +++++++++++++++++++++-- lv_core/lv_group.h | 6 ++++++ lv_themes/lv_theme.c | 3 +++ lv_themes/lv_theme.h | 7 +++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index 46b71d15f..f5c585ade 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -8,6 +8,7 @@ *********************/ #include "lv_group.h" #if USE_LV_GROUP != 0 +#include "../lv_themes/lv_theme.h" #include /********************* @@ -48,14 +49,15 @@ lv_group_t * lv_group_create(void) if(group == NULL) return NULL; lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *)); - group->style_mod = style_mod_def; - group->style_mod_edit = style_mod_edit_def; group->obj_focus = NULL; group->frozen = 0; group->focus_cb = NULL; group->click_focus = 1; group->editing = 0; + /*Initialize style modification callbacks from current theme*/ + lv_group_report_style_mod(group); + return group; } @@ -522,4 +524,21 @@ static void style_mod_edit_def(lv_style_t * style) } +/** + * Notify the group that current theme changed and style modification callbacks need to be refreshed. + * @param group pointer to group + */ +void lv_group_report_style_mod(lv_group_t * group) +{ + group->style_mod = style_mod_def; + group->style_mod_edit = style_mod_edit_def; + lv_theme_t * th = lv_theme_get_current(); + if(th) { + if (th->group.style_mod) + group->style_mod = th->group.style_mod; + if (th->group.style_mod_edit) + group->style_mod_edit = th->group.style_mod_edit; + } +} + #endif /*USE_LV_GROUP != 0*/ diff --git a/lv_core/lv_group.h b/lv_core/lv_group.h index 133d5954e..38fcfe009 100644 --- a/lv_core/lv_group.h +++ b/lv_core/lv_group.h @@ -236,6 +236,12 @@ bool lv_group_get_click_focus(const lv_group_t * group); */ bool lv_group_get_wrap(lv_group_t * group); +/** + * Notify the group that current theme changed and style modification callbacks need to be refreshed. + * @param group pointer to group + */ +void lv_group_report_style_mod(lv_group_t * group); + /********************** * MACROS **********************/ diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index 4b76c8b78..1b192af62 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -80,6 +80,9 @@ void lv_theme_set_current(lv_theme_t * th) if(s) memcpy(&th_styles[i], (void *)s, sizeof(lv_style_t)); } + /*Copy group style modification callback functions*/ + current_theme.group = th->group; + /*Let the object know their style might change*/ lv_obj_report_style_mod(NULL); #endif diff --git a/lv_themes/lv_theme.h b/lv_themes/lv_theme.h index 24db3d5e6..8d681feae 100644 --- a/lv_themes/lv_theme.h +++ b/lv_themes/lv_theme.h @@ -20,6 +20,7 @@ extern "C" { #endif #include "../lv_core/lv_style.h" +#include "../lv_core/lv_group.h" /********************* * DEFINES @@ -291,6 +292,12 @@ typedef struct { } win; #endif } style; + + struct + { + lv_group_style_mod_func_t style_mod; + lv_group_style_mod_func_t style_mod_edit; + } group; } lv_theme_t; /********************** From fabd551e2ad3171383ecfdae740900da3c588e1b Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 12 Feb 2019 11:03:34 -0500 Subject: [PATCH 16/33] Fix error reported by @canardos in lv_imgbtn --- lv_objx/lv_imgbtn.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lv_objx/lv_imgbtn.c b/lv_objx/lv_imgbtn.c index abae278f3..3f97d5d67 100644 --- a/lv_objx/lv_imgbtn.c +++ b/lv_objx/lv_imgbtn.c @@ -81,11 +81,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) } /*Copy an existing image button*/ else { + lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy); #if LV_IMGBTN_TILED == 0 memcpy(ext->img_src, copy_ext->img_src, sizeof(ext->img_src)); #else - lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy); - memcpy(ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left)); memcpy(ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid)); memcpy(ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right)); From f5b8dd17b81eebae6fdd53dd581e2f5075c7e08f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 12 Feb 2019 22:48:39 +0100 Subject: [PATCH 17/33] lv_list_set_selected_btn fix --- lv_objx/lv_list.c | 5 +++-- lv_objx/lv_list.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index 8accb665a..48763d663 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -300,6 +300,7 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn) } ext->selected_btn = btn; + ext->last_sel = btn; if(ext->selected_btn) { lv_btn_state_t s = lv_btn_get_state(ext->selected_btn); @@ -760,7 +761,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) lv_group_t * g = lv_obj_get_group(list); if(lv_group_get_editing(g)) { lv_list_ext_t * ext = lv_obj_get_ext_attr(list); - if(NULL != ext->last_sel) { + if(ext->last_sel) { /* Select the last used button */ lv_list_set_btn_selected(list, ext->last_sel); } @@ -779,7 +780,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) lv_list_set_btn_selected(list, last_clicked_btn); } else { lv_list_ext_t * ext = lv_obj_get_ext_attr(list); - if(NULL != ext->last_sel) { + if(ext->last_sel) { /* Select the last used button */ lv_list_set_btn_selected(list, ext->last_sel); } diff --git a/lv_objx/lv_list.h b/lv_objx/lv_list.h index 0fe0c1291..a31877082 100644 --- a/lv_objx/lv_list.h +++ b/lv_objx/lv_list.h @@ -59,8 +59,8 @@ typedef struct uint32_t size; /*the number of items(buttons) in the list*/ bool single_mode; /* whether single selected mode is enabled */ #if USE_LV_GROUP - lv_obj_t * last_sel; /* Last btn selected */ - lv_obj_t * selected_btn; + lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */ + lv_obj_t * selected_btn; /* The button is currently being selected*/ #endif } lv_list_ext_t; From 92babea8c8bf496681071491f14717b535217556 Mon Sep 17 00:00:00 2001 From: manison Date: Tue, 12 Feb 2019 16:41:26 +0100 Subject: [PATCH 18/33] fix typo in function name --- lv_core/lv_obj.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index 6924ce158..47ec93e18 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -38,9 +38,9 @@ /********************** * STATIC PROTOTYPES **********************/ -static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff); +static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff); static void report_style_mod_core(void * style_p, lv_obj_t * obj); -static void refresh_childen_style(lv_obj_t * obj); +static void refresh_children_style(lv_obj_t * obj); static void delete_children(lv_obj_t * obj); static bool lv_obj_design(lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode); static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -551,7 +551,7 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) obj->coords.x2 += diff.x; obj->coords.y2 += diff.y; - refresh_childen_position(obj, diff.x, diff.y); + refresh_children_position(obj, diff.x, diff.y); /*Inform the object about its new coordinates*/ obj->signal_func(obj, LV_SIGNAL_CORD_CHG, &ori); @@ -987,7 +987,7 @@ void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style) obj->style_p = style; /*Send a signal about style change to every children with NULL style*/ - refresh_childen_style(obj); + refresh_children_style(obj); /*Notify the object about the style change too*/ lv_obj_refresh_style(obj); @@ -1872,7 +1872,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) * @param x_diff x coordinate shift * @param y_diff y coordinate shift */ -static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff) +static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff) { lv_obj_t * i; LL_READ(obj->child_ll, i) { @@ -1881,7 +1881,7 @@ static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord i->coords.x2 += x_diff; i->coords.y2 += y_diff; - refresh_childen_position(i, x_diff, y_diff); + refresh_children_position(i, x_diff, y_diff); } } @@ -1895,7 +1895,7 @@ static void report_style_mod_core(void * style_p, lv_obj_t * obj) lv_obj_t * i; LL_READ(obj->child_ll, i) { if(i->style_p == style_p || style_p == NULL) { - refresh_childen_style(i); + refresh_children_style(i); lv_obj_refresh_style(i); } @@ -1908,16 +1908,16 @@ static void report_style_mod_core(void * style_p, lv_obj_t * obj) * because the NULL styles are inherited from the parent * @param obj pointer to an object */ -static void refresh_childen_style(lv_obj_t * obj) +static void refresh_children_style(lv_obj_t * obj) { lv_obj_t * child = lv_obj_get_child(obj, NULL); while(child != NULL) { if(child->style_p == NULL) { - refresh_childen_style(child); /*Check children too*/ + refresh_children_style(child); /*Check children too*/ lv_obj_refresh_style(child); /*Notify the child about the style change*/ } else if(child->style_p->glass) { /*Children with 'glass' parent might be effected if their style == NULL*/ - refresh_childen_style(child); + refresh_children_style(child); } child = lv_obj_get_child(obj, child); } From 533d39b4c2c3bb29e032da99a0d73ceaf6d20fc6 Mon Sep 17 00:00:00 2001 From: Muhammet Asan Date: Thu, 14 Feb 2019 13:25:34 +0100 Subject: [PATCH 19/33] 10 times faster int to string implementation --- lv_misc/lv_math.c | 64 ++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 42 deletions(-) diff --git a/lv_misc/lv_math.c b/lv_misc/lv_math.c index a0d26053e..394246916 100644 --- a/lv_misc/lv_math.c +++ b/lv_misc/lv_math.c @@ -34,7 +34,7 @@ static int16_t sin0_90_table[] = { 28377, 28659, 28932, 29196, 29451, 29697, 29934, 30162, 30381, 30591, 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165, 32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, - 32767 + 32767 }; @@ -54,53 +54,33 @@ static int16_t sin0_90_table[] = { */ char * lv_math_num_to_str(int32_t num, char * buf) { - char * buf_ori = buf; - if(num == 0) { + if (num == 0) { buf[0] = '0'; buf[1] = '\0'; return buf; - } else if(num < 0) { - (*buf) = '-'; - buf++; - num = LV_MATH_ABS(num); } - uint32_t output = 0; - int8_t i; - - for(i = 31; i >= 0; i--) { - if((output & 0xF) >= 5) - output += 3; - if(((output & 0xF0) >> 4) >= 5) - output += (3 << 4); - if(((output & 0xF00) >> 8) >= 5) - output += (3 << 8); - if(((output & 0xF000) >> 12) >= 5) - output += (3 << 12); - if(((output & 0xF0000) >> 16) >= 5) - output += (3 << 16); - if(((output & 0xF00000) >> 20) >= 5) - output += (3 << 20); - if(((output & 0xF000000) >> 24) >= 5) - output += (3 << 24); - if(((output & 0xF0000000) >> 28) >= 5) - output += (3 << 28); - output = (output << 1) | ((num >> i) & 1); + int8_t digitCount = 0; + int8_t i = 0; + if (num < 0) { + buf[digitCount++] = '-'; + num = abs(num); + ++i; } - - uint8_t digit; - bool leading_zero_ready = false; - for(i = 28; i >= 0; i -= 4) { - digit = ((output >> i) & 0xF) + '0'; - if(digit == '0' && leading_zero_ready == false) continue; - - leading_zero_ready = true; - (*buf) = digit; - buf++; + while (num) { + char digit = num % 10; + buf[digitCount++] = digit + 48; + num /= 10; } - - (*buf) = '\0'; - - return buf_ori; + buf[digitCount] = '\0'; + digitCount--; + while (digitCount > i) { + char temp = buf[i]; + buf[i] = buf[digitCount]; + buf[digitCount] = temp; + digitCount--; + i++; + } + return buf; } /** From 96adbe382762b593b3ddf83559e4850531d0d659 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 15 Feb 2019 06:27:49 +0100 Subject: [PATCH 20/33] spinbox fixes --- lv_objx/lv_spinbox.c | 227 +++++++++++++++++++------------------------ lv_objx/lv_spinbox.h | 8 +- 2 files changed, 101 insertions(+), 134 deletions(-) diff --git a/lv_objx/lv_spinbox.c b/lv_objx/lv_spinbox.c index 13e19de7a..726121e59 100644 --- a/lv_objx/lv_spinbox.c +++ b/lv_objx/lv_spinbox.c @@ -10,6 +10,7 @@ #if USE_LV_SPINBOX != 0 #include "../lv_themes/lv_theme.h" +#include "../lv_misc/lv_math.h" /********************* * DEFINES @@ -64,12 +65,12 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy) /*Initialize the allocated 'ext'*/ ext->ta.one_line = 1; ext->ta.pwd_mode = 0; - ext->ta.accapted_chars = "1234567890+-."; + ext->ta.accapted_chars = "1234567890+-. "; ext->value = 0; ext->dec_point_pos = 0; - ext->digit_count = 5; - ext->digit_padding_left = 0; + ext->digit_count = 8; + ext->digit_padding_left = 2; ext->step = 1; ext->range_max = 99999; ext->range_min = -99999; @@ -188,13 +189,11 @@ void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_m ext->range_max = range_max; ext->range_min = range_min; - if(ext->value > ext->range_max) - { + if(ext->value > ext->range_max) { ext->value = ext->range_max; lv_obj_invalidate(spinbox); } - if(ext->value < ext->range_min) - { + if(ext->value < ext->range_min) { ext->value = ext->range_min; lv_obj_invalidate(spinbox); } @@ -251,11 +250,9 @@ void lv_spinbox_step_next(lv_obj_t * spinbox) { lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); - - if((ext->step / 10) < ext->range_max && (ext->step / 10) > ext->range_min && (ext->step / 10) > 0) - { - ext->step /= 10; - } + int32_t new_step = ext->step / 10; + if((new_step) > 0) ext->step = new_step; + else ext->step = 1; lv_spinbox_updatevalue(spinbox); } @@ -268,11 +265,8 @@ void lv_spinbox_step_previous(lv_obj_t * spinbox) { lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); - - if((ext->step * 10) <= ext->range_max && (ext->step * 10) > ext->range_min && (ext->step * 10) > 0) - { - ext->step *= 10; - } + int32_t new_step = ext->step * 10; + if(new_step <= ext->range_max) ext->step = new_step; lv_spinbox_updatevalue(spinbox); } @@ -285,20 +279,16 @@ void lv_spinbox_increment(lv_obj_t * spinbox) { lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); - if(ext->value + ext->step <= ext->range_max) - { + if(ext->value + ext->step <= ext->range_max) { /*Special mode when zero crossing*/ - if((ext->value + ext->step) > 0 && ext->value < 0) - { - ext->value = -ext->value; - }/*end special mode*/ + if((ext->value + ext->step) > 0 && ext->value < 0) ext->value = -ext->value; ext->value += ext->step; - if(ext->value_changed_cb != NULL) - { - ext->value_changed_cb(spinbox, ext->value); - } + } else { + ext->value = ext->range_max; } + + if(ext->value_changed_cb != NULL) ext->value_changed_cb(spinbox, ext->value); lv_spinbox_updatevalue(spinbox); } @@ -310,20 +300,15 @@ void lv_spinbox_decrement(lv_obj_t * spinbox) { lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); - if(ext->value - ext->step >= ext->range_min) - { + if(ext->value - ext->step >= ext->range_min) { /*Special mode when zero crossing*/ - if((ext->value - ext->step) < 0 && ext->value > 0) - { - ext->value = -ext->value; - }/*end special mode*/ + if((ext->value - ext->step) < 0 && ext->value > 0) ext->value = -ext->value; ext->value -= ext->step; - - if(ext->value_changed_cb != NULL) - { - ext->value_changed_cb(spinbox, ext->value); - } + } else { + ext->value = ext->range_min; } + + if(ext->value_changed_cb != NULL) ext->value_changed_cb(spinbox, ext->value); lv_spinbox_updatevalue(spinbox); } @@ -365,137 +350,121 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p if(buf->type[i] == NULL) break; } buf->type[i] = "lv_spinbox"; - }else if(sign == LV_SIGNAL_CONTROLL) - { + } + else if(sign == LV_SIGNAL_CONTROLL) { lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ - if(c == LV_GROUP_KEY_RIGHT) - { - if(indev_type == LV_INDEV_TYPE_ENCODER) - { - lv_spinbox_increment(spinbox); - } - else - { - lv_spinbox_step_next(spinbox); - } + if(c == LV_GROUP_KEY_RIGHT) { + if(indev_type == LV_INDEV_TYPE_ENCODER) lv_spinbox_increment(spinbox); + else lv_spinbox_step_next(spinbox); } - else if(c == LV_GROUP_KEY_LEFT) - { - if(indev_type == LV_INDEV_TYPE_ENCODER) - { - lv_spinbox_decrement(spinbox); - } - else - { + else if(c == LV_GROUP_KEY_LEFT) { + if(indev_type == LV_INDEV_TYPE_ENCODER) lv_spinbox_decrement(spinbox); + else lv_spinbox_step_previous(spinbox); + } + else if(c == LV_GROUP_KEY_UP) { + lv_spinbox_increment(spinbox); + } + else if(c == LV_GROUP_KEY_DOWN) { + lv_spinbox_decrement(spinbox); + } + else if(c == LV_GROUP_KEY_ENTER) { + + if(ext->step > 1) { + lv_spinbox_step_next(spinbox); + } else { + /*Restart from the MSB*/ + ext->step = 1; + uint32_t i; + for(i = 0; i < ext->digit_count; i++) { + int32_t new_step = ext->step * 10; + if(new_step >= ext->range_max) break; + ext->step = new_step; + } lv_spinbox_step_previous(spinbox); } } - else if(c == LV_GROUP_KEY_UP) - { - lv_spinbox_increment(spinbox); - } - else if(c == LV_GROUP_KEY_DOWN) - { - lv_spinbox_decrement(spinbox); - } - else - { - if(c == LV_GROUP_KEY_ENTER) - { - int p = lv_ta_get_cursor_pos(spinbox); - if(p == (1 + ext->digit_padding_left + ext->digit_count)) - { - for(int i = 0; i < ext->digit_count; i++) - lv_spinbox_step_previous(spinbox); - } else - { - lv_spinbox_step_next(spinbox); - } - - - lv_spinbox_updatevalue(spinbox); - } - else - { - lv_ta_add_char(spinbox, c); - } + else { + lv_ta_add_char(spinbox, c); } } - return res; } static void lv_spinbox_updatevalue(lv_obj_t * spinbox) { lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); - int32_t v = ext->value; - int32_t intDigits, decDigits; - uint8_t dc = ext->digit_count; - intDigits = (ext->dec_point_pos==0) ? ext->digit_count : ext->dec_point_pos; - decDigits = ext->digit_count - intDigits; + char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8]; + memset(buf, 0, sizeof(buf)); + char * buf_p = buf; - ext->digits[0] = v>=0 ? '+' : '-'; + /*Add the sign*/ + (*buf_p) = ext->value >= 0 ? '+' : '-'; + buf_p++; - int pl; /*padding left*/ - for(pl = 0; pl < ext->digit_padding_left; pl++) - { - ext->digits[1 + pl] = ' '; + int i; + /*padding left*/ + for(i = 0; i < ext->digit_padding_left; i++) { + (*buf_p) = ' '; + buf_p++; } - int i = 0; - uint8_t digits[16]; + char digits[64]; + /*Convert the numbers to string (the sign is already handled so always covert positive number)*/ + lv_math_num_to_str(ext->value < 0 ? -ext->value : ext->value, digits); - if(v < 0) v = -v; - - for(i = 0; i < dc; i++) - { - digits[i] = v%10; - v = v/10; + /*Add leading zeros*/ + int lz_cnt = ext->digit_count - (int)strlen(digits); + if(lz_cnt > 0) { + for(i = strlen(digits); i >= 0; i--) { + digits[i + lz_cnt] = digits[i]; + } + for(i = 0; i < lz_cnt; i++) { + digits[i] = '0'; + } } - int k; - for(k = 0; k < intDigits; k++) - { - ext->digits[1 + pl + k] = '0' + digits[--i]; + int32_t intDigits; + intDigits = (ext->dec_point_pos == 0) ? ext->digit_count : ext->dec_point_pos; + + /*Add the decimal part*/ + for(i = 0; i < intDigits && digits[i] != '\0'; i++) { + (*buf_p) = digits[i]; + buf_p++; } if(ext->dec_point_pos != 0) { - ext->digits[1 + pl + intDigits] = '.'; + /*Insert the decimal point*/ + (*buf_p) = '.'; + buf_p++; - int d; - - for(d = 0; d < decDigits; d++) - { - ext->digits[1 + pl + intDigits + 1 + d] = '0' + digits[--i]; + for(/*Leave i*/ ;i < ext->digit_count && digits[i] != '\0'; i++) { + (*buf_p) = digits[i]; + buf_p++; } - - ext->digits[1 + pl + intDigits + 1 + decDigits] = '\0'; - } else { - ext->digits[1 + pl + intDigits] = '\0'; - } + /*Refresh the text*/ + lv_ta_set_text(spinbox, (char*)buf); - lv_ta_set_text(spinbox, (char*)ext->digits); + /*Set the cursor position*/ int32_t step = ext->step; - uint8_t cPos = ext->digit_count + pl; + uint8_t cur_pos = ext->digit_count; while(step >= 10) { step /= 10; - cPos--; + cur_pos--; } - if(cPos > pl + intDigits ) - { - cPos ++; - } + if(cur_pos > intDigits ) cur_pos ++; /*Skip teh decimal point*/ - lv_ta_set_cursor_pos(spinbox, cPos); + cur_pos += ext->digit_padding_left; + + lv_ta_set_cursor_pos(spinbox, cur_pos); } #endif diff --git a/lv_objx/lv_spinbox.h b/lv_objx/lv_spinbox.h index c2956d055..ca5761487 100644 --- a/lv_objx/lv_spinbox.h +++ b/lv_objx/lv_spinbox.h @@ -50,11 +50,9 @@ typedef struct { int32_t range_max; int32_t range_min; int32_t step; - uint8_t digit_count:4; - uint8_t dec_point_pos:4; /*if 0, there is no separator and the number is an integer*/ - uint8_t digit_padding_left:4; - uint8_t digit_padding_right:4; - uint8_t digits[1+1+LV_SPINBOX_MAX_DIGIT_COUNT]; /*1 sign, 1 point, 16 num digits*/ + uint16_t digit_count:4; + uint16_t dec_point_pos:4; /*if 0, there is no separator and the number is an integer*/ + uint16_t digit_padding_left:4; lv_spinbox_value_changed_cb_t value_changed_cb; } lv_spinbox_ext_t; From e3bbe0a4fd8d5f9f84a875d54fd35f7236156ade Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 15 Feb 2019 06:34:19 +0100 Subject: [PATCH 21/33] spinbox fixes --- lv_misc/lv_math.h | 6 +++--- lv_objx/lv_spinbox.c | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lv_misc/lv_math.h b/lv_misc/lv_math.h index 1f2e402d8..a0229eb1b 100644 --- a/lv_misc/lv_math.h +++ b/lv_misc/lv_math.h @@ -19,9 +19,9 @@ extern "C" { /********************* * DEFINES *********************/ -#define LV_MATH_MIN(a,b) (ab?a:b) -#define LV_MATH_ABS(x) ((x)>0?(x):(-(x))) +#define LV_MATH_MIN(a,b) ((a) < (b) ? (a) : (b)) +#define LV_MATH_MAX(a,b) ((a) > (b) ? (a) : (b)) +#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) #define LV_TRIGO_SIN_MAX 32767 #define LV_TRIGO_SHIFT 15 /* >> LV_TRIGO_SHIFT to normalize*/ diff --git a/lv_objx/lv_spinbox.c b/lv_objx/lv_spinbox.c index 726121e59..70fac33ce 100644 --- a/lv_objx/lv_spinbox.c +++ b/lv_objx/lv_spinbox.c @@ -69,8 +69,8 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy) ext->value = 0; ext->dec_point_pos = 0; - ext->digit_count = 8; - ext->digit_padding_left = 2; + ext->digit_count = 5; + ext->digit_padding_left = 0; ext->step = 1; ext->range_max = 99999; ext->range_min = -99999; @@ -264,9 +264,10 @@ void lv_spinbox_step_next(lv_obj_t * spinbox) void lv_spinbox_step_previous(lv_obj_t * spinbox) { lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); - + int32_t step_limit; + step_limit = LV_MATH_MAX(ext->range_max, (ext->range_min < 0 ? (-ext->range_min) : ext->range_min)); int32_t new_step = ext->step * 10; - if(new_step <= ext->range_max) ext->step = new_step; + if(new_step <= step_limit) ext->step = new_step; lv_spinbox_updatevalue(spinbox); } From 8ec60fbe3ed2deb0fdef49cb278aba01ef3c2f67 Mon Sep 17 00:00:00 2001 From: manison Date: Fri, 15 Feb 2019 08:46:12 +0100 Subject: [PATCH 22/33] add groups to the linked list https://github.com/littlevgl/lvgl/issues/806 --- lv_core/lv_group.c | 54 ++++++++++++++++++++++++++++++++------------ lv_core/lv_group.h | 8 ++++++- lv_core/lv_obj.c | 4 ++++ lv_misc/lv_gc.h | 1 + lv_themes/lv_theme.c | 5 ++++ 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index f5c585ade..83c22ca76 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -10,6 +10,7 @@ #if USE_LV_GROUP != 0 #include "../lv_themes/lv_theme.h" #include +#include "../lv_misc/lv_gc.h" /********************* * DEFINES @@ -24,7 +25,8 @@ **********************/ static void style_mod_def(lv_style_t * style); static void style_mod_edit_def(lv_style_t * style); -static void lv_group_refocus(lv_group_t *g); +static void refresh_theme(lv_group_t * g, lv_theme_t * th); +static void lv_group_refocus(lv_group_t * g); /********************** * STATIC VARIABLES @@ -38,13 +40,21 @@ static void lv_group_refocus(lv_group_t *g); * GLOBAL FUNCTIONS **********************/ +/** + * Init. the group module + */ +void lv_group_init(void) +{ + lv_ll_init(&LV_GC_ROOT(_lv_group_ll), sizeof(lv_group_t)); +} + /** * Create a new object group * @return pointer to the new object group */ lv_group_t * lv_group_create(void) { - lv_group_t * group = lv_mem_alloc(sizeof(lv_group_t)); + lv_group_t * group = lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll)); lv_mem_assert(group); if(group == NULL) return NULL; lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *)); @@ -56,7 +66,7 @@ lv_group_t * lv_group_create(void) group->editing = 0; /*Initialize style modification callbacks from current theme*/ - lv_group_report_style_mod(group); + refresh_theme(group, lv_theme_get_current()); return group; } @@ -462,6 +472,25 @@ bool lv_group_get_wrap(lv_group_t * group) return group->wrap ? true : false; } +/** + * Notify the group that current theme changed and style modification callbacks need to be refreshed. + * @param group pointer to group. If NULL then all groups are notified. + */ +void lv_group_report_style_mod(lv_group_t * group) +{ + lv_theme_t * th = lv_theme_get_current(); + + if(group != NULL) { + refresh_theme(group, th); + return; + } + + lv_group_t * i; + LL_READ(LV_GC_ROOT(_lv_group_ll), i) { + refresh_theme(i, th); + } +} + /********************** * STATIC FUNCTIONS **********************/ @@ -524,20 +553,15 @@ static void style_mod_edit_def(lv_style_t * style) } -/** - * Notify the group that current theme changed and style modification callbacks need to be refreshed. - * @param group pointer to group - */ -void lv_group_report_style_mod(lv_group_t * group) +static void refresh_theme(lv_group_t * g, lv_theme_t * th) { - group->style_mod = style_mod_def; - group->style_mod_edit = style_mod_edit_def; - lv_theme_t * th = lv_theme_get_current(); + g->style_mod = style_mod_def; + g->style_mod_edit = style_mod_edit_def; if(th) { - if (th->group.style_mod) - group->style_mod = th->group.style_mod; - if (th->group.style_mod_edit) - group->style_mod_edit = th->group.style_mod_edit; + if(th->group.style_mod) + g->style_mod = th->group.style_mod; + if(th->group.style_mod_edit) + g->style_mod_edit = th->group.style_mod_edit; } } diff --git a/lv_core/lv_group.h b/lv_core/lv_group.h index 38fcfe009..7b3a6d482 100644 --- a/lv_core/lv_group.h +++ b/lv_core/lv_group.h @@ -72,6 +72,12 @@ typedef enum _lv_group_refocus_policy_t { * GLOBAL PROTOTYPES **********************/ +/** +* Init. the group module +* @remarks Internal function, do not call directly. +*/ +void lv_group_init(void); + /** * Create a new object group * @return pointer to the new object group @@ -238,7 +244,7 @@ bool lv_group_get_wrap(lv_group_t * group); /** * Notify the group that current theme changed and style modification callbacks need to be refreshed. - * @param group pointer to group + * @param group pointer to group. If NULL then all groups are notified. */ void lv_group_report_style_mod(lv_group_t * group); diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index f379e1635..41049bdfd 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -91,6 +91,10 @@ void lv_init(void) lv_anim_init(); #endif +#if USE_LV_GROUP + lv_group_init(); +#endif + /*Init. the sstyles*/ lv_style_init(); diff --git a/lv_misc/lv_gc.h b/lv_misc/lv_gc.h index 72b10fc45..38090f044 100644 --- a/lv_misc/lv_gc.h +++ b/lv_misc/lv_gc.h @@ -35,6 +35,7 @@ extern "C" { prefix lv_ll_t _lv_drv_ll;\ prefix lv_ll_t _lv_file_ll;\ prefix lv_ll_t _lv_anim_ll;\ + prefix lv_ll_t _lv_group_ll;\ prefix void * _lv_def_scr;\ prefix void * _lv_act_scr;\ prefix void * _lv_top_layer;\ diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index 1b192af62..b27e035a7 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -85,6 +85,11 @@ void lv_theme_set_current(lv_theme_t * th) /*Let the object know their style might change*/ lv_obj_report_style_mod(NULL); + +#if USE_LV_GROUP + lv_group_report_style_mod(NULL); +#endif + #endif } From 3c7b6ae94cfa8a739133fc9d992f63f0b0c4c5bb Mon Sep 17 00:00:00 2001 From: manison Date: Fri, 15 Feb 2019 08:59:53 +0100 Subject: [PATCH 23/33] copy default style modifiers to all themes --- lv_themes/lv_theme_alien.c | 47 +++++++++++++++++++++++++++++++++++ lv_themes/lv_theme_default.c | 47 +++++++++++++++++++++++++++++++++++ lv_themes/lv_theme_material.c | 47 +++++++++++++++++++++++++++++++++++ lv_themes/lv_theme_mono.c | 47 +++++++++++++++++++++++++++++++++++ lv_themes/lv_theme_nemo.c | 47 +++++++++++++++++++++++++++++++++++ lv_themes/lv_theme_night.c | 47 +++++++++++++++++++++++++++++++++++ lv_themes/lv_theme_templ.c | 47 +++++++++++++++++++++++++++++++++++ lv_themes/lv_theme_zen.c | 47 +++++++++++++++++++++++++++++++++++ 8 files changed, 376 insertions(+) diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index e660c9dba..2babbb1e3 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -806,6 +806,50 @@ static void win_init(void) #endif } +static void style_mod(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_ORANGE; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 2; +#endif +} + +static void style_mod_edit(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -862,6 +906,9 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); + theme.group.style_mod = style_mod; + theme.group.style_mod_edit = style_mod_edit; + return &theme; } diff --git a/lv_themes/lv_theme_default.c b/lv_themes/lv_theme_default.c index f16e47a9d..cc6dd3d60 100644 --- a/lv_themes/lv_theme_default.c +++ b/lv_themes/lv_theme_default.c @@ -355,6 +355,50 @@ static void win_init(void) #endif } +static void style_mod(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_ORANGE; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 2; +#endif +} + +static void style_mod_edit(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -406,6 +450,9 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font) tabview_init(); win_init(); + theme.group.style_mod = style_mod; + theme.group.style_mod_edit = style_mod_edit; + return &theme; } diff --git a/lv_themes/lv_theme_material.c b/lv_themes/lv_theme_material.c index d59b781f1..5912f826f 100644 --- a/lv_themes/lv_theme_material.c +++ b/lv_themes/lv_theme_material.c @@ -785,6 +785,50 @@ static void win_init(void) #endif } +static void style_mod(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_ORANGE; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 2; +#endif +} + +static void style_mod_edit(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -843,6 +887,9 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); + theme.group.style_mod = style_mod; + theme.group.style_mod_edit = style_mod_edit; + return &theme; } diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index babfc4998..5ed43c209 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -412,6 +412,50 @@ static void win_init(void) #endif } +static void style_mod(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_ORANGE; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 2; +#endif +} + +static void style_mod_edit(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -467,6 +511,9 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font) tabview_init(); win_init(); + theme.group.style_mod = style_mod; + theme.group.style_mod_edit = style_mod_edit; + return &theme; } diff --git a/lv_themes/lv_theme_nemo.c b/lv_themes/lv_theme_nemo.c index c10fc303f..8d62e2e83 100644 --- a/lv_themes/lv_theme_nemo.c +++ b/lv_themes/lv_theme_nemo.c @@ -781,6 +781,50 @@ static void win_init(void) #endif } +static void style_mod(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_ORANGE; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 2; +#endif +} + +static void style_mod_edit(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -836,6 +880,9 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); + theme.group.style_mod = style_mod; + theme.group.style_mod_edit = style_mod_edit; + return &theme; } diff --git a/lv_themes/lv_theme_night.c b/lv_themes/lv_theme_night.c index 00be1dae2..abbbc493c 100644 --- a/lv_themes/lv_theme_night.c +++ b/lv_themes/lv_theme_night.c @@ -695,6 +695,50 @@ static void win_init(void) #endif } +static void style_mod(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_ORANGE; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 2; +#endif +} + +static void style_mod_edit(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -753,6 +797,9 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); + theme.group.style_mod = style_mod; + theme.group.style_mod_edit = style_mod_edit; + return &theme; } diff --git a/lv_themes/lv_theme_templ.c b/lv_themes/lv_theme_templ.c index 906ec52a2..8cbb1b307 100644 --- a/lv_themes/lv_theme_templ.c +++ b/lv_themes/lv_theme_templ.c @@ -364,6 +364,50 @@ static void win_init(void) #endif } +static void style_mod(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_ORANGE; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 2; +#endif +} + +static void style_mod_edit(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -419,6 +463,9 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font) tabview_init(); win_init(); + theme.group.style_mod = style_mod; + theme.group.style_mod_edit = style_mod_edit; + return &theme; } diff --git a/lv_themes/lv_theme_zen.c b/lv_themes/lv_theme_zen.c index 769032d5a..da7ac37db 100644 --- a/lv_themes/lv_theme_zen.c +++ b/lv_themes/lv_theme_zen.c @@ -758,6 +758,50 @@ static void win_init(void) #endif } +static void style_mod(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_ORANGE; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 2; +#endif +} + +static void style_mod_edit(lv_style_t * style) +{ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -816,6 +860,9 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); + theme.group.style_mod = style_mod; + theme.group.style_mod_edit = style_mod_edit; + return &theme; } From f9d8269274e384e9e6f5e375530ac5d687ed113d Mon Sep 17 00:00:00 2001 From: manison Date: Fri, 15 Feb 2019 09:54:47 +0100 Subject: [PATCH 24/33] update theme focus styles --- lv_themes/lv_theme_alien.c | 11 +-------- lv_themes/lv_theme_material.c | 10 ++++---- lv_themes/lv_theme_mono.c | 16 ++----------- lv_themes/lv_theme_nemo.c | 45 ++++++++--------------------------- lv_themes/lv_theme_night.c | 14 +---------- lv_themes/lv_theme_zen.c | 8 +------ 6 files changed, 20 insertions(+), 84 deletions(-) diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index 2babbb1e3..90d699d8a 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -811,16 +811,7 @@ static void style_mod(lv_style_t * style) #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_ORANGE; - - /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); - - style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.border.color = lv_color_hsv_to_rgb(_hue, 70, 90); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; diff --git a/lv_themes/lv_theme_material.c b/lv_themes/lv_theme_material.c index 5912f826f..2fc54789c 100644 --- a/lv_themes/lv_theme_material.c +++ b/lv_themes/lv_theme_material.c @@ -790,16 +790,16 @@ static void style_mod(lv_style_t * style) #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_ORANGE; + style->body.border.color = lv_color_hsv_to_rgb(_hue, 90, 70); /*If not empty or has border then emphasis the border*/ if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); + style->body.main_color = lv_color_mix(style->body.main_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_60); - style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); + style->text.color = lv_color_mix(style->text.color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index 5ed43c209..982e7703f 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -417,16 +417,10 @@ static void style_mod(lv_style_t * style) #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_ORANGE; + style->body.border.color = LV_COLOR_BLACK; /*If not empty or has border then emphasis the border*/ if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); - - style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -439,16 +433,10 @@ static void style_mod_edit(lv_style_t * style) #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_GREEN; + style->body.border.color = LV_COLOR_BLACK; /*If not empty or has border then emphasis the border*/ if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); - - style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; diff --git a/lv_themes/lv_theme_nemo.c b/lv_themes/lv_theme_nemo.c index 8d62e2e83..b9bd21fc3 100644 --- a/lv_themes/lv_theme_nemo.c +++ b/lv_themes/lv_theme_nemo.c @@ -784,18 +784,15 @@ static void win_init(void) static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 - /*Make the style to be a little bit orange*/ - style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_ORANGE; - - /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); - - style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); + style->body.border.width = 2; + style->body.border.color = LV_COLOR_SILVER; + style->body.border.opa = LV_OPA_70; + style->body.padding.hor = 0; + style->body.padding.ver = 0; + style->body.shadow.width = LV_DPI / 20; + style->body.shadow.color = lv_color_hsv_to_rgb(_hue, 20, 90); + style->body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80); + style->body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -803,28 +800,6 @@ static void style_mod(lv_style_t * style) #endif } -static void style_mod_edit(lv_style_t * style) -{ -#if LV_COLOR_DEPTH != 1 - /*Make the style to be a little bit orange*/ - style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_GREEN; - - /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); - - style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); -#else - style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_BLACK; - style->body.border.width = 3; -#endif -} - /********************** * GLOBAL FUNCTIONS **********************/ @@ -881,7 +856,7 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font) win_init(); theme.group.style_mod = style_mod; - theme.group.style_mod_edit = style_mod_edit; + theme.group.style_mod_edit = style_mod; return &theme; } diff --git a/lv_themes/lv_theme_night.c b/lv_themes/lv_theme_night.c index abbbc493c..ee99285c9 100644 --- a/lv_themes/lv_theme_night.c +++ b/lv_themes/lv_theme_night.c @@ -700,16 +700,10 @@ static void style_mod(lv_style_t * style) #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_ORANGE; + style->body.border.color = lv_color_hsv_to_rgb(_hue, 80, 70); /*If not empty or has border then emphasis the border*/ if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); - - style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -726,12 +720,6 @@ static void style_mod_edit(lv_style_t * style) /*If not empty or has border then emphasis the border*/ if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); - - style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; diff --git a/lv_themes/lv_theme_zen.c b/lv_themes/lv_theme_zen.c index da7ac37db..4419ebc6b 100644 --- a/lv_themes/lv_theme_zen.c +++ b/lv_themes/lv_theme_zen.c @@ -763,16 +763,10 @@ static void style_mod(lv_style_t * style) #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; - style->body.border.color = LV_COLOR_ORANGE; + style->body.border.color = lv_color_hsv_to_rgb(_hue, 40, 50); /*If not empty or has border then emphasis the border*/ if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - - style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); - style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60); - - style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; From 19ea8ac55f79cd6b557348dc0001e3e3fbf4e6f8 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Sun, 17 Feb 2019 14:58:10 -0500 Subject: [PATCH 25/33] Fix compilation error introduced in 1e8ea6b15bea6dbd8c9314d58c70a3ba49f9ac2b --- lv_misc/lv_symbol_def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_misc/lv_symbol_def.h b/lv_misc/lv_symbol_def.h index e8ea76d57..e60952b6a 100644 --- a/lv_misc/lv_symbol_def.h +++ b/lv_misc/lv_symbol_def.h @@ -73,7 +73,7 @@ extern "C" { #define SYMBOL_BATTERY_EMPTY _SYMBOL_VALUE1(F0) #define SYMBOL_BLUETOOTH _SYMBOL_VALUE1(F1) #define LV_SYMBOL_GLYPH_LAST 0xF1 -#define SYMBOL_DUMMY _SYMBOL_VALUE1(xFF) /*Invalid symbol. If written before a string then `lv_img` will show it as a label*/ +#define SYMBOL_DUMMY _SYMBOL_VALUE1(FF) /*Invalid symbol. If written before a string then `lv_img` will show it as a label*/ #else #define LV_SYMBOL_GLYPH_FIRST 0xF800 From 20282ce89fccfc00a9b1aec080fc43bf4953c260 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 18 Feb 2019 05:57:04 +0100 Subject: [PATCH 26/33] remove var. declaration in for loop header --- lv_objx/lv_chart.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lv_objx/lv_chart.c b/lv_objx/lv_chart.c index 3bd6f5304..0060c1499 100644 --- a/lv_objx/lv_chart.c +++ b/lv_objx/lv_chart.c @@ -175,9 +175,10 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie) if(chart == NULL || serie == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - if(ext == NULL) - return; - for(uint32_t i = 0; i < ext->point_cnt; i++) + if(ext == NULL) return; + + uint32_t i; + for(i = 0; i < ext->point_cnt; i++) { serie->points[i] = LV_CHART_POINT_DEF; } From 9572c7d4edbe9b06bb119a4ad8e7222dae8ab4e0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 18 Feb 2019 05:57:18 +0100 Subject: [PATCH 27/33] lv_imgbtn: bugfix --- lv_objx/lv_imgbtn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_objx/lv_imgbtn.c b/lv_objx/lv_imgbtn.c index 3f97d5d67..ed1d72b42 100644 --- a/lv_objx/lv_imgbtn.c +++ b/lv_objx/lv_imgbtn.c @@ -385,7 +385,7 @@ static void refr_img(lv_obj_t * imgbtn) ext->act_cf = LV_IMG_CF_UNKOWN; } - + lv_obj_invalidate(imgbtn); } #endif From 62195b7cc7c9c9dc643985c11f4f4de6571b530c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 18 Feb 2019 06:41:02 +0100 Subject: [PATCH 28/33] lv_label_draw fix with offset.y --- lv_draw/lv_draw_label.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lv_draw/lv_draw_label.c b/lv_draw/lv_draw_label.c index d80c9a0c2..0744ff114 100644 --- a/lv_draw/lv_draw_label.c +++ b/lv_draw/lv_draw_label.c @@ -78,6 +78,14 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st pos.x = coords->x1; pos.y = coords->y1; + lv_coord_t x_ofs = 0; + lv_coord_t y_ofs = 0; + if(offset != NULL) { + x_ofs = offset->x; + y_ofs = offset->y; + pos.y += y_ofs; + } + uint32_t line_start = 0; uint32_t line_end = lv_txt_get_next_line(txt, font, style->text.letter_space, w, flag); @@ -115,14 +123,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st lv_color_t recolor; lv_coord_t letter_w; - lv_coord_t x_ofs = 0; - lv_coord_t y_ofs = 0; - if(offset != NULL) { - x_ofs = offset->x; - y_ofs = offset->y; - pos.y += y_ofs; - } - /*Real draw need a background color for higher bpp letter*/ #if LV_VDB_SIZE == 0 lv_rletter_set_background(style->body.main_color); From 5dfac5a92be890d58414df3d0bb319875f24ef7a Mon Sep 17 00:00:00 2001 From: manison Date: Mon, 18 Feb 2019 08:24:51 +0100 Subject: [PATCH 29/33] use memcpy rather than structure assignment, since this might not be supported by all compilers --- lv_themes/lv_theme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index b27e035a7..4c76cb00e 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -81,7 +81,7 @@ void lv_theme_set_current(lv_theme_t * th) } /*Copy group style modification callback functions*/ - current_theme.group = th->group; + memcpy(¤t_theme.group, &th->group, sizeof(th->group)); /*Let the object know their style might change*/ lv_obj_report_style_mod(NULL); From df88e319a8ef76d8bb03b7a4a025584ba91e59e4 Mon Sep 17 00:00:00 2001 From: manison Date: Mon, 18 Feb 2019 08:34:41 +0100 Subject: [PATCH 30/33] fixed compilation errors when USE_LV_GROUP == 0 --- lv_themes/lv_theme.c | 2 ++ lv_themes/lv_theme.h | 2 ++ lv_themes/lv_theme_alien.c | 6 ++++++ lv_themes/lv_theme_default.c | 6 ++++++ lv_themes/lv_theme_material.c | 6 ++++++ lv_themes/lv_theme_mono.c | 6 ++++++ lv_themes/lv_theme_nemo.c | 6 ++++++ lv_themes/lv_theme_night.c | 6 ++++++ lv_themes/lv_theme_templ.c | 6 ++++++ lv_themes/lv_theme_zen.c | 6 ++++++ 10 files changed, 52 insertions(+) diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index 4c76cb00e..3db5a4cdc 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -80,8 +80,10 @@ void lv_theme_set_current(lv_theme_t * th) if(s) memcpy(&th_styles[i], (void *)s, sizeof(lv_style_t)); } +#if USE_LV_GROUP /*Copy group style modification callback functions*/ memcpy(¤t_theme.group, &th->group, sizeof(th->group)); +#endif /*Let the object know their style might change*/ lv_obj_report_style_mod(NULL); diff --git a/lv_themes/lv_theme.h b/lv_themes/lv_theme.h index 8d681feae..66bbd3d2d 100644 --- a/lv_themes/lv_theme.h +++ b/lv_themes/lv_theme.h @@ -293,11 +293,13 @@ typedef struct { #endif } style; +#if USE_LV_GROUP struct { lv_group_style_mod_func_t style_mod; lv_group_style_mod_func_t style_mod_edit; } group; +#endif } lv_theme_t; /********************** diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index 90d699d8a..45f706ee4 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -806,6 +806,8 @@ static void win_init(void) #endif } +#if USE_LV_GROUP + static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 @@ -841,6 +843,8 @@ static void style_mod_edit(lv_style_t * style) #endif } +#endif /*USE_LV_GROUP*/ + /********************** * GLOBAL FUNCTIONS **********************/ @@ -897,8 +901,10 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); +#if USE_LV_GROUP theme.group.style_mod = style_mod; theme.group.style_mod_edit = style_mod_edit; +#endif return &theme; } diff --git a/lv_themes/lv_theme_default.c b/lv_themes/lv_theme_default.c index cc6dd3d60..3a65455d4 100644 --- a/lv_themes/lv_theme_default.c +++ b/lv_themes/lv_theme_default.c @@ -355,6 +355,8 @@ static void win_init(void) #endif } +#if USE_LV_GROUP + static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 @@ -399,6 +401,8 @@ static void style_mod_edit(lv_style_t * style) #endif } +#endif /*USE_LV_GROUP*/ + /********************** * GLOBAL FUNCTIONS **********************/ @@ -450,8 +454,10 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font) tabview_init(); win_init(); +#if USE_LV_GROUP theme.group.style_mod = style_mod; theme.group.style_mod_edit = style_mod_edit; +#endif return &theme; } diff --git a/lv_themes/lv_theme_material.c b/lv_themes/lv_theme_material.c index 2fc54789c..812dfd362 100644 --- a/lv_themes/lv_theme_material.c +++ b/lv_themes/lv_theme_material.c @@ -785,6 +785,8 @@ static void win_init(void) #endif } +#if USE_LV_GROUP + static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 @@ -829,6 +831,8 @@ static void style_mod_edit(lv_style_t * style) #endif } +#endif /*USE_LV_GROUP*/ + /********************** * GLOBAL FUNCTIONS **********************/ @@ -887,8 +891,10 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); +#if USE_LV_GROUP theme.group.style_mod = style_mod; theme.group.style_mod_edit = style_mod_edit; +#endif return &theme; } diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index 982e7703f..25ce93f89 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -412,6 +412,8 @@ static void win_init(void) #endif } +#if USE_LV_GROUP + static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 @@ -444,6 +446,8 @@ static void style_mod_edit(lv_style_t * style) #endif } +#endif /*USE_LV_GROUP*/ + /********************** * GLOBAL FUNCTIONS **********************/ @@ -499,8 +503,10 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font) tabview_init(); win_init(); +#if USE_LV_GROUP theme.group.style_mod = style_mod; theme.group.style_mod_edit = style_mod_edit; +#endif return &theme; } diff --git a/lv_themes/lv_theme_nemo.c b/lv_themes/lv_theme_nemo.c index b9bd21fc3..5550a5352 100644 --- a/lv_themes/lv_theme_nemo.c +++ b/lv_themes/lv_theme_nemo.c @@ -781,6 +781,8 @@ static void win_init(void) #endif } +#if USE_LV_GROUP + static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 @@ -800,6 +802,8 @@ static void style_mod(lv_style_t * style) #endif } +#endif /*USE_LV_GROUP*/ + /********************** * GLOBAL FUNCTIONS **********************/ @@ -855,8 +859,10 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); +#if USE_LV_GROUP theme.group.style_mod = style_mod; theme.group.style_mod_edit = style_mod; +#endif return &theme; } diff --git a/lv_themes/lv_theme_night.c b/lv_themes/lv_theme_night.c index ee99285c9..047c811a6 100644 --- a/lv_themes/lv_theme_night.c +++ b/lv_themes/lv_theme_night.c @@ -695,6 +695,8 @@ static void win_init(void) #endif } +#if USE_LV_GROUP + static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 @@ -727,6 +729,8 @@ static void style_mod_edit(lv_style_t * style) #endif } +#endif /*USE_LV_GROUP*/ + /********************** * GLOBAL FUNCTIONS **********************/ @@ -785,8 +789,10 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); +#if USE_LV_GROUP theme.group.style_mod = style_mod; theme.group.style_mod_edit = style_mod_edit; +#endif return &theme; } diff --git a/lv_themes/lv_theme_templ.c b/lv_themes/lv_theme_templ.c index 8cbb1b307..46f3793b7 100644 --- a/lv_themes/lv_theme_templ.c +++ b/lv_themes/lv_theme_templ.c @@ -364,6 +364,8 @@ static void win_init(void) #endif } +#if USE_LV_GROUP + static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 @@ -408,6 +410,8 @@ static void style_mod_edit(lv_style_t * style) #endif } +#endif /*USE_LV_GROUP*/ + /********************** * GLOBAL FUNCTIONS **********************/ @@ -463,8 +467,10 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font) tabview_init(); win_init(); +#if USE_LV_GROUP theme.group.style_mod = style_mod; theme.group.style_mod_edit = style_mod_edit; +#endif return &theme; } diff --git a/lv_themes/lv_theme_zen.c b/lv_themes/lv_theme_zen.c index 4419ebc6b..c55e8c8de 100644 --- a/lv_themes/lv_theme_zen.c +++ b/lv_themes/lv_theme_zen.c @@ -758,6 +758,8 @@ static void win_init(void) #endif } +#if USE_LV_GROUP + static void style_mod(lv_style_t * style) { #if LV_COLOR_DEPTH != 1 @@ -796,6 +798,8 @@ static void style_mod_edit(lv_style_t * style) #endif } +#endif /*USE_LV_GROUP*/ + /********************** * GLOBAL FUNCTIONS **********************/ @@ -854,8 +858,10 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font) table_init(); win_init(); +#if USE_LV_GROUP theme.group.style_mod = style_mod; theme.group.style_mod_edit = style_mod_edit; +#endif return &theme; } From 2e0b8e10ae07e891e98ec5e1e4f52b0b1cf7a340 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Mon, 18 Feb 2019 12:15:57 -0500 Subject: [PATCH 31/33] Add missing include to lv_math.c --- lv_misc/lv_math.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lv_misc/lv_math.c b/lv_misc/lv_math.c index a0d26053e..e22d784dd 100644 --- a/lv_misc/lv_math.c +++ b/lv_misc/lv_math.c @@ -8,6 +8,7 @@ *********************/ #include "lv_math.h" #include +#include /********************* * DEFINES From d05ec536fdf76de435dc2b41d2739f800c8e6696 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Mon, 18 Feb 2019 12:17:56 -0500 Subject: [PATCH 32/33] Fix compilation errors when USE_LV_GROUP is 0 --- lv_objx/lv_ddlist.c | 4 ++++ lv_objx/lv_roller.c | 6 ++++++ lv_objx/lv_tabview.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index c8805d591..9106b6daa 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -624,6 +624,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par } else if(sign == LV_SIGNAL_CLEANUP) { ext->label = NULL; } else if(sign == LV_SIGNAL_FOCUS) { +#if USE_LV_GROUP lv_group_t * g = lv_obj_get_group(ddlist); bool editing = lv_group_get_editing(g); lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); @@ -651,6 +652,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par lv_ddlist_refr_size(ddlist, true); } } +#endif } else if(sign == LV_SIGNAL_DEFOCUS) { if(ext->opened) { ext->opened = false; @@ -686,9 +688,11 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par ext->opened = 0; if(ext->action) ext->action(ddlist); +#if USE_LV_GROUP lv_group_t * g = lv_obj_get_group(ddlist); bool editing = lv_group_get_editing(g); if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ +#endif } else { ext->opened = 1; } diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index ae3419ddb..28c8b801d 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -361,6 +361,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par refr_position(roller, false); } } else if(sign == LV_SIGNAL_FOCUS) { +#if USE_LV_GROUP lv_group_t * g = lv_obj_get_group(roller); bool editing = lv_group_get_editing(g); lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); @@ -382,12 +383,15 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Save the current value. Used to revert this state if ENER wont't be pressed*/ } +#endif } else if(sign == LV_SIGNAL_DEFOCUS) { +#if USE_LV_GROUP /*Revert the original state*/ if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) { ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori; refr_position(roller, true); } +#endif } else if(sign == LV_SIGNAL_CONTROLL) { char c = *((char *)param); if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) { @@ -402,9 +406,11 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/ if(ext->ddlist.action) ext->ddlist.action(roller); +#if USE_LV_GROUP lv_group_t * g = lv_obj_get_group(roller); bool editing = lv_group_get_editing(g); if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ +#endif } } else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index 8b16ec878..3f71b441d 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -621,12 +621,14 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); /*With ENCODER select the first button only in edit mode*/ if(indev_type == LV_INDEV_TYPE_ENCODER) { +#if USE_LV_GROUP lv_group_t * g = lv_obj_get_group(tabview); if(lv_group_get_editing(g)) { lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns); btnm_ext->btn_id_pr = 0; lv_obj_invalidate(ext->btns); } +#endif } else { lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns); btnm_ext->btn_id_pr = 0; From 8581a249bde2d630de1aef375a56abf6201cb848 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 20 Feb 2019 06:20:29 +0100 Subject: [PATCH 33/33] lv_group_create: inititalize missing fields --- lv_core/lv_group.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index 83c22ca76..16235f32d 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -64,6 +64,8 @@ lv_group_t * lv_group_create(void) group->focus_cb = NULL; group->click_focus = 1; group->editing = 0; + group->refocus_policy = LV_GROUP_REFOCUS_POLICY_PREV; + group->wrap = 1; /*Initialize style modification callbacks from current theme*/ refresh_theme(group, lv_theme_get_current());