From 7007d9e5113e1d31e8634634df6ab071fd0435de Mon Sep 17 00:00:00 2001 From: xaowang96 Date: Fri, 24 Nov 2023 19:19:24 +0800 Subject: [PATCH] feat(gif): add API to pause/resume gif timer (#4854) Signed-off-by: wangxuedong --- src/libs/gif/lv_gif.c | 12 ++++++++++++ src/libs/gif/lv_gif.h | 31 ++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/libs/gif/lv_gif.c b/src/libs/gif/lv_gif.c index 447704341..dcde349ed 100644 --- a/src/libs/gif/lv_gif.c +++ b/src/libs/gif/lv_gif.c @@ -106,6 +106,18 @@ void lv_gif_restart(lv_obj_t * obj) lv_timer_reset(gifobj->timer); } +void lv_gif_pause(lv_obj_t * obj) +{ + lv_gif_t * gifobj = (lv_gif_t *) obj; + lv_timer_pause(gifobj->timer); +} + +void lv_gif_resume(lv_obj_t * obj) +{ + lv_gif_t * gifobj = (lv_gif_t *) obj; + lv_timer_resume(gifobj->timer); +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/libs/gif/lv_gif.h b/src/libs/gif/lv_gif.h index 56e5724b0..574118811 100644 --- a/src/libs/gif/lv_gif.h +++ b/src/libs/gif/lv_gif.h @@ -41,9 +41,38 @@ extern const lv_obj_class_t lv_gif_class; * GLOBAL PROTOTYPES **********************/ +/** + * Create a gif object + * @param parent pointer to an object, it will be the parent of the new gif. + * @return pointer to the gif obj + */ lv_obj_t * lv_gif_create(lv_obj_t * parent); + +/** + * Set the gif data to display on the object + * @param obj pointer to a gif object + * @param src 1) pointer to an ::lv_image_dsc_t descriptor (which contains gif raw data) or + * 2) path to a gif file (e.g. "S:/dir/anim.gif") + */ void lv_gif_set_src(lv_obj_t * obj, const void * src); -void lv_gif_restart(lv_obj_t * gif); + +/** + * Restart a gif animation. + * @param obj pointer to a gif obj + */ +void lv_gif_restart(lv_obj_t * obj); + +/** + * Pause a gif animation. + * @param obj pointer to a gif obj + */ +void lv_gif_pause(lv_obj_t * obj); + +/** + * Resume a gif animation. + * @param obj pointer to a gif obj + */ +void lv_gif_resume(lv_obj_t * obj); /********************** * MACROS