Merge pull request #8074 from natinusala/master

menu_animation: add delayed animations
This commit is contained in:
Twinaphex 2019-01-23 19:06:19 +01:00 committed by GitHub
commit 39d50591af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -333,6 +333,29 @@ void menu_animation_free(void)
da_free(anim.pending); da_free(anim.pending);
} }
static void menu_delayed_animation_cb(void *userdata)
{
menu_delayed_animation_t *delayed_animation = (menu_delayed_animation_t*) userdata;
menu_animation_push(&delayed_animation->entry);
free(delayed_animation);
}
void menu_animation_push_delayed(unsigned delay, menu_animation_ctx_entry_t *entry)
{
menu_timer_ctx_entry_t timer_entry;
menu_delayed_animation_t *delayed_animation = (menu_delayed_animation_t*) malloc(sizeof(menu_delayed_animation_t));
memcpy(&delayed_animation->entry, entry, sizeof(menu_animation_ctx_entry_t));
timer_entry.cb = menu_delayed_animation_cb;
timer_entry.duration = delay;
timer_entry.userdata = delayed_animation;
menu_timer_start(&delayed_animation->timer, &timer_entry);
}
bool menu_animation_push(menu_animation_ctx_entry_t *entry) bool menu_animation_push(menu_animation_ctx_entry_t *entry)
{ {
struct tween t; struct tween t;

View File

@ -127,6 +127,12 @@ typedef struct menu_timer_ctx_entry
void *userdata; void *userdata;
} menu_timer_ctx_entry_t; } menu_timer_ctx_entry_t;
typedef struct menu_delayed_animation
{
menu_timer_t timer;
menu_animation_ctx_entry_t entry;
} menu_delayed_animation_t;
void menu_timer_start(menu_timer_t *timer, menu_timer_ctx_entry_t *timer_entry); void menu_timer_start(menu_timer_t *timer, menu_timer_ctx_entry_t *timer_entry);
void menu_timer_kill(menu_timer_t *timer); void menu_timer_kill(menu_timer_t *timer);
@ -151,6 +157,8 @@ void menu_animation_kill_by_subject(menu_animation_ctx_subject_t *subject);
bool menu_animation_push(menu_animation_ctx_entry_t *entry); bool menu_animation_push(menu_animation_ctx_entry_t *entry);
void menu_animation_push_delayed(unsigned delay, menu_animation_ctx_entry_t *entry);
float menu_animation_get_delta_time(void); float menu_animation_get_delta_time(void);
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data); bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data);