improve hscrollable to support no widget animator

This commit is contained in:
lixianjing 2019-06-04 09:26:27 +08:00
parent 54dace018f
commit 98275f7bd1

View File

@ -24,7 +24,10 @@
#include "tkc/utils.h"
#include "base/hscrollable.h"
#include "base/widget_vtable.h"
#ifndef WITHOUT_WIDGET_ANIMATOR
#include "widget_animators/widget_animator_scroll.h"
#endif /*WITHOUT_WIDGET_ANIMATOR*/
static widget_t* hscrollable_get_widget(hscrollable_t* hscrollable) {
return hscrollable != NULL ? hscrollable->widget : NULL;
@ -103,6 +106,7 @@ ret_t hscrollable_scroll_to(hscrollable_t* hscrollable, int32_t xoffset_end, int
return RET_OK;
}
#ifndef WITHOUT_WIDGET_ANIMATOR
hscrollable->xoffset_end = xoffset_end;
xoffset_end = hscrollable->xoffset_end;
@ -112,6 +116,9 @@ ret_t hscrollable_scroll_to(hscrollable_t* hscrollable, int32_t xoffset_end, int
widget_animator_scroll_set_params(hscrollable->wa, xoffset, 0, xoffset_end, 0);
widget_animator_on(hscrollable->wa, EVT_ANIM_END, hscrollable_on_scroll_done, hscrollable);
widget_animator_start(hscrollable->wa);
#else
hscrollable->xoffset = xoffset_end;
#endif /*WITHOUT_WIDGET_ANIMATOR*/
return RET_OK;
}
@ -324,4 +331,4 @@ ret_t hscrollable_destroy(hscrollable_t* hscrollable) {
TKMEM_FREE(hscrollable);
return RET_OK;
}
}