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

feat(anim): clarify reverse play in animation API (#7338)

This commit is contained in:
Victor Wheeler 2024-12-17 23:43:00 -07:00 committed by GitHub
parent e1f2b2e451
commit 64e01e5248
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 110 additions and 103 deletions

View File

@ -766,7 +766,7 @@ static void arc_anim(lv_obj_t * obj)
lv_anim_set_exec_cb(&a, arc_anim_cb);
lv_anim_set_values(&a, 0, 100);
lv_anim_set_duration(&a, t1);
lv_anim_set_playback_duration(&a, t2);
lv_anim_set_reverse_duration(&a, t2);
lv_anim_set_var(&a, obj);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
@ -787,7 +787,7 @@ static void scroll_anim(lv_obj_t * obj, int32_t y_max)
lv_anim_set_exec_cb(&a, scroll_anim_y_cb);
lv_anim_set_values(&a, 0, y_max);
lv_anim_set_duration(&a, t);
lv_anim_set_playback_duration(&a, t);
lv_anim_set_reverse_duration(&a, t);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
@ -808,7 +808,7 @@ static void fall_anim(lv_obj_t * obj, int32_t y_max)
lv_anim_set_exec_cb(&a, shake_anim_y_cb);
lv_anim_set_values(&a, 0, y_max);
lv_anim_set_duration(&a, t1);
lv_anim_set_playback_duration(&a, t2);
lv_anim_set_reverse_duration(&a, t2);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
}

View File

@ -360,7 +360,7 @@ void lv_demo_music_resume(void)
lv_anim_set_exec_cb(&a, spectrum_anim_cb);
lv_anim_set_var(&a, spectrum_obj);
lv_anim_set_duration(&a, ((spectrum_len - spectrum_i) * 1000) / 30);
lv_anim_set_playback_duration(&a, 0);
lv_anim_set_reverse_duration(&a, 0);
lv_anim_set_completed_cb(&a, spectrum_end_cb);
lv_anim_start(&a);

View File

@ -124,7 +124,7 @@ static void obj_test_task_cb(lv_timer_t * tmr)
lv_anim_set_duration(&a, LV_DEMO_STRESS_TIME_STEP * 2);
lv_anim_set_exec_cb(&a, set_width_anim);
lv_anim_set_values(&a, 100, 200);
lv_anim_set_playback_duration(&a, LV_DEMO_STRESS_TIME_STEP * 2);
lv_anim_set_reverse_duration(&a, LV_DEMO_STRESS_TIME_STEP * 2);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
@ -227,7 +227,7 @@ static void obj_test_task_cb(lv_timer_t * tmr)
lv_anim_set_values(&a, 180, 400);
lv_anim_set_duration(&a, LV_DEMO_STRESS_TIME_STEP * 2);
lv_anim_set_delay(&a, LV_DEMO_STRESS_TIME_STEP + 25);
lv_anim_set_playback_duration(&a, LV_DEMO_STRESS_TIME_STEP * 5);
lv_anim_set_reverse_duration(&a, LV_DEMO_STRESS_TIME_STEP * 5);
lv_anim_set_repeat_count(&a, 3);
lv_anim_set_exec_cb(&a, arc_set_end_angle_anim);
lv_anim_start(&a);

View File

@ -235,7 +235,7 @@ void lv_demo_widgets_start_slideshow(void)
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, scroll_anim_y_cb);
lv_anim_set_duration(&a, t);
lv_anim_set_playback_duration(&a, t);
lv_anim_set_reverse_duration(&a, t);
lv_anim_set_values(&a, 0, v);
lv_anim_set_var(&a, tab);
lv_anim_set_completed_cb(&a, slideshow_anim_completed_cb);
@ -701,7 +701,7 @@ static void analytics_create(lv_obj_t * parent)
lv_anim_set_exec_cb(&a, scale1_indic1_anim_cb);
lv_anim_set_var(&a, arc);
lv_anim_set_duration(&a, 4100);
lv_anim_set_playback_duration(&a, 2700);
lv_anim_set_reverse_duration(&a, 2700);
lv_anim_start(&a);
arc = lv_arc_create(scale1);
@ -717,7 +717,7 @@ static void analytics_create(lv_obj_t * parent)
lv_anim_set_exec_cb(&a, scale1_indic1_anim_cb);
lv_anim_set_var(&a, arc);
lv_anim_set_duration(&a, 2600);
lv_anim_set_playback_duration(&a, 3200);
lv_anim_set_reverse_duration(&a, 3200);
lv_anim_start(&a);
arc = lv_arc_create(scale1);
@ -733,7 +733,7 @@ static void analytics_create(lv_obj_t * parent)
lv_anim_set_exec_cb(&a, scale1_indic1_anim_cb);
lv_anim_set_var(&a, arc);
lv_anim_set_duration(&a, 2800);
lv_anim_set_playback_duration(&a, 1800);
lv_anim_set_reverse_duration(&a, 1800);
lv_anim_start(&a);
/*Scale 2*/
@ -864,7 +864,7 @@ static void analytics_create(lv_obj_t * parent)
lv_anim_set_exec_cb(&a, scale3_anim_cb);
lv_anim_set_var(&a, scale3);
lv_anim_set_duration(&a, 4100);
lv_anim_set_playback_duration(&a, 800);
lv_anim_set_reverse_duration(&a, 800);
lv_anim_start(&a);
lv_obj_align(scale3_mbps_label, LV_ALIGN_TOP_MID, 10, lv_pct(55));
@ -1673,7 +1673,7 @@ static void slideshow_anim_completed_cb(lv_anim_t * a_old)
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, scroll_anim_y_cb);
lv_anim_set_duration(&a, t);
lv_anim_set_playback_duration(&a, t);
lv_anim_set_reverse_duration(&a, t);
lv_anim_set_values(&a, 0, v);
lv_anim_set_var(&a, tab);
lv_anim_set_completed_cb(&a, slideshow_anim_completed_cb);

View File

@ -115,10 +115,10 @@ To create an Animation, start by creating an Animation *template* in an
lv_anim_set_start_cb(&anim_template, start_cb);
/* When ready, play the Animation backward with this duration. Default is 0 (disabled) [ms] */
lv_anim_set_playback_duration(&anim_template, time);
lv_anim_set_reverse_duration(&anim_template, time);
/* Delay before playback. Default is 0 (disabled) [ms] */
lv_anim_set_playback_delay(&anim_template, delay);
/* Delay before reverse play. Default is 0 (disabled) [ms] */
lv_anim_set_reverse_delay(&anim_template, delay);
/* Number of repetitions. Default is 1. LV_ANIM_REPEAT_INFINITE for infinite repetition */
lv_anim_set_repeat_count(&anim_template, cnt);
@ -201,10 +201,10 @@ Sometimes an Animation needs to play forward, and then play backwards, effective
reversing course, animating from the ``end`` value back to the ``start`` value again.
To do this, pass a non-zero value to this function to set the duration for the
reverse portion of the Animation:
:cpp:expr:`lv_anim_set_playback_duration(&anim_template, duration_in_ms)`.
:cpp:expr:`lv_anim_set_reverse_duration(&anim_template, duration_in_ms)`.
Optionally, you can also introduce a delay between the forward and backward
directions using :cpp:expr:`lv_anim_set_playback_delay(&anim_template, delay_in_ms)`
directions using :cpp:expr:`lv_anim_set_reverse_delay(&anim_template, delay_in_ms)`
@ -321,7 +321,7 @@ easy to create complex composite Animations. To create and use an Animation Tim
own copy of the contents of the Animation template, so if you do not need it
later, its contents do not need to be preserved after this call.
It supports forward and backward playback of the entire Animation group, using
It supports forward and reverse play of the entire Animation group, using
:cpp:expr:`lv_anim_timeline_set_reverse(timeline, reverse)`. Note that if you want to
play in reverse from the end of the Timeline, you need to call
:cpp:expr:`lv_anim_timeline_set_progress(timeline, LV_ANIM_TIMELINE_PROGRESS_MAX)`
@ -337,7 +337,7 @@ Call :cpp:expr:`lv_anim_timeline_set_progress(timeline, progress)` function to s
state of the Animation Timeline according to the ``progress`` value. ``progress`` is
a value between ``0`` and ``32767`` (:c:macro:`LV_ANIM_TIMELINE_PROGRESS_MAX`) to indicate the
proportion of the Timeline that has "played". Example: a ``progress`` value of
:cpp:expr:`LV_ANIM_TIMELINE_PROGRESS_MAX / 2` would set the Timeline playback to its
:cpp:expr:`LV_ANIM_TIMELINE_PROGRESS_MAX / 2` would set the Timeline play to its
half-way point.
Call :cpp:expr:`lv_anim_timeline_get_playtime(timeline)` function to get the total

View File

@ -28,8 +28,8 @@ void lv_example_anim_2(void)
lv_anim_set_var(&a, obj);
lv_anim_set_values(&a, 10, 50);
lv_anim_set_duration(&a, 1000);
lv_anim_set_playback_delay(&a, 100);
lv_anim_set_playback_duration(&a, 300);
lv_anim_set_reverse_delay(&a, 100);
lv_anim_set_reverse_duration(&a, 300);
lv_anim_set_repeat_delay(&a, 500);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);

View File

@ -39,12 +39,12 @@ void lv_example_flex_5(void)
lv_anim_set_exec_cb(&a, row_gap_anim);
lv_anim_set_duration(&a, 500);
lv_anim_set_playback_duration(&a, 500);
lv_anim_set_reverse_duration(&a, 500);
lv_anim_start(&a);
lv_anim_set_exec_cb(&a, column_gap_anim);
lv_anim_set_duration(&a, 3000);
lv_anim_set_playback_duration(&a, 3000);
lv_anim_set_reverse_duration(&a, 3000);
lv_anim_start(&a);
}

View File

@ -50,12 +50,12 @@ void lv_example_grid_5(void)
lv_anim_set_exec_cb(&a, row_gap_anim);
lv_anim_set_duration(&a, 500);
lv_anim_set_playback_duration(&a, 500);
lv_anim_set_reverse_duration(&a, 500);
lv_anim_start(&a);
lv_anim_set_exec_cb(&a, column_gap_anim);
lv_anim_set_duration(&a, 3000);
lv_anim_set_playback_duration(&a, 3000);
lv_anim_set_reverse_duration(&a, 3000);
lv_anim_start(&a);
}

View File

@ -29,7 +29,7 @@ void lv_example_bar_3(void)
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, set_temp);
lv_anim_set_duration(&a, 3000);
lv_anim_set_playback_duration(&a, 3000);
lv_anim_set_reverse_duration(&a, 3000);
lv_anim_set_var(&a, bar);
lv_anim_set_values(&a, -20, 40);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);

View File

@ -67,7 +67,7 @@ void lv_example_bar_6(void)
lv_anim_set_values(&a, 0, 100);
lv_anim_set_exec_cb(&a, set_value);
lv_anim_set_duration(&a, 4000);
lv_anim_set_playback_duration(&a, 4000);
lv_anim_set_reverse_duration(&a, 4000);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);

View File

@ -35,7 +35,7 @@ void lv_example_image_3(void)
lv_anim_set_exec_cb(&a, set_scale);
lv_anim_set_values(&a, 128, 256);
lv_anim_set_playback_duration(&a, 3000);
lv_anim_set_reverse_duration(&a, 3000);
lv_anim_start(&a);
}

View File

@ -32,7 +32,7 @@ void lv_example_image_4(void)
lv_anim_set_exec_cb(&a, ofs_y_anim);
lv_anim_set_values(&a, 0, 100);
lv_anim_set_duration(&a, 3000);
lv_anim_set_playback_duration(&a, 500);
lv_anim_set_reverse_duration(&a, 500);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);

View File

@ -54,7 +54,7 @@ void lv_example_scale_3(void)
lv_anim_set_exec_cb(&anim_scale_line, set_needle_line_value);
lv_anim_set_duration(&anim_scale_line, 1000);
lv_anim_set_repeat_count(&anim_scale_line, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_playback_duration(&anim_scale_line, 1000);
lv_anim_set_reverse_duration(&anim_scale_line, 1000);
lv_anim_set_values(&anim_scale_line, 10, 40);
lv_anim_start(&anim_scale_line);
@ -92,7 +92,7 @@ void lv_example_scale_3(void)
lv_anim_set_exec_cb(&anim_scale_img, set_needle_img_value);
lv_anim_set_duration(&anim_scale_img, 1000);
lv_anim_set_repeat_count(&anim_scale_img, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_playback_duration(&anim_scale_img, 1000);
lv_anim_set_reverse_duration(&anim_scale_img, 1000);
lv_anim_set_values(&anim_scale_img, 10, 40);
lv_anim_start(&anim_scale_img);
}

View File

@ -87,10 +87,16 @@ extern "C" {
#define LV_LABEL_LONG_SCROLL_CIRCULAR LV_LABEL_LONG_MODE_SCROLL_CIRCULAR
#define LV_LABEL_LONG_CLIP LV_LABEL_LONG_MODE_CLIP
#define lv_anim_set_playback_delay lv_anim_set_reverse_delay
#define lv_anim_set_playback_duration lv_anim_set_reverse_duration
/**********************
* DEPRECATED FUNCTIONS
**********************/
#define lv_anim_set_time lv_anim_set_duration
#define lv_anim_set_playback_time lv_anim_set_reverse_duration
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@ -137,7 +137,7 @@ uint32_t lv_anim_get_playtime(const lv_anim_t * a)
uint32_t repeat_cnt = a->repeat_cnt;
if(repeat_cnt < 1) repeat_cnt = 1;
uint32_t playtime = a->repeat_delay + a->duration + a->playback_delay + a->playback_duration;
uint32_t playtime = a->repeat_delay + a->duration + a->reverse_delay + a->reverse_duration;
playtime = playtime * repeat_cnt;
return playtime;
}
@ -408,19 +408,19 @@ void lv_anim_set_deleted_cb(lv_anim_t * a, lv_anim_deleted_cb_t deleted_cb)
a->deleted_cb = deleted_cb;
}
void lv_anim_set_playback_duration(lv_anim_t * a, uint32_t duration)
void lv_anim_set_reverse_duration(lv_anim_t * a, uint32_t duration)
{
a->playback_duration = duration;
a->reverse_duration = duration;
}
void lv_anim_set_playback_time(lv_anim_t * a, uint32_t duration)
void lv_anim_set_reverse_time(lv_anim_t * a, uint32_t duration)
{
lv_anim_set_playback_duration(a, duration);
lv_anim_set_reverse_duration(a, duration);
}
void lv_anim_set_playback_delay(lv_anim_t * a, uint32_t delay)
void lv_anim_set_reverse_delay(lv_anim_t * a, uint32_t delay)
{
a->playback_delay = delay;
a->reverse_delay = delay;
}
void lv_anim_set_repeat_count(lv_anim_t * a, uint32_t cnt)
@ -572,20 +572,20 @@ static void anim_timer(lv_timer_t * param)
/**
* Called when an animation is completed to do the necessary things
* e.g. repeat, play back, delete etc.
* e.g. repeat, play in reverse, delete etc.
* @param a pointer to an animation descriptor
*/
static void anim_completed_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_INFINITE) {
if(a->reverse_play_in_progress == 0 && a->repeat_cnt > 0 && a->repeat_cnt != LV_ANIM_REPEAT_INFINITE) {
a->repeat_cnt--;
}
/*Delete the animation if
* - 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_cnt == 0 && (a->playback_duration == 0 || a->playback_now == 1)) {
/*Delete animation if
* - no repeat left and no reverse play scheduled (simple one shot animation); or
* - no repeat, reverse play enabled (reverse_duration != 0) and reverse play is completed. */
if(a->repeat_cnt == 0 && (a->reverse_duration == 0 || a->reverse_play_in_progress == 1)) {
/*Delete the animation from the list.
* This way the `completed_cb` will see the animations like it's animation is already deleted*/
@ -604,21 +604,21 @@ static void anim_completed_handler(lv_anim_t * a)
int32_t over_time = 0;
if(a->act_time > a->duration) over_time = a->act_time - a->duration;
a->act_time = over_time - (int32_t)(a->repeat_delay);
/*Swap the start and end values in play back mode*/
if(a->playback_duration != 0) {
/*If now turning back use the 'playback_pause*/
if(a->playback_now == 0) a->act_time = -(int32_t)(a->playback_delay);
/*Swap start and end values in reverse-play mode*/
if(a->reverse_duration != 0) {
/*If now now playing in reverse, use the 'reverse_delay'.*/
if(a->reverse_play_in_progress == 0) a->act_time = -(int32_t)(a->reverse_delay);
/*Toggle the play back state*/
a->playback_now = a->playback_now == 0 ? 1 : 0;
/*Toggle reverse-play state*/
a->reverse_play_in_progress = a->reverse_play_in_progress == 0 ? 1 : 0;
/*Swap the start and end values*/
int32_t tmp = a->start_value;
a->start_value = a->end_value;
a->end_value = tmp;
/*Swap the time and playback_duration*/
/*Swap the time and reverse_duration*/
tmp = a->duration;
a->duration = a->playback_duration;
a->playback_duration = tmp;
a->duration = a->reverse_duration;
a->reverse_duration = tmp;
}
}
}
@ -663,8 +663,8 @@ static uint32_t convert_speed_to_time(uint32_t speed_or_time, int32_t start, int
static void resolve_time(lv_anim_t * a)
{
a->duration = convert_speed_to_time(a->duration, a->start_value, a->end_value);
a->playback_duration = convert_speed_to_time(a->playback_duration, a->start_value, a->end_value);
a->playback_delay = convert_speed_to_time(a->playback_delay, a->start_value, a->end_value);
a->reverse_duration = convert_speed_to_time(a->reverse_duration, a->start_value, a->end_value);
a->reverse_delay = convert_speed_to_time(a->reverse_delay, a->start_value, a->end_value);
a->repeat_delay = convert_speed_to_time(a->repeat_delay, a->start_value, a->end_value);
}

View File

@ -122,35 +122,36 @@ typedef struct {
/** Describes an animation*/
struct _lv_anim_t {
void * var; /**< Variable to animate*/
void * var; /**< Variable (Widget or other user-provided object) to animate */
lv_anim_exec_xcb_t exec_cb; /**< Function to execute to animate */
lv_anim_custom_exec_cb_t custom_exec_cb; /**< Function to execute to animate,
* same purpose as exec_cb but different parameters */
lv_anim_start_cb_t start_cb; /**< Call it when the animation is starts (considering `delay`)*/
lv_anim_completed_cb_t completed_cb; /**< Call it when the animation is fully completed*/
lv_anim_deleted_cb_t deleted_cb; /**< Call it when the animation is deleted*/
lv_anim_get_value_cb_t get_value_cb; /**< Get the current value in relative mode*/
lv_anim_start_cb_t start_cb; /**< Call it when animation is starts (considering `delay`) */
lv_anim_completed_cb_t completed_cb; /**< Call it when animation is fully completed */
lv_anim_deleted_cb_t deleted_cb; /**< Call it when animation is deleted */
lv_anim_get_value_cb_t get_value_cb; /**< Get current value in relative mode */
void * user_data; /**< Custom user data */
lv_anim_path_cb_t path_cb; /**< Describe the path (curve) of animations*/
lv_anim_path_cb_t path_cb; /**< Provides path (curve) of animation */
int32_t start_value; /**< Start value */
int32_t current_value; /**< Current value */
int32_t end_value; /**< End value */
int32_t duration; /**< 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_duration; /**< Duration of playback animation*/
uint32_t repeat_delay; /**< Wait before repeat*/
uint32_t repeat_cnt; /**< Repeat count for the animation*/
int32_t duration; /**< Animation duration in ms */
int32_t act_time; /**< Ms elapsed since animation started. Set to negative to make delay. */
uint32_t reverse_delay; /**< Wait (in ms) after forward play ends and before reverse play begins. */
uint32_t reverse_duration; /**< Reverse animation duration in ms */
uint32_t repeat_delay; /**< Wait before repeating */
uint32_t repeat_cnt; /**< Repeat count for animation */
union _lv_anim_path_para_t {
lv_anim_bezier3_para_t bezier3; /**< Parameter used when path is custom_bezier */
} parameter;
/* Animation system use these - user shouldn't set */
uint32_t last_timer_run;
uint8_t playback_now : 1; /**< Play back is in progress*/
uint8_t run_round : 1; /**< Indicates the animation has run in this round*/
uint8_t start_cb_called : 1; /**< Indicates that the `start_cb` was already called*/
uint8_t early_apply : 1; /**< 1: Apply start value immediately even is there is `delay`*/
uint8_t reverse_play_in_progress : 1; /**< Reverse play is in progress */
uint8_t run_round : 1; /**< When not equal to global.anim_state.anim_run_round (which toggles each
* time animation timer executes), indicates this animation needs to be updated. */
uint8_t start_cb_called : 1; /**< Indicates that `start_cb` was already called */
uint8_t early_apply : 1; /**< 1: Apply start value immediately even is there is a `delay` */
};
/**********************
@ -262,19 +263,19 @@ void lv_anim_set_deleted_cb(lv_anim_t * a, lv_anim_deleted_cb_t deleted_cb);
* @param a pointer to an initialized `lv_anim_t` variable
* @param duration duration of playback animation in milliseconds. 0: disable playback
*/
void lv_anim_set_playback_duration(lv_anim_t * a, uint32_t duration);
void lv_anim_set_reverse_duration(lv_anim_t * a, uint32_t duration);
/**
* Legacy `lv_anim_set_playback_time` API will be removed soon, use `lv_anim_set_playback_duration` instead.
* Legacy `lv_anim_set_reverse_time` API will be removed soon, use `lv_anim_set_reverse_duration` instead.
*/
void lv_anim_set_playback_time(lv_anim_t * a, uint32_t duration);
void lv_anim_set_reverse_time(lv_anim_t * a, uint32_t duration);
/**
* 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.
*/
void lv_anim_set_playback_delay(lv_anim_t * a, uint32_t delay);
void lv_anim_set_reverse_delay(lv_anim_t * a, uint32_t delay);
/**
* Make the animation repeat itself.

View File

@ -109,7 +109,7 @@ uint32_t lv_anim_timeline_start(lv_anim_timeline_t * at)
lv_anim_set_var(&a, at);
lv_anim_set_exec_cb(&a, anim_timeline_exec_cb);
lv_anim_set_values(&a, start, end);
lv_anim_set_time(&a, duration);
lv_anim_set_duration(&a, duration);
lv_anim_set_path_cb(&a, anim_timeline_path_cb);
lv_anim_set_repeat_count(&a, repeat);
lv_anim_set_repeat_delay(&a, delay);

View File

@ -92,7 +92,7 @@ void lv_animimg_set_duration(lv_obj_t * obj, uint32_t duration)
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_animimg_t * animimg = (lv_animimg_t *)obj;
lv_anim_set_duration(&animimg->anim, duration);
lv_anim_set_playback_delay(&animimg->anim, duration);
lv_anim_set_reverse_delay(&animimg->anim, duration);
}
void lv_animimg_set_repeat_count(lv_obj_t * obj, uint32_t count)

View File

@ -908,7 +908,7 @@ static void overwrite_anim_property(lv_anim_t * dest, const lv_anim_t * src, lv_
dest->repeat_cnt = src->repeat_cnt;
dest->repeat_delay = src->repeat_delay;
dest->completed_cb = src->completed_cb;
dest->playback_delay = src->playback_delay;
dest->reverse_delay = src->reverse_delay;
break;
case LV_LABEL_LONG_MODE_SCROLL_CIRCULAR:
/** If the dest animation is already running, overwrite is not allowed */
@ -961,8 +961,8 @@ static void lv_label_refr_text(lv_obj_t * obj)
lv_anim_init(&a);
lv_anim_set_var(&a, obj);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_playback_delay(&a, LV_LABEL_SCROLL_DELAY);
lv_anim_set_repeat_delay(&a, a.playback_delay);
lv_anim_set_reverse_delay(&a, LV_LABEL_SCROLL_DELAY);
lv_anim_set_repeat_delay(&a, a.reverse_delay);
bool hor_anim = false;
if(size.x > lv_area_get_width(&txt_coords)) {
@ -992,16 +992,16 @@ static void lv_label_refr_text(lv_obj_t * obj)
lv_anim_t * anim_cur = lv_anim_get(obj, set_ofs_x_anim);
int32_t act_time = 0;
bool playback_now = false;
bool reverse_play_in_progress = false;
if(anim_cur) {
act_time = anim_cur->act_time;
playback_now = anim_cur->playback_now;
reverse_play_in_progress = anim_cur->reverse_play_in_progress;
}
if(act_time < a.duration) {
a.act_time = act_time; /*To keep the old position*/
a.early_apply = 0;
if(playback_now) {
a.playback_now = 1;
if(reverse_play_in_progress) {
a.reverse_play_in_progress = 1;
/*Swap the start and end values*/
int32_t tmp;
tmp = a.start_value;
@ -1011,7 +1011,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
}
lv_anim_set_duration(&a, anim_time);
lv_anim_set_playback_duration(&a, a.duration);
lv_anim_set_reverse_duration(&a, a.duration);
/*If a template animation exists, overwrite some property*/
if(anim_template)
@ -1031,16 +1031,16 @@ static void lv_label_refr_text(lv_obj_t * obj)
lv_anim_t * anim_cur = lv_anim_get(obj, set_ofs_y_anim);
int32_t act_time = 0;
bool playback_now = false;
bool reverse_play_in_progress = false;
if(anim_cur) {
act_time = anim_cur->act_time;
playback_now = anim_cur->playback_now;
reverse_play_in_progress = anim_cur->reverse_play_in_progress;
}
if(act_time < a.duration) {
a.act_time = act_time; /*To keep the old position*/
a.early_apply = 0;
if(playback_now) {
a.playback_now = 1;
if(reverse_play_in_progress) {
a.reverse_play_in_progress = 1;
/*Swap the start and end values*/
int32_t tmp;
tmp = a.start_value;
@ -1050,7 +1050,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
}
lv_anim_set_duration(&a, anim_time);
lv_anim_set_playback_duration(&a, a.duration);
lv_anim_set_reverse_duration(&a, a.duration);
/*If a template animation exists, overwrite some property*/
if(anim_template)

View File

@ -125,10 +125,10 @@ void lv_lottie_set_src_data(lv_obj_t * obj, const void * src, size_t src_size)
float f_total;
tvg_animation_get_total_frame(lottie->tvg_anim, &f_total);
lv_anim_set_time(lottie->anim, (int32_t)f_total * 1000 / 60); /*60 FPS*/
lv_anim_set_duration(lottie->anim, (int32_t)f_total * 1000 / 60); /*60 FPS*/
lottie->anim->act_time = 0;
lottie->anim->end_value = (int32_t)f_total;
lottie->anim->playback_now = false;
lottie->anim->reverse_play_in_progress = false;
lottie_update(lottie, 0); /*Render immediately*/
}
@ -143,10 +143,10 @@ void lv_lottie_set_src_file(lv_obj_t * obj, const char * src)
float f_total;
tvg_animation_get_total_frame(lottie->tvg_anim, &f_total);
lv_anim_set_time(lottie->anim, (int32_t)f_total * 1000 / 60); /*60 FPS*/
lv_anim_set_duration(lottie->anim, (int32_t)f_total * 1000 / 60); /*60 FPS*/
lottie->anim->act_time = 0;
lottie->anim->end_value = (int32_t)f_total;
lottie->anim->playback_now = false;
lottie->anim->reverse_play_in_progress = false;
lottie_update(lottie, 0); /*Render immediately*/
}

View File

@ -1160,7 +1160,7 @@ static void start_cursor_blink(lv_obj_t * obj)
lv_anim_set_var(&a, ta);
lv_anim_set_exec_cb(&a, cursor_blink_anim_cb);
lv_anim_set_duration(&a, blink_time);
lv_anim_set_playback_duration(&a, blink_time);
lv_anim_set_reverse_duration(&a, 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_INFINITE);

View File

@ -29,7 +29,7 @@ void test_gradient_vertical_misalignment(void)
lv_anim_set_var(&a, obj);
lv_anim_set_exec_cb(&a, obj_set_height_helper);
lv_anim_set_duration(&a, 1000);
lv_anim_set_playback_duration(&a, 1000);
lv_anim_set_reverse_duration(&a, 1000);
lv_anim_set_repeat_count(&a, 100);
lv_anim_set_values(&a, 0, 300);
lv_anim_start(&a);