-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
lv_lottie.h
117 lines (95 loc) · 2.98 KB
/
lv_lottie.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* @file lv_lottie.h
*
*/
#ifndef LV_LOTTIE_H
#define LV_LOTTIE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../misc/lv_types.h"
#if LV_USE_LOTTIE
/*Testing of dependencies*/
#if LV_USE_CANVAS == 0
#error "lv_lottie: lv_canvas is required. Enable it in lv_conf.h (LV_USE_CANVAS 1)"
#endif
#if LV_USE_THORVG == 0
#error "lv_lottie: ThorVG is required. Enable it in lv_conf.h (LV_USE_THORVG_INTERNAL/EXTERNAL 1)"
#endif
#include "../../widgets/canvas/lv_canvas.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
#ifndef __THORVG_CAPI_H__ /*To avoid redefinition of typedef warning*/
typedef struct _Tvg_Paint Tvg_Paint;
typedef struct _Tvg_Canvas Tvg_Canvas;
typedef struct _Tvg_Animation Tvg_Animation;
#endif
typedef struct {
lv_canvas_t canvas;
Tvg_Paint * tvg_paint;
Tvg_Canvas * tvg_canvas;
Tvg_Animation * tvg_anim;
lv_anim_t * anim;
int32_t last_rendered_time;
} lv_lottie_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a lottie animation
* @param parent pointer to the parent widget
* @return pointer to the created Lottie animation widget
*/
lv_obj_t * lv_lottie_create(lv_obj_t * parent);
/**
* Set a buffer for the animation. It also defines the size of the animation
* @param obj pointer to a lottie widget
* @param w width of the animation and buffer
* @param h height of the animation and buffer
* @param buf a static buffer with `width x height x 4` byte size
*/
void lv_lottie_set_buffer(lv_obj_t * obj, int32_t w, int32_t h, void * buf);
/**
* Set a draw buffer for the animation. It also defines the size of the animation
* @param obj pointer to a lottie widget
* @param draw_buf an initialized draw buffer with ARGB8888 color format
*/
void lv_lottie_set_draw_buf(lv_obj_t * obj, lv_draw_buf_t * draw_buf);
/**
* Set the source for the animation as an array
* @param obj pointer to a lottie widget
* @param src the lottie animation converted to an nul terminated array
* @param src_size size of the source array in bytes
*/
void lv_lottie_set_src_data(lv_obj_t * obj, const void * src, size_t src_size);
/**
* Set the source for the animation as a path.
* Lottie doesn't use LVGL's File System API.
* @param obj pointer to a lottie widget
* @param src path to a json file, e.g. "path/to/file.json"
*/
void lv_lottie_set_src_file(lv_obj_t * obj, const char * src);
/**
* Get the LVGL animation which controls the lottie animation
* @param obj pointer to a lottie widget
* @return the LVGL animation
*/
lv_anim_t * lv_lottie_get_anim(lv_obj_t * obj);
/**********************
* GLOBAL VARIABLES
**********************/
/**********************
* MACROS
**********************/
#endif /*LV_USE_LOTTIE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_LOTTIE_H*/