mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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:
parent
c54f4b3440
commit
b58d3656d7
12 changed files with 74 additions and 43 deletions
|
@ -486,6 +486,7 @@ bool option_screen(const struct settings_list *setting,
|
|||
temp_var = oldvalue = *(bool*)setting->setting?1:0;
|
||||
}
|
||||
else return false; /* only int/bools can go here */
|
||||
push_current_activity(ACTIVITY_OPTIONSELECT);
|
||||
gui_synclist_init(&lists, value_setting_get_name_cb,
|
||||
(void*)setting, false, 1, parent);
|
||||
if (setting->lang_id == -1)
|
||||
|
@ -566,6 +567,7 @@ bool option_screen(const struct settings_list *setting,
|
|||
if (function == sound_get_fn(SOUND_VOLUME))
|
||||
global_status.last_volume_change = current_tick;
|
||||
}
|
||||
pop_current_activity();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -317,6 +317,9 @@ static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_ente
|
|||
* - an action taken while pressing the enter button,
|
||||
* then release the enter button*/
|
||||
bool can_quit = false;
|
||||
|
||||
push_current_activity(ACTIVITY_QUICKSCREEN);
|
||||
|
||||
FOR_NB_SCREENS(i)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
pop_current_activity();
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
|
|
@ -780,7 +780,7 @@ static __attribute__((noinline)) void skin_render_playlistviewer(struct playlist
|
|||
int cur_pos, start_item, max;
|
||||
int nb_lines = viewport_get_nb_lines(viewer->vp);
|
||||
#if CONFIG_TUNER
|
||||
if (current_screen() == GO_TO_FM)
|
||||
if (get_current_activity() == ACTIVITY_FM)
|
||||
{
|
||||
cur_pos = radio_current_preset();
|
||||
start_item = cur_pos + viewer->start_offset;
|
||||
|
|
|
@ -1730,37 +1730,7 @@ const char *get_token_value(struct gui_wps *gwps,
|
|||
|
||||
case SKIN_TOKEN_CURRENT_SCREEN:
|
||||
{
|
||||
int curr_screen = current_screen();
|
||||
|
||||
#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;
|
||||
}
|
||||
int curr_screen = get_current_activity();
|
||||
if (intval)
|
||||
{
|
||||
*intval = curr_screen;
|
||||
|
|
|
@ -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(&buttonbar, "<<<", "", "");
|
||||
#endif
|
||||
|
||||
menu_callback_type menu_callback = NULL;
|
||||
|
||||
/* if hide_theme is true, assume parent has been fixed before passed into
|
||||
|
|
17
apps/misc.c
17
apps/misc.c
|
@ -1021,3 +1021,20 @@ int clamp_value_wrap(int value, int max, int min)
|
|||
}
|
||||
#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];
|
||||
}
|
||||
|
||||
|
|
20
apps/misc.h
20
apps/misc.h
|
@ -100,4 +100,24 @@ int clamp_value_wrap(int value, int max, int min);
|
|||
#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 */
|
||||
|
|
|
@ -403,6 +403,7 @@ void radio_screen(void)
|
|||
#endif
|
||||
|
||||
/* change status to "in screen" */
|
||||
push_current_activity(ACTIVITY_FM);
|
||||
in_screen = true;
|
||||
|
||||
if(radio_preset_count() <= 0)
|
||||
|
@ -868,6 +869,7 @@ void radio_screen(void)
|
|||
cpu_idle_mode(false);
|
||||
#endif
|
||||
fms_fix_displays(FMS_EXIT);
|
||||
pop_current_activity();
|
||||
in_screen = false;
|
||||
} /* radio_screen */
|
||||
|
||||
|
|
|
@ -1108,6 +1108,7 @@ bool recording_screen(bool no_source)
|
|||
|
||||
struct audio_recording_options rec_options;
|
||||
rec_status = RCSTAT_IN_RECSCREEN;
|
||||
push_current_activity(ACTIVITY_RECORDING);
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
|
||||
&& !defined(SIMULATOR)
|
||||
|
@ -2089,7 +2090,7 @@ rec_abort:
|
|||
#endif
|
||||
|
||||
settings_save();
|
||||
|
||||
pop_current_activity();
|
||||
return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
|
||||
} /* recording_screen */
|
||||
|
||||
|
|
|
@ -151,6 +151,7 @@ static int browser(void* param)
|
|||
#endif
|
||||
strcpy(folder, last_folder);
|
||||
}
|
||||
push_current_activity(ACTIVITY_FILEBROWSER);
|
||||
break;
|
||||
#ifdef HAVE_TAGCACHE
|
||||
case GO_TO_DBBROWSER:
|
||||
|
@ -246,12 +247,14 @@ static int browser(void* param)
|
|||
filter = SHOW_ID3DB;
|
||||
tc->dirlevel = last_db_dirlevel;
|
||||
tc->selected_item = last_db_selection;
|
||||
push_current_activity(ACTIVITY_DATABASEBROWSER);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL);
|
||||
ret_val = rockbox_browse(&browse);
|
||||
pop_current_activity();
|
||||
switch ((intptr_t)param)
|
||||
{
|
||||
case GO_TO_FILEBROWSER:
|
||||
|
@ -285,6 +288,7 @@ static int wpsscrn(void* param)
|
|||
{
|
||||
int ret_val = GO_TO_PREVIOUS;
|
||||
(void)param;
|
||||
push_current_activity(ACTIVITY_WPS);
|
||||
if (audio_status())
|
||||
{
|
||||
talk_shutup();
|
||||
|
@ -306,6 +310,7 @@ static int wpsscrn(void* param)
|
|||
{
|
||||
splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME));
|
||||
}
|
||||
pop_current_activity();
|
||||
return ret_val;
|
||||
}
|
||||
#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 */
|
||||
int old_previous = last_screen;
|
||||
int ret_val;
|
||||
enum current_activity activity = ACTIVITY_UNKNOWN;
|
||||
if (screen <= GO_TO_ROOT)
|
||||
return screen;
|
||||
if (screen == old_previous)
|
||||
old_previous = GO_TO_ROOT;
|
||||
global_status.last_screen = (char)screen;
|
||||
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);
|
||||
|
||||
if (activity != ACTIVITY_UNKNOWN)
|
||||
pop_current_activity();
|
||||
|
||||
last_screen = screen;
|
||||
if (ret_val == GO_TO_PREVIOUS)
|
||||
last_screen = old_previous;
|
||||
|
@ -578,16 +597,13 @@ void previous_music_is_wps(void)
|
|||
previous_music = GO_TO_WPS;
|
||||
}
|
||||
|
||||
int current_screen(void)
|
||||
{
|
||||
return next_screen;
|
||||
}
|
||||
|
||||
void root_menu(void)
|
||||
{
|
||||
int previous_browser = GO_TO_FILEBROWSER;
|
||||
int selected = 0;
|
||||
|
||||
push_current_activity(ACTIVITY_MAINMENU);
|
||||
|
||||
if (global_settings.start_in_screen == 0)
|
||||
next_screen = (int)global_status.last_screen;
|
||||
else next_screen = global_settings.start_in_screen - 2;
|
||||
|
|
|
@ -64,6 +64,4 @@ extern const struct menu_item_ex root_menu_;
|
|||
|
||||
extern void previous_music_is_wps(void);
|
||||
|
||||
extern int current_screen(void);
|
||||
|
||||
#endif /* __ROOT_MENU_H__ */
|
||||
|
|
|
@ -266,8 +266,10 @@ Example: \config{\%?mp<Stop|Play|Pause|Ffwd|Rew|Rec|Rec pause|FM|FM pause>}
|
|||
|
||||
\section{Current Screen}
|
||||
\begin{tagmap}
|
||||
\config{\%cs} & The current screen, 1-5, in the order:
|
||||
Menus, WPS, Recording screen, FM Radio screen, Current Playlist screen\\
|
||||
\config{\%cs} & The current screen, 1-15, in the order:
|
||||
Menus, WPS, Recording screen, FM Radio screen, Current Playlist screen,
|
||||
Settings menus, File browser, Database, Plugins, Quickscreen,
|
||||
Pitchscreen, Setting chooser\\
|
||||
\end{tagmap}
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue