mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 11:08:34 +08:00
improve slidview
This commit is contained in:
parent
88d4d40bf3
commit
7700653c80
@ -3,6 +3,7 @@
|
||||
2023/02/20
|
||||
* 修复API注释错误(感谢俊圣提供补丁)
|
||||
* 删除pages中的页面时,分发事件页面变化和值变化事件 (感谢雨欣提供补丁)
|
||||
* 控件把最后一个要修改的值缓存起来,动画播完后切换到该值(感谢雨欣提供补丁)
|
||||
|
||||
2023/02/19
|
||||
* 增加函数tk\_sha256\_file。
|
||||
|
@ -152,23 +152,28 @@ static ret_t slide_view_on_pointer_down(slide_view_t* slide_view, pointer_event_
|
||||
}
|
||||
|
||||
static ret_t slide_view_on_scroll_done(void* ctx, event_t* e) {
|
||||
uint32_t active;
|
||||
widget_t* widget = WIDGET(ctx);
|
||||
slide_view_t* slide_view = SLIDE_VIEW(ctx);
|
||||
return_value_if_fail(widget != NULL && slide_view != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if (slide_view->xoffset < 0 || slide_view->yoffset < 0) {
|
||||
active = widget_index_of(slide_view->prev);
|
||||
active = active == slide_view->last_active ? active : slide_view->last_active;
|
||||
if (slide_view->remove_when_anim_done) {
|
||||
widget_destroy(slide_view->next);
|
||||
slide_view_set_active_no_animate_impl(widget, widget_index_of(slide_view->prev), TRUE);
|
||||
slide_view_set_active_no_animate_impl(widget, active, TRUE);
|
||||
} else {
|
||||
slide_view_set_active_no_animate(widget, widget_index_of(slide_view->prev));
|
||||
slide_view_set_active_no_animate(widget, active);
|
||||
}
|
||||
} else if (slide_view->xoffset > 0 || slide_view->yoffset > 0) {
|
||||
active = widget_index_of(slide_view->next);
|
||||
active = active == slide_view->last_active ? active : slide_view->last_active;
|
||||
if (slide_view->remove_when_anim_done) {
|
||||
widget_destroy(slide_view->prev);
|
||||
slide_view_set_active_no_animate_impl(widget, widget_index_of(slide_view->next), TRUE);
|
||||
slide_view_set_active_no_animate_impl(widget, active, TRUE);
|
||||
} else {
|
||||
slide_view_set_active_no_animate(widget, widget_index_of(slide_view->next));
|
||||
slide_view_set_active_no_animate(widget, active);
|
||||
}
|
||||
}
|
||||
|
||||
@ -903,6 +908,7 @@ static ret_t slide_view_set_active_no_animate_impl(widget_t* widget, uint32_t ac
|
||||
|
||||
if (widget_dispatch(widget, (event_t*)&evt) != RET_STOP) {
|
||||
slide_view->active = active;
|
||||
slide_view->last_active = slide_view->active;
|
||||
evt.e.type = EVT_VALUE_CHANGED;
|
||||
widget_dispatch(widget, (event_t*)&evt);
|
||||
widget_dispatch_simple_event(widget, EVT_PAGE_CHANGED);
|
||||
@ -912,6 +918,7 @@ static ret_t slide_view_set_active_no_animate_impl(widget_t* widget, uint32_t ac
|
||||
slide_view_restore_target(widget);
|
||||
} else {
|
||||
slide_view->active = active;
|
||||
slide_view->last_active = slide_view->active;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
@ -928,8 +935,10 @@ static ret_t slide_view_set_active_animate(widget_t* widget, uint32_t active) {
|
||||
slide_view_t* slide_view = SLIDE_VIEW(widget);
|
||||
return_value_if_fail(slide_view != NULL, RET_BAD_PARAMS);
|
||||
if (slide_view->animating) {
|
||||
log_warn("slide_view is animating, so slide_view is busy!\r\n");
|
||||
return RET_BUSY;
|
||||
log_debug("slide_view is animating, so slide_view is busy!\r\n");
|
||||
log_debug("When the animation is played, the last active takes effect!\r\n");
|
||||
slide_view->last_active = active;
|
||||
return RET_OK;
|
||||
}
|
||||
old_active = slide_view->active;
|
||||
|
||||
|
@ -133,6 +133,7 @@ typedef struct _slide_view_t {
|
||||
int32_t xoffset;
|
||||
int32_t yoffset;
|
||||
uint32_t active;
|
||||
uint32_t last_active;
|
||||
uint32_t timer_id;
|
||||
bool_t dragged;
|
||||
bool_t pressed;
|
||||
|
Loading…
Reference in New Issue
Block a user