tileview asn scroll propagation improvments

This commit is contained in:
Gabor Kiss-Vamosi
2018-11-25 19:40:19 +01:00
parent 2cda0fc1fe
commit a9eb9f9ea5
5 changed files with 41 additions and 7 deletions

View File

@@ -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
*************************/

View File

@@ -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;
}

View File

@@ -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 &&

View File

@@ -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

1
lvgl.h
View File

@@ -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"