Playlist Viewer Changes to bring consistency:

- combine its two context menus to one and
- make the ACTION_STD_MENU go to the main menu as it does in all other screens
- call playlist_viewer() via root_menu to reduce call depth and to be consistent with other screens (and for the above changes to be more flexible w.r.t to the following screen)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24791 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2010-02-20 19:06:39 +00:00
parent abb3dd4ec2
commit c19e53654b
8 changed files with 60 additions and 35 deletions

View File

@ -859,11 +859,14 @@ long gui_wps_show(void)
case ACTION_WPS_CONTEXT:
{
gwps_leave_wps();
int retval = onplay(wps_state.id3->path,
FILE_ATTR_AUDIO, CONTEXT_WPS);
/* if music is stopped in the context menu we want to exit the wps */
if (onplay(wps_state.id3->path,
FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU
if (retval == ONPLAY_MAINMENU
|| !audio_status())
return GO_TO_ROOT;
else if (retval == ONPLAY_PLAYLIST)
return GO_TO_PLAYLIST_VIEWER;
restore = true;
}
break;
@ -1150,9 +1153,7 @@ long gui_wps_show(void)
break;
case ACTION_WPS_VIEW_PLAYLIST:
gwps_leave_wps();
if (playlist_viewer()) /* true if USB connected */
return GO_TO_ROOT;
restore = true;
return GO_TO_PLAYLIST_VIEWER;
break;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED)

View File

@ -60,10 +60,16 @@ int save_playlist_screen(struct playlist_info* playlist)
return 0;
}
static int playlist_view_(void)
{
return GO_TO_PLAYLIST_VIEWER;
}
MENUITEM_FUNCTION(create_playlist_item, 0, ID2P(LANG_CREATE_PLAYLIST),
(int(*)(void))create_playlist, NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(view_playlist, 0, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST),
(int(*)(void))playlist_viewer, NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(view_cur_playlist, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST),
(int(*)(void))playlist_view_, NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(save_playlist, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST),
(int(*)(void*))save_playlist_screen,
NULL, NULL, Icon_NOICON);
@ -78,5 +84,5 @@ MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL,
&recursive_dir_insert, &warn_on_erase);
MAKE_MENU(playlist_options, ID2P(LANG_PLAYLISTS), NULL,
Icon_Playlist,
&create_playlist_item, &view_playlist, &save_playlist, &catalog);
&create_playlist_item, &view_cur_playlist, &save_playlist, &catalog);

View File

@ -137,15 +137,13 @@ static bool shuffle_playlist(void)
return false;
}
static bool save_playlist(void)
{
save_playlist_screen(NULL);
return false;
}
MENUITEM_FUNCTION(playlist_viewer_item, 0, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST),
playlist_viewer, NULL, NULL, Icon_Playlist);
extern struct menu_item_ex view_cur_playlist; /* from playlist_menu.c */
MENUITEM_FUNCTION(search_playlist_item, 0, ID2P(LANG_SEARCH_IN_PLAYLIST),
search_playlist, NULL, NULL, Icon_Playlist);
MENUITEM_FUNCTION(playlist_save_item, 0, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST),
@ -154,7 +152,7 @@ MENUITEM_FUNCTION(reshuffle_item, 0, ID2P(LANG_SHUFFLE_PLAYLIST),
shuffle_playlist, NULL, NULL, Icon_Playlist);
MAKE_ONPLAYMENU( wps_playlist_menu, ID2P(LANG_PLAYLIST),
NULL, Icon_Playlist,
&playlist_viewer_item, &search_playlist_item,
&view_cur_playlist, &search_playlist_item,
&playlist_save_item, &reshuffle_item
);
@ -1188,6 +1186,8 @@ int onplay(char* file, int attr, int from)
case GO_TO_ROOT:
case GO_TO_MAINMENU:
return ONPLAY_MAINMENU;
case GO_TO_PLAYLIST_VIEWER:
return ONPLAY_PLAYLIST;
default:
return onplay_result;
}

View File

@ -27,7 +27,8 @@ enum {
ONPLAY_MAINMENU = -1,
ONPLAY_OK = 0,
ONPLAY_RELOAD_DIR,
ONPLAY_START_PLAY
ONPLAY_START_PLAY,
ONPLAY_PLAYLIST,
};
#endif

View File

@ -448,7 +448,8 @@ static int onplay_menu(int index)
playlist_buffer_get_track(&viewer.buffer, index);
MENUITEM_STRINGLIST(menu_items, ID2P(LANG_PLAYLIST), NULL,
ID2P(LANG_REMOVE), ID2P(LANG_MOVE),
ID2P(LANG_CATALOG_ADD_TO), ID2P(LANG_CATALOG_ADD_TO_NEW));
ID2P(LANG_CATALOG_ADD_TO), ID2P(LANG_CATALOG_ADD_TO_NEW),
ID2P(LANG_PLAYLISTVIEWER_SETTINGS));
bool current = (current_track->index == viewer.current_playing_track);
result = do_menu(&menu_items, NULL, NULL, false);
@ -503,6 +504,10 @@ static int onplay_menu(int index)
result==3, NULL);
ret = 0;
break;
case 4: /* playlist viewer settings */
/* true on usb connect */
ret = viewer_menu() ? -1 : 0;
break;
}
}
return ret;
@ -531,7 +536,7 @@ static int save_playlist_func(void)
}
/* View current playlist */
bool playlist_viewer(void)
enum playlist_viewer_result playlist_viewer(void)
{
return playlist_viewer_ex(NULL);
}
@ -606,9 +611,9 @@ static enum themable_icons playlist_callback_icons(int selected_item,
/* Main viewer function. Filename identifies playlist to be viewed. If NULL,
view current playlist. */
bool playlist_viewer_ex(const char* filename)
enum playlist_viewer_result playlist_viewer_ex(const char* filename)
{
bool ret = false; /* return value */
enum playlist_viewer_result ret = PLAYLIST_VIEWER_OK;
bool exit=false; /* exit viewer */
int button;
struct gui_synclist playlist_lists;
@ -730,7 +735,7 @@ bool playlist_viewer_ex(const char* filename)
if (ret_val < 0)
{
ret = true;
ret = PLAYLIST_VIEWER_USB;
goto exit;
}
else if (ret_val > 0)
@ -747,23 +752,12 @@ bool playlist_viewer_ex(const char* filename)
break;
}
case ACTION_STD_MENU:
if (viewer_menu())
{
ret = true;
goto exit;
}
gui_synclist_set_icon_callback(
&playlist_lists,
global_settings.playlist_viewer_icons?
&playlist_callback_icons:NULL
);
gui_synclist_draw(&playlist_lists);
break;
ret = PLAYLIST_VIEWER_MAINMENU;
goto exit;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED)
{
ret = true;
ret = PLAYLIST_VIEWER_USB;
goto exit;
}
break;

View File

@ -23,8 +23,14 @@
#ifndef _PLAYLIST_VIEWER_H_
#define _PLAYLIST_VIEWER_H_
bool playlist_viewer(void);
bool playlist_viewer_ex(const char* filename);
enum playlist_viewer_result playlist_viewer(void);
enum playlist_viewer_result playlist_viewer_ex(const char* filename);
bool search_playlist(void);
enum playlist_viewer_result {
PLAYLIST_VIEWER_OK,
PLAYLIST_VIEWER_USB,
PLAYLIST_VIEWER_MAINMENU,
};
#endif

View File

@ -60,6 +60,7 @@
#include "wps.h"
#include "bookmark.h"
#include "playlist.h"
#include "playlist_viewer.h"
#include "menus/exported_menus.h"
#ifdef HAVE_RTC_ALARM
#include "rtc.h"
@ -313,6 +314,20 @@ static int radio(void* param)
}
#endif
static int playlist_view(void * param)
{
(void)param;
switch (playlist_viewer())
{
case PLAYLIST_VIEWER_MAINMENU:
case PLAYLIST_VIEWER_USB:
return GO_TO_ROOT;
case PLAYLIST_VIEWER_OK:
return GO_TO_PREVIOUS;
}
return GO_TO_PREVIOUS;
}
static int load_bmarks(void* param)
{
(void)param;
@ -381,7 +396,8 @@ static const struct root_items items[] = {
#endif
[GO_TO_RECENTBMARKS] = { load_bmarks, NULL, &bookmark_settings_menu },
[GO_TO_BROWSEPLUGINS] = { plugins_menu, NULL, NULL },
[GO_TO_BROWSEPLUGINS] = { plugins_menu, NULL, NULL },
[GO_TO_PLAYLIST_VIEWER] = { playlist_view, NULL, NULL },
};
static const int nb_items = sizeof(items)/sizeof(*items);

View File

@ -52,6 +52,7 @@ enum {
will need editing if this is the case. */
GO_TO_BROWSEPLUGINS,
GO_TO_TIMESCREEN,
GO_TO_PLAYLIST_VIEWER,
};
extern const struct menu_item_ex root_menu_;