From 99bb4cb8f109d3dfe5b43c2f48dea52672ed4c1f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 9 Dec 2020 14:02:28 +0100 Subject: [PATCH] fix(page): fix LV_SCOLLBAR_MODE_DRAG fixes https://forum.lvgl.io/t/page-scrollbar-appears-even-if-scrollbar-mode-is-set-to-lv-scrlbar-mode-drag/3883 --- CHANGELOG.md | 1 + src/lv_widgets/lv_page.c | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bc5582bf..0dc6dae23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Bugfixes - fix(lv_scr_load_anim) fix when multiple screen are loaded at tsame time with delay +- fix(page) fix LV_SCOLLBAR_MODE_DRAG ## v7.8.0 (01.12.2020) diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 2400dccd3..936537c0a 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -1250,8 +1250,22 @@ static void scrlbar_refresh(lv_obj_t * page) (scrl_w + bg_left + bg_right - obj_w), obj_h - sb_width - sb_bottom); - if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_AUTO || - ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) ext->scrlbar.hor_draw = 1; + if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_AUTO) ext->scrlbar.hor_draw = 1; + else if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) { + lv_indev_t * indev = lv_indev_get_next(NULL); + while(indev) { + if(indev->driver.type == LV_INDEV_TYPE_POINTER && (indev->proc.types.pointer.drag_dir & LV_DRAG_DIR_HOR)) { + lv_obj_t * drag_obj = indev->proc.types.pointer.act_obj; + while(drag_obj && drag_obj->drag_parent) drag_obj = lv_obj_get_parent(drag_obj); + + if(drag_obj && drag_obj == scrl) { + ext->scrlbar.hor_draw = 1; + break; + } + } + indev = lv_indev_get_next(indev); + } + } } /*Full sized vertical scroll bar*/ @@ -1275,8 +1289,22 @@ static void scrlbar_refresh(lv_obj_t * page) (obj_h - size_tmp - 2 * sb_ver_pad)) / (scrl_h + bg_top + bg_bottom - obj_h)); - if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_AUTO || - ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) ext->scrlbar.ver_draw = 1; + if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_AUTO) ext->scrlbar.ver_draw = 1; + else if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) { + lv_indev_t * indev = lv_indev_get_next(NULL); + while(indev) { + if(indev->driver.type == LV_INDEV_TYPE_POINTER && (indev->proc.types.pointer.drag_dir & LV_DRAG_DIR_VER)) { + lv_obj_t * drag_obj = indev->proc.types.pointer.act_obj; + while(drag_obj && drag_obj->drag_parent) drag_obj = lv_obj_get_parent(drag_obj); + + if(drag_obj && drag_obj == scrl) { + ext->scrlbar.ver_draw = 1; + break; + } + } + indev = lv_indev_get_next(indev); + } + } } /*Invalidate the new scrollbar areas*/