From fde4826754e6495446f439ff5ff44195385741cb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 11 Dec 2015 21:34:27 +0100 Subject: [PATCH] Add MENU_ENTRIES_CTL_SHOW_BACK --- menu/drivers/materialui.c | 2 +- menu/drivers/rgui.c | 2 +- menu/menu_entries.c | 11 +++++------ menu/menu_entries.h | 5 ++--- ui/drivers/cocoa/cocoatouch_menu.m | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 91ad832d5d..c67f240914 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -827,7 +827,7 @@ static void mui_frame(void *data) title_margin = mui->margin; - if (menu_entries_show_back()) + if (menu_entries_ctl(MENU_ENTRIES_CTL_SHOW_BACK, NULL)) { title_margin = mui->icon_size; mui_draw_icon(mui, mui->textures.list[MUI_TEXTURE_BACK].id, diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 4c10b6adff..3e27219687 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -519,7 +519,7 @@ static void rgui_render(void *data) hover_color = HOVER_COLOR(settings); normal_color = NORMAL_COLOR(settings); - if (menu_entries_show_back()) + if (menu_entries_ctl(MENU_ENTRIES_CTL_SHOW_BACK, NULL)) blit_line(fb_data, fb_pitch, RGUI_TERM_START_X(fb_width), RGUI_TERM_START_X(fb_width), diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 9baa82c7f4..3bfcab1e63 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -447,12 +447,6 @@ int menu_entries_get_title(char *s, size_t len) return 0; } -/* Returns true if a Back button should be shown (i.e. we are at least - * one level deep in the menu hierarchy). */ -bool menu_entries_show_back(void) -{ - return (menu_entries_get_stack_size(0) > 1); -} /* Sets 's' to the name of the current core * (shown at the top of the UI). */ @@ -729,6 +723,11 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data) { switch (state) { + /* Returns true if a Back button should be shown + * (i.e. we are at least + * one level deep in the menu hierarchy). */ + case MENU_ENTRIES_CTL_SHOW_BACK: + return (menu_entries_get_stack_size(0) > 1); case MENU_ENTRIES_CTL_NONE: default: break; diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 8105e84900..68de3b596d 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -103,7 +103,8 @@ typedef struct menu_file_list_cbs enum menu_entries_ctl_state { - MENU_ENTRIES_CTL_NONE = 0 + MENU_ENTRIES_CTL_NONE = 0, + MENU_ENTRIES_CTL_SHOW_BACK }; typedef struct menu_list menu_list_t; @@ -118,8 +119,6 @@ void menu_entries_get(size_t i, menu_entry_t *entry); int menu_entries_get_title(char *title, size_t title_len); -bool menu_entries_show_back(void); - int menu_entries_get_core_title(char *title_msg, size_t title_msg_len); rarch_setting_t *menu_setting_get_ptr(void); diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index 959f6df88d..ba5db77892 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -672,7 +672,7 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath [self.sections addObject:everything]; weakSelf = self; - if (menu_entries_show_back()) + if (menu_entries_ctl(MENU_ENTRIES_CTL_SHOW_BACK, NULL)) [self set_leftbutton:BOXSTRING("Back") target:weakSelf action:@selector(menuBack)];