From 7db7482ac58b6b11146816d244f4aac00dc81087 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 21 Jun 2018 22:15:19 +0200 Subject: [PATCH 1/4] fixes in lv_roller, lv_ddlist design to be pixel prefect --- lv_objx/lv_ddlist.c | 4 ++-- lv_objx/lv_roller.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index ce4985ea8..89e5e601d 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -448,7 +448,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig rect_area.y1 += ext->sel_opt_id * (font_h + style->text.line_space); rect_area.y1 -= style->text.line_space / 2; - rect_area.y2 = rect_area.y1 + font_h + style->text.line_space; + rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1; rect_area.x1 = ddlist->coords.x1; rect_area.x2 = ddlist->coords.x2; @@ -474,7 +474,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig area_sel.y1 += ext->sel_opt_id * (font_h + style->text.line_space); area_sel.y1 -= style->text.line_space / 2; - area_sel.y2 = area_sel.y1 + font_h + style->text.line_space; + area_sel.y2 = area_sel.y1 + font_h + style->text.line_space - 1; area_sel.x1 = ddlist->coords.x1; area_sel.x2 = ddlist->coords.x2; lv_area_t mask_sel; diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index 3fed3e2bb..c23db3576 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -228,7 +228,8 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig lv_coord_t font_h = lv_font_get_height(font); lv_area_t rect_area; rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2; - rect_area.y2 = rect_area.y1 + font_h + style->text.line_space; + if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1 --; /*Compensate the two rounding error*/ + rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1; rect_area.x1 = roller->coords.x1; rect_area.x2 = roller->coords.x2; @@ -244,7 +245,8 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig /*Redraw the text on the selected area with a different color*/ lv_area_t rect_area; rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2; - rect_area.y2 = rect_area.y1 + font_h + style->text.line_space; + if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1 --; /*Compensate the two rounding error*/ + rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1; rect_area.x1 = roller->coords.x1; rect_area.x2 = roller->coords.x2; lv_area_t mask_sel; From dd7c562c96060f95c609fa02574ef751c2ce5780 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 26 Jun 2018 18:30:38 +0200 Subject: [PATCH 2/4] lv_ddlist: fix the selection of options with non ASCII characters --- lv_objx/lv_ddlist.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index 89e5e601d..a60ca725d 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -634,9 +634,12 @@ static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist) uint16_t new_opt = 0; const char * txt = lv_label_get_text(ext->label); - uint16_t i; - for(i = 0; i < letter_i; i++) { - if(txt[i] == '\n') new_opt ++; + uint32_t i = 0; + uint32_t line_cnt = 0; + uint32_t letter; + for(line_cnt = 0; line_cnt < letter_i; line_cnt++) { + letter = lv_txt_utf8_next(txt, &i); + if(letter == '\n') new_opt ++; } ext->sel_opt_id = new_opt; From 7bd4775b01dac8c01f77c7b4017ea5ac3d15723d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 3 Jul 2018 14:19:04 +0200 Subject: [PATCH 3/4] lv_page: add scrolling on LV_GROUP_KEY_UP/DOWN/LEFT/RIGHT --- lv_objx/lv_page.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index d3c20ec58..4ded6a3a2 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -21,6 +21,7 @@ * DEFINES *********************/ #define LV_PAGE_SB_MIN_SIZE (LV_DPI / 8) +#define LV_PAGE_GROUP_SCROLL_ANIM_TIME 200 /********************** * TYPEDEFS @@ -515,7 +516,54 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) /*Ensure ext. size for the scrollbars if they are out of the page*/ if(page->ext_size < (-ext->sb.style->body.padding.hor)) page->ext_size = -ext->sb.style->body.padding.hor; if(page->ext_size < (-ext->sb.style->body.padding.ver)) page->ext_size = -ext->sb.style->body.padding.ver; - } else if(sign == LV_SIGNAL_GET_TYPE) { + } else if(sign == LV_SIGNAL_CONTROLL) { + uint32_t c = *((uint32_t *) param); + lv_obj_t * scrl = lv_page_get_scrl(page); + if(c == LV_GROUP_KEY_DOWN || c == LV_GROUP_KEY_RIGHT) { +#if USE_LV_ANIMATION + lv_anim_t a; + a.var = scrl; + a.start = lv_obj_get_y(scrl); + a.end = a.start - LV_DPI / 2; + a.fp = (lv_anim_fp_t)lv_obj_set_y; + a.path = lv_anim_path_linear; + a.end_cb = NULL; + a.act_time = 0; + a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME; + a.playback = 0; + a.playback_pause = 0; + a.repeat = 0; + a.repeat_pause = 0; + lv_anim_create(&a); +#else + lv_obj_set_y(scrl, lv_obj_get_y(scrl) - LV_DPI / 2); +#endif + + } + else if(c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_LEFT) { +#if USE_LV_ANIMATION + lv_anim_t a; + a.var = scrl; + a.start = lv_obj_get_y(scrl); + a.end = a.start + LV_DPI / 2; + a.fp = (lv_anim_fp_t)lv_obj_set_y; + a.path = lv_anim_path_linear; + a.end_cb = NULL; + a.act_time = 0; + a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME; + a.playback = 0; + a.playback_pause = 0; + a.repeat = 0; + a.repeat_pause = 0; + lv_anim_create(&a); +#else + lv_obj_set_y(scrl, lv_obj_get_y(scrl) - LV_DPI / 2); +#endif + } + } + + + else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; uint8_t i; for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/ From a4a210c9e5f42bd284db575908968aae1e77412a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 3 Jul 2018 14:27:53 +0200 Subject: [PATCH 4/4] lv_page_focus: delete all positioning animations to be sure the new focus won't be overwritten --- lv_objx/lv_page.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 4ded6a3a2..541435abe 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -283,6 +283,16 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue) */ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) { + +#if USE_LV_ANIMATION == 0 + anim_tiem = 0; +#endif + + /* Be sure there is no position changing animation in progress + * because it can overide the current changes*/ + lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_y); + lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_pos); + lv_page_ext_t * ext = lv_obj_get_ext_attr(page); lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG); lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);