FS#11925 - Add a proper system to keep track of the current screen/activity to make %cs far more useful

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29944 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2011-06-01 14:41:49 +00:00
parent c54f4b3440
commit b58d3656d7
12 changed files with 74 additions and 43 deletions

View file

@ -486,6 +486,7 @@ bool option_screen(const struct settings_list *setting,
temp_var = oldvalue = *(bool*)setting->setting?1:0; temp_var = oldvalue = *(bool*)setting->setting?1:0;
} }
else return false; /* only int/bools can go here */ else return false; /* only int/bools can go here */
push_current_activity(ACTIVITY_OPTIONSELECT);
gui_synclist_init(&lists, value_setting_get_name_cb, gui_synclist_init(&lists, value_setting_get_name_cb,
(void*)setting, false, 1, parent); (void*)setting, false, 1, parent);
if (setting->lang_id == -1) if (setting->lang_id == -1)
@ -566,6 +567,7 @@ bool option_screen(const struct settings_list *setting,
if (function == sound_get_fn(SOUND_VOLUME)) if (function == sound_get_fn(SOUND_VOLUME))
global_status.last_volume_change = current_tick; global_status.last_volume_change = current_tick;
} }
pop_current_activity();
return false; return false;
} }

View file

@ -317,6 +317,9 @@ static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_ente
* - an action taken while pressing the enter button, * - an action taken while pressing the enter button,
* then release the enter button*/ * then release the enter button*/
bool can_quit = false; bool can_quit = false;
push_current_activity(ACTIVITY_QUICKSCREEN);
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
screens[i].set_viewport(NULL); screens[i].set_viewport(NULL);
@ -369,6 +372,7 @@ static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_ente
viewportmanager_theme_undo(i, true); viewportmanager_theme_undo(i, true);
} }
pop_current_activity();
return changed; return changed;
} }

View file

@ -780,7 +780,7 @@ static __attribute__((noinline)) void skin_render_playlistviewer(struct playlist
int cur_pos, start_item, max; int cur_pos, start_item, max;
int nb_lines = viewport_get_nb_lines(viewer->vp); int nb_lines = viewport_get_nb_lines(viewer->vp);
#if CONFIG_TUNER #if CONFIG_TUNER
if (current_screen() == GO_TO_FM) if (get_current_activity() == ACTIVITY_FM)
{ {
cur_pos = radio_current_preset(); cur_pos = radio_current_preset();
start_item = cur_pos + viewer->start_offset; start_item = cur_pos + viewer->start_offset;

View file

@ -1730,37 +1730,7 @@ const char *get_token_value(struct gui_wps *gwps,
case SKIN_TOKEN_CURRENT_SCREEN: case SKIN_TOKEN_CURRENT_SCREEN:
{ {
int curr_screen = current_screen(); int curr_screen = get_current_activity();
#ifdef HAVE_RECORDING
/* override current_screen() for recording screen since it may
* be entered from the radio screen */
if (in_recording_screen())
curr_screen = GO_TO_RECSCREEN;
#endif
switch (curr_screen)
{
case GO_TO_WPS:
curr_screen = 2;
break;
#ifdef HAVE_RECORDING
case GO_TO_RECSCREEN:
curr_screen = 3;
break;
#endif
#if CONFIG_TUNER
case GO_TO_FM:
curr_screen = 4;
break;
#endif
case GO_TO_PLAYLIST_VIEWER:
curr_screen = 5;
break;
default: /* lists */
curr_screen = 1;
break;
}
if (intval) if (intval)
{ {
*intval = curr_screen; *intval = curr_screen;

View file

@ -345,7 +345,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) ); gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) );
gui_buttonbar_set(&buttonbar, "<<<", "", ""); gui_buttonbar_set(&buttonbar, "<<<", "", "");
#endif #endif
menu_callback_type menu_callback = NULL; menu_callback_type menu_callback = NULL;
/* if hide_theme is true, assume parent has been fixed before passed into /* if hide_theme is true, assume parent has been fixed before passed into

View file

@ -1021,3 +1021,20 @@ int clamp_value_wrap(int value, int max, int min)
} }
#endif #endif
#endif #endif
#define MAX_ACTIVITY_DEPTH 12
static enum current_activity
current_activity[MAX_ACTIVITY_DEPTH] = {ACTIVITY_UNKNOWN};
static int current_activity_top = 0;
void push_current_activity(enum current_activity screen)
{
current_activity[current_activity_top++] = screen;
}
void pop_current_activity(void)
{
current_activity_top--;
}
enum current_activity get_current_activity(void)
{
return current_activity[current_activity_top?current_activity_top-1:0];
}

View file

@ -100,4 +100,24 @@ int clamp_value_wrap(int value, int max, int min);
#endif #endif
#endif #endif
enum current_activity {
ACTIVITY_UNKNOWN = 0,
ACTIVITY_MAINMENU,
ACTIVITY_WPS,
ACTIVITY_RECORDING,
ACTIVITY_FM,
ACTIVITY_PLAYLISTVIEWER,
ACTIVITY_SETTINGS,
ACTIVITY_FILEBROWSER,
ACTIVITY_DATABASEBROWSER,
ACTIVITY_PLUGINBROWSER,
ACTIVITY_QUICKSCREEN,
ACTIVITY_PITCHSCREEN,
ACTIVITY_OPTIONSELECT
};
void push_current_activity(enum current_activity screen);
void pop_current_activity(void);
enum current_activity get_current_activity(void);
#endif /* MISC_H */ #endif /* MISC_H */

View file

@ -403,6 +403,7 @@ void radio_screen(void)
#endif #endif
/* change status to "in screen" */ /* change status to "in screen" */
push_current_activity(ACTIVITY_FM);
in_screen = true; in_screen = true;
if(radio_preset_count() <= 0) if(radio_preset_count() <= 0)
@ -868,6 +869,7 @@ void radio_screen(void)
cpu_idle_mode(false); cpu_idle_mode(false);
#endif #endif
fms_fix_displays(FMS_EXIT); fms_fix_displays(FMS_EXIT);
pop_current_activity();
in_screen = false; in_screen = false;
} /* radio_screen */ } /* radio_screen */

View file

@ -1108,6 +1108,7 @@ bool recording_screen(bool no_source)
struct audio_recording_options rec_options; struct audio_recording_options rec_options;
rec_status = RCSTAT_IN_RECSCREEN; rec_status = RCSTAT_IN_RECSCREEN;
push_current_activity(ACTIVITY_RECORDING);
#if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \ #if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
&& !defined(SIMULATOR) && !defined(SIMULATOR)
@ -2089,7 +2090,7 @@ rec_abort:
#endif #endif
settings_save(); settings_save();
pop_current_activity();
return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0; return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
} /* recording_screen */ } /* recording_screen */

View file

@ -151,6 +151,7 @@ static int browser(void* param)
#endif #endif
strcpy(folder, last_folder); strcpy(folder, last_folder);
} }
push_current_activity(ACTIVITY_FILEBROWSER);
break; break;
#ifdef HAVE_TAGCACHE #ifdef HAVE_TAGCACHE
case GO_TO_DBBROWSER: case GO_TO_DBBROWSER:
@ -246,12 +247,14 @@ static int browser(void* param)
filter = SHOW_ID3DB; filter = SHOW_ID3DB;
tc->dirlevel = last_db_dirlevel; tc->dirlevel = last_db_dirlevel;
tc->selected_item = last_db_selection; tc->selected_item = last_db_selection;
push_current_activity(ACTIVITY_DATABASEBROWSER);
break; break;
#endif #endif
} }
browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL); browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL);
ret_val = rockbox_browse(&browse); ret_val = rockbox_browse(&browse);
pop_current_activity();
switch ((intptr_t)param) switch ((intptr_t)param)
{ {
case GO_TO_FILEBROWSER: case GO_TO_FILEBROWSER:
@ -285,6 +288,7 @@ static int wpsscrn(void* param)
{ {
int ret_val = GO_TO_PREVIOUS; int ret_val = GO_TO_PREVIOUS;
(void)param; (void)param;
push_current_activity(ACTIVITY_WPS);
if (audio_status()) if (audio_status())
{ {
talk_shutup(); talk_shutup();
@ -306,6 +310,7 @@ static int wpsscrn(void* param)
{ {
splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME)); splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME));
} }
pop_current_activity();
return ret_val; return ret_val;
} }
#if CONFIG_TUNER #if CONFIG_TUNER
@ -511,13 +516,27 @@ static inline int load_screen(int screen)
if we dont we will always return to the wrong screen on boot */ if we dont we will always return to the wrong screen on boot */
int old_previous = last_screen; int old_previous = last_screen;
int ret_val; int ret_val;
enum current_activity activity = ACTIVITY_UNKNOWN;
if (screen <= GO_TO_ROOT) if (screen <= GO_TO_ROOT)
return screen; return screen;
if (screen == old_previous) if (screen == old_previous)
old_previous = GO_TO_ROOT; old_previous = GO_TO_ROOT;
global_status.last_screen = (char)screen; global_status.last_screen = (char)screen;
status_save(); status_save();
if (screen == GO_TO_BROWSEPLUGINS)
activity = ACTIVITY_PLUGINBROWSER;
else if (screen == GO_TO_MAINMENU)
activity = ACTIVITY_SETTINGS;
if (activity != ACTIVITY_UNKNOWN)
push_current_activity(activity);
ret_val = items[screen].function(items[screen].param); ret_val = items[screen].function(items[screen].param);
if (activity != ACTIVITY_UNKNOWN)
pop_current_activity();
last_screen = screen; last_screen = screen;
if (ret_val == GO_TO_PREVIOUS) if (ret_val == GO_TO_PREVIOUS)
last_screen = old_previous; last_screen = old_previous;
@ -578,16 +597,13 @@ void previous_music_is_wps(void)
previous_music = GO_TO_WPS; previous_music = GO_TO_WPS;
} }
int current_screen(void)
{
return next_screen;
}
void root_menu(void) void root_menu(void)
{ {
int previous_browser = GO_TO_FILEBROWSER; int previous_browser = GO_TO_FILEBROWSER;
int selected = 0; int selected = 0;
push_current_activity(ACTIVITY_MAINMENU);
if (global_settings.start_in_screen == 0) if (global_settings.start_in_screen == 0)
next_screen = (int)global_status.last_screen; next_screen = (int)global_status.last_screen;
else next_screen = global_settings.start_in_screen - 2; else next_screen = global_settings.start_in_screen - 2;

View file

@ -64,6 +64,4 @@ extern const struct menu_item_ex root_menu_;
extern void previous_music_is_wps(void); extern void previous_music_is_wps(void);
extern int current_screen(void);
#endif /* __ROOT_MENU_H__ */ #endif /* __ROOT_MENU_H__ */

View file

@ -266,8 +266,10 @@ Example: \config{\%?mp<Stop|Play|Pause|Ffwd|Rew|Rec|Rec pause|FM|FM pause>}
\section{Current Screen} \section{Current Screen}
\begin{tagmap} \begin{tagmap}
\config{\%cs} & The current screen, 1-5, in the order: \config{\%cs} & The current screen, 1-15, in the order:
Menus, WPS, Recording screen, FM Radio screen, Current Playlist screen\\ Menus, WPS, Recording screen, FM Radio screen, Current Playlist screen,
Settings menus, File browser, Database, Plugins, Quickscreen,
Pitchscreen, Setting chooser\\
\end{tagmap} \end{tagmap}
The tag can also be used as the switch in a conditional tag. For players without The tag can also be used as the switch in a conditional tag. For players without
some capabilities (e.g. having no FM radio) some values will be never yielded. some capabilities (e.g. having no FM radio) some values will be never yielded.