feat(obj) add lv_obj_del_delayed()
This commit is contained in:
@@ -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 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
|
## Screens
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,18 @@ void lv_obj_clean(lv_obj_t * obj)
|
|||||||
LV_LOG_TRACE("finished (delete %p)", 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)
|
void lv_obj_del_anim_ready_cb(lv_anim_t * a)
|
||||||
{
|
{
|
||||||
lv_obj_del(a->var);
|
lv_obj_del(a->var);
|
||||||
|
|||||||
@@ -56,6 +56,13 @@ void lv_obj_del(struct _lv_obj_t * obj);
|
|||||||
*/
|
*/
|
||||||
void lv_obj_clean(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
|
* 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
|
* @param a pointer to the animation
|
||||||
|
|||||||
Reference in New Issue
Block a user