feat(animimg): add getter function for underlying animation (#6838)

This commit is contained in:
Lorenzo Arena
2024-09-20 10:50:17 +02:00
committed by GitHub
parent 8dea3225ff
commit ff3ffb8eeb
3 changed files with 25 additions and 0 deletions

View File

@@ -33,6 +33,16 @@ Image sources
To set the image in a state, use the
:cpp:expr:`lv_animimg_set_src(imagebutton, dsc[], num)`.
Using the inner animation
-------------------------
For more advanced use cases, the animation internally used by the image can be
retrieved using the :cpp:expr:`lv_animimg_get_anim(image)`. This way, the
:ref:`Animation <animations>` functions can be used, for example to
override the animation values using the
:cpp:expr:`lv_anim_set_values(anim, start, end)` or to set a callback
on the animation completed event.
.. _lv_animimg_events:
Events

View File

@@ -134,6 +134,13 @@ uint32_t lv_animimg_get_repeat_count(lv_obj_t * obj)
return lv_anim_get_repeat_count(&animimg->anim);
}
lv_anim_t * lv_animimg_get_anim(lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_animimg_t * animimg = (lv_animimg_t *)obj;
return &animimg->anim;
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -14,6 +14,7 @@ extern "C" {
* INCLUDES
*********************/
#include "../image/lv_image.h"
#include "../../misc/lv_types.h"
#if LV_USE_ANIMIMG != 0
@@ -112,6 +113,13 @@ uint32_t lv_animimg_get_duration(lv_obj_t * img);
*/
uint32_t lv_animimg_get_repeat_count(lv_obj_t * img);
/**
* Get the image animation underlying animation.
* @param img pointer to an animation image object
* @return the animation reference
*/
lv_anim_t * lv_animimg_get_anim(lv_obj_t * img);
#endif /*LV_USE_ANIMIMG*/
#ifdef __cplusplus