feat(anim): call start callback when animation restarts (#8403)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_VG_LITE - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_VG_LITE - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_VG_LITE - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
André Costa
2025-06-29 06:40:38 +02:00
committed by GitHub
parent 2bc3b082e4
commit b2bf3b7e34
3 changed files with 37 additions and 0 deletions
+1
View File
@@ -686,6 +686,7 @@ static void anim_completed_handler(lv_anim_t * a)
else {
/*Restart the animation. If the time is over a little compensate it.*/
int32_t over_time = 0;
a->start_cb_called = 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 start and end values in reverse-play mode*/
+27
View File
@@ -18,6 +18,11 @@ void tearDown(void)
lv_anim_enable_vsync_mode(false);
}
static void start_cb(lv_anim_t * anim)
{
(*(int *)lv_anim_get_user_data(anim))++;
}
static void exec_cb(void * var, int32_t v)
{
int32_t * var_i32 = var;
@@ -193,6 +198,28 @@ void test_scroll_anim_delete(void)
TEST_ASSERT_EQUAL(1, var);
}
void test_anim_start_cb_is_called(void)
{
int32_t var;
int start_cb_call_count = 0;
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, &var);
lv_anim_set_user_data(&a, (void *)&start_cb_call_count);
lv_anim_set_start_cb(&a, start_cb);
lv_anim_set_values(&a, 0, 100);
lv_anim_set_exec_cb(&a, exec_cb);
lv_anim_set_duration(&a, 100);
lv_anim_set_repeat_count(&a, 2);
lv_anim_start(&a);
lv_test_wait(50);
TEST_ASSERT_EQUAL(1, start_cb_call_count);
lv_test_wait(100);
TEST_ASSERT_EQUAL(2, start_cb_call_count);
lv_test_wait(50);
/*Delete the animation to avoid accessing it after return*/
lv_anim_delete(&var, exec_cb);
}
void test_anim_vsync_mode(void)
{
@@ -584,6 +584,7 @@ void test_anim_timeline_without_exec_cb_but_anim_start_cb_and_completed_cb(void)
anim_timeline = lv_anim_timeline_create();
lv_anim_timeline_add(anim_timeline, 200, &anim1);
lv_anim_timeline_set_progress(anim_timeline, 0);
lv_anim_timeline_set_repeat_count(anim_timeline, 2);
lv_anim_timeline_start(anim_timeline);
lv_refr_now(NULL);
@@ -605,6 +606,14 @@ void test_anim_timeline_without_exec_cb_but_anim_start_cb_and_completed_cb(void)
lv_test_wait(300); /*Now we are at 520ms */
TEST_ASSERT_EQUAL(1, anim1_start_called);
TEST_ASSERT_EQUAL(1, anim1_completed_called);
lv_test_wait(200); /*Now we are at 720ms */
TEST_ASSERT_EQUAL(2, anim1_start_called);
TEST_ASSERT_EQUAL(1, anim1_completed_called);
lv_test_wait(300); /*Now we are at 1020ms */
TEST_ASSERT_EQUAL(2, anim1_start_called);
TEST_ASSERT_EQUAL(2, anim1_completed_called);
}
#endif