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

animation bugix

This commit is contained in:
Kiss-Vamosi Gabor 2016-12-17 22:09:25 +01:00
parent 05d03015cb
commit a68901ce82
3 changed files with 102 additions and 47 deletions

View File

@ -258,47 +258,6 @@ lv_obj_t * lv_app_win_open(lv_app_inst_t * app)
lv_win_add_ctrl_btn(app->win, "U:/icon_down", lv_app_win_minim_action);
lv_win_add_ctrl_btn(app->win, "U:/icon_close", lv_app_win_close_action);
app->dsc->win_open(app, app->win);
#if LV_APP_ANIM_WIN_OPEN != 0
anim_t a;
a.act_time = 0;
a.time = LV_APP_ANIM_WIN_OPEN;
a.end_cb = NULL;
a.playback = 0;
a.repeat = 0;
a.var = app->win;
a.path = anim_get_path(ANIM_PATH_LIN);
#if LV_APP_ANIM_WIN_OPEN_COMPLEX != 0
area_t cords;
lv_obj_get_cords(app->sc, &cords);
a.start = lv_obj_get_width(app->sc);
a.end = LV_HOR_RES;
a.fp = (anim_fp_t) lv_obj_set_width;
anim_create(&a);
a.start = lv_obj_get_height(app->sc);
a.end = LV_VER_RES;
a.fp = (anim_fp_t) lv_obj_set_height;
anim_create(&a);
a.start = cords.x1;
a.end = 0;
a.fp = (anim_fp_t) lv_obj_set_x;
anim_create(&a);
a.start = cords.y1;
a.end = 0;
a.fp = (anim_fp_t) lv_obj_set_y;
anim_create(&a);
#endif /*LV_APP_ANIM_WIN_OPEN_COMPLEX*/
a.start = OPA_TRANSP;
a.end = OPA_COVER;
a.fp = (anim_fp_t) lv_obj_set_opar;
anim_create(&a);
#endif /*LV_APP_ANIM_WIN_OPEN*/
return app->win;
}
@ -459,6 +418,49 @@ static lv_action_res_t lv_app_sc_rel_action(lv_obj_t * sc, lv_dispi_t * dispi)
else {
lv_app_inst_t * app = lv_obj_get_free_p(sc);
lv_app_win_open(app);
app->dsc->win_open(app, app->win);
/*Make an animation on window open*/
#if LV_APP_ANIM_WIN_OPEN != 0
anim_t a;
a.act_time = 0;
a.time = LV_APP_ANIM_WIN_OPEN;
a.end_cb = NULL;
a.playback = 0;
a.repeat = 0;
a.var = app->win;
a.path = anim_get_path(ANIM_PATH_LIN);
#if LV_APP_ANIM_WIN_COMPLEX != 0
area_t cords;
lv_obj_get_cords(app->sc, &cords);
a.start = lv_obj_get_width(app->sc);
a.end = LV_HOR_RES;
a.fp = (anim_fp_t) lv_obj_set_width;
anim_create(&a);
a.start = lv_obj_get_height(app->sc);
a.end = LV_VER_RES;
a.fp = (anim_fp_t) lv_obj_set_height;
anim_create(&a);
a.start = cords.x1;
a.end = 0;
a.fp = (anim_fp_t) lv_obj_set_x;
anim_create(&a);
a.start = cords.y1;
a.end = 0;
a.fp = (anim_fp_t) lv_obj_set_y;
anim_create(&a);
#endif /*LV_APP_ANIM_WIN_OPEN_COMPLEX*/
a.start = OPA_TRANSP;
a.end = OPA_COVER;
a.fp = (anim_fp_t) lv_obj_set_opar;
anim_create(&a);
#endif /*LV_APP_ANIM_WIN_OPEN*/
}
return LV_ACTION_RES_OK;
@ -496,9 +498,47 @@ static lv_action_res_t lv_app_win_minim_action(lv_obj_t * close_btn, lv_dispi_t
{
lv_obj_t * win = lv_win_get_from_ctrl_btn(close_btn);
lv_app_inst_t * app = lv_obj_get_free_p(win);
/*Make an animation on window open*/
#if LV_APP_ANIM_WIN_OPEN != 0
anim_t a;
a.act_time = 0;
a.time = LV_APP_ANIM_WIN_OPEN;
a.end_cb = NULL;
a.playback = 0;
a.repeat = 0;
a.var = app->win;
a.path = anim_get_path(ANIM_PATH_LIN);
#if LV_APP_ANIM_WIN_COMPLEX != 0
area_t cords;
lv_obj_get_cords(app->sc, &cords);
#if LV_APP_ANIM_WIN_CLOSE != 0
lv_obj_anim(app->win, LV_ANIM_FLOAT_BOTTOM | ANIM_OUT, LV_APP_ANIM_WIN_CLOSE, 0, lv_app_win_minim_anim_cb);
a.end = lv_obj_get_width(app->sc);
a.start = LV_HOR_RES;
a.fp = (anim_fp_t) lv_obj_set_width;
anim_create(&a);
a.end = lv_obj_get_height(app->sc);
a.start = LV_VER_RES;
a.fp = (anim_fp_t) lv_obj_set_height;
anim_create(&a);
a.end = cords.x1;
a.start = 0;
a.fp = (anim_fp_t) lv_obj_set_x;
anim_create(&a);
a.end = cords.y1;
a.start = 0;
a.fp = (anim_fp_t) lv_obj_set_y;
anim_create(&a);
#endif /*LV_APP_ANIM_WIN_COMPLEX*/
a.end = OPA_TRANSP;
a.start = OPA_COVER;
a.fp = (anim_fp_t) lv_obj_set_opar;
a.end_cb = (void (*)(void *))lv_app_win_minim_anim_cb;
//a.time = 500;
anim_create(&a);
#else
lv_app_win_close(app);
return LV_ACTION_RES_INV;

View File

@ -92,7 +92,7 @@ static void my_app_run(lv_app_inst_t * app, const char * cstr)
{
/*Check the create string*/
if(cstr == NULL || cstr[0] == '\0') {
cstr = "No create string";
cstr = "No create\nstring";
}
/*Initialize the application*/

View File

@ -29,13 +29,14 @@
* STATIC PROTOTYPES
**********************/
static void anim_task (void);
static void anim_ready_handler(anim_t * a);
static bool anim_ready_handler(anim_t * a);
/**********************
* STATIC VARIABLES
**********************/
static ll_dsc_t anim_ll;
static uint32_t last_task_run;
static bool anim_del_global_flag = false;
static anim_path_t anim_path_lin[] =
{64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
@ -106,6 +107,7 @@ bool anim_del(void * var, anim_fp_t fp)
ll_rem(&anim_ll, a);
dm_free(a);
del = true;
anim_del_global_flag = true;
}
a = a_next;
@ -193,7 +195,11 @@ static void anim_task (void)
/*If the time is elapsed the animation is ready*/
if(a->act_time >= a->time) {
anim_ready_handler(a);
bool invalid;
invalid = anim_ready_handler(a);
if(invalid != false) {
a_next = ll_get_head(&anim_ll); /*a_next might be invalid if animation delete occurred*/
}
}
}
@ -207,9 +213,12 @@ static void anim_task (void)
* Called when an animation is ready to do the necessary thinks
* e.g. repeat, play back, delete etc.
* @param a pointer to an animation descriptor
* @return true: animation delete occurred
* */
static void anim_ready_handler(anim_t * a)
static bool anim_ready_handler(anim_t * a)
{
bool invalid = false;
/*Delete the animation if
* - no repeat and no play back (simple one shot animation)
* - no repeat, play back is enabled and play back is ready */
@ -221,7 +230,11 @@ static void anim_ready_handler(anim_t * a)
dm_free(a);
/*Call the callback function at the end*/
/* Check if an animation is deleted in the cb function
* if yes then the caller function has to know this*/
anim_del_global_flag = false;
if(cb != NULL) cb(p);
invalid = anim_del_global_flag;
}
/*If the animation is not deleted then restart it*/
else {
@ -240,4 +253,6 @@ static void anim_ready_handler(anim_t * a)
a->end = tmp;
}
}
return invalid;
}