From 3426dbca7f1fa177bc12078177f402fcadecf599 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 15 May 2015 00:03:06 +0200 Subject: [PATCH] Start using menu_entries_get_end --- menu/drivers/glui.c | 10 +++++----- menu/drivers/rgui.c | 25 +++++++++++-------------- menu/drivers/rmenu.c | 9 ++++----- menu/drivers/rmenu_xui.cpp | 2 +- menu/drivers/xmb.c | 2 +- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 7967e771db..1331e734e8 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -139,8 +139,7 @@ static void glui_draw_scrollbar(gl_t *gl) return; glui = (glui_handle_t*)menu->userdata; - content_height = menu_list_get_size(menu->menu_list) - * glui->line_height; + content_height = menu_entries_get_end() * glui->line_height; total_height = global->video_data.height - menu->header_height * 2; height = total_height / (content_height / total_height); y = total_height * menu->scroll_y / content_height; @@ -254,12 +253,12 @@ static void glui_render(void) if (menu->scroll_y < 0) menu->scroll_y = 0; - bottom = menu_list_get_size(menu->menu_list) * glui->line_height + bottom = menu_entries_get_end() * glui->line_height - global->video_data.height + menu->header_height * 2; if (menu->scroll_y > bottom) menu->scroll_y = bottom; - if (menu_list_get_size(menu->menu_list) * glui->line_height + if (menu_entries_get_end() * glui->line_height < global->video_data.height - menu->header_height*2) menu->scroll_y = 0; } @@ -272,13 +271,14 @@ static void glui_render_menu_list(runloop_t *runloop, size_t i = 0; uint64_t frame_count = video_driver_get_frame_count(); global_t *global = global_get_ptr(); + size_t end = menu_entries_get_end(); if (!menu_display_update_pending()) return; glui->list_block.carr.coords.vertices = 0; - for (i = 0; i < menu_list_get_size(menu->menu_list); i++) + for (i = 0; i < end; i++) { unsigned y; menu_entry_t entry; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index e7546e65d3..ad837481cc 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -376,7 +376,7 @@ static void rgui_render(void) if (settings->menu.mouse.enable) { if (menu->mouse.scrolldown && menu->begin - < menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT) + < menu_entries_get_end() - RGUI_TERM_HEIGHT) menu->begin++; if (menu->mouse.scrollup && menu->begin > 0) @@ -386,17 +386,15 @@ static void rgui_render(void) } /* Do not scroll if all items are visible. */ - if (menu_list_get_size(menu->menu_list) <= RGUI_TERM_HEIGHT) + if (menu_entries_get_end() <= RGUI_TERM_HEIGHT) menu->begin = 0; - bottom = menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT; + bottom = menu_entries_get_end() - RGUI_TERM_HEIGHT; if (menu->begin > bottom) menu->begin = bottom; - end = (menu->begin + RGUI_TERM_HEIGHT <= - menu_list_get_size(menu->menu_list)) ? - menu->begin + RGUI_TERM_HEIGHT : - menu_list_get_size(menu->menu_list); + end = (menu->begin + RGUI_TERM_HEIGHT <= menu_entries_get_end()) ? + menu->begin + RGUI_TERM_HEIGHT : menu_entries_get_end(); rgui_render_background(); @@ -445,8 +443,9 @@ static void rgui_render(void) x = RGUI_TERM_START_X; y = RGUI_TERM_START_Y; + i = 0; - for (i = menu->begin; i < end; i++, y += FONT_HEIGHT_STRIDE) + for (i = menu_entries_get_start(); i < end; i++, y += FONT_HEIGHT_STRIDE) { menu_entry_t entry; char message[PATH_MAX_LENGTH], @@ -595,6 +594,7 @@ static void rgui_navigation_set(bool scroll) menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) return; + size_t end = menu_entries_get_end(); if (!scroll) return; @@ -602,13 +602,10 @@ static void rgui_navigation_set(bool scroll) if (menu->navigation.selection_ptr < RGUI_TERM_HEIGHT/2) menu->begin = 0; else if (menu->navigation.selection_ptr >= RGUI_TERM_HEIGHT/2 - && menu->navigation.selection_ptr < - menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT/2) + && menu->navigation.selection_ptr < (end - RGUI_TERM_HEIGHT/2)) menu->begin = menu->navigation.selection_ptr - RGUI_TERM_HEIGHT/2; - else if (menu->navigation.selection_ptr >= - menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT/2) - menu->begin = menu_list_get_size(menu->menu_list) - - RGUI_TERM_HEIGHT; + else if (menu->navigation.selection_ptr >= (end - RGUI_TERM_HEIGHT/2)) + menu->begin = end - RGUI_TERM_HEIGHT; } static void rgui_navigation_set_last(void) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index c12c1a830a..bb56fdb19c 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -132,6 +132,7 @@ static void rmenu_render(void) global_t *global = global_get_ptr(); runloop_t *runloop = rarch_main_get_ptr(); uint64_t frame_count = video_driver_get_frame_count(); + size_t entries_end = menu_entries_get_end(): if (!menu) return; @@ -155,12 +156,10 @@ static void rmenu_render(void) begin = (menu->navigation.selection_ptr >= (ENTRIES_HEIGHT / 2)) ? (menu->navigation.selection_ptr - (ENTRIES_HEIGHT / 2)) : 0; - end = ((menu->navigation.selection_ptr + ENTRIES_HEIGHT) <= - menu_list_get_size(menu->menu_list)) ? - menu->navigation.selection_ptr + ENTRIES_HEIGHT : - menu_list_get_size(menu->menu_list); + end = ((menu->navigation.selection_ptr + ENTRIES_HEIGHT) <= entries_end) + ? menu->navigation.selection_ptr + ENTRIES_HEIGHT : entries_end; - if (menu_list_get_size(menu->menu_list) <= ENTRIES_HEIGHT) + if (entries_end <= ENTRIES_HEIGHT) begin = 0; if (end - begin > ENTRIES_HEIGHT) diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 730e7e7db7..8bb8aec04a 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -566,7 +566,7 @@ static void rmenu_xui_render(void) XuiTextElementSetText(m_menutitlebottom, strw_buffer); } - end = menu_list_get_size(menu->menu_list); + end = menu_entries_get_end(); for (i = 0; i < end; i++) { menu_entry_t entry; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 5fe2615e49..84329133dc 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -456,7 +456,7 @@ static void xmb_selection_pointer_changed(void) return; current = menu->navigation.selection_ptr; - end = menu_list_get_size(menu->menu_list); + end = menu_entries_get_end(); for (i = 0; i < end; i++) {