From d4eefc020f39b4ffe2ffb9af29cd2564ed19cfe1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 5 Sep 2015 18:49:48 +0200 Subject: [PATCH] Cleanups --- menu/drivers/glui.c | 5 +++-- menu/drivers/rgui.c | 11 ++++++----- menu/drivers/xmb.c | 4 ++-- menu/menu_navigation.c | 12 ++++++------ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 519b5cc6d4..cd5f247245 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -682,6 +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; if (!menu || !menu->userdata) return 0; @@ -692,9 +693,9 @@ static float glui_get_scroll(void) if (glui->line_height) half = (height / glui->line_height) / 2; - if (nav->selection_ptr < (unsigned)half) + if (selection < (unsigned)half) return 0; - return ((nav->selection_ptr + 2 - half) * glui->line_height); + return ((selection + 2 - half) * glui->line_height); } static void glui_navigation_set(bool scroll) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 62b11d3454..c9c8a40d1a 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -682,6 +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; if (!menu) return; @@ -690,12 +691,12 @@ static void rgui_navigation_set(bool scroll) if (!scroll) return; - if (nav->selection_ptr < RGUI_TERM_HEIGHT/2) + if (selection < RGUI_TERM_HEIGHT/2) menu_entries_set_start(0); - else if (nav->selection_ptr >= RGUI_TERM_HEIGHT/2 - && nav->selection_ptr < (end - RGUI_TERM_HEIGHT/2)) - menu_entries_set_start(nav->selection_ptr - RGUI_TERM_HEIGHT/2); - else if (nav->selection_ptr >= (end - RGUI_TERM_HEIGHT/2)) + else if (selection >= (RGUI_TERM_HEIGHT/2) + && selection < (end - RGUI_TERM_HEIGHT/2)) + menu_entries_set_start(selection - RGUI_TERM_HEIGHT/2); + else if (selection >= (end - RGUI_TERM_HEIGHT/2)) menu_entries_set_start(end - RGUI_TERM_HEIGHT); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 704e13ac69..a0400c9530 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -981,6 +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; if (!menu) return; @@ -1002,8 +1003,7 @@ static void xmb_list_switch(xmb_handle_t *xmb) xmb_list_switch_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_switch_new(xmb, menu_list->selection_buf, - dir, nav->selection_ptr); + xmb_list_switch_new(xmb, menu_list->selection_buf, dir, selection); xmb->categories.active.idx_old = xmb->categories.selection_ptr; if (settings->menu.boxart_enable) diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 8c42b3dee5..d1defbd639 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -105,13 +105,13 @@ void menu_navigation_decrement(menu_navigation_t *nav, unsigned scroll_speed) { menu_list_t *menu_list = menu_list_get_ptr(); settings_t *settings = config_get_ptr(); + size_t selection = nav->selection_ptr; if (!nav) return; - if (nav->selection_ptr >= scroll_speed) - menu_navigation_set(nav, - nav->selection_ptr - scroll_speed, true); + if (selection >= scroll_speed) + menu_navigation_set(nav, selection - scroll_speed, true); else { if (settings->menu.navigation.wraparound.vertical_enable) @@ -133,14 +133,14 @@ void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed) { settings_t *settings = config_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); + size_t selection = nav->selection_ptr; if (!nav) return; - if (nav->selection_ptr + scroll_speed < (menu_list_get_size(menu_list))) + if ((selection + scroll_speed) < (menu_list_get_size(menu_list))) { - menu_navigation_set(nav, - nav->selection_ptr + scroll_speed, true); + menu_navigation_set(nav, selection + scroll_speed, true); menu_driver_navigation_increment(); } else