mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Merge pull request #5273 from heuripedes/xmb-lists
XMB horizontal browsing tweaks
This commit is contained in:
commit
aef66e3d9e
@ -1118,7 +1118,7 @@ static void xmb_selection_pointer_changed(
|
||||
|
||||
video_driver_get_size(NULL, &height);
|
||||
|
||||
tag.id = (int)(uintptr_t)menu_list;
|
||||
tag.id = (uintptr_t)selection_buf;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num);
|
||||
@ -1394,7 +1394,7 @@ static xmb_node_t* xmb_get_userdata_from_horizontal_list(
|
||||
menu_entries_get_actiondata_at_offset(xmb->horizontal_list, i);
|
||||
}
|
||||
|
||||
static void xmb_push_animations(xmb_node_t *node, float ia, float ix)
|
||||
static void xmb_push_animations(xmb_node_t *node, uintptr_t tag, float ia, float ix)
|
||||
{
|
||||
menu_animation_ctx_entry_t entry;
|
||||
|
||||
@ -1402,7 +1402,7 @@ static void xmb_push_animations(xmb_node_t *node, float ia, float ix)
|
||||
entry.target_value = ia;
|
||||
entry.subject = &node->alpha;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.tag = -1;
|
||||
entry.tag = tag;
|
||||
entry.cb = NULL;
|
||||
|
||||
if (entry.subject)
|
||||
@ -1435,7 +1435,7 @@ static void xmb_list_switch_old(xmb_handle_t *xmb,
|
||||
if (!node)
|
||||
continue;
|
||||
|
||||
xmb_push_animations(node, ia, -xmb->icon.spacing.horizontal * dir);
|
||||
xmb_push_animations(node, (uintptr_t)list, ia, -xmb->icon.spacing.horizontal * dir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,7 +1501,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb,
|
||||
if (i == current)
|
||||
ia = xmb->items.active.alpha;
|
||||
|
||||
xmb_push_animations(node, ia, 0);
|
||||
xmb_push_animations(node, (uintptr_t)list, ia, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3736,28 +3736,18 @@ static void xmb_list_clear(file_list_t *list)
|
||||
{
|
||||
size_t i;
|
||||
size_t size = list->size;
|
||||
menu_animation_ctx_tag_t tag = { (uintptr_t)list };
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
|
||||
for (i = 0; i < size; ++i)
|
||||
{
|
||||
menu_animation_ctx_subject_t subject;
|
||||
float *subjects[5];
|
||||
xmb_node_t *node = (xmb_node_t*)
|
||||
menu_entries_get_userdata_at_offset(list, i);
|
||||
|
||||
if (!node)
|
||||
continue;
|
||||
|
||||
subjects[0] = &node->alpha;
|
||||
subjects[1] = &node->label_alpha;
|
||||
subjects[2] = &node->zoom;
|
||||
subjects[3] = &node->x;
|
||||
subjects[4] = &node->y;
|
||||
|
||||
subject.count = 5;
|
||||
subject.data = subjects;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_SUBJECT, &subject);
|
||||
|
||||
file_list_free_userdata(list, i);
|
||||
}
|
||||
}
|
||||
@ -3766,29 +3756,12 @@ static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst)
|
||||
{
|
||||
size_t i;
|
||||
size_t size = dst->size;
|
||||
menu_animation_ctx_tag_t tag = { (uintptr_t)dst };
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
|
||||
for (i = 0; i < size; ++i)
|
||||
{
|
||||
xmb_node_t *node = (xmb_node_t*)
|
||||
menu_entries_get_userdata_at_offset(dst, i);
|
||||
|
||||
if (node)
|
||||
{
|
||||
menu_animation_ctx_subject_t subject;
|
||||
float *subjects[5];
|
||||
|
||||
subjects[0] = &node->alpha;
|
||||
subjects[1] = &node->label_alpha;
|
||||
subjects[2] = &node->zoom;
|
||||
subjects[3] = &node->x;
|
||||
subjects[4] = &node->y;
|
||||
|
||||
subject.count = 5;
|
||||
subject.data = subjects;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_SUBJECT, &subject);
|
||||
}
|
||||
|
||||
file_list_free_userdata(dst, i);
|
||||
file_list_free_actiondata(dst, i); /* this one was allocated by us */
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ struct tween
|
||||
float initial_value;
|
||||
float target_value;
|
||||
float *subject;
|
||||
int tag;
|
||||
uintptr_t tag;
|
||||
easing_cb easing;
|
||||
tween_cb cb;
|
||||
};
|
||||
@ -462,6 +462,32 @@ bool menu_animation_push(menu_animation_ctx_entry_t *entry)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int menu_animation_defrag_cmp(const void *a, const void *b)
|
||||
{
|
||||
const struct tween *ta = (const struct tween *)a;
|
||||
const struct tween *tb = (const struct tween *)b;
|
||||
|
||||
return tb->alive - ta->alive;
|
||||
}
|
||||
|
||||
/* defragments and shrinks the tween list when possible */
|
||||
static void menu_animation_defrag()
|
||||
{
|
||||
size_t i;
|
||||
|
||||
qsort(anim.list, anim.size, sizeof(anim.list[0]), menu_animation_defrag_cmp);
|
||||
|
||||
for (i = anim.size-1; i > 0; i--)
|
||||
{
|
||||
if (anim.list[i].alive)
|
||||
break;
|
||||
|
||||
anim.size--;
|
||||
}
|
||||
|
||||
anim.first_dead = anim.size;
|
||||
}
|
||||
|
||||
bool menu_animation_update(float delta_time)
|
||||
{
|
||||
unsigned i;
|
||||
@ -486,9 +512,6 @@ bool menu_animation_update(float delta_time)
|
||||
*tween->subject = tween->target_value;
|
||||
tween->alive = false;
|
||||
|
||||
if (i < anim.first_dead)
|
||||
anim.first_dead = i;
|
||||
|
||||
if (tween->cb)
|
||||
tween->cb();
|
||||
}
|
||||
@ -497,13 +520,16 @@ bool menu_animation_update(float delta_time)
|
||||
active_tweens += 1;
|
||||
}
|
||||
|
||||
if (!active_tweens)
|
||||
if (active_tweens)
|
||||
menu_animation_defrag();
|
||||
else
|
||||
{
|
||||
anim.size = 0;
|
||||
anim.first_dead = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
animation_is_active = true;
|
||||
|
||||
return true;
|
||||
@ -624,7 +650,7 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||
unsigned i;
|
||||
menu_animation_ctx_tag_t *tag = (menu_animation_ctx_tag_t*)data;
|
||||
|
||||
if (!tag || tag->id == -1)
|
||||
if (!tag || tag->id == (uintptr_t)-1)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < anim.size; ++i)
|
||||
|
@ -93,7 +93,7 @@ typedef struct menu_animation_ctx_delta
|
||||
|
||||
typedef struct menu_animation_ctx_tag
|
||||
{
|
||||
int id;
|
||||
uintptr_t id;
|
||||
} menu_animation_ctx_tag_t;
|
||||
|
||||
typedef struct menu_animation_ctx_subject
|
||||
@ -108,7 +108,7 @@ typedef struct menu_animation_ctx_entry
|
||||
float target_value;
|
||||
float *subject;
|
||||
enum menu_animation_easing_type easing_enum;
|
||||
int tag;
|
||||
uintptr_t tag;
|
||||
tween_cb cb;
|
||||
} menu_animation_ctx_entry_t;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user