From a9eb9f9ea542fbf0cffce0bf623f607077d43e94 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 25 Nov 2018 19:40:19 +0100 Subject: [PATCH] tileview asn scroll propagation improvments --- lv_conf_templ.h | 6 ++++++ lv_objx/lv_list.c | 16 +++++++++++++--- lv_objx/lv_tileview.c | 5 +---- lv_objx/lv_tileview.h | 20 ++++++++++++++++++++ lvgl.h | 1 + 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/lv_conf_templ.h b/lv_conf_templ.h index 4d0d44858..b6606acd2 100644 --- a/lv_conf_templ.h +++ b/lv_conf_templ.h @@ -226,6 +226,12 @@ #define LV_TABVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/ #endif +/*Tileview (dependencies: lv_page) */ +#define USE_LV_TILEVIEW 1 +#if USE_LV_TILEVIEW +#define LV_TILEVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/ +#endif + /************************* * Data visualizer objects *************************/ diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index 3de23185e..6e7a232fd 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -833,9 +833,12 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para res = ancestor_btn_signal(btn, sign, param); if(res != LV_RES_OK) return res; -#if USE_LV_GROUP if(sign == LV_SIGNAL_RELEASED) { lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn)); + lv_list_ext_t * ext = lv_obj_get_ext_attr(list); + ext->page.scroll_prop_ip = 0; + +#if USE_LV_GROUP lv_group_t * g = lv_obj_get_group(list); if(lv_group_get_focused(g) == list && lv_indev_is_dragging(lv_indev_get_act()) == false) { /* Is the list is focused then be sure only the button being released @@ -855,16 +858,23 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para /* If `click_focus == 1` then LV_SIGNAL_FOCUS need to know which button triggered the focus * to mark it as selected (pressed state)*/ last_clicked_btn = btn; +#endif } - if(sign == LV_SIGNAL_CLEANUP) { + else if(sign == LV_SIGNAL_PRESS_LOST) { + lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn)); + lv_list_ext_t * ext = lv_obj_get_ext_attr(list); + ext->page.scroll_prop_ip = 0; + } + else if(sign == LV_SIGNAL_CLEANUP) { +#if USE_LV_GROUP lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn)); lv_obj_t * sel = lv_list_get_btn_selected(list); if(sel == btn) lv_list_set_btn_selected(list, lv_list_get_next_btn(list, btn)); +#endif } -#endif return res; } diff --git a/lv_objx/lv_tileview.c b/lv_objx/lv_tileview.c index 6d56f6613..92aeeb8cd 100644 --- a/lv_objx/lv_tileview.c +++ b/lv_objx/lv_tileview.c @@ -127,6 +127,7 @@ void lv_tileview_add_element(lv_obj_t * tileview, lv_obj_t * element) (void) tileview; /*Unused*/ lv_obj_set_free_ptr(element, lv_obj_get_signal_func(element)); lv_obj_set_signal_func(element, element_signal_func); + lv_obj_set_drag_parent(element, true); } @@ -363,7 +364,6 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_coord_t w = lv_obj_get_width(tileview); if(ext->drag_top_en == 0) { if(y > -(ext->act_id.y * h) && indev->proc.vect.y > 0 && ext->drag_hor == 0) { - printf("top: y:%d\n", y); if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && ext->page.edge_flash.top_ip == 0 && ext->page.edge_flash.bottom_ip == 0) { @@ -375,7 +375,6 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void } } if(ext->drag_bottom_en == 0 && indev->proc.vect.y < 0 && ext->drag_hor == 0) { - printf("bottom: y:%d\n", y); if(y < -(ext->act_id.y * h)) { if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && @@ -389,7 +388,6 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void } if(ext->drag_left_en == 0) { if(x > -(ext->act_id.x * w) && indev->proc.vect.x > 0 && ext->drag_ver == 0) { - printf("left: x:%d\n", x); if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && ext->page.edge_flash.top_ip == 0 && ext->page.edge_flash.bottom_ip == 0) { @@ -401,7 +399,6 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void } } if(ext->drag_right_en == 0 && indev->proc.vect.x < 0 && ext->drag_ver == 0) { - printf("right: x:%d\n", x); if(x < -(ext->act_id.x * w)) { if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && diff --git a/lv_objx/lv_tileview.h b/lv_objx/lv_tileview.h index ee358724d..7a479e1de 100644 --- a/lv_objx/lv_tileview.h +++ b/lv_objx/lv_tileview.h @@ -107,6 +107,16 @@ void lv_tileview_set_valid_positions(lv_obj_t * tileview, const lv_point_t * val */ void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, bool anim_en); +/** + * Enable the edge flash effect. (Show an arc when the an edge is reached) + * @param tileview pointer to a Tileview + * @param en true or false to enable/disable end flash + */ +static inline void lv_tileview_set_edge_flash(lv_obj_t * tileview, bool en) +{ + lv_page_set_edge_flash(tileview, en); +} + /** * Set a style of a tileview. * @param tileview pointer to tileview object @@ -119,6 +129,16 @@ void lv_tileview_set_style(lv_obj_t * tileview, lv_tileview_style_t type, lv_sty * Getter functions *====================*/ +/** + * Get the scroll propagation property + * @param tileview pointer to a Tileview + * @return true or false + */ +static inline bool lv_tileview_get_edge_flash(lv_obj_t * tileview) +{ + return lv_page_get_edge_flash(tileview); +} + /** * Get style of a tileview. * @param tileview pointer to tileview object diff --git a/lvgl.h b/lvgl.h index 7d7e37e0d..dfaf55a92 100644 --- a/lvgl.h +++ b/lvgl.h @@ -47,6 +47,7 @@ extern "C" { #include "lv_objx/lv_ta.h" #include "lv_objx/lv_win.h" #include "lv_objx/lv_tabview.h" +#include "lv_objx/lv_tileview.h" #include "lv_objx/lv_mbox.h" #include "lv_objx/lv_gauge.h" #include "lv_objx/lv_lmeter.h"