Use menu_navigation_get_selection

This commit is contained in:
twinaphex 2015-09-06 02:06:02 +02:00
parent 028e07e3e0
commit d6e3040e5d
8 changed files with 26 additions and 22 deletions

View File

@ -91,14 +91,15 @@ static int action_left_scroll(unsigned type, const char *label,
unsigned scroll_speed = 0, fast_scroll_speed = 0;
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
size_t selection = menu_navigation_get_selection(nav);
if (!nav || !menu_list)
return -1;
scroll_speed = (max(nav->scroll.acceleration, 2) - 2) / 4 + 1;
fast_scroll_speed = 4 + 4 * scroll_speed;
if (nav->selection_ptr > fast_scroll_speed)
menu_navigation_set(nav, nav->selection_ptr - fast_scroll_speed, true);
if (selection > fast_scroll_speed)
menu_navigation_set(nav, selection - fast_scroll_speed, true);
else
menu_navigation_clear(nav, false);

View File

@ -120,14 +120,15 @@ static int action_right_scroll(unsigned type, const char *label,
unsigned scroll_speed = 0, fast_scroll_speed = 0;
menu_list_t *menu_list = menu_list_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
size_t selection = menu_navigation_get_selection(nav);
if (!nav || !menu_list)
return -1;
scroll_speed = (max(nav->scroll.acceleration, 2) - 2) / 4 + 1;
fast_scroll_speed = 4 + 4 * scroll_speed;
if (nav->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu_list)))
menu_navigation_set(nav, nav->selection_ptr + fast_scroll_speed, true);
if (selection + fast_scroll_speed < (menu_list_get_size(menu_list)))
menu_navigation_set(nav, selection + fast_scroll_speed, true);
else
{
if ((menu_list_get_size(menu_list) > 0))

View File

@ -363,7 +363,7 @@ static void glui_render_menu_list(glui_handle_t *glui,
menu_entries_get(i, &entry);
entry_selected = (nav->selection_ptr == i);
entry_selected = (menu_navigation_get_selection(nav) == i);
glui_render_label_value(glui, y, width, *frame_count / 40,
entry_selected ? hover_color : normal_color, entry_selected,
@ -430,7 +430,7 @@ static void glui_frame(void)
glui_render_quad(gl, 0,
disp->header_height - menu->scroll_y + glui->line_height *
nav->selection_ptr, width, glui->line_height, 1, 1, 1, 0.1);
menu_navigation_get_selection(nav), width, glui->line_height, 1, 1, 1, 0.1);
anim->is_active = true;
anim->label.is_updated = false;
@ -682,7 +682,7 @@ static float glui_get_scroll(void)
glui_handle_t *glui = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
size_t selection = nav->selection_ptr;
size_t selection = menu_navigation_get_selection(nav);
if (!menu || !menu->userdata)
return 0;

View File

@ -506,7 +506,7 @@ static void rgui_render(void)
unsigned entry_spacing = menu_entry_get_spacing(i);
bool entry_selected = menu_entry_is_currently_selected(i);
if (i > (nav->selection_ptr + 100))
if (i > (menu_navigation_get_selection(nav) + 100))
continue;
entry_path[0] = '\0';
@ -682,7 +682,7 @@ static void rgui_navigation_set(bool scroll)
menu_handle_t *menu = menu_driver_get_ptr();
menu_framebuf_t *frame_buf = menu_display_fb_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
size_t selection = nav->selection_ptr;
size_t selection = menu_navigation_get_selection(nav);
if (!menu)
return;

View File

@ -135,6 +135,7 @@ static void rmenu_render(void)
menu_navigation_t *nav = menu_navigation_get_ptr();
uint64_t *frame_count = video_driver_get_frame_count();
size_t entries_end = menu_entries_get_end();
size_t selection = menu_navigation_get_selection(nav);
if (!menu)
return;
@ -156,10 +157,10 @@ static void rmenu_render(void)
if (!menu_list->selection_buf)
return;
begin = (nav->selection_ptr >= (ENTRIES_HEIGHT / 2)) ?
(nav->selection_ptr - (ENTRIES_HEIGHT / 2)) : 0;
end = ((nav->selection_ptr + ENTRIES_HEIGHT) <= entries_end)
? nav->selection_ptr + ENTRIES_HEIGHT : entries_end;
begin = (selection >= (ENTRIES_HEIGHT / 2)) ?
(selection - (ENTRIES_HEIGHT / 2)) : 0;
end = ((selection + ENTRIES_HEIGHT) <= entries_end)
? selection + ENTRIES_HEIGHT : entries_end;
if (entries_end <= ENTRIES_HEIGHT)
begin = 0;

View File

@ -589,7 +589,7 @@ static void rmenu_xui_render(void)
mbstowcs(msg_right, entry_value, sizeof(msg_right) / sizeof(wchar_t));
rmenu_xui_set_list_text(i, msg_left, msg_right);
}
XuiListSetCurSelVisible(m_menulist, nav->selection_ptr);
XuiListSetCurSelVisible(m_menulist, menu_navigation_get_selection(nav));
if (menu->keyboard.display)
{
@ -615,7 +615,7 @@ static void rmenu_xui_populate_entries(const char *path,
(void)label;
(void)path;
XuiListSetCurSelVisible(m_menulist, nav->selection_ptr);
XuiListSetCurSelVisible(m_menulist, menu_navigation_get_selection(nav));
}
static void rmenu_xui_navigation_clear(bool pending_push)
@ -624,7 +624,7 @@ static void rmenu_xui_navigation_clear(bool pending_push)
menu_navigation_t *nav = menu_navigation_get_ptr();
if (menu)
XuiListSetCurSelVisible(m_menulist, nav->selection_ptr);
XuiListSetCurSelVisible(m_menulist, menu_navigation_get_selection(nav));
}
static void rmenu_xui_navigation_set_visible(void)
@ -633,7 +633,7 @@ static void rmenu_xui_navigation_set_visible(void)
menu_navigation_t *nav = menu_navigation_get_ptr();
if (menu)
XuiListSetCurSelVisible(m_menulist, nav->selection_ptr);
XuiListSetCurSelVisible(m_menulist, menu_navigation_get_selection(nav));
}
static void rmenu_xui_navigation_alphabet(size_t *ptr_out)

View File

@ -642,7 +642,7 @@ static void xmb_selection_pointer_changed(bool allow_animations)
if (!xmb)
return;
current = nav->selection_ptr;
current = menu_navigation_get_selection(nav);
end = menu_entries_get_end();
tag = (uintptr_t)menu_list;
threshold = xmb->icon.size*10;
@ -981,7 +981,7 @@ static void xmb_list_switch(xmb_handle_t *xmb)
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
settings_t *settings = config_get_ptr();
size_t selection = nav->selection_ptr;
size_t selection = menu_navigation_get_selection(nav);
if (!menu)
return;
@ -1498,7 +1498,7 @@ static void xmb_render(void)
video_driver_get_size(NULL, &height);
current = nav->selection_ptr;
current = menu_navigation_get_selection(nav);
end = menu_list_get_size(menu_list);
if (settings->menu.pointer.enable || settings->menu.mouse.enable)

View File

@ -33,8 +33,8 @@
/* Clicks the back button */
int menu_entry_go_back(void)
{
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
if (!menu_list)
return -1;
menu_list_pop_stack(menu_list, &nav->selection_ptr);
@ -323,9 +323,10 @@ void menu_entry_get(menu_entry_t *entry, size_t i,
bool menu_entry_is_currently_selected(unsigned id)
{
menu_navigation_t *nav = menu_navigation_get_ptr();
size_t selection = menu_navigation_get_selection(nav);
if (!nav)
return false;
return (id == nav->selection_ptr);
return (id == selection);
}
/* Performs whatever actions are associated with menu entry 'i'.