mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 22:14:17 +00:00
Create menu_animation_push
This commit is contained in:
parent
2273b1d05f
commit
da044da3b4
@ -1609,7 +1609,8 @@ static void mui_navigation_set(void *data, bool scroll)
|
||||
entry.tag = -1;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
|
||||
static void mui_list_set_selection(void *data, file_list_t *list)
|
||||
|
@ -1123,21 +1123,25 @@ static void xmb_selection_pointer_changed(
|
||||
entry.tag = tag.id;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.subject = &node->label_alpha;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = iz;
|
||||
entry.subject = &node->zoom;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = iy;
|
||||
entry.subject = &node->y;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1187,17 +1191,20 @@ static void xmb_list_open_old(xmb_handle_t *xmb,
|
||||
entry.tag = -1;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = 0;
|
||||
entry.subject = &node->label_alpha;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = xmb->icon.size * dir * -2;
|
||||
entry.subject = &node->x;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1257,16 +1264,19 @@ static void xmb_list_open_new(xmb_handle_t *xmb,
|
||||
entry.tag = -1;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.subject = &node->label_alpha;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = 0;
|
||||
entry.subject = &node->x;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1320,16 +1330,19 @@ static void xmb_push_animations(xmb_node_t *node, float ia, float ix)
|
||||
entry.tag = -1;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.subject = &node->label_alpha;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = ix;
|
||||
entry.subject = &node->x;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
|
||||
static void xmb_list_switch_old(xmb_handle_t *xmb,
|
||||
@ -1505,12 +1518,14 @@ static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb)
|
||||
entry.tag = -1;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = iz;
|
||||
entry.subject = &node->zoom;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1538,7 +1553,8 @@ static void xmb_list_switch(xmb_handle_t *xmb)
|
||||
entry.tag = -1;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
dir = -1;
|
||||
if (xmb->categories.selection_ptr > xmb->categories.selection_ptr_old)
|
||||
@ -1584,7 +1600,8 @@ static void xmb_list_open_horizontal_list(xmb_handle_t *xmb)
|
||||
entry.tag = -1;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1857,20 +1874,24 @@ static void xmb_list_open(xmb_handle_t *xmb)
|
||||
switch (xmb->depth)
|
||||
{
|
||||
case 1:
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = 0;
|
||||
entry.subject = &xmb->textures.arrow.alpha;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
break;
|
||||
case 2:
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
entry.target_value = 1;
|
||||
entry.subject = &xmb->textures.arrow.alpha;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3835,7 +3856,8 @@ static void xmb_toggle(void *userdata, bool menu_on)
|
||||
entry.tag = -1;
|
||||
entry.cb = NULL;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry);
|
||||
if (entry.subject)
|
||||
menu_animation_push(&entry);
|
||||
|
||||
tmp = !menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL);
|
||||
|
||||
|
@ -311,153 +311,129 @@ static void menu_animation_ticker_generic(uint64_t idx,
|
||||
*width = max_width;
|
||||
}
|
||||
|
||||
static void menu_animation_push_internal(menu_animation_t *anim,
|
||||
const struct tween *t)
|
||||
{
|
||||
struct tween *target = NULL;
|
||||
|
||||
if (anim->first_dead < anim->size && !anim->list[anim->first_dead].alive)
|
||||
target = &anim->list[anim->first_dead++];
|
||||
else
|
||||
{
|
||||
if (anim->size >= anim->capacity)
|
||||
{
|
||||
anim->capacity++;
|
||||
anim->list = (struct tween*)realloc(anim->list,
|
||||
anim->capacity * sizeof(struct tween));
|
||||
}
|
||||
|
||||
target = &anim->list[anim->size++];
|
||||
}
|
||||
|
||||
*target = *t;
|
||||
}
|
||||
|
||||
static bool menu_animation_push(menu_animation_t *anim, menu_animation_ctx_entry_t *entry)
|
||||
bool menu_animation_push(menu_animation_ctx_entry_t *entry)
|
||||
{
|
||||
struct tween t;
|
||||
struct tween *target = NULL;
|
||||
|
||||
if (!entry || !entry->subject)
|
||||
return false;
|
||||
|
||||
t.alive = true;
|
||||
t.duration = entry->duration;
|
||||
t.running_since = 0;
|
||||
t.initial_value = *entry->subject;
|
||||
t.target_value = entry->target_value;
|
||||
t.subject = entry->subject;
|
||||
t.tag = entry->tag;
|
||||
t.cb = entry->cb;
|
||||
t.easing = NULL;
|
||||
t.alive = true;
|
||||
t.duration = entry->duration;
|
||||
t.running_since = 0;
|
||||
t.initial_value = *entry->subject;
|
||||
t.target_value = entry->target_value;
|
||||
t.subject = entry->subject;
|
||||
t.tag = entry->tag;
|
||||
t.cb = entry->cb;
|
||||
t.easing = NULL;
|
||||
|
||||
switch (entry->easing_enum)
|
||||
{
|
||||
case EASING_LINEAR:
|
||||
t.easing = &easing_linear;
|
||||
t.easing = &easing_linear;
|
||||
break;
|
||||
/* Quad */
|
||||
case EASING_IN_QUAD:
|
||||
t.easing = &easing_in_quad;
|
||||
t.easing = &easing_in_quad;
|
||||
break;
|
||||
case EASING_OUT_QUAD:
|
||||
t.easing = &easing_out_quad;
|
||||
t.easing = &easing_out_quad;
|
||||
break;
|
||||
case EASING_IN_OUT_QUAD:
|
||||
t.easing = &easing_in_out_quad;
|
||||
t.easing = &easing_in_out_quad;
|
||||
break;
|
||||
case EASING_OUT_IN_QUAD:
|
||||
t.easing = &easing_out_in_quad;
|
||||
t.easing = &easing_out_in_quad;
|
||||
break;
|
||||
/* Cubic */
|
||||
case EASING_IN_CUBIC:
|
||||
t.easing = &easing_in_cubic;
|
||||
t.easing = &easing_in_cubic;
|
||||
break;
|
||||
case EASING_OUT_CUBIC:
|
||||
t.easing = &easing_out_cubic;
|
||||
t.easing = &easing_out_cubic;
|
||||
break;
|
||||
case EASING_IN_OUT_CUBIC:
|
||||
t.easing = &easing_in_out_cubic;
|
||||
t.easing = &easing_in_out_cubic;
|
||||
break;
|
||||
case EASING_OUT_IN_CUBIC:
|
||||
t.easing = &easing_out_in_cubic;
|
||||
t.easing = &easing_out_in_cubic;
|
||||
break;
|
||||
/* Quart */
|
||||
case EASING_IN_QUART:
|
||||
t.easing = &easing_in_quart;
|
||||
t.easing = &easing_in_quart;
|
||||
break;
|
||||
case EASING_OUT_QUART:
|
||||
t.easing = &easing_out_quart;
|
||||
t.easing = &easing_out_quart;
|
||||
break;
|
||||
case EASING_IN_OUT_QUART:
|
||||
t.easing = &easing_in_out_quart;
|
||||
t.easing = &easing_in_out_quart;
|
||||
break;
|
||||
case EASING_OUT_IN_QUART:
|
||||
t.easing = &easing_out_in_quart;
|
||||
t.easing = &easing_out_in_quart;
|
||||
break;
|
||||
/* Quint */
|
||||
case EASING_IN_QUINT:
|
||||
t.easing = &easing_in_quint;
|
||||
t.easing = &easing_in_quint;
|
||||
break;
|
||||
case EASING_OUT_QUINT:
|
||||
t.easing = &easing_out_quint;
|
||||
t.easing = &easing_out_quint;
|
||||
break;
|
||||
case EASING_IN_OUT_QUINT:
|
||||
t.easing = &easing_in_out_quint;
|
||||
t.easing = &easing_in_out_quint;
|
||||
break;
|
||||
case EASING_OUT_IN_QUINT:
|
||||
t.easing = &easing_out_in_quint;
|
||||
t.easing = &easing_out_in_quint;
|
||||
break;
|
||||
/* Sine */
|
||||
case EASING_IN_SINE:
|
||||
t.easing = &easing_in_sine;
|
||||
t.easing = &easing_in_sine;
|
||||
break;
|
||||
case EASING_OUT_SINE:
|
||||
t.easing = &easing_out_sine;
|
||||
t.easing = &easing_out_sine;
|
||||
break;
|
||||
case EASING_IN_OUT_SINE:
|
||||
t.easing = &easing_in_out_sine;
|
||||
t.easing = &easing_in_out_sine;
|
||||
break;
|
||||
case EASING_OUT_IN_SINE:
|
||||
t.easing = &easing_out_in_sine;
|
||||
t.easing = &easing_out_in_sine;
|
||||
break;
|
||||
/* Expo */
|
||||
case EASING_IN_EXPO:
|
||||
t.easing = &easing_in_expo;
|
||||
t.easing = &easing_in_expo;
|
||||
break;
|
||||
case EASING_OUT_EXPO:
|
||||
t.easing = &easing_out_expo;
|
||||
t.easing = &easing_out_expo;
|
||||
break;
|
||||
case EASING_IN_OUT_EXPO:
|
||||
t.easing = &easing_in_out_expo;
|
||||
t.easing = &easing_in_out_expo;
|
||||
break;
|
||||
case EASING_OUT_IN_EXPO:
|
||||
t.easing = &easing_out_in_expo;
|
||||
t.easing = &easing_out_in_expo;
|
||||
break;
|
||||
/* Circ */
|
||||
case EASING_IN_CIRC:
|
||||
t.easing = &easing_in_circ;
|
||||
t.easing = &easing_in_circ;
|
||||
break;
|
||||
case EASING_OUT_CIRC:
|
||||
t.easing = &easing_out_circ;
|
||||
t.easing = &easing_out_circ;
|
||||
break;
|
||||
case EASING_IN_OUT_CIRC:
|
||||
t.easing = &easing_in_out_circ;
|
||||
t.easing = &easing_in_out_circ;
|
||||
break;
|
||||
case EASING_OUT_IN_CIRC:
|
||||
t.easing = &easing_out_in_circ;
|
||||
t.easing = &easing_out_in_circ;
|
||||
break;
|
||||
/* Bounce */
|
||||
case EASING_IN_BOUNCE:
|
||||
t.easing = &easing_in_bounce;
|
||||
t.easing = &easing_in_bounce;
|
||||
break;
|
||||
case EASING_OUT_BOUNCE:
|
||||
t.easing = &easing_out_bounce;
|
||||
t.easing = &easing_out_bounce;
|
||||
break;
|
||||
case EASING_IN_OUT_BOUNCE:
|
||||
t.easing = &easing_in_out_bounce;
|
||||
t.easing = &easing_in_out_bounce;
|
||||
break;
|
||||
case EASING_OUT_IN_BOUNCE:
|
||||
t.easing = &easing_out_in_bounce;
|
||||
t.easing = &easing_out_in_bounce;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -467,7 +443,21 @@ static bool menu_animation_push(menu_animation_t *anim, menu_animation_ctx_entry
|
||||
if (!t.easing || t.duration == 0 || t.initial_value == t.target_value)
|
||||
return false;
|
||||
|
||||
menu_animation_push_internal(anim, &t);
|
||||
if (anim.first_dead < anim.size && !anim.list[anim.first_dead].alive)
|
||||
target = &anim.list[anim.first_dead++];
|
||||
else
|
||||
{
|
||||
if (anim.size >= anim.capacity)
|
||||
{
|
||||
anim.capacity++;
|
||||
anim.list = (struct tween*)realloc(anim.list,
|
||||
anim.capacity * sizeof(struct tween));
|
||||
}
|
||||
|
||||
target = &anim.list[anim.size++];
|
||||
}
|
||||
|
||||
*target = t;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -679,8 +669,6 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MENU_ANIMATION_CTL_PUSH:
|
||||
return menu_animation_push(&anim, (menu_animation_ctx_entry_t *)data);
|
||||
case MENU_ANIMATION_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
|
@ -36,8 +36,7 @@ enum menu_animation_ctl_state
|
||||
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_PUSH
|
||||
MENU_ANIMATION_CTL_KILL_BY_SUBJECT
|
||||
};
|
||||
|
||||
enum menu_animation_easing_type
|
||||
@ -132,6 +131,8 @@ void menu_animation_update_time(void);
|
||||
|
||||
bool menu_animation_is_active(void);
|
||||
|
||||
bool menu_animation_push(menu_animation_ctx_entry_t *entry);
|
||||
|
||||
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
Loading…
x
Reference in New Issue
Block a user