Start using menu_list_get_ptr and menu_navigation_get_ptr

This commit is contained in:
twinaphex 2015-05-07 05:08:34 +02:00
parent a8e5d98b0c
commit 058b1dfdf0
3 changed files with 14 additions and 18 deletions

View File

@ -159,34 +159,29 @@ static int action_toggle_scroll(unsigned type, const char *label,
unsigned action, bool wraparound) unsigned action, bool wraparound)
{ {
unsigned scroll_speed = 0, fast_scroll_speed = 0; unsigned scroll_speed = 0, fast_scroll_speed = 0;
menu_handle_t *menu = menu_driver_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr();
if (!menu) menu_navigation_t *nav = menu_navigation_get_ptr();
if (!nav || !menu_list)
return -1; return -1;
scroll_speed = (max(menu->navigation.scroll.acceleration, 2) - 2) / 4 + 1; scroll_speed = (max(nav->scroll.acceleration, 2) - 2) / 4 + 1;
fast_scroll_speed = 4 + 4 * scroll_speed; fast_scroll_speed = 4 + 4 * scroll_speed;
switch (action) switch (action)
{ {
case MENU_ACTION_LEFT: case MENU_ACTION_LEFT:
if (menu->navigation.selection_ptr > fast_scroll_speed) if (nav->selection_ptr > fast_scroll_speed)
menu_navigation_set(&menu->navigation, menu_navigation_set(nav, nav->selection_ptr - fast_scroll_speed, true);
menu->navigation.selection_ptr - fast_scroll_speed, true);
else else
menu_navigation_clear(&menu->navigation, false); menu_navigation_clear(nav, false);
break; break;
case MENU_ACTION_RIGHT: case MENU_ACTION_RIGHT:
if (menu->navigation.selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list))) if (nav->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu_list)))
{ menu_navigation_set(nav, nav->selection_ptr + fast_scroll_speed, true);
menu_navigation_set(&menu->navigation,
menu->navigation.selection_ptr + fast_scroll_speed, true);
}
else else
{ {
if ((menu_list_get_size(menu->menu_list) > 0)) if ((menu_list_get_size(menu_list) > 0))
{ menu_navigation_set_last(nav);
menu_navigation_set_last(&menu->navigation);
}
} }
break; break;
} }

View File

@ -22,8 +22,7 @@
#include <string.h> #include <string.h>
#include <retro_inline.h> #include <retro_inline.h>
menu_list_t *menu_list_get_ptr(void)
static menu_list_t *menu_list_get_ptr(void)
{ {
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
if (!menu) if (!menu)

View File

@ -40,6 +40,8 @@ typedef struct menu_entry
unsigned spacing; unsigned spacing;
} menu_entry_t; } menu_entry_t;
menu_list_t *menu_list_get_ptr(void);
void menu_list_free(menu_list_t *menu_list); void menu_list_free(menu_list_t *menu_list);
menu_list_t *menu_list_new(void); menu_list_t *menu_list_new(void);