1 /**
2  * @file lv_anim_timeline.h
3  *
4  */
5 
6 #ifndef LV_ANIM_TIMELINE_H
7 #define LV_ANIM_TIMELINE_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "lv_anim.h"
17 
18 /*********************
19  *      DEFINES
20  *********************/
21 
22 #define LV_ANIM_TIMELINE_PROGRESS_MAX 0xFFFF
23 
24 /**********************
25  *      TYPEDEFS
26  **********************/
27 
28 typedef struct _lv_anim_timeline_t lv_anim_timeline_t;
29 
30 /**********************
31 * GLOBAL PROTOTYPES
32 **********************/
33 
34 /**
35  * Create an animation timeline.
36  * @return pointer to the animation timeline.
37  */
38 lv_anim_timeline_t * lv_anim_timeline_create(void);
39 
40 /**
41  * Delete animation timeline.
42  * @param at    pointer to the animation timeline.
43  */
44 void lv_anim_timeline_delete(lv_anim_timeline_t * at);
45 
46 /**
47  * Add animation to the animation timeline.
48  * @param at            pointer to the animation timeline.
49  * @param start_time    the time the animation started on the timeline, note that start_time will override the value of delay.
50  * @param a             pointer to an animation.
51  */
52 void lv_anim_timeline_add(lv_anim_timeline_t * at, uint32_t start_time, const lv_anim_t * a);
53 
54 /**
55  * Start the animation timeline.
56  * @param at    pointer to the animation timeline.
57  * @return total time spent in animation timeline.
58  */
59 uint32_t lv_anim_timeline_start(lv_anim_timeline_t * at);
60 
61 /**
62  * Pause the animation timeline.
63  * @param at    pointer to the animation timeline.
64  */
65 void lv_anim_timeline_pause(lv_anim_timeline_t * at);
66 
67 /**
68  * Set the playback direction of the animation timeline.
69  * @param at        pointer to the animation timeline.
70  * @param reverse   whether to play in reverse.
71  */
72 void lv_anim_timeline_set_reverse(lv_anim_timeline_t * at, bool reverse);
73 
74 /**
75  * Make the animation timeline repeat itself.
76  * @param at        pointer to the animation timeline.
77  * @param cnt       repeat count or `LV_ANIM_REPEAT_INFINITE` for infinite repetition. 0: to disable repetition.
78  */
79 void lv_anim_timeline_set_repeat_count(lv_anim_timeline_t * at, uint32_t cnt);
80 
81 /**
82  * Set a delay before repeating the animation timeline.
83  * @param at        pointer to the animation timeline.
84  * @param delay     delay in milliseconds before repeating the animation timeline.
85  */
86 void lv_anim_timeline_set_repeat_delay(lv_anim_timeline_t * at, uint32_t delay);
87 
88 /**
89  * Set the progress of the animation timeline.
90  * @param at        pointer to the animation timeline.
91  * @param progress  set value 0~65535 to map 0~100% animation progress.
92  */
93 void lv_anim_timeline_set_progress(lv_anim_timeline_t * at, uint16_t progress);
94 
95 /**
96  * Get the time used to play the animation timeline.
97  * @param at    pointer to the animation timeline.
98  * @return total time spent in animation timeline.
99  */
100 uint32_t lv_anim_timeline_get_playtime(lv_anim_timeline_t * at);
101 
102 /**
103  * Get whether the animation timeline is played in reverse.
104  * @param at    pointer to the animation timeline.
105  * @return return true if it is reverse playback.
106  */
107 bool lv_anim_timeline_get_reverse(lv_anim_timeline_t * at);
108 
109 /**
110  * Get the progress of the animation timeline.
111  * @param at    pointer to the animation timeline.
112  * @return return value 0~65535 to map 0~100% animation progress.
113  */
114 uint16_t lv_anim_timeline_get_progress(lv_anim_timeline_t * at);
115 
116 /**
117  * Get repeat count of the animation timeline.
118  * @param at    pointer to the animation timeline.
119  */
120 uint32_t lv_anim_timeline_get_repeat_count(lv_anim_timeline_t * at);
121 
122 /**
123  * Get repeat delay of the animation timeline.
124  * @param at    pointer to the animation timeline.
125  */
126 uint32_t lv_anim_timeline_get_repeat_delay(lv_anim_timeline_t * at);
127 
128 /**********************
129  *      MACROS
130  **********************/
131 
132 #ifdef __cplusplus
133 } /*extern "C"*/
134 #endif
135 
136 #endif /*LV_ANIM_TIMELINE_H*/
137