improve slide view

This commit is contained in:
xianjimli 2018-11-21 10:17:24 +08:00
parent 76694a1bc1
commit e69aa2d6f5
3 changed files with 24 additions and 9 deletions

View File

@ -281,7 +281,7 @@
#include "assets/inc/images/3.data"
#include "assets/inc/images/arrow_left_n.data"
#include "assets/inc/images/edit_clear_p.data"
#endif/*WITH_STB_IMAGE*/
#endif /*WITH_STB_IMAGE*/
#ifdef WITH_VGCANVAS
#include "assets/inc/images/pointer_4.bsvg"
#include "assets/inc/images/pointer_2.bsvg"
@ -294,17 +294,17 @@
#include "assets/inc/images/pointer_red.bsvg"
#include "assets/inc/images/pointer_big.bsvg"
#include "assets/inc/images/girl.bsvg"
#endif/*WITH_VGCANVAS*/
#endif /*WITH_VGCANVAS*/
#ifdef WITH_STB_FONT
#ifdef WITH_MINI_FONT
#include "assets/inc/fonts/default.mini.res"
#else/*WITH_MINI_FONT*/
#else /*WITH_MINI_FONT*/
#include "assets/inc/fonts/default.res"
#endif/*WITH_MINI_FONT*/
#else/*WITH_STB_FONT*/
#endif /*WITH_MINI_FONT*/
#else /*WITH_STB_FONT*/
#include "assets/inc/fonts/default.data"
#endif/*WITH_STB_FONT*/
#endif/*WITH_FS_RES*/
#endif /*WITH_STB_FONT*/
#endif /*WITH_FS_RES*/
ret_t assets_init(void) {
assets_manager_t* rm = assets_manager();
@ -508,7 +508,7 @@ ret_t assets_init(void) {
assets_manager_add(rm, image_pointer_red);
assets_manager_add(rm, image_pointer_big);
assets_manager_add(rm, image_girl);
#endif/*WITH_VGCANVAS*/
#endif /*WITH_VGCANVAS*/
#endif
tk_init_assets();

View File

@ -1,4 +1,9 @@
# 最新动态
* 2018/11/21
* 修改资源生成工具支持SVG。
* 修改slide\_view增加一个拖动阀值由该阀值和速度共同决定是否切换页面。
* 修改一些编译警告。
* 2018/11/20
* 合并BUG #35的补丁
* 合并BUG #25的补丁

View File

@ -97,7 +97,9 @@ ret_t slide_view_activate_next(slide_view_t* slide_view) {
}
static ret_t slide_view_on_paint_self(widget_t* widget, canvas_t* c) {
return widget_paint_helper(widget, c, NULL, NULL);
(void)widget;
(void)c;
return RET_OK;
}
static ret_t slide_view_on_pointer_down(slide_view_t* slide_view, pointer_event_t* e) {
@ -131,6 +133,8 @@ static ret_t slide_view_on_scroll_done(void* ctx, event_t* e) {
return RET_OK;
}
#define DRAG_THRESHOLD 30
static ret_t slide_view_on_pointer_up(slide_view_t* slide_view, pointer_event_t* e) {
uint32_t v_threshhold = 100;
widget_t* widget = WIDGET(slide_view);
@ -151,6 +155,9 @@ static ret_t slide_view_on_pointer_up(slide_view_t* slide_view, pointer_event_t*
} else if (yoffset < 0 && slide_view_get_next(slide_view) == NULL) {
rollback = TRUE;
}
if (tk_abs(yoffset) < DRAG_THRESHOLD) {
rollback = TRUE;
}
if (!rollback) {
yoffset_end = yoffset > 0 ? h : -h;
@ -169,6 +176,9 @@ static ret_t slide_view_on_pointer_up(slide_view_t* slide_view, pointer_event_t*
} else if (xoffset < 0 && slide_view_get_next(slide_view) == NULL) {
rollback = TRUE;
}
if (tk_abs(xoffset) < DRAG_THRESHOLD) {
rollback = TRUE;
}
if (!rollback) {
xoffset_end = xoffset > 0 ? w : -w;