Co-authored-by: qinshijing <qinshijing@xiaomi.com>
This commit is contained in:
@@ -48,6 +48,9 @@ lv_anim_set_path(&a, lv_anim_path_ease_in);
|
|||||||
/*Set a callback to indicate when the animation is ready (idle).*/
|
/*Set a callback to indicate when the animation is ready (idle).*/
|
||||||
lv_anim_set_ready_cb(&a, ready_cb);
|
lv_anim_set_ready_cb(&a, ready_cb);
|
||||||
|
|
||||||
|
/*Set a callback to indicate when the animation is deleted (idle).*/
|
||||||
|
lv_anim_set_deleted_cb(&a, deleted_cb);
|
||||||
|
|
||||||
/*Set a callback to indicate when the animation is started (after delay).*/
|
/*Set a callback to indicate when the animation is started (after delay).*/
|
||||||
lv_anim_set_start_cb(&a, start_cb);
|
lv_anim_set_start_cb(&a, start_cb);
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb)
|
|||||||
|
|
||||||
if((a->var == var || var == NULL) && (a->exec_cb == exec_cb || exec_cb == NULL)) {
|
if((a->var == var || var == NULL) && (a->exec_cb == exec_cb || exec_cb == NULL)) {
|
||||||
_lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a);
|
_lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a);
|
||||||
|
if(a->deleted_cb != NULL) a->deleted_cb(a);
|
||||||
lv_mem_free(a);
|
lv_mem_free(a);
|
||||||
anim_mark_list_change(); /*Read by `anim_timer`. It need to know if a delete occurred in
|
anim_mark_list_change(); /*Read by `anim_timer`. It need to know if a delete occurred in
|
||||||
the linked list*/
|
the linked list*/
|
||||||
@@ -434,6 +435,7 @@ static void anim_ready_handler(lv_anim_t * a)
|
|||||||
|
|
||||||
/*Call the callback function at the end*/
|
/*Call the callback function at the end*/
|
||||||
if(a->ready_cb != NULL) a->ready_cb(a);
|
if(a->ready_cb != NULL) a->ready_cb(a);
|
||||||
|
if(a->deleted_cb != NULL) a->deleted_cb(a);
|
||||||
lv_mem_free(a);
|
lv_mem_free(a);
|
||||||
}
|
}
|
||||||
/*If the animation is not deleted then restart it*/
|
/*If the animation is not deleted then restart it*/
|
||||||
|
|||||||
@@ -66,12 +66,16 @@ typedef void (*lv_anim_start_cb_t)(struct _lv_anim_t *);
|
|||||||
/** Callback used when the animation values are relative to get the current value*/
|
/** Callback used when the animation values are relative to get the current value*/
|
||||||
typedef int32_t (*lv_anim_get_value_cb_t)(struct _lv_anim_t *);
|
typedef int32_t (*lv_anim_get_value_cb_t)(struct _lv_anim_t *);
|
||||||
|
|
||||||
|
/** Callback used when the animation is deleted*/
|
||||||
|
typedef void (*lv_anim_deleted_cb_t)(struct _lv_anim_t *);
|
||||||
|
|
||||||
/** Describes an animation*/
|
/** Describes an animation*/
|
||||||
typedef struct _lv_anim_t {
|
typedef struct _lv_anim_t {
|
||||||
void * var; /**<Variable to animate*/
|
void * var; /**<Variable to animate*/
|
||||||
lv_anim_exec_xcb_t exec_cb; /**< Function to execute to animate*/
|
lv_anim_exec_xcb_t exec_cb; /**< Function to execute to animate*/
|
||||||
lv_anim_start_cb_t start_cb; /**< Call it when the animation is starts (considering `delay`)*/
|
lv_anim_start_cb_t start_cb; /**< Call it when the animation is starts (considering `delay`)*/
|
||||||
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
|
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
|
||||||
|
lv_anim_deleted_cb_t deleted_cb; /**< Call it when the animation is deleted*/
|
||||||
lv_anim_get_value_cb_t get_value_cb; /**< Get the current value in relative mode*/
|
lv_anim_get_value_cb_t get_value_cb; /**< Get the current value in relative mode*/
|
||||||
#if LV_USE_USER_DATA
|
#if LV_USE_USER_DATA
|
||||||
void * user_data; /**< Custom user data*/
|
void * user_data; /**< Custom user data*/
|
||||||
@@ -225,6 +229,16 @@ static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_
|
|||||||
a->ready_cb = ready_cb;
|
a->ready_cb = ready_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a function call when the animation is deleted.
|
||||||
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
|
* @param deleted_cb a function call when the animation is deleted
|
||||||
|
*/
|
||||||
|
static inline void lv_anim_set_deleted_cb(lv_anim_t * a, lv_anim_deleted_cb_t deleted_cb)
|
||||||
|
{
|
||||||
|
a->deleted_cb = deleted_cb;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the animation to play back to when the forward direction is ready
|
* Make the animation to play back to when the forward direction is ready
|
||||||
* @param a pointer to an initialized `lv_anim_t` variable
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
|
|||||||
Reference in New Issue
Block a user