mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
change anim API and add repeat count
This commit is contained in:
parent
7fa082b7b5
commit
0310f2d789
@ -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);
|
||||
lv_anim_t 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_time(&a, t, 0);
|
||||
lv_anim_create(&a);
|
||||
lv_anim_set_time(&a, t);
|
||||
lv_anim_start(&a);
|
||||
} else {
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
|
@ -82,12 +82,13 @@ void lv_anim_init(lv_anim_t * a)
|
||||
a->start = 0;
|
||||
a->end = 100;
|
||||
a->path_cb = lv_anim_path_linear;
|
||||
a->repeat_cnt = 1;
|
||||
}
|
||||
/**
|
||||
* Create an animation
|
||||
* @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")
|
||||
/* 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*/
|
||||
a->playback_now = 0;
|
||||
a->time_orig = a->time;
|
||||
memcpy(new_anim, a, sizeof(lv_anim_t));
|
||||
|
||||
/*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)
|
||||
{
|
||||
/*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
|
||||
* - 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 */
|
||||
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.
|
||||
* 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*/
|
||||
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*/
|
||||
if(a->playback != 0) {
|
||||
if(a->playback_time != 0) {
|
||||
/*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*/
|
||||
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;
|
||||
a->start = a->end;
|
||||
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
|
||||
|
||||
#define LV_ANIM_REPEAT_INFINIT 0xFFFF
|
||||
|
||||
struct _lv_anim_t;
|
||||
|
||||
/** 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*/
|
||||
int32_t start; /**< Start value*/
|
||||
int32_t end; /**< End value*/
|
||||
uint16_t time; /**< Animation time in ms*/
|
||||
int16_t act_time; /**< Current time in animation. Set to negative to make delay.*/
|
||||
uint16_t playback_pause; /**< Wait before play back*/
|
||||
uint16_t repeat_pause; /**< Wait before repeat*/
|
||||
uint32_t time; /**< Animation time in ms*/
|
||||
int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/
|
||||
uint32_t playback_delay; /**< Wait before play back*/
|
||||
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
|
||||
lv_anim_user_data_t user_data; /**< Custom user data*/
|
||||
#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*/
|
||||
uint32_t time_orig;
|
||||
uint8_t playback_now : 1; /**< Play back is in progress*/
|
||||
uint32_t has_run : 1; /**< Indicates the animation has run in this round*/
|
||||
} lv_anim_t;
|
||||
@ -106,29 +109,45 @@ void lv_anim_core_init(void);
|
||||
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 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.
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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->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 *`.
|
||||
* 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.
|
||||
* The variable to animate can be stored in the animation's `user_sata`
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @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
|
||||
* @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_pause = wait_time;
|
||||
a->playback_time = 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 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 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_pause = wait_time;
|
||||
a->repeat_cnt = cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
* @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
|
||||
@ -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);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* This function exist becasue 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
|
||||
* the API more conequent and makes easier to genrate bindings.
|
||||
* 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 make
|
||||
* the API more consequent and makes easier to generate bindings.
|
||||
* @param a pointer to an animation.
|
||||
* @param exec_cb a function pointer which is animating '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_t a;
|
||||
a.var = anim_info;
|
||||
a.start = LV_BAR_ANIM_STATE_START;
|
||||
a.end = LV_BAR_ANIM_STATE_END;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_bar_anim;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = lv_bar_anim_ready;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, anim_info);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_bar_anim);
|
||||
lv_anim_set_values(&a, LV_BAR_ANIM_STATE_START, LV_BAR_ANIM_STATE_END);
|
||||
lv_anim_set_ready_cb(&a, lv_bar_anim_ready);
|
||||
lv_anim_set_time(&a, ext->anim_time);
|
||||
lv_anim_start(&a);
|
||||
|
||||
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) {
|
||||
lv_anim_t 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_time(&a, ext->anim_time, 0);
|
||||
lv_anim_create(&a);
|
||||
lv_anim_set_time(&a, ext->anim_time);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
#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) {
|
||||
lv_anim_t 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_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_create(&a);
|
||||
lv_anim_start(&a);
|
||||
|
||||
}
|
||||
#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*/
|
||||
else if(ext->long_mode == LV_LABEL_LONG_SROLL) {
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t anim;
|
||||
anim.var = label;
|
||||
anim.repeat = 1;
|
||||
anim.playback = 1;
|
||||
anim.start = 0;
|
||||
anim.ready_cb = NULL;
|
||||
anim.path_cb = lv_anim_path_linear;
|
||||
anim.playback_pause =
|
||||
(((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, label);
|
||||
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||
lv_anim_set_playback_delay(&a, (((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
|
||||
ext->anim_speed) *
|
||||
LV_LABEL_WAIT_CHAR_COUNT;
|
||||
anim.repeat_pause = anim.playback_pause;
|
||||
anim.act_time = -anim.playback_pause;
|
||||
LV_LABEL_WAIT_CHAR_COUNT);
|
||||
lv_anim_set_repeat_delay(&a, a.playback_delay);
|
||||
|
||||
bool hor_anim = false;
|
||||
if(size.x > lv_area_get_width(&txt_coords)) {
|
||||
anim.end = lv_area_get_width(&txt_coords) - size.x;
|
||||
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);
|
||||
lv_anim_set_values(&a, 0, lv_area_get_width(&txt_coords) - size.x);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_label_set_offset_x);
|
||||
lv_anim_set_time(&a, lv_anim_speed_to_time(ext->anim_speed, a.start, a.end));
|
||||
lv_anim_set_playback_time(&a, a.time);
|
||||
lv_anim_start(&a);
|
||||
hor_anim = true;
|
||||
} else {
|
||||
/*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) {
|
||||
anim.end = 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;
|
||||
|
||||
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
|
||||
lv_anim_create(&anim);
|
||||
lv_anim_set_values(&a, 0, lv_area_get_height(&txt_coords) - size.y - (lv_font_get_line_height(font)));
|
||||
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));
|
||||
lv_anim_set_playback_time(&a, a.time);
|
||||
lv_anim_start(&a);
|
||||
} else {
|
||||
/*Delete the offset animation if not required*/
|
||||
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*/
|
||||
else if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
|
||||
#if LV_USE_ANIMATION
|
||||
lv_label_align_t align = lv_label_get_align(label);
|
||||
|
||||
lv_anim_t anim;
|
||||
anim.var = label;
|
||||
anim.repeat = 1;
|
||||
anim.playback = 0;
|
||||
anim.act_time = -(((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, label);
|
||||
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||
uint32_t delay = (((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
|
||||
ext->anim_speed) *
|
||||
LV_LABEL_WAIT_CHAR_COUNT;
|
||||
anim.ready_cb = NULL;
|
||||
anim.path_cb = lv_anim_path_linear;
|
||||
anim.playback_pause = 0;
|
||||
anim.repeat_pause = 0;
|
||||
lv_anim_set_delay(&a, delay);
|
||||
|
||||
bool hor_anim = false;
|
||||
if(size.x > lv_area_get_width(&txt_coords)) {
|
||||
if(align == LV_LABEL_ALIGN_RIGHT) {
|
||||
anim.end = 0;
|
||||
anim.start = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
|
||||
} else {
|
||||
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);
|
||||
lv_anim_set_values(&a, 0, -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_label_set_offset_x);
|
||||
lv_anim_set_time(&a, lv_anim_speed_to_time(ext->anim_speed, a.start, a.end));
|
||||
lv_anim_start(&a);
|
||||
hor_anim = true;
|
||||
} else {
|
||||
/*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(align == LV_LABEL_ALIGN_RIGHT) {
|
||||
anim.end = 0;
|
||||
anim.start = -size.y - (lv_font_get_line_height(font));
|
||||
} else {
|
||||
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);
|
||||
lv_anim_set_values(&a, 0, -size.y - (lv_font_get_line_height(font)));
|
||||
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));
|
||||
lv_anim_start(&a);
|
||||
} else {
|
||||
/*Delete the offset animation if not required*/
|
||||
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 {
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.var = scrl;
|
||||
a.start = lv_obj_get_y(scrl);
|
||||
a.end = new_y;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = NULL;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, scrl);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||
lv_anim_set_values(&a, lv_obj_get_y(scrl), new_y);
|
||||
lv_anim_set_time(&a, LV_LIST_DEF_ANIM_TIME);
|
||||
lv_anim_start(&a);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -585,19 +578,12 @@ void lv_list_down(const lv_obj_t * list)
|
||||
} else {
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.var = scrl;
|
||||
a.start = lv_obj_get_y(scrl);
|
||||
a.end = new_y;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = NULL;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, scrl);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||
lv_anim_set_values(&a, lv_obj_get_y(scrl), new_y);
|
||||
lv_anim_set_time(&a, LV_LIST_DEF_ANIM_TIME);
|
||||
lv_anim_start(&a);
|
||||
#endif
|
||||
}
|
||||
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) {
|
||||
/*Add shrinking animations*/
|
||||
lv_anim_t a;
|
||||
a.var = mbox;
|
||||
a.start = lv_obj_get_height(mbox);
|
||||
a.end = 0;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_height;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = NULL;
|
||||
a.act_time = -delay;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, mbox);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_height);
|
||||
lv_anim_set_values(&a, lv_obj_get_height(mbox), 0);
|
||||
lv_anim_set_time(&a, lv_msgbox_get_anim_time(mbox));
|
||||
lv_anim_set_delay(&a, delay);
|
||||
lv_anim_start(&a);
|
||||
|
||||
a.start = lv_obj_get_width(mbox);
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_width;
|
||||
a.ready_cb = lv_msgbox_close_ready_cb;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_set_exec_cb(&a,(lv_anim_exec_xcb_t)lv_obj_set_width);
|
||||
lv_anim_set_values(&a, lv_obj_get_width(mbox), 0);
|
||||
lv_anim_set_ready_cb(&a, lv_msgbox_close_ready_cb);
|
||||
lv_anim_start(&a);
|
||||
|
||||
/*Disable fit to let shrinking work*/
|
||||
lv_cont_set_fit(mbox, LV_FIT_NONE);
|
||||
} else {
|
||||
/*Create an animation to delete the mbox `delay` ms later*/
|
||||
lv_anim_t a;
|
||||
a.var = mbox;
|
||||
a.start = 0;
|
||||
a.end = 1;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)NULL;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = lv_msgbox_close_ready_cb;
|
||||
a.act_time = -delay;
|
||||
a.time = 0;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, mbox);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)NULL);
|
||||
lv_anim_set_values(&a, 0, 1);
|
||||
lv_anim_set_ready_cb(&a, lv_msgbox_close_ready_cb);
|
||||
lv_anim_set_time(&a, lv_msgbox_get_anim_time(mbox));
|
||||
lv_anim_set_delay(&a, delay);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
#else
|
||||
(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 {
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.act_time = 0;
|
||||
a.start = lv_obj_get_y(ext->scrl);
|
||||
a.end = scrlable_y;
|
||||
a.time = lv_page_get_anim_time(page);
|
||||
a.ready_cb = NULL;
|
||||
a.playback = 0;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, ext->scrl);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||
lv_anim_set_values(&a, lv_obj_get_y(ext->scrl), scrlable_y);
|
||||
lv_anim_set_time(&a, lv_page_get_anim_time(page));
|
||||
lv_anim_start(&a);
|
||||
|
||||
a.start = lv_obj_get_x(ext->scrl);
|
||||
a.end = scrlable_x;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_set_values(&a, lv_obj_get_x(ext->scrl), scrlable_x);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||
lv_anim_start(&a);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -531,19 +525,12 @@ void lv_page_scroll_hor(lv_obj_t * page, lv_coord_t dist)
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.var = scrl;
|
||||
a.start = lv_obj_get_x(scrl);
|
||||
a.end = a.start + dist;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = NULL;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, scrl);
|
||||
lv_anim_set_exec_cb(&a, (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);
|
||||
lv_anim_set_time(&a, lv_page_get_anim_time(page));
|
||||
lv_anim_start(&a);
|
||||
#else
|
||||
lv_obj_set_x(scrl, lv_obj_get_x(scrl) + dist);
|
||||
#endif
|
||||
@ -560,19 +547,12 @@ void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist)
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.var = scrl;
|
||||
a.start = lv_obj_get_y(scrl);
|
||||
a.end = a.start + dist;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = NULL;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, scrl);
|
||||
lv_anim_set_exec_cb(&a, (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);
|
||||
lv_anim_set_time(&a, lv_page_get_anim_time(page));
|
||||
lv_anim_start(&a);
|
||||
#else
|
||||
lv_obj_set_y(scrl, lv_obj_get_y(scrl) + dist);
|
||||
#endif
|
||||
@ -598,19 +578,15 @@ void lv_page_start_edge_flash(lv_obj_t * page, lv_page_edge_t edge)
|
||||
}
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = page;
|
||||
a.start = 0;
|
||||
a.end = LV_PAGE_END_FLASH_SIZE;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)edge_flash_anim;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = edge_flash_anim_end;
|
||||
a.act_time = 0;
|
||||
a.time = LV_PAGE_END_ANIM_TIME;
|
||||
a.playback = 1;
|
||||
a.playback_pause = LV_PAGE_END_ANIM_WAIT_TIME;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, page);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)edge_flash_anim);
|
||||
lv_anim_set_values(&a, 0, LV_PAGE_END_FLASH_SIZE);
|
||||
lv_anim_set_time(&a, lv_page_get_anim_time(page));
|
||||
lv_anim_set_playback_time(&a, lv_page_get_anim_time(page));
|
||||
lv_anim_set_playback_delay(&a, LV_PAGE_END_ANIM_WAIT_TIME);
|
||||
lv_anim_set_ready_cb(&a, edge_flash_anim_end);
|
||||
lv_anim_start(&a);
|
||||
|
||||
switch(edge) {
|
||||
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);
|
||||
} else {
|
||||
#if LV_USE_ANIMATION
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = roller_scrl;
|
||||
a.start = lv_obj_get_y(roller_scrl);
|
||||
a.end = new_y;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
a.ready_cb = scroll_anim_ready_cb;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, roller_scrl);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||
lv_anim_set_values(&a, lv_obj_get_y(roller_scrl), new_y);
|
||||
lv_anim_set_time(&a, anim_time);
|
||||
lv_anim_start(&a);
|
||||
#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: {
|
||||
ext->anim_type = LV_SPINNER_TYPE_FILLSPIN_ARC;
|
||||
lv_anim_t a;
|
||||
a.var = preload;
|
||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
|
||||
/* Clockwise */
|
||||
a.start = 0;
|
||||
a.end = 360;
|
||||
} else {
|
||||
a.start = 360;
|
||||
a.end = 0;
|
||||
}
|
||||
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_init(&a);
|
||||
lv_anim_set_var(&a, preload);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_spinner_anim);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
|
||||
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||
lv_anim_set_time(&a, ext->time);
|
||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) lv_anim_set_values(&a, 0, 360);
|
||||
else lv_anim_set_values(&a, 360, 0);
|
||||
lv_anim_start(&a);
|
||||
|
||||
lv_anim_t b;
|
||||
b.var = preload;
|
||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
|
||||
/* Clockwise */
|
||||
b.start = ext->arc_length;
|
||||
b.end = 360 - ext->arc_length;
|
||||
} 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);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_set_arc_length);
|
||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) lv_anim_set_values(&a, ext->arc_length, 360 - ext->arc_length);
|
||||
else lv_anim_set_values(&a, 360 - ext->arc_length, ext->arc_length);
|
||||
|
||||
lv_anim_set_playback_time(&a, ext->time);
|
||||
lv_anim_start(&a);
|
||||
break;
|
||||
}
|
||||
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: {
|
||||
ext->anim_type = type;
|
||||
lv_anim_t a;
|
||||
a.var = preload;
|
||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
|
||||
/* Clockwise */
|
||||
a.start = 0;
|
||||
a.end = 360;
|
||||
} else {
|
||||
a.start = 360;
|
||||
a.end = 0;
|
||||
}
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, preload);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_spinner_anim);
|
||||
lv_anim_set_time(&a, ext->time);
|
||||
lv_anim_set_path_cb(&a, (LV_SPINNER_TYPE_CONSTANT_ARC == type ? lv_anim_path_linear : lv_anim_path_ease_in_out));
|
||||
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) lv_anim_set_values(&a, 0, 360);
|
||||
else lv_anim_set_values(&a, 360, 0);
|
||||
lv_anim_start(&a);
|
||||
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
|
||||
else {
|
||||
lv_anim_t a;
|
||||
a.var = lv_page_get_scrl(ext->content);
|
||||
a.start = lv_obj_get_x(lv_page_get_scrl(ext->content));
|
||||
a.end = cont_x;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
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);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, lv_page_get_scrl(ext->content));
|
||||
lv_anim_set_exec_cb(&a, (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);
|
||||
lv_anim_set_time(&a, ext->anim_time);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
#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
|
||||
else {
|
||||
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) {
|
||||
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;
|
||||
case LV_TABVIEW_BTNS_POS_TOP:
|
||||
case LV_TABVIEW_BTNS_POS_BOTTOM:
|
||||
a.start = lv_obj_get_x(ext->indic);
|
||||
a.end = indic_pos;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||
lv_anim_set_values(&a, lv_obj_get_x(ext->indic), indic_pos);
|
||||
break;
|
||||
case LV_TABVIEW_BTNS_POS_LEFT:
|
||||
case LV_TABVIEW_BTNS_POS_RIGHT:
|
||||
a.start = lv_obj_get_y(ext->indic);
|
||||
a.end = indic_pos;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||
lv_anim_set_values(&a, lv_obj_get_y(ext->indic), indic_pos);
|
||||
break;
|
||||
}
|
||||
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
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);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
#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) {
|
||||
/*Create a cursor blinker animation*/
|
||||
lv_anim_t a;
|
||||
a.var = ta;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)cursor_blink_anim;
|
||||
a.time = ext->cursor.blink_time;
|
||||
a.act_time = 0;
|
||||
a.ready_cb = NULL;
|
||||
a.start = 1;
|
||||
a.end = 0;
|
||||
a.repeat = 1;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 1;
|
||||
a.playback_pause = 0;
|
||||
a.path_cb = lv_anim_path_step;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, ta);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
||||
lv_anim_set_time(&a, ext->cursor.blink_time);
|
||||
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
|
||||
lv_anim_set_values(&a, 0, 1);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -279,19 +275,14 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
|
||||
#if LV_USE_ANIMATION
|
||||
/*Auto hide characters*/
|
||||
lv_anim_t a;
|
||||
a.var = ta;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)pwd_char_hider_anim;
|
||||
a.time = ext->pwd_show_time;
|
||||
a.act_time = 0;
|
||||
a.ready_cb = pwd_char_hider_anim_ready;
|
||||
a.start = 0;
|
||||
a.end = 1;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.path_cb = lv_anim_path_step;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, ta);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
|
||||
lv_anim_set_time(&a, ext->pwd_show_time);
|
||||
lv_anim_set_values(&a, 0, 1);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
|
||||
lv_anim_start(&a);
|
||||
|
||||
#else
|
||||
pwd_char_hider(ta);
|
||||
@ -363,19 +354,14 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt)
|
||||
#if LV_USE_ANIMATION
|
||||
/*Auto hide characters*/
|
||||
lv_anim_t a;
|
||||
a.var = ta;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)pwd_char_hider_anim;
|
||||
a.time = ext->pwd_show_time;
|
||||
a.act_time = 0;
|
||||
a.ready_cb = pwd_char_hider_anim_ready;
|
||||
a.start = 0;
|
||||
a.end = 1;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.path_cb = lv_anim_path_step;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, ta);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
|
||||
lv_anim_set_time(&a, ext->pwd_show_time);
|
||||
lv_anim_set_values(&a, 0, 1);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
|
||||
lv_anim_start(&a);
|
||||
#else
|
||||
pwd_char_hider(ta);
|
||||
#endif
|
||||
@ -514,19 +500,14 @@ void lv_textarea_set_text(lv_obj_t * ta, const char * txt)
|
||||
#if LV_USE_ANIMATION
|
||||
/*Auto hide characters*/
|
||||
lv_anim_t a;
|
||||
a.var = ta;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)pwd_char_hider_anim;
|
||||
a.time = ext->pwd_show_time;
|
||||
a.act_time = 0;
|
||||
a.ready_cb = pwd_char_hider_anim_ready;
|
||||
a.start = 0;
|
||||
a.end = 1;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.path_cb = lv_anim_path_step;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, ta);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
|
||||
lv_anim_set_time(&a, ext->pwd_show_time);
|
||||
lv_anim_set_values(&a, 0, 1);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
|
||||
lv_anim_start(&a);
|
||||
#else
|
||||
pwd_char_hider(ta);
|
||||
#endif
|
||||
@ -632,19 +613,15 @@ void lv_textarea_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
if(ext->cursor.blink_time) {
|
||||
/*Reset cursor blink animation*/
|
||||
lv_anim_t a;
|
||||
a.var = ta;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)cursor_blink_anim;
|
||||
a.time = ext->cursor.blink_time;
|
||||
a.act_time = 0;
|
||||
a.ready_cb = NULL;
|
||||
a.start = 1;
|
||||
a.end = 0;
|
||||
a.repeat = 1;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 1;
|
||||
a.playback_pause = 0;
|
||||
a.path_cb = lv_anim_path_step;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, ta);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
||||
lv_anim_set_time(&a, ext->cursor.blink_time);
|
||||
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
|
||||
lv_anim_set_values(&a, 1, 0);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -903,19 +880,14 @@ void lv_textarea_set_cursor_blink_time(lv_obj_t * ta, uint16_t time)
|
||||
if(ext->cursor.blink_time) {
|
||||
/*Reset cursor blink animation*/
|
||||
lv_anim_t a;
|
||||
a.var = ta;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)cursor_blink_anim;
|
||||
a.time = ext->cursor.blink_time;
|
||||
a.act_time = 0;
|
||||
a.ready_cb = NULL;
|
||||
a.start = 1;
|
||||
a.end = 0;
|
||||
a.repeat = 1;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 1;
|
||||
a.playback_pause = 0;
|
||||
a.path_cb = lv_anim_path_step;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, ta);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
||||
lv_anim_set_time(&a, ext->cursor.blink_time);
|
||||
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
|
||||
lv_anim_set_values(&a, 1, 0);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_step);
|
||||
lv_anim_start(&a);
|
||||
} else {
|
||||
lv_anim_del(ta, (lv_anim_exec_xcb_t)cursor_blink_anim);
|
||||
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 y_act = lv_obj_get_y(scrl);
|
||||
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = scrl;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||
a.path_cb = lv_anim_path_linear;
|
||||
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_init(&a);
|
||||
lv_anim_set_var(&a, scrl);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||
lv_anim_set_time(&a, ext->anim_time);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_linear);
|
||||
|
||||
|
||||
if(x_coord != x_act) {
|
||||
a.start = x_act;
|
||||
a.end = x_coord;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_set_values(&a, x_act, x_coord);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
if(y_coord != y_act) {
|
||||
a.start = y_act;
|
||||
a.end = y_coord;
|
||||
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||
lv_anim_create(&a);
|
||||
lv_anim_set_exec_cb(&a,(lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||
lv_anim_set_values(&a, y_act, y_coord);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user