mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
perf(anim_timeline) add lv_anim_timeline_stop() (#2411)
* add anim_timeline Signed-off-by: FASTSHIFT <vifextech@foxmail.com> * add anim_timeline Signed-off-by: FASTSHIFT <vifextech@foxmail.com> * add lv_anim_timeline.c to lv_misc.mk Signed-off-by: FASTSHIFT <vifextech@foxmail.com> * LV_ANIM_TIMELINE_END uses global variables to replace macros, lv_anim_timeline_set_progress() adds user_data, act_time uses int32_t type * solve the problem of uninitialized variable and act_time comparison * add LV_ANIM_TIMELINE_CUSTOM_EXEC option Signed-off-by: FASTSHIFT <vifextech@foxmail.com> * add LV_ANIM_TIMELINE_CUSTOM_EXEC in lv_conf_internal.h * redesign lv_anim_timeline Signed-off-by: FASTSHIFT <vifextech@foxmail.com> * add missing LV_USE_USER_DATA * remove set_progress, update doc * update workflow files * Remove lv_example_anim_timeline_2.c and LV_ANIM_TIMELINE_CUSTOM_EXEC, update lv_anim_timeline_1.c example Signed-off-by: FASTSHIFT <vifextech@foxmail.com> * fix warning * fix(anim_timeline) heap use after free Signed-off-by: FASTSHIFT <vifextech@foxmail.com> * fix(docs) wrong spelling of words in pictures * perf(anim_timeline) add lv_anim_timeline_stop() Signed-off-by: FASTSHIFT <vifextech@foxmail.com> Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
parent
c28c146310
commit
202cf1c8cb
@ -117,6 +117,8 @@ Finally, call `lv_anim_timeline_start(at)` to start the animation timeline.
|
||||
|
||||
It supports forward and backward playback of the entire animation group, using `lv_anim_timeline_set_reverse(at, reverse)`.
|
||||
|
||||
Call the `lv_anim_timeline_stop(at)` to stop the animation timeline.
|
||||
|
||||
Call the `lv_anim_timeline_set_progress(at, progress)` function to set the state of the object corresponding to the progress of the timeline.
|
||||
|
||||
Call the `lv_anim_timeline_get_playtime(at)` function to get the total duration of the entire animation timeline.
|
||||
|
@ -89,7 +89,7 @@ static void anim_timeline_create(void)
|
||||
lv_anim_timeline_add(anim_timeline, 400, &a6);
|
||||
}
|
||||
|
||||
static void btn_run_event_handler(lv_event_t * e)
|
||||
static void btn_start_event_handler(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
|
||||
@ -111,6 +111,14 @@ static void btn_del_event_handler(lv_event_t * e)
|
||||
}
|
||||
}
|
||||
|
||||
static void btn_stop_event_handler(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(e);
|
||||
if (anim_timeline) {
|
||||
lv_anim_timeline_stop(anim_timeline);
|
||||
}
|
||||
}
|
||||
|
||||
static void slider_prg_event_handler(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * slider = lv_event_get_target(e);
|
||||
@ -132,31 +140,45 @@ void lv_example_anim_timeline_1(void)
|
||||
lv_obj_set_flex_flow(par, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(par, LV_FLEX_ALIGN_SPACE_AROUND, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * btn_run = lv_btn_create(par);
|
||||
lv_obj_add_event_cb(btn_run, btn_run_event_handler, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
lv_obj_add_flag(btn_run, LV_OBJ_FLAG_IGNORE_LAYOUT);
|
||||
lv_obj_add_flag(btn_run, LV_OBJ_FLAG_CHECKABLE);
|
||||
lv_obj_align(btn_run, LV_ALIGN_TOP_MID, -50, 20);
|
||||
/* create btn_start */
|
||||
lv_obj_t * btn_start = lv_btn_create(par);
|
||||
lv_obj_add_event_cb(btn_start, btn_start_event_handler, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
lv_obj_add_flag(btn_start, LV_OBJ_FLAG_IGNORE_LAYOUT);
|
||||
lv_obj_add_flag(btn_start, LV_OBJ_FLAG_CHECKABLE);
|
||||
lv_obj_align(btn_start, LV_ALIGN_TOP_MID, -100, 20);
|
||||
|
||||
lv_obj_t * label_run = lv_label_create(btn_run);
|
||||
lv_label_set_text(label_run, "Run");
|
||||
lv_obj_center(label_run);
|
||||
lv_obj_t * label_start = lv_label_create(btn_start);
|
||||
lv_label_set_text(label_start, "Start");
|
||||
lv_obj_center(label_start);
|
||||
|
||||
/* create btn_del */
|
||||
lv_obj_t * btn_del = lv_btn_create(par);
|
||||
lv_obj_add_event_cb(btn_del, btn_del_event_handler, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_add_flag(btn_del, LV_OBJ_FLAG_IGNORE_LAYOUT);
|
||||
lv_obj_align(btn_del, LV_ALIGN_TOP_MID, 50, 20);
|
||||
lv_obj_align(btn_del, LV_ALIGN_TOP_MID, 0, 20);
|
||||
|
||||
lv_obj_t * label_del = lv_label_create(btn_del);
|
||||
lv_label_set_text(label_del, "Stop");
|
||||
lv_label_set_text(label_del, "Delete");
|
||||
lv_obj_center(label_del);
|
||||
|
||||
/* create btn_stop */
|
||||
lv_obj_t * btn_stop = lv_btn_create(par);
|
||||
lv_obj_add_event_cb(btn_stop, btn_stop_event_handler, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_add_flag(btn_stop, LV_OBJ_FLAG_IGNORE_LAYOUT);
|
||||
lv_obj_align(btn_stop, LV_ALIGN_TOP_MID, 100, 20);
|
||||
|
||||
lv_obj_t * label_stop = lv_label_create(btn_stop);
|
||||
lv_label_set_text(label_stop, "Stop");
|
||||
lv_obj_center(label_stop);
|
||||
|
||||
/* create slider_prg */
|
||||
lv_obj_t * slider_prg = lv_slider_create(par);
|
||||
lv_obj_add_event_cb(slider_prg, slider_prg_event_handler, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
lv_obj_add_flag(slider_prg, LV_OBJ_FLAG_IGNORE_LAYOUT);
|
||||
lv_obj_align(slider_prg, LV_ALIGN_BOTTOM_MID, 0, -20);
|
||||
lv_slider_set_range(slider_prg, 0, 65535);
|
||||
|
||||
/* create 3 objects */
|
||||
obj1 = lv_obj_create(par);
|
||||
lv_obj_set_size(obj1, obj_width, obj_height);
|
||||
|
||||
|
@ -62,10 +62,7 @@ void lv_anim_timeline_del(lv_anim_timeline_t * at)
|
||||
{
|
||||
LV_ASSERT_NULL(at);
|
||||
|
||||
for(uint32_t i = 0; i < at->anim_dsc_cnt; i++) {
|
||||
lv_anim_t * a = &(at->anim_dsc[i].anim);
|
||||
lv_anim_custom_del(a, (lv_anim_custom_exec_cb_t)a->exec_cb);
|
||||
}
|
||||
lv_anim_timeline_stop(at);
|
||||
|
||||
lv_mem_free(at->anim_dsc);
|
||||
lv_mem_free(at);
|
||||
@ -111,6 +108,16 @@ uint32_t lv_anim_timeline_start(lv_anim_timeline_t * at)
|
||||
return playtime;
|
||||
}
|
||||
|
||||
void lv_anim_timeline_stop(lv_anim_timeline_t * at)
|
||||
{
|
||||
LV_ASSERT_NULL(at);
|
||||
|
||||
for(uint32_t i = 0; i < at->anim_dsc_cnt; i++) {
|
||||
lv_anim_t * a = &(at->anim_dsc[i].anim);
|
||||
lv_anim_custom_del(a, (lv_anim_custom_exec_cb_t)a->exec_cb);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_anim_timeline_set_reverse(lv_anim_timeline_t * at, bool reverse)
|
||||
{
|
||||
LV_ASSERT_NULL(at);
|
||||
|
@ -58,6 +58,12 @@ void lv_anim_timeline_add(lv_anim_timeline_t * at, uint32_t start_time, lv_anim_
|
||||
*/
|
||||
uint32_t lv_anim_timeline_start(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Stop the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
*/
|
||||
void lv_anim_timeline_stop(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Set the playback direction of the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
|
Loading…
x
Reference in New Issue
Block a user