diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index fc216530e9..d86190dc1f 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -2752,7 +2752,7 @@ static void materialui_list_clear(file_list_t *list) subject.count = 2; subject.data = subjects; - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_SUBJECT, &subject); + menu_animation_kill_by_subject(&subject); file_list_free_userdata(list, i); } diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 7dc34bfb8b..cfea3c388d 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -1177,7 +1177,7 @@ static void stripes_selection_pointer_changed( tag = (uintptr_t)selection_buf; - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + menu_animation_kill_by_tag(&tag); menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num); for (i = 0; i < end; i++) @@ -3830,7 +3830,7 @@ static void stripes_list_clear(file_list_t *list) { menu_animation_ctx_tag tag = (uintptr_t)list; - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + menu_animation_kill_by_tag(&tag); stripes_free_list_nodes(list, false); } @@ -3846,7 +3846,7 @@ static void stripes_list_deep_copy(const file_list_t *src, file_list_t *dst, size_t i, j = 0; menu_animation_ctx_tag tag = (uintptr_t)dst; - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + menu_animation_kill_by_tag(&tag); /* use true here because file_list_copy() doesn't free actiondata */ stripes_free_list_nodes(dst, true); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 922d7ce607..d649768f50 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1231,7 +1231,7 @@ static void xmb_selection_pointer_changed( tag = (uintptr_t)selection_buf; - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + menu_animation_kill_by_tag(&tag); menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num); for (i = 0; i < end; i++) @@ -4930,7 +4930,7 @@ static void xmb_list_clear(file_list_t *list) { menu_animation_ctx_tag tag = (uintptr_t)list; - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + menu_animation_kill_by_tag(&tag); xmb_free_list_nodes(list, false); } @@ -4946,7 +4946,7 @@ static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst, size_t i, j = 0; menu_animation_ctx_tag tag = (uintptr_t)dst; - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + menu_animation_kill_by_tag(&tag); /* use true here because file_list_copy() doesn't free actiondata */ xmb_free_list_nodes(dst, true); diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 628c41013e..f31c143a22 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -617,6 +617,58 @@ bool menu_animation_is_active(void) return animation_is_active; } +bool menu_animation_kill_by_tag(menu_animation_ctx_tag *tag) +{ + unsigned i; + + if (!tag || *tag == (uintptr_t)-1) + return false; + + for (i = 0; i < anim.size; ++i) + { + if (anim.list[i].tag != *tag) + continue; + + anim.list[i].alive = false; + anim.list[i].subject = NULL; + + if (i < anim.first_dead) + anim.first_dead = i; + + anim.need_defrag = true; + } + + return true; +} + +void menu_animation_kill_by_subject(menu_animation_ctx_subject_t *subject) +{ + unsigned i, j, killed = 0; + float **sub = (float**)subject->data; + + for (i = 0; i < anim.size && killed < subject->count; ++i) + { + if (!anim.list[i].alive) + continue; + + for (j = 0; j < subject->count; ++j) + { + if (anim.list[i].subject != sub[j]) + continue; + + anim.list[i].alive = false; + anim.list[i].subject = NULL; + + if (i < anim.first_dead) + anim.first_dead = i; + + killed++; + anim.need_defrag = true; + break; + } + } +} + bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) { switch (state) @@ -653,59 +705,6 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) *ptr = delta_time; } break; - case MENU_ANIMATION_CTL_KILL_BY_TAG: - { - unsigned i; - menu_animation_ctx_tag *tag = (menu_animation_ctx_tag*)data; - - if (!tag || *tag == (uintptr_t)-1) - return false; - - for (i = 0; i < anim.size; ++i) - { - if (anim.list[i].tag != *tag) - continue; - - anim.list[i].alive = false; - anim.list[i].subject = NULL; - - if (i < anim.first_dead) - anim.first_dead = i; - - anim.need_defrag = true; - } - } - break; - case MENU_ANIMATION_CTL_KILL_BY_SUBJECT: - { - unsigned i, j, killed = 0; - menu_animation_ctx_subject_t *subject = - (menu_animation_ctx_subject_t*)data; - float **sub = (float**)subject->data; - - for (i = 0; i < anim.size && killed < subject->count; ++i) - { - if (!anim.list[i].alive) - continue; - - for (j = 0; j < subject->count; ++j) - { - if (anim.list[i].subject != sub[j]) - continue; - - anim.list[i].alive = false; - anim.list[i].subject = NULL; - - if (i < anim.first_dead) - anim.first_dead = i; - - killed++; - anim.need_defrag = true; - break; - } - } - } - break; case MENU_ANIMATION_CTL_NONE: default: break; diff --git a/menu/menu_animation.h b/menu/menu_animation.h index 2f6c8aefbb..8e63ee1ef2 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -34,9 +34,7 @@ enum menu_animation_ctl_state MENU_ANIMATION_CTL_DEINIT, MENU_ANIMATION_CTL_CLEAR_ACTIVE, MENU_ANIMATION_CTL_SET_ACTIVE, - MENU_ANIMATION_CTL_DELTA_TIME, - MENU_ANIMATION_CTL_KILL_BY_TAG, - MENU_ANIMATION_CTL_KILL_BY_SUBJECT + MENU_ANIMATION_CTL_DELTA_TIME }; enum menu_animation_easing_type @@ -130,6 +128,10 @@ void menu_animation_update_time(bool timedate_enable); bool menu_animation_is_active(void); +bool menu_animation_kill_by_tag(menu_animation_ctx_tag *tag); + +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_ctl(enum menu_animation_ctl_state state, void *data);