From bd0347f1ae11dec4498cd982a1778b380d6476bc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 25 Feb 2016 13:23:39 +0100 Subject: [PATCH] Create MENU_ANIMATION_CTL_KILL_BY_TAG --- menu/drivers/xmb.c | 16 ++++++++------- menu/menu_animation.c | 46 ++++++++++++++++++++++--------------------- menu/menu_animation.h | 10 +++++++--- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 5b2336ec8a..ebb8fc18f5 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -592,7 +592,8 @@ static void xmb_selection_pointer_changed( xmb_handle_t *xmb, bool allow_animations) { size_t skip; - unsigned i, end, tag, height, depth; + unsigned i, end, height, depth; + menu_animation_ctx_tag_t tag; size_t selection, num = 0; int threshold = 0; menu_list_t *menu_list = NULL; @@ -607,12 +608,13 @@ static void xmb_selection_pointer_changed( return; end = menu_entries_get_end(); - tag = (uintptr_t)menu_list; threshold = xmb->icon.size*10; video_driver_get_size(NULL, &height); - menu_animation_kill_by_tag(tag); + tag.id = (uintptr_t)menu_list; + + menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num); skip = 0; @@ -657,13 +659,13 @@ static void xmb_selection_pointer_changed( else { menu_animation_push(XMB_DELAY, ia, &node->alpha, - EASING_IN_OUT_QUAD, tag, NULL); + EASING_IN_OUT_QUAD, tag.id, NULL); menu_animation_push(XMB_DELAY, ia, &node->label_alpha, - EASING_IN_OUT_QUAD, tag, NULL); + EASING_IN_OUT_QUAD, tag.id, NULL); menu_animation_push(XMB_DELAY, iz, &node->zoom, - EASING_IN_OUT_QUAD, tag, NULL); + EASING_IN_OUT_QUAD, tag.id, NULL); menu_animation_push(XMB_DELAY, iy, &node->y, - EASING_IN_OUT_QUAD, tag, NULL); + EASING_IN_OUT_QUAD, tag.id, NULL); } } diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 821ce991de..44c06630aa 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -52,6 +52,9 @@ struct menu_animation retro_time_t old_time; }; +typedef float (*easing_cb) (float, float, float, float); +typedef void (*tween_cb) (void); + typedef struct menu_animation menu_animation_t; static menu_animation_t *menu_animation_get_ptr(void) @@ -425,28 +428,6 @@ void menu_animation_kill_by_subject(size_t count, const void *subjects) } } -void menu_animation_kill_by_tag(int tag) -{ - unsigned i; - menu_animation_t *anim = menu_animation_get_ptr(); - - if (tag == -1) - return; - - for (i = 0; i < anim->size; ++i) - { - if (anim->list[i].tag == tag) - { - anim->list[i].alive = false; - anim->list[i].subject = NULL; - - if (i < anim->first_dead) - anim->first_dead = i; - } - } -} - - bool menu_animation_push(float duration, float target_value, float* subject, enum menu_animation_easing_type easing_enum, int tag, tween_cb cb) { @@ -698,6 +679,27 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) anim->is_active = true; } break; + case MENU_ANIMATION_CTL_KILL_BY_TAG: + { + unsigned i; + menu_animation_ctx_tag_t *tag = (menu_animation_ctx_tag_t*)data; + + if (!tag || tag->id == -1) + return false; + + for (i = 0; i < anim->size; ++i) + { + if (anim->list[i].tag != tag->id) + continue; + + anim->list[i].alive = false; + anim->list[i].subject = NULL; + + if (i < anim->first_dead) + anim->first_dead = i; + } + } + break; default: case MENU_ANIMATION_CTL_NONE: break; diff --git a/menu/menu_animation.h b/menu/menu_animation.h index 0a11588e61..962e59ba6f 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -41,7 +41,8 @@ enum menu_animation_ctl_state MENU_ANIMATION_CTL_SET_ACTIVE, MENU_ANIMATION_CTL_DELTA_TIME, MENU_ANIMATION_CTL_UPDATE_TIME, - MENU_ANIMATION_CTL_UPDATE + MENU_ANIMATION_CTL_UPDATE, + MENU_ANIMATION_CTL_KILL_BY_TAG }; enum menu_animation_easing_type @@ -90,9 +91,12 @@ enum menu_animation_easing_type EASING_OUT_IN_BOUNCE }; -void menu_animation_kill_by_subject(size_t count, const void *subjects); +typedef struct menu_animation_ctx_tag +{ + int id; +} menu_animation_ctx_tag_t; -void menu_animation_kill_by_tag(int tag); +void menu_animation_kill_by_subject(size_t count, const void *subjects); /* Use -1 for untagged */ bool menu_animation_push(float duration, float target_value, float* subject,