Fix the various bugs associated with pressing MENU to move in and out of

the Rockbox Menu


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12666 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-03-07 10:13:07 +00:00
parent 67b3206709
commit 43b2d091ba
2 changed files with 20 additions and 12 deletions

View file

@ -607,7 +607,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
const struct menu_item_ex *menu_stack[MAX_MENUS]; const struct menu_item_ex *menu_stack[MAX_MENUS];
int menu_stack_selected_item[MAX_MENUS]; int menu_stack_selected_item[MAX_MENUS];
int stack_top = 0; int stack_top = 0;
bool in_stringlist; bool in_stringlist, done = false;
menu_callback_type menu_callback = NULL; menu_callback_type menu_callback = NULL;
if (start_menu == NULL) if (start_menu == NULL)
menu = &main_menu_; menu = &main_menu_;
@ -630,7 +630,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
/* load the callback, and only reload it if menu changes */ /* load the callback, and only reload it if menu changes */
get_menu_callback(menu, &menu_callback); get_menu_callback(menu, &menu_callback);
while (ret == 0) while (!done)
{ {
action = get_action(CONTEXT_MAINMENU,HZ); action = get_action(CONTEXT_MAINMENU,HZ);
/* HZ so the status bar redraws corectly */ /* HZ so the status bar redraws corectly */
@ -660,6 +660,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
else if (action == ACTION_MENU_WPS) else if (action == ACTION_MENU_WPS)
{ {
ret = GO_TO_PREVIOUS_MUSIC; ret = GO_TO_PREVIOUS_MUSIC;
done = true;
} }
else if (action == ACTION_MENU_STOP) else if (action == ACTION_MENU_STOP)
{ {
@ -677,6 +678,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
ret = GO_TO_ROOT; ret = GO_TO_ROOT;
else else
ret = GO_TO_PREVIOUS; ret = GO_TO_PREVIOUS;
done = true;
} }
else if (action == ACTION_STD_CANCEL) else if (action == ACTION_STD_CANCEL)
{ {
@ -697,7 +699,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
else if (menu != &root_menu_) else if (menu != &root_menu_)
{ {
ret = GO_TO_PREVIOUS; ret = GO_TO_PREVIOUS;
break; done = true;
} }
} }
else if (action == ACTION_STD_OK) else if (action == ACTION_STD_OK)
@ -766,9 +768,9 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
} }
break; break;
case MT_RETURN_VALUE: case MT_RETURN_VALUE:
if (start_selected) ret = temp->value;
*start_selected = selected; done = true;
return temp->value; break;
} }
if (type != MT_MENU && menu_callback) if (type != MT_MENU && menu_callback)
menu_callback(ACTION_EXIT_MENUITEM,temp); menu_callback(ACTION_EXIT_MENUITEM,temp);
@ -786,7 +788,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
} }
action_signalscreenchange(); action_signalscreenchange();
if (start_selected) if (start_selected)
*start_selected = selected; *start_selected = get_menu_selection(
gui_synclist_get_sel_pos(&lists), menu);
return ret; return ret;
} }

View file

@ -359,16 +359,21 @@ void root_menu(void)
switch (ret_val) switch (ret_val)
{ {
case GO_TO_ROOT: case GO_TO_ROOT:
selected = get_selection(last_screen); if (last_screen != GO_TO_ROOT)
selected = get_selection(last_screen);
ret_val = do_menu(&root_menu_, &selected); ret_val = do_menu(&root_menu_, &selected);
/* As long as MENU_ATTACHED_USB == GO_TO_ROOT this works */ /* As long as MENU_ATTACHED_USB == GO_TO_ROOT this works */
if (ret_val == MENU_ATTACHED_USB) if (ret_val <= GO_TO_ROOT)
{ {
check_boot(); if (ret_val == MENU_ATTACHED_USB)
check_boot();
else if (ret_val == GO_TO_PREVIOUS)
{
ret_val = last_screen;
last_screen = GO_TO_ROOT;
}
continue; continue;
} }
else if (ret_val <= GO_TO_ROOT)
continue;
last_screen = GO_TO_ROOT; last_screen = GO_TO_ROOT;
break; break;