diff --git a/ui/drivers/cocoa/cocoa_common.h b/ui/drivers/cocoa/cocoa_common.h index f527dd398d..d01f88f623 100644 --- a/ui/drivers/cocoa/cocoa_common.h +++ b/ui/drivers/cocoa/cocoa_common.h @@ -41,6 +41,7 @@ @interface RAMenuBase : UITableViewController @property (nonatomic) NSMutableArray* sections; @property (nonatomic) BOOL hidesHeaders; +@property (nonatomic) RAMenuBase* last_menu; - (id)initWithStyle:(UITableViewStyle)style; - (id)itemForIndexPath:(NSIndexPath*)indexPath; @@ -64,6 +65,7 @@ extern apple_frontend_settings_t apple_frontend_settings; @property (nonatomic) UIWindow* window; @property (nonatomic) NSString* documentsDirectory; @property (nonatomic) RAMenuBase* mainmenu; +@property (nonatomic) int menu_count; + (RetroArch_iOS*)get; @@ -71,6 +73,7 @@ extern apple_frontend_settings_t apple_frontend_settings; - (void)toggleUI; - (void)refreshSystemConfig; +- (void)mainMenuPushPop: (bool)pushp; - (void)mainMenuRefresh; @end diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index 3646f70bd9..33255904e5 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -588,31 +588,7 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)reloadData { [self willReloadData]; - - // Here are two options: - - // Option 1. This is like how setting app works, but not exactly. - // There is a typedef for the 'withRowAnimation' that has lots of - // options, just Google UITableViewRowAnimation -#if 0 - - [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] - withRowAnimation:UITableViewRowAnimationAutomatic]; -#else - - // Option 2. This is a "bigger" transition, but doesn't look as - // much like Settings. It has more options. Just Google - // UIViewAnimationOptionTransition - - [UIView transitionWithView:self.tableView - duration:0.40f - options:UIViewAnimationOptionTransitionCrossDissolve - animations:^(void) - { - [self.tableView reloadData]; - } - completion: nil]; -#endif + [self.tableView reloadData]; } -(void)renderMessageBox:(NSString *)msg @@ -673,7 +649,7 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath end = menu_entries_get_end(); for (i = menu_entries_get_start(); i < end; i++) [everything addObject:[self make_menu_item_for_entry: i]]; - + self.sections = [NSMutableArray array]; [self.sections addObject:everything]; @@ -756,9 +732,6 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)menuSelect: (uint32_t) i { menu_entry_select(i); -#if 0 - [self willReloadData]; -#endif } - (void)menuBack diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index b4e5f77e5b..bbfeb9064c 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -265,8 +265,8 @@ enum [self.window makeKeyAndVisible]; self.mainmenu = [RAMainMenu new]; - - [self pushViewController:self.mainmenu animated:YES]; + self.mainmenu.last_menu = self.mainmenu; + [self pushViewController:self.mainmenu animated:NO]; btpad_set_inquiry_state(false); @@ -400,11 +400,31 @@ static void ui_companion_cocoatouch_event_command(void *data, btstack_set_poweron(is_btstack); } -- (void)mainMenuRefresh +- (void)mainMenuRefresh { [self.mainmenu reloadData]; } +- (void)mainMenuPushPop: (bool)pushp +{ + if ( pushp ) { + self.menu_count++; + RAMenuBase* next_menu = [RAMainMenu new]; + next_menu.last_menu = self.mainmenu; + self.mainmenu = next_menu; + [self pushViewController:self.mainmenu animated:YES]; + } else { + if ( self.menu_count == 0 ) { + [self.mainmenu reloadData]; + } else { + self.menu_count--; + + [self popViewControllerAnimated:YES]; + self.mainmenu = self.mainmenu.last_menu; + } + } +} + - (void)mainMenuRenderMessageBox:(NSString *)msg { [self.mainmenu renderMessageBox:msg]; @@ -499,13 +519,25 @@ static void *ui_companion_cocoatouch_init(void) return handle; } +static size_t old_size = 0; static void ui_companion_cocoatouch_notify_list_pushed(void *data, file_list_t *list, file_list_t *menu_list) { RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform; + bool pushp = false; + size_t new_size = file_list_get_size( menu_list ); + if ( old_size == new_size ) { + pushp = false; + } else if ( old_size < new_size ) { + pushp = true; + } else if ( old_size > new_size ) { + printf( "notify_list_pushed: old size should not be larger\n" ); + } + old_size = new_size; + if (ap) - [ap mainMenuRefresh]; + [ap mainMenuPushPop: pushp]; } static void ui_companion_cocoatouch_notify_refresh(void *data) @@ -513,7 +545,7 @@ static void ui_companion_cocoatouch_notify_refresh(void *data) RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform; if (ap) - [ap mainMenuRefresh]; + [ap mainMenuRefresh]; } static void ui_companion_cocoatouch_render_messagebox(const char *msg)