change anim API and add repeat count
This commit is contained in:
@@ -1459,10 +1459,11 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
|
|||||||
t = t - ((obj->state_dsc.anim * t) / 255);
|
t = t - ((obj->state_dsc.anim * t) / 255);
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
lv_anim_init(&a);
|
lv_anim_init(&a);
|
||||||
lv_anim_set_exec_cb(&a, obj, obj_state_anim_cb);
|
lv_anim_set_var(&a, obj);
|
||||||
|
lv_anim_set_exec_cb(&a, obj_state_anim_cb);
|
||||||
lv_anim_set_values(&a, obj->state_dsc.anim, 255);
|
lv_anim_set_values(&a, obj->state_dsc.anim, 255);
|
||||||
lv_anim_set_time(&a, t, 0);
|
lv_anim_set_time(&a, t);
|
||||||
lv_anim_create(&a);
|
lv_anim_start(&a);
|
||||||
} else {
|
} else {
|
||||||
lv_obj_refresh_style(obj);
|
lv_obj_refresh_style(obj);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,12 +82,13 @@ void lv_anim_init(lv_anim_t * a)
|
|||||||
a->start = 0;
|
a->start = 0;
|
||||||
a->end = 100;
|
a->end = 100;
|
||||||
a->path_cb = lv_anim_path_linear;
|
a->path_cb = lv_anim_path_linear;
|
||||||
|
a->repeat_cnt = 1;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create an animation
|
* Create an animation
|
||||||
* @param a an initialized 'anim_t' variable. Not required after call.
|
* @param a an initialized 'anim_t' variable. Not required after call.
|
||||||
*/
|
*/
|
||||||
void lv_anim_create(lv_anim_t * a)
|
void lv_anim_start(lv_anim_t * a)
|
||||||
{
|
{
|
||||||
LV_LOG_TRACE("animation create started")
|
LV_LOG_TRACE("animation create started")
|
||||||
/* Do not let two animations for the same 'var' with the same 'fp'*/
|
/* Do not let two animations for the same 'var' with the same 'fp'*/
|
||||||
@@ -105,6 +106,7 @@ void lv_anim_create(lv_anim_t * a)
|
|||||||
|
|
||||||
/*Initialize the animation descriptor*/
|
/*Initialize the animation descriptor*/
|
||||||
a->playback_now = 0;
|
a->playback_now = 0;
|
||||||
|
a->time_orig = a->time;
|
||||||
memcpy(new_anim, a, sizeof(lv_anim_t));
|
memcpy(new_anim, a, sizeof(lv_anim_t));
|
||||||
|
|
||||||
/*Set the start value*/
|
/*Set the start value*/
|
||||||
@@ -455,11 +457,15 @@ static void anim_task(lv_task_t * param)
|
|||||||
* */
|
* */
|
||||||
static bool anim_ready_handler(lv_anim_t * a)
|
static bool anim_ready_handler(lv_anim_t * a)
|
||||||
{
|
{
|
||||||
|
/*In the end of a forward anim decrement repeat cnt.*/
|
||||||
|
if(a->playback_now == 0 && a->repeat_cnt > 0 && a->repeat_cnt != LV_ANIM_REPEAT_INFINIT) {
|
||||||
|
a->repeat_cnt--;
|
||||||
|
}
|
||||||
|
|
||||||
/*Delete the animation if
|
/*Delete the animation if
|
||||||
* - no repeat and no play back (simple one shot animation)
|
* - no repeat left and no play back (simple one shot animation)
|
||||||
* - no repeat, play back is enabled and play back is ready */
|
* - no repeat, play back is enabled and play back is ready */
|
||||||
if((a->repeat == 0 && a->playback == 0) || (a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) {
|
if(a->repeat_cnt == 0 && ((a->playback_time == 0) || (a->playback_time && a->playback_now == 1))) {
|
||||||
|
|
||||||
/*Create copy from the animation and delete the animation from the list.
|
/*Create copy from the animation and delete the animation from the list.
|
||||||
* This way the `ready_cb` will see the animations like it's animation is ready deleted*/
|
* This way the `ready_cb` will see the animations like it's animation is ready deleted*/
|
||||||
@@ -475,11 +481,11 @@ static bool anim_ready_handler(lv_anim_t * a)
|
|||||||
}
|
}
|
||||||
/*If the animation is not deleted then restart it*/
|
/*If the animation is not deleted then restart it*/
|
||||||
else {
|
else {
|
||||||
a->act_time = -a->repeat_pause; /*Restart the animation*/
|
a->act_time = -a->repeat_delay; /*Restart the animation*/
|
||||||
/*Swap the start and end values in play back mode*/
|
/*Swap the start and end values in play back mode*/
|
||||||
if(a->playback != 0) {
|
if(a->playback_time != 0) {
|
||||||
/*If now turning back use the 'playback_pause*/
|
/*If now turning back use the 'playback_pause*/
|
||||||
if(a->playback_now == 0) a->act_time = -a->playback_pause;
|
if(a->playback_now == 0) a->act_time = -a->playback_delay;
|
||||||
|
|
||||||
/*Toggle the play back state*/
|
/*Toggle the play back state*/
|
||||||
a->playback_now = a->playback_now == 0 ? 1 : 0;
|
a->playback_now = a->playback_now == 0 ? 1 : 0;
|
||||||
@@ -488,6 +494,8 @@ static bool anim_ready_handler(lv_anim_t * a)
|
|||||||
tmp = a->start;
|
tmp = a->start;
|
||||||
a->start = a->end;
|
a->start = a->end;
|
||||||
a->end = tmp;
|
a->end = tmp;
|
||||||
|
|
||||||
|
a->time = a->playback_now == 0 ? a->time_orig : a->playback_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ typedef lv_coord_t lv_anim_value_t;
|
|||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
|
|
||||||
|
#define LV_ANIM_REPEAT_INFINIT 0xFFFF
|
||||||
|
|
||||||
struct _lv_anim_t;
|
struct _lv_anim_t;
|
||||||
|
|
||||||
/** Generic prototype of "animator" functions.
|
/** Generic prototype of "animator" functions.
|
||||||
@@ -69,17 +71,18 @@ typedef struct _lv_anim_t
|
|||||||
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
|
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
|
||||||
int32_t start; /**< Start value*/
|
int32_t start; /**< Start value*/
|
||||||
int32_t end; /**< End value*/
|
int32_t end; /**< End value*/
|
||||||
uint16_t time; /**< Animation time in ms*/
|
uint32_t time; /**< Animation time in ms*/
|
||||||
int16_t act_time; /**< Current time in animation. Set to negative to make delay.*/
|
int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/
|
||||||
uint16_t playback_pause; /**< Wait before play back*/
|
uint32_t playback_delay; /**< Wait before play back*/
|
||||||
uint16_t repeat_pause; /**< Wait before repeat*/
|
uint32_t playback_time; /**< Duration of playback animation*/
|
||||||
|
uint32_t repeat_delay; /**< Wait before repeat*/
|
||||||
|
uint16_t repeat_cnt; /**< Repeat count for the animation*/
|
||||||
#if LV_USE_USER_DATA
|
#if LV_USE_USER_DATA
|
||||||
lv_anim_user_data_t user_data; /**< Custom user data*/
|
lv_anim_user_data_t user_data; /**< Custom user data*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t playback : 1; /**< When the animation is ready play it back*/
|
|
||||||
uint8_t repeat : 1; /**< Repeat the animation infinitely*/
|
|
||||||
/*Animation system use these - user shouldn't set*/
|
/*Animation system use these - user shouldn't set*/
|
||||||
|
uint32_t time_orig;
|
||||||
uint8_t playback_now : 1; /**< Play back is in progress*/
|
uint8_t playback_now : 1; /**< Play back is in progress*/
|
||||||
uint32_t has_run : 1; /**< Indicates the animation has run in this round*/
|
uint32_t has_run : 1; /**< Indicates the animation has run in this round*/
|
||||||
} lv_anim_t;
|
} lv_anim_t;
|
||||||
@@ -106,29 +109,45 @@ void lv_anim_core_init(void);
|
|||||||
void lv_anim_init(lv_anim_t * a);
|
void lv_anim_init(lv_anim_t * a);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a variable to animate function to execute on `var`
|
* Set a variable to animate
|
||||||
* @param a pointer to an initialized `lv_anim_t` variable
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
* @param var pointer to a variable to animate
|
* @param var pointer to a variable to animate
|
||||||
* @param exec_cb a function to execute.
|
*/
|
||||||
|
static inline void lv_anim_set_var(lv_anim_t * a, void * var)
|
||||||
|
{
|
||||||
|
a->var = var;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a function to animate `var`
|
||||||
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
|
* @param exec_cb a function to execute during animation
|
||||||
* LittelvGL's built-in functions can be used.
|
* LittelvGL's built-in functions can be used.
|
||||||
* E.g. lv_obj_set_x
|
* E.g. lv_obj_set_x
|
||||||
*/
|
*/
|
||||||
static inline void lv_anim_set_exec_cb(lv_anim_t * a, void * var, lv_anim_exec_xcb_t exec_cb)
|
static inline void lv_anim_set_exec_cb(lv_anim_t * a, lv_anim_exec_xcb_t exec_cb)
|
||||||
{
|
{
|
||||||
a->var = var;
|
|
||||||
a->exec_cb = exec_cb;
|
a->exec_cb = exec_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the duration and delay of an animation
|
* Set the duration of an animation
|
||||||
* @param a pointer to an initialized `lv_anim_t` variable
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
* @param duration duration of the animation in milliseconds
|
* @param duration duration of the animation in milliseconds
|
||||||
* @param delay delay before the animation in milliseconds
|
|
||||||
*/
|
*/
|
||||||
static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, int16_t delay)
|
static inline void lv_anim_set_time(lv_anim_t * a, uint32_t duration)
|
||||||
{
|
{
|
||||||
a->time = duration;
|
a->time = duration;
|
||||||
a->act_time = (int16_t)(-delay);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a delay before starting the animation
|
||||||
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
|
* @param delay delay before the animation in milliseconds
|
||||||
|
*/
|
||||||
|
static inline void lv_anim_set_delay(lv_anim_t * a, uint32_t delay)
|
||||||
|
{
|
||||||
|
a->act_time = (int32_t)(-delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,10 +163,11 @@ static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_a
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to `lv_anim_set_var_and_cb` but `lv_anim_custom_exec_cb_t` receives
|
* Similar to `lv_anim_set_exec_cb` but `lv_anim_custom_exec_cb_t` receives
|
||||||
* `lv_anim_t * ` as its first parameter instead of `void *`.
|
* `lv_anim_t * ` as its first parameter instead of `void *`.
|
||||||
* This function might be used when LittlevGL is binded to other languages because
|
* This function might be used when LittlevGL is binded to other languages because
|
||||||
* it's more consistent to have `lv_anim_t *` as first parameter.
|
* it's more consistent to have `lv_anim_t *` as first parameter.
|
||||||
|
* The variable to animate can be stored in the animation's `user_sata`
|
||||||
* @param a pointer to an initialized `lv_anim_t` variable
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
* @param exec_cb a function to execute.
|
* @param exec_cb a function to execute.
|
||||||
*/
|
*/
|
||||||
@@ -181,48 +201,48 @@ static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_
|
|||||||
/**
|
/**
|
||||||
* Make the animation to play back to when the forward direction is ready
|
* Make the animation to play back to when the forward direction is ready
|
||||||
* @param a pointer to an initialized `lv_anim_t` variable
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
* @param wait_time time in milliseconds to wait before starting the back direction
|
* @param time the duration of the playback animation in in milliseconds. 0: disable playback
|
||||||
*/
|
*/
|
||||||
static inline void lv_anim_set_playback(lv_anim_t * a, uint16_t wait_time)
|
static inline void lv_anim_set_playback_time(lv_anim_t * a, uint16_t time)
|
||||||
{
|
{
|
||||||
a->playback = 1;
|
a->playback_time = time;
|
||||||
a->playback_pause = wait_time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable playback. (Disabled after `lv_anim_init()`)
|
* Make the animation to play back to when the forward direction is ready
|
||||||
* @param a pointer to an initialized `lv_anim_t` variable
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
|
* @param delay delay in milliseconds before starting the playback animation.
|
||||||
*/
|
*/
|
||||||
static inline void lv_anim_clear_playback(lv_anim_t * a)
|
static inline void lv_anim_set_playback_delay(lv_anim_t * a, uint16_t delay)
|
||||||
{
|
{
|
||||||
a->playback = 0;
|
a->playback_delay = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the animation to start again when ready.
|
* Make the animation repeat itself.
|
||||||
* @param a pointer to an initialized `lv_anim_t` variable
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
* @param wait_time time in milliseconds to wait before starting the animation again
|
* @param cnt repeat count or `LV_ANIM_REPEAT_INFINITE` for infinite repetition. 0: to disable repetition.
|
||||||
*/
|
*/
|
||||||
static inline void lv_anim_set_repeat(lv_anim_t * a, uint16_t wait_time)
|
static inline void lv_anim_set_repeat_count(lv_anim_t * a, uint16_t cnt)
|
||||||
{
|
{
|
||||||
a->repeat = 1;
|
a->repeat_cnt = cnt;
|
||||||
a->repeat_pause = wait_time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable repeat. (Disabled after `lv_anim_init()`)
|
* Set a delay before repeating the animation.
|
||||||
* @param a pointer to an initialized `lv_anim_t` variable
|
* @param a pointer to an initialized `lv_anim_t` variable
|
||||||
|
* @param delay delay in milliseconds before repeating the animation.
|
||||||
*/
|
*/
|
||||||
static inline void lv_anim_clear_repeat(lv_anim_t * a)
|
static inline void lv_anim_set_repeat_delay(lv_anim_t * a, uint16_t delay)
|
||||||
{
|
{
|
||||||
a->repeat = 0;
|
a->repeat_delay = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an animation
|
* Create an animation
|
||||||
* @param a an initialized 'anim_t' variable. Not required after call.
|
* @param a an initialized 'anim_t' variable. Not required after call.
|
||||||
*/
|
*/
|
||||||
void lv_anim_create(lv_anim_t * a);
|
void lv_anim_start(lv_anim_t * a);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an animation of a variable with a given animator function
|
* Delete an animation of a variable with a given animator function
|
||||||
@@ -234,11 +254,11 @@ void lv_anim_create(lv_anim_t * a);
|
|||||||
bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb);
|
bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an aniamation by getting the animated variable from `a`.
|
* Delete an animation by getting the animated variable from `a`.
|
||||||
* Only animations with `exec_cb` will be deleted.
|
* Only animations with `exec_cb` will be deleted.
|
||||||
* This function exist becasue it's logical that all anim functions receives an
|
* This function exists because it's logical that all anim. functions receives an
|
||||||
* `lv_anim_t` as their first parameter. It's not practical in C but might makes
|
* `lv_anim_t` as their first parameter. It's not practical in C but might make
|
||||||
* the API more conequent and makes easier to genrate bindings.
|
* the API more consequent and makes easier to generate bindings.
|
||||||
* @param a pointer to an animation.
|
* @param a pointer to an animation.
|
||||||
* @param exec_cb a function pointer which is animating 'var',
|
* @param exec_cb a function pointer which is animating 'var',
|
||||||
* or NULL to ignore it and delete all the animations of 'var
|
* or NULL to ignore it and delete all the animations of 'var
|
||||||
|
|||||||
@@ -697,20 +697,13 @@ static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_
|
|||||||
lv_anim_del(anim_info, NULL);
|
lv_anim_del(anim_info, NULL);
|
||||||
|
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = anim_info;
|
lv_anim_init(&a);
|
||||||
a.start = LV_BAR_ANIM_STATE_START;
|
lv_anim_set_var(&a, anim_info);
|
||||||
a.end = LV_BAR_ANIM_STATE_END;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_bar_anim);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_bar_anim;
|
lv_anim_set_values(&a, LV_BAR_ANIM_STATE_START, LV_BAR_ANIM_STATE_END);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_ready_cb(&a, lv_bar_anim_ready);
|
||||||
a.ready_cb = lv_bar_anim_ready;
|
lv_anim_set_time(&a, ext->anim_time);
|
||||||
a.act_time = 0;
|
lv_anim_start(&a);
|
||||||
a.time = ext->anim_time;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
|
|
||||||
lv_anim_create(&a);
|
|
||||||
|
|
||||||
ext->cur_value = new_value;
|
ext->cur_value = new_value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -509,10 +509,11 @@ void lv_dropdown_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
|
|||||||
if(ext->dir != LV_DROPDOWN_DIR_UP) {
|
if(ext->dir != LV_DROPDOWN_DIR_UP) {
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
lv_anim_init(&a);
|
lv_anim_init(&a);
|
||||||
lv_anim_set_exec_cb(&a, ddlist, list_anim);
|
lv_anim_set_var(&a, ddlist);
|
||||||
|
lv_anim_set_exec_cb(&a, list_anim);
|
||||||
lv_anim_set_values(&a, 0, lv_obj_get_height(ext->page));
|
lv_anim_set_values(&a, 0, lv_obj_get_height(ext->page));
|
||||||
lv_anim_set_time(&a, ext->anim_time, 0);
|
lv_anim_set_time(&a, ext->anim_time);
|
||||||
lv_anim_create(&a);
|
lv_anim_start(&a);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -540,11 +541,12 @@ void lv_dropdown_close(lv_obj_t * ddlist, lv_anim_enable_t anim)
|
|||||||
if(ext->dir != LV_DROPDOWN_DIR_UP) {
|
if(ext->dir != LV_DROPDOWN_DIR_UP) {
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
lv_anim_init(&a);
|
lv_anim_init(&a);
|
||||||
lv_anim_set_exec_cb(&a, ddlist, list_anim);
|
lv_anim_set_var(&a, ddlist);
|
||||||
|
lv_anim_set_exec_cb(&a, list_anim);
|
||||||
lv_anim_set_values(&a, lv_obj_get_height(ext->page), 0);
|
lv_anim_set_values(&a, lv_obj_get_height(ext->page), 0);
|
||||||
lv_anim_set_time(&a, ext->anim_time, 0);
|
lv_anim_set_time(&a, ext->anim_time);
|
||||||
lv_anim_set_ready_cb(&a, close_anim_ready);
|
lv_anim_set_ready_cb(&a, close_anim_ready);
|
||||||
lv_anim_create(&a);
|
lv_anim_start(&a);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1204,26 +1204,22 @@ static void lv_label_refr_text(lv_obj_t * label)
|
|||||||
/*In roll mode keep the size but start offset animations*/
|
/*In roll mode keep the size but start offset animations*/
|
||||||
else if(ext->long_mode == LV_LABEL_LONG_SROLL) {
|
else if(ext->long_mode == LV_LABEL_LONG_SROLL) {
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t anim;
|
lv_anim_t a;
|
||||||
anim.var = label;
|
lv_anim_init(&a);
|
||||||
anim.repeat = 1;
|
lv_anim_set_var(&a, label);
|
||||||
anim.playback = 1;
|
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||||
anim.start = 0;
|
lv_anim_set_playback_delay(&a, (((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
|
||||||
anim.ready_cb = NULL;
|
|
||||||
anim.path_cb = lv_anim_path_linear;
|
|
||||||
anim.playback_pause =
|
|
||||||
(((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
|
|
||||||
ext->anim_speed) *
|
ext->anim_speed) *
|
||||||
LV_LABEL_WAIT_CHAR_COUNT;
|
LV_LABEL_WAIT_CHAR_COUNT);
|
||||||
anim.repeat_pause = anim.playback_pause;
|
lv_anim_set_repeat_delay(&a, a.playback_delay);
|
||||||
anim.act_time = -anim.playback_pause;
|
|
||||||
|
|
||||||
bool hor_anim = false;
|
bool hor_anim = false;
|
||||||
if(size.x > lv_area_get_width(&txt_coords)) {
|
if(size.x > lv_area_get_width(&txt_coords)) {
|
||||||
anim.end = lv_area_get_width(&txt_coords) - size.x;
|
lv_anim_set_values(&a, 0, lv_area_get_width(&txt_coords) - size.x);
|
||||||
anim.exec_cb = (lv_anim_exec_xcb_t)lv_label_set_offset_x;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_label_set_offset_x);
|
||||||
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
|
lv_anim_set_time(&a, lv_anim_speed_to_time(ext->anim_speed, a.start, a.end));
|
||||||
lv_anim_create(&anim);
|
lv_anim_set_playback_time(&a, a.time);
|
||||||
|
lv_anim_start(&a);
|
||||||
hor_anim = true;
|
hor_anim = true;
|
||||||
} else {
|
} else {
|
||||||
/*Delete the offset animation if not required*/
|
/*Delete the offset animation if not required*/
|
||||||
@@ -1232,11 +1228,11 @@ static void lv_label_refr_text(lv_obj_t * label)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(size.y > lv_area_get_height(&txt_coords) && hor_anim == false) {
|
if(size.y > lv_area_get_height(&txt_coords) && hor_anim == false) {
|
||||||
anim.end = lv_area_get_height(&txt_coords) - size.y - (lv_font_get_line_height(font));
|
lv_anim_set_values(&a, 0, lv_area_get_height(&txt_coords) - size.y - (lv_font_get_line_height(font)));
|
||||||
anim.exec_cb = (lv_anim_exec_xcb_t)lv_label_set_offset_y;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_label_set_offset_y);
|
||||||
|
lv_anim_set_time(&a, lv_anim_speed_to_time(ext->anim_speed, a.start, a.end));
|
||||||
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
|
lv_anim_set_playback_time(&a, a.time);
|
||||||
lv_anim_create(&anim);
|
lv_anim_start(&a);
|
||||||
} else {
|
} else {
|
||||||
/*Delete the offset animation if not required*/
|
/*Delete the offset animation if not required*/
|
||||||
lv_anim_del(label, (lv_anim_exec_xcb_t)lv_label_set_offset_y);
|
lv_anim_del(label, (lv_anim_exec_xcb_t)lv_label_set_offset_y);
|
||||||
@@ -1247,33 +1243,21 @@ static void lv_label_refr_text(lv_obj_t * label)
|
|||||||
/*In roll inf. mode keep the size but start offset animations*/
|
/*In roll inf. mode keep the size but start offset animations*/
|
||||||
else if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
|
else if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_label_align_t align = lv_label_get_align(label);
|
lv_anim_t a;
|
||||||
|
lv_anim_init(&a);
|
||||||
lv_anim_t anim;
|
lv_anim_set_var(&a, label);
|
||||||
anim.var = label;
|
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||||
anim.repeat = 1;
|
uint32_t delay = (((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
|
||||||
anim.playback = 0;
|
|
||||||
anim.act_time = -(((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
|
|
||||||
ext->anim_speed) *
|
ext->anim_speed) *
|
||||||
LV_LABEL_WAIT_CHAR_COUNT;
|
LV_LABEL_WAIT_CHAR_COUNT;
|
||||||
anim.ready_cb = NULL;
|
lv_anim_set_delay(&a, delay);
|
||||||
anim.path_cb = lv_anim_path_linear;
|
|
||||||
anim.playback_pause = 0;
|
|
||||||
anim.repeat_pause = 0;
|
|
||||||
|
|
||||||
bool hor_anim = false;
|
bool hor_anim = false;
|
||||||
if(size.x > lv_area_get_width(&txt_coords)) {
|
if(size.x > lv_area_get_width(&txt_coords)) {
|
||||||
if(align == LV_LABEL_ALIGN_RIGHT) {
|
lv_anim_set_values(&a, 0, -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT);
|
||||||
anim.end = 0;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_label_set_offset_x);
|
||||||
anim.start = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
|
lv_anim_set_time(&a, lv_anim_speed_to_time(ext->anim_speed, a.start, a.end));
|
||||||
} else {
|
lv_anim_start(&a);
|
||||||
anim.start = 0;
|
|
||||||
anim.end = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
anim.exec_cb = (lv_anim_exec_xcb_t)lv_label_set_offset_x;
|
|
||||||
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
|
|
||||||
lv_anim_create(&anim);
|
|
||||||
hor_anim = true;
|
hor_anim = true;
|
||||||
} else {
|
} else {
|
||||||
/*Delete the offset animation if not required*/
|
/*Delete the offset animation if not required*/
|
||||||
@@ -1282,17 +1266,10 @@ static void lv_label_refr_text(lv_obj_t * label)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(size.y > lv_area_get_height(&txt_coords) && hor_anim == false) {
|
if(size.y > lv_area_get_height(&txt_coords) && hor_anim == false) {
|
||||||
if(align == LV_LABEL_ALIGN_RIGHT) {
|
lv_anim_set_values(&a, 0, -size.y - (lv_font_get_line_height(font)));
|
||||||
anim.end = 0;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_label_set_offset_y);
|
||||||
anim.start = -size.y - (lv_font_get_line_height(font));
|
lv_anim_set_time(&a, lv_anim_speed_to_time(ext->anim_speed, a.start, a.end));
|
||||||
} else {
|
lv_anim_start(&a);
|
||||||
anim.start = 0;
|
|
||||||
anim.end = -size.y - (lv_font_get_line_height(font));
|
|
||||||
}
|
|
||||||
|
|
||||||
anim.exec_cb = (lv_anim_exec_xcb_t)lv_label_set_offset_y;
|
|
||||||
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
|
|
||||||
lv_anim_create(&anim);
|
|
||||||
} else {
|
} else {
|
||||||
/*Delete the offset animation if not required*/
|
/*Delete the offset animation if not required*/
|
||||||
lv_anim_del(label, (lv_anim_exec_xcb_t)lv_label_set_offset_y);
|
lv_anim_del(label, (lv_anim_exec_xcb_t)lv_label_set_offset_y);
|
||||||
|
|||||||
@@ -541,19 +541,12 @@ void lv_list_up(const lv_obj_t * list)
|
|||||||
} else {
|
} else {
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = scrl;
|
lv_anim_init(&a);
|
||||||
a.start = lv_obj_get_y(scrl);
|
lv_anim_set_var(&a, scrl);
|
||||||
a.end = new_y;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
lv_anim_set_values(&a, lv_obj_get_y(scrl), new_y);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_time(&a, LV_LIST_DEF_ANIM_TIME);
|
||||||
a.ready_cb = NULL;
|
lv_anim_start(&a);
|
||||||
a.act_time = 0;
|
|
||||||
a.time = LV_LIST_DEF_ANIM_TIME;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -585,19 +578,12 @@ void lv_list_down(const lv_obj_t * list)
|
|||||||
} else {
|
} else {
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = scrl;
|
lv_anim_init(&a);
|
||||||
a.start = lv_obj_get_y(scrl);
|
lv_anim_set_var(&a, scrl);
|
||||||
a.end = new_y;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
lv_anim_set_values(&a, lv_obj_get_y(scrl), new_y);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_time(&a, LV_LIST_DEF_ANIM_TIME);
|
||||||
a.ready_cb = NULL;
|
lv_anim_start(&a);
|
||||||
a.act_time = 0;
|
|
||||||
a.time = LV_LIST_DEF_ANIM_TIME;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -211,43 +211,32 @@ void lv_msgbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
|
|||||||
if(lv_msgbox_get_anim_time(mbox) != 0) {
|
if(lv_msgbox_get_anim_time(mbox) != 0) {
|
||||||
/*Add shrinking animations*/
|
/*Add shrinking animations*/
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = mbox;
|
lv_anim_init(&a);
|
||||||
a.start = lv_obj_get_height(mbox);
|
lv_anim_set_var(&a, mbox);
|
||||||
a.end = 0;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_height);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_height;
|
lv_anim_set_values(&a, lv_obj_get_height(mbox), 0);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_time(&a, lv_msgbox_get_anim_time(mbox));
|
||||||
a.ready_cb = NULL;
|
lv_anim_set_delay(&a, delay);
|
||||||
a.act_time = -delay;
|
lv_anim_start(&a);
|
||||||
a.time = lv_msgbox_get_anim_time(mbox);
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
|
|
||||||
a.start = lv_obj_get_width(mbox);
|
lv_anim_set_exec_cb(&a,(lv_anim_exec_xcb_t)lv_obj_set_width);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_width;
|
lv_anim_set_values(&a, lv_obj_get_width(mbox), 0);
|
||||||
a.ready_cb = lv_msgbox_close_ready_cb;
|
lv_anim_set_ready_cb(&a, lv_msgbox_close_ready_cb);
|
||||||
lv_anim_create(&a);
|
lv_anim_start(&a);
|
||||||
|
|
||||||
/*Disable fit to let shrinking work*/
|
/*Disable fit to let shrinking work*/
|
||||||
lv_cont_set_fit(mbox, LV_FIT_NONE);
|
lv_cont_set_fit(mbox, LV_FIT_NONE);
|
||||||
} else {
|
} else {
|
||||||
/*Create an animation to delete the mbox `delay` ms later*/
|
/*Create an animation to delete the mbox `delay` ms later*/
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = mbox;
|
lv_anim_init(&a);
|
||||||
a.start = 0;
|
lv_anim_set_var(&a, mbox);
|
||||||
a.end = 1;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)NULL);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)NULL;
|
lv_anim_set_values(&a, 0, 1);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_ready_cb(&a, lv_msgbox_close_ready_cb);
|
||||||
a.ready_cb = lv_msgbox_close_ready_cb;
|
lv_anim_set_time(&a, lv_msgbox_get_anim_time(mbox));
|
||||||
a.act_time = -delay;
|
lv_anim_set_delay(&a, delay);
|
||||||
a.time = 0;
|
lv_anim_start(&a);
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void)delay; /*Unused*/
|
(void)delay; /*Unused*/
|
||||||
|
|||||||
@@ -500,22 +500,16 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_
|
|||||||
} else {
|
} else {
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.act_time = 0;
|
lv_anim_init(&a);
|
||||||
a.start = lv_obj_get_y(ext->scrl);
|
lv_anim_set_var(&a, ext->scrl);
|
||||||
a.end = scrlable_y;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||||
a.time = lv_page_get_anim_time(page);
|
lv_anim_set_values(&a, lv_obj_get_y(ext->scrl), scrlable_y);
|
||||||
a.ready_cb = NULL;
|
lv_anim_set_time(&a, lv_page_get_anim_time(page));
|
||||||
a.playback = 0;
|
lv_anim_start(&a);
|
||||||
a.repeat = 0;
|
|
||||||
a.var = ext->scrl;
|
|
||||||
a.path_cb = lv_anim_path_linear;
|
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
|
|
||||||
a.start = lv_obj_get_x(ext->scrl);
|
lv_anim_set_values(&a, lv_obj_get_x(ext->scrl), scrlable_x);
|
||||||
a.end = scrlable_x;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
lv_anim_start(&a);
|
||||||
lv_anim_create(&a);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -531,19 +525,12 @@ void lv_page_scroll_hor(lv_obj_t * page, lv_coord_t dist)
|
|||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = scrl;
|
lv_anim_init(&a);
|
||||||
a.start = lv_obj_get_x(scrl);
|
lv_anim_set_var(&a, scrl);
|
||||||
a.end = a.start + dist;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
lv_anim_set_values(&a, lv_obj_get_x(scrl), lv_obj_get_x(scrl) + dist);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_time(&a, lv_page_get_anim_time(page));
|
||||||
a.ready_cb = NULL;
|
lv_anim_start(&a);
|
||||||
a.act_time = 0;
|
|
||||||
a.time = LV_PAGE_SCROLL_ANIM_TIME;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
#else
|
#else
|
||||||
lv_obj_set_x(scrl, lv_obj_get_x(scrl) + dist);
|
lv_obj_set_x(scrl, lv_obj_get_x(scrl) + dist);
|
||||||
#endif
|
#endif
|
||||||
@@ -560,19 +547,12 @@ void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist)
|
|||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = scrl;
|
lv_anim_init(&a);
|
||||||
a.start = lv_obj_get_y(scrl);
|
lv_anim_set_var(&a, scrl);
|
||||||
a.end = a.start + dist;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
lv_anim_set_values(&a, lv_obj_get_y(scrl), lv_obj_get_y(scrl) + dist);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_time(&a, lv_page_get_anim_time(page));
|
||||||
a.ready_cb = NULL;
|
lv_anim_start(&a);
|
||||||
a.act_time = 0;
|
|
||||||
a.time = LV_PAGE_SCROLL_ANIM_TIME;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
#else
|
#else
|
||||||
lv_obj_set_y(scrl, lv_obj_get_y(scrl) + dist);
|
lv_obj_set_y(scrl, lv_obj_get_y(scrl) + dist);
|
||||||
#endif
|
#endif
|
||||||
@@ -598,19 +578,15 @@ void lv_page_start_edge_flash(lv_obj_t * page, lv_page_edge_t edge)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = page;
|
lv_anim_init(&a);
|
||||||
a.start = 0;
|
lv_anim_set_var(&a, page);
|
||||||
a.end = LV_PAGE_END_FLASH_SIZE;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)edge_flash_anim);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)edge_flash_anim;
|
lv_anim_set_values(&a, 0, LV_PAGE_END_FLASH_SIZE);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_time(&a, lv_page_get_anim_time(page));
|
||||||
a.ready_cb = edge_flash_anim_end;
|
lv_anim_set_playback_time(&a, lv_page_get_anim_time(page));
|
||||||
a.act_time = 0;
|
lv_anim_set_playback_delay(&a, LV_PAGE_END_ANIM_WAIT_TIME);
|
||||||
a.time = LV_PAGE_END_ANIM_TIME;
|
lv_anim_set_ready_cb(&a, edge_flash_anim_end);
|
||||||
a.playback = 1;
|
lv_anim_start(&a);
|
||||||
a.playback_pause = LV_PAGE_END_ANIM_WAIT_TIME;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
|
|
||||||
switch(edge) {
|
switch(edge) {
|
||||||
case LV_PAGE_EDGE_BOTTOM: ext->edge_flash.bottom_ip = 1; break;
|
case LV_PAGE_EDGE_BOTTOM: ext->edge_flash.bottom_ip = 1; break;
|
||||||
|
|||||||
@@ -699,20 +699,14 @@ static void refr_position(lv_obj_t * roller, lv_anim_enable_t anim_en)
|
|||||||
lv_obj_set_y(roller_scrl, new_y);
|
lv_obj_set_y(roller_scrl, new_y);
|
||||||
} else {
|
} else {
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
|
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = roller_scrl;
|
lv_anim_init(&a);
|
||||||
a.start = lv_obj_get_y(roller_scrl);
|
lv_anim_set_var(&a, roller_scrl);
|
||||||
a.end = new_y;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
lv_anim_set_values(&a, lv_obj_get_y(roller_scrl), new_y);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_time(&a, anim_time);
|
||||||
a.ready_cb = scroll_anim_ready_cb;
|
lv_anim_start(&a);
|
||||||
a.act_time = 0;
|
|
||||||
a.time = anim_time;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,46 +169,22 @@ void lv_spinner_set_type(lv_obj_t * preload, lv_spinner_type_t type)
|
|||||||
case LV_SPINNER_TYPE_FILLSPIN_ARC: {
|
case LV_SPINNER_TYPE_FILLSPIN_ARC: {
|
||||||
ext->anim_type = LV_SPINNER_TYPE_FILLSPIN_ARC;
|
ext->anim_type = LV_SPINNER_TYPE_FILLSPIN_ARC;
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = preload;
|
lv_anim_init(&a);
|
||||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
|
lv_anim_set_var(&a, preload);
|
||||||
/* Clockwise */
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_spinner_anim);
|
||||||
a.start = 0;
|
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
|
||||||
a.end = 360;
|
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||||
} else {
|
lv_anim_set_time(&a, ext->time);
|
||||||
a.start = 360;
|
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) lv_anim_set_values(&a, 0, 360);
|
||||||
a.end = 0;
|
else lv_anim_set_values(&a, 360, 0);
|
||||||
}
|
lv_anim_start(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_spinner_spinner_anim;
|
|
||||||
a.path_cb = lv_anim_path_ease_in_out;
|
|
||||||
a.ready_cb = NULL;
|
|
||||||
a.act_time = 0;
|
|
||||||
a.time = ext->time;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 1;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
|
|
||||||
lv_anim_t b;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_set_arc_length);
|
||||||
b.var = preload;
|
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) lv_anim_set_values(&a, ext->arc_length, 360 - ext->arc_length);
|
||||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
|
else lv_anim_set_values(&a, 360 - ext->arc_length, ext->arc_length);
|
||||||
/* Clockwise */
|
|
||||||
b.start = ext->arc_length;
|
lv_anim_set_playback_time(&a, ext->time);
|
||||||
b.end = 360 - ext->arc_length;
|
lv_anim_start(&a);
|
||||||
} else {
|
|
||||||
b.start = 360 - ext->arc_length;
|
|
||||||
b.end = ext->arc_length;
|
|
||||||
}
|
|
||||||
b.exec_cb = (lv_anim_exec_xcb_t)lv_spinner_set_arc_length;
|
|
||||||
b.path_cb = lv_anim_path_ease_in_out;
|
|
||||||
b.ready_cb = NULL;
|
|
||||||
b.act_time = 0;
|
|
||||||
b.time = ext->time;
|
|
||||||
b.playback = 1;
|
|
||||||
b.playback_pause = 0;
|
|
||||||
b.repeat = 1;
|
|
||||||
b.repeat_pause = 0;
|
|
||||||
lv_anim_create(&b);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LV_SPINNER_TYPE_CONSTANT_ARC:
|
case LV_SPINNER_TYPE_CONSTANT_ARC:
|
||||||
@@ -216,26 +192,15 @@ void lv_spinner_set_type(lv_obj_t * preload, lv_spinner_type_t type)
|
|||||||
default: {
|
default: {
|
||||||
ext->anim_type = type;
|
ext->anim_type = type;
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = preload;
|
lv_anim_init(&a);
|
||||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
|
lv_anim_set_var(&a, preload);
|
||||||
/* Clockwise */
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_spinner_anim);
|
||||||
a.start = 0;
|
lv_anim_set_time(&a, ext->time);
|
||||||
a.end = 360;
|
lv_anim_set_path_cb(&a, (LV_SPINNER_TYPE_CONSTANT_ARC == type ? lv_anim_path_linear : lv_anim_path_ease_in_out));
|
||||||
} else {
|
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||||
a.start = 360;
|
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) lv_anim_set_values(&a, 0, 360);
|
||||||
a.end = 0;
|
else lv_anim_set_values(&a, 360, 0);
|
||||||
}
|
lv_anim_start(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_spinner_spinner_anim;
|
|
||||||
a.path_cb = (LV_SPINNER_TYPE_CONSTANT_ARC == type ?
|
|
||||||
lv_anim_path_linear : lv_anim_path_ease_in_out);
|
|
||||||
a.ready_cb = NULL;
|
|
||||||
a.act_time = 0;
|
|
||||||
a.time = ext->time;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 1;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -357,19 +357,12 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
|
|||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
else {
|
else {
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = lv_page_get_scrl(ext->content);
|
lv_anim_init(&a);
|
||||||
a.start = lv_obj_get_x(lv_page_get_scrl(ext->content));
|
lv_anim_set_var(&a, lv_page_get_scrl(ext->content));
|
||||||
a.end = cont_x;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
lv_anim_set_values(&a, lv_obj_get_x(lv_page_get_scrl(ext->content)), cont_x);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_time(&a, ext->anim_time);
|
||||||
a.ready_cb = NULL;
|
lv_anim_start(&a);
|
||||||
a.act_time = 0;
|
|
||||||
a.time = ext->anim_time;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -413,7 +406,9 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
|
|||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
else {
|
else {
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = ext->indic;
|
lv_anim_init(&a);
|
||||||
|
lv_anim_set_var(&a, ext->indic);
|
||||||
|
lv_anim_set_time(&a, ext->anim_time);
|
||||||
|
|
||||||
switch(ext->btns_pos) {
|
switch(ext->btns_pos) {
|
||||||
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
|
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
|
||||||
@@ -421,27 +416,17 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
|
|||||||
break;
|
break;
|
||||||
case LV_TABVIEW_BTNS_POS_TOP:
|
case LV_TABVIEW_BTNS_POS_TOP:
|
||||||
case LV_TABVIEW_BTNS_POS_BOTTOM:
|
case LV_TABVIEW_BTNS_POS_BOTTOM:
|
||||||
a.start = lv_obj_get_x(ext->indic);
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||||
a.end = indic_pos;
|
lv_anim_set_values(&a, lv_obj_get_x(ext->indic), indic_pos);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
|
||||||
break;
|
break;
|
||||||
case LV_TABVIEW_BTNS_POS_LEFT:
|
case LV_TABVIEW_BTNS_POS_LEFT:
|
||||||
case LV_TABVIEW_BTNS_POS_RIGHT:
|
case LV_TABVIEW_BTNS_POS_RIGHT:
|
||||||
a.start = lv_obj_get_y(ext->indic);
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||||
a.end = indic_pos;
|
lv_anim_set_values(&a, lv_obj_get_y(ext->indic), indic_pos);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_start(&a);
|
||||||
a.ready_cb = NULL;
|
|
||||||
a.act_time = 0;
|
|
||||||
a.time = ext->anim_time;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -193,19 +193,15 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
if(ext->cursor.blink_time) {
|
if(ext->cursor.blink_time) {
|
||||||
/*Create a cursor blinker animation*/
|
/*Create a cursor blinker animation*/
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = ta;
|
lv_anim_init(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)cursor_blink_anim;
|
lv_anim_set_var(&a, ta);
|
||||||
a.time = ext->cursor.blink_time;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
||||||
a.act_time = 0;
|
lv_anim_set_time(&a, ext->cursor.blink_time);
|
||||||
a.ready_cb = NULL;
|
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
|
||||||
a.start = 1;
|
lv_anim_set_values(&a, 0, 1);
|
||||||
a.end = 0;
|
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||||
a.repeat = 1;
|
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||||
a.repeat_pause = 0;
|
lv_anim_start(&a);
|
||||||
a.playback = 1;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.path_cb = lv_anim_path_step;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -279,19 +275,14 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
|
|||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
/*Auto hide characters*/
|
/*Auto hide characters*/
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = ta;
|
lv_anim_init(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)pwd_char_hider_anim;
|
lv_anim_set_var(&a, ta);
|
||||||
a.time = ext->pwd_show_time;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
|
||||||
a.act_time = 0;
|
lv_anim_set_time(&a, ext->pwd_show_time);
|
||||||
a.ready_cb = pwd_char_hider_anim_ready;
|
lv_anim_set_values(&a, 0, 1);
|
||||||
a.start = 0;
|
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||||
a.end = 1;
|
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
|
||||||
a.repeat = 0;
|
lv_anim_start(&a);
|
||||||
a.repeat_pause = 0;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.path_cb = lv_anim_path_step;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
pwd_char_hider(ta);
|
pwd_char_hider(ta);
|
||||||
@@ -363,19 +354,14 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt)
|
|||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
/*Auto hide characters*/
|
/*Auto hide characters*/
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = ta;
|
lv_anim_init(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)pwd_char_hider_anim;
|
lv_anim_set_var(&a, ta);
|
||||||
a.time = ext->pwd_show_time;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
|
||||||
a.act_time = 0;
|
lv_anim_set_time(&a, ext->pwd_show_time);
|
||||||
a.ready_cb = pwd_char_hider_anim_ready;
|
lv_anim_set_values(&a, 0, 1);
|
||||||
a.start = 0;
|
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||||
a.end = 1;
|
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
|
||||||
a.repeat = 0;
|
lv_anim_start(&a);
|
||||||
a.repeat_pause = 0;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.path_cb = lv_anim_path_step;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
#else
|
#else
|
||||||
pwd_char_hider(ta);
|
pwd_char_hider(ta);
|
||||||
#endif
|
#endif
|
||||||
@@ -514,19 +500,14 @@ void lv_textarea_set_text(lv_obj_t * ta, const char * txt)
|
|||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
/*Auto hide characters*/
|
/*Auto hide characters*/
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = ta;
|
lv_anim_init(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)pwd_char_hider_anim;
|
lv_anim_set_var(&a, ta);
|
||||||
a.time = ext->pwd_show_time;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
|
||||||
a.act_time = 0;
|
lv_anim_set_time(&a, ext->pwd_show_time);
|
||||||
a.ready_cb = pwd_char_hider_anim_ready;
|
lv_anim_set_values(&a, 0, 1);
|
||||||
a.start = 0;
|
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||||
a.end = 1;
|
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
|
||||||
a.repeat = 0;
|
lv_anim_start(&a);
|
||||||
a.repeat_pause = 0;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.path_cb = lv_anim_path_step;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
#else
|
#else
|
||||||
pwd_char_hider(ta);
|
pwd_char_hider(ta);
|
||||||
#endif
|
#endif
|
||||||
@@ -632,19 +613,15 @@ void lv_textarea_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
|||||||
if(ext->cursor.blink_time) {
|
if(ext->cursor.blink_time) {
|
||||||
/*Reset cursor blink animation*/
|
/*Reset cursor blink animation*/
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = ta;
|
lv_anim_init(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)cursor_blink_anim;
|
lv_anim_set_var(&a, ta);
|
||||||
a.time = ext->cursor.blink_time;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
||||||
a.act_time = 0;
|
lv_anim_set_time(&a, ext->cursor.blink_time);
|
||||||
a.ready_cb = NULL;
|
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
|
||||||
a.start = 1;
|
lv_anim_set_values(&a, 1, 0);
|
||||||
a.end = 0;
|
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||||
a.repeat = 1;
|
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||||
a.repeat_pause = 0;
|
lv_anim_start(&a);
|
||||||
a.playback = 1;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.path_cb = lv_anim_path_step;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -903,19 +880,14 @@ void lv_textarea_set_cursor_blink_time(lv_obj_t * ta, uint16_t time)
|
|||||||
if(ext->cursor.blink_time) {
|
if(ext->cursor.blink_time) {
|
||||||
/*Reset cursor blink animation*/
|
/*Reset cursor blink animation*/
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = ta;
|
lv_anim_init(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)cursor_blink_anim;
|
lv_anim_set_var(&a, ta);
|
||||||
a.time = ext->cursor.blink_time;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
||||||
a.act_time = 0;
|
lv_anim_set_time(&a, ext->cursor.blink_time);
|
||||||
a.ready_cb = NULL;
|
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
|
||||||
a.start = 1;
|
lv_anim_set_values(&a, 1, 0);
|
||||||
a.end = 0;
|
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||||
a.repeat = 1;
|
lv_anim_start(&a);
|
||||||
a.repeat_pause = 0;
|
|
||||||
a.playback = 1;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.path_cb = lv_anim_path_step;
|
|
||||||
lv_anim_create(&a);
|
|
||||||
} else {
|
} else {
|
||||||
lv_anim_del(ta, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
lv_anim_del(ta, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
||||||
ext->cursor.state = 1;
|
ext->cursor.state = 1;
|
||||||
|
|||||||
@@ -232,29 +232,24 @@ void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, l
|
|||||||
lv_coord_t x_act = lv_obj_get_x(scrl);
|
lv_coord_t x_act = lv_obj_get_x(scrl);
|
||||||
lv_coord_t y_act = lv_obj_get_y(scrl);
|
lv_coord_t y_act = lv_obj_get_y(scrl);
|
||||||
|
|
||||||
|
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
a.var = scrl;
|
lv_anim_init(&a);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
lv_anim_set_var(&a, scrl);
|
||||||
a.path_cb = lv_anim_path_linear;
|
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||||
a.ready_cb = NULL;
|
lv_anim_set_time(&a, ext->anim_time);
|
||||||
a.act_time = 0;
|
lv_anim_set_path_cb(&a, lv_anim_path_linear);
|
||||||
a.time = ext->anim_time;
|
|
||||||
a.playback = 0;
|
|
||||||
a.playback_pause = 0;
|
|
||||||
a.repeat = 0;
|
|
||||||
a.repeat_pause = 0;
|
|
||||||
|
|
||||||
if(x_coord != x_act) {
|
if(x_coord != x_act) {
|
||||||
a.start = x_act;
|
lv_anim_set_values(&a, x_act, x_coord);
|
||||||
a.end = x_coord;
|
lv_anim_start(&a);
|
||||||
lv_anim_create(&a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(y_coord != y_act) {
|
if(y_coord != y_act) {
|
||||||
a.start = y_act;
|
lv_anim_set_exec_cb(&a,(lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||||
a.end = y_coord;
|
lv_anim_set_values(&a, y_act, y_coord);
|
||||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
lv_anim_start(&a);
|
||||||
lv_anim_create(&a);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user