fix(anim) and improvement (#2738)

* fix(anim): fix the callback type error of lv_anim_set_start_cb

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

* feat(anim): add lv_anim_custom_get which paired with lv_anim_get

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2021-10-29 03:22:41 -05:00
committed by GitHub
parent 6df51225c2
commit 3d0a21e8c4

View File

@@ -196,7 +196,7 @@ static inline void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb)
* @param a pointer to an initialized `lv_anim_t` variable
* @param start_cb a function call when the animation starts
*/
static inline void lv_anim_set_start_cb(lv_anim_t * a, lv_anim_ready_cb_t start_cb)
static inline void lv_anim_set_start_cb(lv_anim_t * a, lv_anim_start_cb_t start_cb)
{
a->start_cb = start_cb;
}
@@ -351,6 +351,20 @@ static inline bool lv_anim_custom_del(lv_anim_t * a, lv_anim_custom_exec_cb_t ex
return lv_anim_del(a ? a->var : NULL, (lv_anim_exec_xcb_t)exec_cb);
}
/**
* Get the animation of a variable and its `exec_cb`.
* This function exists because it's logical that all anim. functions receives an
* `lv_anim_t` as their first parameter. It's not practical in C but might make
* the API more consequent and makes easier to generate bindings.
* @param a pointer to an animation.
* @param exec_cb a function pointer which is animating 'var', or NULL to return first matching 'var'
* @return pointer to the animation.
*/
static inline lv_anim_t * lv_anim_custom_get(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
{
return lv_anim_get(a ? a->var : NULL, (lv_anim_exec_xcb_t)exec_cb);
}
/**
* Get the number of currently running animations
* @return the number of running animations