1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

add inline anim set functions

This commit is contained in:
Gabor Kiss-Vamosi 2019-05-15 06:15:12 +02:00
parent 72fb15c3fb
commit 5af101a1eb
5 changed files with 148 additions and 4 deletions

View File

@ -90,7 +90,7 @@ void lv_init(void)
lv_font_init();
#if LV_USE_ANIMATION
lv_anim_init();
lv_anim_core_init();
#endif
#if LV_USE_GROUP

View File

@ -318,7 +318,7 @@ void * lv_style_anim_create(lv_style_anim_t * anim)
a.playback_pause = anim->playback_pause;
a.repeat = anim->repeat;
a.repeat_pause = anim->repeat_pause;
a.user_data = anim->user_data;
lv_anim_create(&a);
return dsc;

View File

@ -147,6 +147,69 @@ a.ready_cb = NULL;
a.user_data = NULL;
lv_style_anim_create(&a);
*/
static inline void lv_style_anim_init(lv_style_anim_t * a)
{
memset(a, 0, sizeof(lv_style_anim_t));
}
static inline void lv_style_anim_set_styles(lv_style_anim_t * a, lv_style_t * to_anim, const lv_style_t * start, const lv_style_t * end)
{
a->style_anim = to_anim;
a->style_start = start;
a->style_end = end;
}
static inline void lv_style_anim_set_time(lv_style_anim_t * a, uint16_t duration, uint16_t delay)
{
a->time = duration;
a->act_time = -delay;
}
static inline void lv_style_anim_set_ready_cb(lv_style_anim_t * a, lv_anim_ready_cb_t ready_cb)
{
a->ready_cb = ready_cb;
}
static inline void lv_style_anim_set_playback(lv_style_anim_t * a, uint16_t wait_time)
{
a->playback = 1;
a->playback_pause = wait_time;
}
static inline void lv_style_anim_clear_playback(lv_style_anim_t * a)
{
a->playback = 0;
}
static inline void lv_style_anim_set_repeat(lv_style_anim_t * a, uint16_t wait_time)
{
a->repeat = 1;
a->repeat_pause = wait_time;
}
static inline void lv_style_anim_clear_repeat(lv_style_anim_t * a)
{
a->repeat = 0;
}
static inline void lv_style_anim_set_user_data(lv_style_anim_t * a, lv_anim_user_data_t user_data)
{
memcpy(&a->user_data, &user_data, sizeof(user_data));
}
static inline lv_anim_user_data_t lv_style_anim_get_user_data(lv_style_anim_t * a)
{
return a->user_data;
}
static inline lv_anim_user_data_t * lv_style_anim_get_user_data_ptr(lv_style_anim_t * a)
{
return &a->user_data;
}
#endif
/**********************

View File

@ -53,7 +53,7 @@ static bool anim_list_changed;
/**
* Init. the animation module
*/
void lv_anim_init(void)
void lv_anim_core_init(void)
{
lv_ll_init(&LV_GC_ROOT(_lv_anim_ll), sizeof(lv_anim_t));
last_task_run = lv_tick_get();

View File

@ -98,7 +98,88 @@ lv_anim_create(&a);
/**
* Init. the animation module
*/
void lv_anim_init(void);
void lv_anim_core_init(void);
/**
* Initialize an animation variable
* @param a pointer to animation
*/
static inline void lv_anim_init(lv_anim_t * a)
{
memset(a, 0, sizeof(lv_anim_t));
}
static inline void lv_anim_set_var(lv_anim_t * a, void * var)
{
a->var = var;
}
static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, uint16_t delay)
{
a->time = duration;
a->act_time = -delay;
}
static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_anim_value_t end)
{
a->start = start;
a->end = end;
}
static inline void lv_anim_set_exec_cb(lv_anim_t * a, lv_anim_exec_cb_t exec_cb)
{
a->exec_cb = exec_cb;
}
static inline void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb)
{
a->path_cb = path_cb;
}
static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_cb)
{
a->ready_cb = ready_cb;
}
static inline void lv_anim_set_playback(lv_anim_t * a, uint16_t wait_time)
{
a->playback = 1;
a->playback_pause = wait_time;
}
static inline void lv_anim_clear_playback(lv_anim_t * a)
{
a->playback = 0;
}
static inline void lv_anim_set_repeat(lv_anim_t * a, uint16_t wait_time)
{
a->repeat = 1;
a->repeat_pause = wait_time;
}
static inline void lv_anim_clear_repeat(lv_anim_t * a)
{
a->repeat = 0;
}
static inline void lv_anim_set_user_data(lv_anim_t * a, lv_anim_user_data_t user_data)
{
memcpy(&a->user_data, &user_data, sizeof(user_data));
}
static inline lv_anim_user_data_t lv_anim_get_user_data(lv_anim_t * a)
{
return a->user_data;
}
static inline lv_anim_user_data_t * lv_anim_get_user_data_ptr(lv_anim_t * a)
{
return &a->user_data;
}
/**
* Create an animation