No longer need menu_navigation_get_ptr inside menu_entry.c

This commit is contained in:
twinaphex 2015-09-25 18:31:54 +02:00
parent 51114f5a6a
commit 2759c9fe04
2 changed files with 17 additions and 9 deletions

View File

@ -354,7 +354,6 @@ int menu_entry_select(uint32_t i)
int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
{
int ret = 0;
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
menu_file_list_cbs_t *cbs = menu_list_get_actiondata_at_offset(menu_list->selection_buf, i);
@ -369,10 +368,10 @@ int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
ret = cbs->action_down(entry->type, entry->label);
break;
case MENU_ACTION_SCROLL_UP:
menu_navigation_ctl(MENU_NAVIGATION_CTL_DESCEND_ALPHABET, &nav->selection_ptr);
menu_navigation_ctl(MENU_NAVIGATION_CTL_DESCEND_ALPHABET, NULL);
break;
case MENU_ACTION_SCROLL_DOWN:
menu_navigation_ctl(MENU_NAVIGATION_CTL_ASCEND_ALPHABET, &nav->selection_ptr);
menu_navigation_ctl(MENU_NAVIGATION_CTL_ASCEND_ALPHABET, NULL);
break;
case MENU_ACTION_CANCEL:
if (cbs && cbs->action_cancel)

View File

@ -135,10 +135,14 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
return true;
case MENU_NAVIGATION_CTL_ASCEND_ALPHABET:
{
size_t *ptr_out = (size_t*)data;
size_t i = 0, ptr = *ptr_out;
size_t i = 0, ptr;
size_t *ptr_out = nav ? (size_t*)&nav->selection_ptr : NULL;
if (!nav || !nav->scroll.indices.size || !ptr_out)
return false;
ptr = *ptr_out;
if (ptr == nav->scroll.indices.list[nav->scroll.indices.size - 1])
return false;
@ -153,13 +157,18 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
return true;
case MENU_NAVIGATION_CTL_DESCEND_ALPHABET:
{
size_t *ptr_out = (size_t*)data;
size_t i, ptr = *ptr_out;
size_t i = 0, ptr;
size_t *ptr_out = nav ? (size_t*)&nav->selection_ptr : NULL;
if (!nav || !nav->scroll.indices.size || ptr == 0 || !ptr_out)
if (!nav || !nav->scroll.indices.size || !ptr_out)
return false;
i = nav->scroll.indices.size - 1;
ptr = *ptr_out;
if (ptr == 0)
return false;
i = nav->scroll.indices.size - 1;
while (i && nav->scroll.indices.list[i - 1] >= ptr)
i--;