1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

feat(obj) add lv_obj_del_delayed()

This commit is contained in:
Gabor Kiss-Vamosi 2021-06-12 08:02:19 +02:00
parent 6f37c4fc56
commit c6a2e15ec2
3 changed files with 21 additions and 0 deletions

View File

@ -121,6 +121,8 @@ This is useful e.g. if you want to delete the parent of an object in the child's
You can remove all the children of an object (but not the object itself) using `lv_obj_clean(obj)`.
You can use `lv_obj_del_delayed(obj, 1000)` to delete an object after some time. The delay is expressed in millliseconds.
## Screens

View File

@ -106,6 +106,18 @@ void lv_obj_clean(lv_obj_t * obj)
LV_LOG_TRACE("finished (delete %p)", obj)
}
void lv_obj_del_delayed(lv_obj_t * obj, uint32_t delay_ms)
{
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, obj);
lv_anim_set_exec_cb(&a, NULL);
lv_anim_set_time(&a, 1);
lv_anim_set_delay(&a, delay_ms);
lv_anim_set_ready_cb(&a, lv_obj_del_anim_ready_cb);
lv_anim_start(&a);
}
void lv_obj_del_anim_ready_cb(lv_anim_t * a)
{
lv_obj_del(a->var);

View File

@ -56,6 +56,13 @@ void lv_obj_del(struct _lv_obj_t * obj);
*/
void lv_obj_clean(struct _lv_obj_t * obj);
/**
* Delete an object after some delay
* @param obj pointer to an object
* @param delay_ms time to wait before delete in milliseconds
*/
void lv_obj_del_delayed(struct _lv_obj_t * obj, uint32_t delay_ms);
/**
* A function to be easily used in animation ready callback to delete an object when the animation is ready
* @param a pointer to the animation