mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
anim: minor updates
This commit is contained in:
parent
b6a86f31d7
commit
5ebed4f24e
@ -96,11 +96,7 @@ void lv_anim_create(lv_anim_t * a)
|
||||
memcpy(new_anim, a, sizeof(lv_anim_t));
|
||||
|
||||
/*Set the start value*/
|
||||
if(new_anim->exec_cb != NULL) {
|
||||
/*Pass `new_anim` if `var` is not set*/
|
||||
if(a->var) new_anim->exec_cb(new_anim->var, new_anim->start);
|
||||
else new_anim->exec_cb(new_anim, new_anim->start);
|
||||
}
|
||||
if(new_anim->exec_cb) new_anim->exec_cb(new_anim->var, new_anim->start);
|
||||
|
||||
/* Creating an animation changed the linked list.
|
||||
* It's important if it happens in a ready callback. (see `anim_task`)*/
|
||||
@ -410,14 +406,7 @@ static void anim_task(lv_task_t * param)
|
||||
new_value = a->path_cb(a);
|
||||
|
||||
/*Apply the calculated value*/
|
||||
if(a->exec_cb != NULL) {
|
||||
/*Pass `a` as first parameter if `var` is not set*/
|
||||
if(a->var) {
|
||||
a->exec_cb(a->var, new_value);
|
||||
} else {
|
||||
a->exec_cb(a, new_value);
|
||||
}
|
||||
}
|
||||
if(a->exec_cb) a->exec_cb(a->var, new_value);
|
||||
|
||||
/*If the time is elapsed the animation is ready*/
|
||||
if(a->act_time >= a->time) {
|
||||
|
@ -106,7 +106,7 @@ void lv_anim_init(lv_anim_t * a);
|
||||
* LittelvGL's built-in functions can be used.
|
||||
* E.g. lv_obj_set_x
|
||||
*/
|
||||
static inline void lv_anim_set_var_and_cb(lv_anim_t * a, void * var, lv_anim_exec_cb_t exec_cb)
|
||||
static inline void lv_anim_set_exec_cb(lv_anim_t * a, void * var, lv_anim_exec_cb_t exec_cb)
|
||||
{
|
||||
a->var = var;
|
||||
a->exec_cb = exec_cb;
|
||||
@ -146,7 +146,7 @@ static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_a
|
||||
*/
|
||||
static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
|
||||
{
|
||||
a->var = NULL;
|
||||
a->var = a;
|
||||
a->exec_cb = (lv_anim_exec_cb_t)exec_cb;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user