From 06f81e8a610f3700423da04216e2ba37adb3cb8f Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 9 Nov 2018 20:13:26 +0800 Subject: [PATCH 1/8] Update lv_conf_templ.h --- lv_conf_templ.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lv_conf_templ.h b/lv_conf_templ.h index 95577bf41..8259de7d8 100644 --- a/lv_conf_templ.h +++ b/lv_conf_templ.h @@ -296,7 +296,6 @@ #define USE_LV_DDLIST 1 #if USE_LV_DDLIST != 0 #define LV_DDLIST_ANIM_TIME 200 /*Open and close default animation time [ms] (0: no animation)*/ -#define LV_DDLIST_USE_STYLE_INDC 1 /*Use a down arrow in ddlist */ #endif /*Roller (dependencies: lv_ddlist)*/ From 4092adbe28c690f293a62e2ecb6ccdceab0c6a16 Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 9 Nov 2018 20:25:48 +0800 Subject: [PATCH 2/8] Update lv_ddlist.c --- lv_objx/lv_ddlist.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index 62d09d513..e4a664a9b 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -153,6 +153,19 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) * Setter functions *====================*/ +/** + * Set arrow draw in a drop down list + * @param ddlist pointer to drop down list object + * @param en enable/disable a arrow draw. E.g. "true" for draw. + */ +void lv_ddlist_set_draw_arrow(lv_obj_t * ddlist, bool en) +{ + lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist); + + /*Set the flag*/ + ext->draw_arrow = en; +} + /** * Set the options in a drop down list from a string * @param ddlist pointer to drop down list object @@ -498,11 +511,12 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig lv_label_get_text(ext->label), LV_TXT_FLAG_NONE, NULL); } } -#if LV_DDLIST_USE_STYLE_INDC != 0 + //Add a down symbol in ddlist else { - if(ext->roller_ddlist) + /*Draw a arrow in ddlist if enabled*/ + if(ext->draw_arrow) { lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG); const lv_font_t * font = style->text.font; @@ -530,11 +544,10 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig if (area_ok) { lv_draw_label(&area_sel, &mask_sel, &new_style, opa_scale, - SYMBOL_DOWN, LV_TXT_FLAG_NONE, NULL); + SYMBOL_DOWN, LV_TXT_FLAG_NONE, NULL); /*Use a down arrow in ddlist, you can replace it with your custom symbol*/ } } } -#endif /*Draw the scrollbar in the ancestor page design function*/ ancestor_design(ddlist, mask, mode); } From 54435fce6038d18617e8b45dacccea647b11ab8c Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 9 Nov 2018 20:27:59 +0800 Subject: [PATCH 3/8] Update lv_ddlist.h --- lv_objx/lv_ddlist.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lv_objx/lv_ddlist.h b/lv_objx/lv_ddlist.h index 73d42af29..6c1d5b396 100644 --- a/lv_objx/lv_ddlist.h +++ b/lv_objx/lv_ddlist.h @@ -54,9 +54,8 @@ typedef struct uint16_t sel_opt_id_ori; /*Store the original index on focus*/ uint16_t anim_time; /*Open/Close animation time [ms]*/ uint8_t opened :1; /*1: The list is opened (handled by the library)*/ -#if LV_DDLIST_USE_STYLE_INDC != 0 - uint8_t roller_ddlist :1; /*0: The list is roller, otherwise ddlist*/ -#endif + uint8_t draw_arrow :1; /*1: Draw arrow*/ + lv_coord_t fix_height; /*Height of the ddlist when opened. (0: auto-size)*/ } lv_ddlist_ext_t; @@ -82,6 +81,13 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy); * Setter functions *====================*/ +/** + * Set arrow draw in a drop down list + * @param ddlist pointer to drop down list object + * @param en enable/disable a arrow draw. E.g. "true" for draw. + */ +void lv_ddlist_set_draw_arrow(lv_obj_t * ddlist, bool en); + /** * Set the options in a drop down list from a string * @param ddlist pointer to drop down list object From ac9ee5d1f806c02aeda18fe4b7e755b327a7e87c Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 9 Nov 2018 20:29:59 +0800 Subject: [PATCH 4/8] Update lv_roller.c --- lv_objx/lv_roller.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index 6f28e6303..cda4cb60d 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -74,9 +74,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t)); lv_mem_assert(ext); if(ext == NULL) return NULL; -#if LV_DDLIST_USE_STYLE_INDC != 0 - ext->ddlist.roller_ddlist = 0; -#endif + ext->ddlist.roller_ddlist = 0; /*Do not draw arrow by default*/ + /*The signal and design functions are not copied so set them here*/ lv_obj_set_signal_func(new_roller, lv_roller_signal); lv_obj_set_design_func(new_roller, lv_roller_design); From e159e1a8bdbfcb598ee41ad152e4007cc4e17d4e Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 9 Nov 2018 20:32:08 +0800 Subject: [PATCH 5/8] Update lv_ddlist.c --- lv_objx/lv_ddlist.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index e4a664a9b..0692280f6 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -92,9 +92,8 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) ext->option_cnt = 0; ext->anim_time = LV_DDLIST_ANIM_TIME; ext->sel_style = &lv_style_plain_color; -#if LV_DDLIST_USE_STYLE_INDC != 0 - ext->roller_ddlist = 1; -#endif + ext->draw_arrow = 0; /*Do not draw arrow by default*/ + /*The signal and design functions are not copied so set them here*/ lv_obj_set_signal_func(new_ddlist, lv_ddlist_signal); lv_obj_set_signal_func(lv_page_get_scrl(new_ddlist), lv_ddlist_scrl_signal); From 4a4d7209baee9ff1c7b5d104364ba2b03ba6c218 Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 9 Nov 2018 21:27:36 +0800 Subject: [PATCH 6/8] Update lv_ddlist.c --- lv_objx/lv_ddlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index 0692280f6..22853f0e1 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -511,7 +511,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig } } - //Add a down symbol in ddlist + /*Add a down symbol in ddlist*/ else { /*Draw a arrow in ddlist if enabled*/ @@ -536,7 +536,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig lv_coord_t w = lv_obj_get_width(ddlist); area_sel.x1 = ddlist->coords.x2 - 20; area_sel.x2 = ddlist->coords.x2 + w; - area_sel.y1 += 2; + area_sel.y1 += (font_h/2-5); /* Height of the symbol is about 10ppx */ lv_area_t mask_sel; bool area_ok; area_ok = lv_area_intersect(&mask_sel, mask, &area_sel); From 134b887adc198441b3a2da7a917c85dceda85f83 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Fri, 9 Nov 2018 16:37:40 -0500 Subject: [PATCH 7/8] Add getter function for `lv_ddlist_set_draw_arrow` --- lv_objx/lv_ddlist.c | 11 +++++++++++ lv_objx/lv_ddlist.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index 22853f0e1..d7749bce5 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -290,6 +290,17 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, lv_style_t * * Getter functions *====================*/ +/** + * Get arrow draw in a drop down list + * @param ddlist pointer to drop down list object + */ +bool lv_ddlist_get_draw_arrow(lv_obj_t * ddlist) +{ + lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist); + + return ext->draw_arrow; +} + /** * Get the options of a drop down list * @param ddlist pointer to drop down list object diff --git a/lv_objx/lv_ddlist.h b/lv_objx/lv_ddlist.h index 6c1d5b396..d928d6520 100644 --- a/lv_objx/lv_ddlist.h +++ b/lv_objx/lv_ddlist.h @@ -154,6 +154,12 @@ void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *s * Getter functions *====================*/ +/** + * Get arrow draw in a drop down list + * @param ddlist pointer to drop down list object + */ +bool lv_ddlist_get_draw_arrow(lv_obj_t * ddlist); + /** * Get the options of a drop down list * @param ddlist pointer to drop down list object From 4637f4085d4a54101df8c981a96be67229b89807 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Fri, 9 Nov 2018 16:44:26 -0500 Subject: [PATCH 8/8] Fix compilation error in lv_roller --- lv_objx/lv_roller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index cda4cb60d..cc8728eb0 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -74,7 +74,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t)); lv_mem_assert(ext); if(ext == NULL) return NULL; - ext->ddlist.roller_ddlist = 0; /*Do not draw arrow by default*/ + ext->ddlist.draw_arrow = 0; /*Do not draw arrow by default*/ /*The signal and design functions are not copied so set them here*/ lv_obj_set_signal_func(new_roller, lv_roller_signal);