1
0
Fork 0
forked from len0rd/rockbox

Some internal rework of the wps:

a) Put duplicated code together. The restoration code into the existing restoration part of the main loop, the exiting code into a separate function
b) Let the STATUSBAR_CHANGED event handle fixing the statusbar

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20329 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2009-03-17 01:39:20 +00:00
parent 788ace2ec6
commit 680990912c
3 changed files with 62 additions and 93 deletions

View file

@ -65,6 +65,25 @@
#include "viewport.h" #include "viewport.h"
#include "pcmbuf.h" #include "pcmbuf.h"
#define GWPS_INSTANT_RESTORE 0
static void gwps_leave_wps(void)
{
int oldbars = VP_SB_HIDE_ALL;
if (global_settings.statusbar)
oldbars = VP_SB_ALLSCREENS;
viewportmanager_set_statusbar(oldbars);
#if LCD_DEPTH > 1
show_main_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_main_backdrop();
#endif
}
static int wpsbars;
/* currently only one wps_state is needed */ /* currently only one wps_state is needed */
struct wps_state wps_state; struct wps_state wps_state;
struct gui_wps gui_wps[NB_SCREENS]; struct gui_wps gui_wps[NB_SCREENS];
@ -147,38 +166,47 @@ static void play_hop(int direction)
#endif #endif
} }
static int fix_wps_bars(void) void gwps_fix_statusbars(void)
{ {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
int i; int i;
int wpsbars = VP_SB_HIDE_ALL; wpsbars = VP_SB_HIDE_ALL;
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
bool draw = global_settings.statusbar; bool draw = false;
if (gui_wps[i].data->wps_sb_tag) if (gui_wps[i].data->wps_sb_tag)
draw = gui_wps[i].data->show_sb_on_wps; draw = gui_wps[i].data->show_sb_on_wps;
if (draw) if (draw)
wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i));
} }
return wpsbars;
#else #else
return VP_SB_ALLSCREENS; wpsbars = VP_SB_ALLSCREENS;
#endif #endif
} }
/* The WPS can be left in two ways:
* a) call a function, which draws over the wps. In this case, the wps
* will be still active (i.e. the below function didn't return)
* b) return with a value evaluated by root_menu.c, in this case the wps
* is really left, and root_menu will handle the next screen
*
* In either way, call gwps_leave_wps(), in order to restore the correct
* "main screen" backdrops and statusbars
*/
long gui_wps_show(void) long gui_wps_show(void)
{ {
long button = 0; long button = 0;
bool restore = false; bool restore = false;
long restoretimer = 0; /* timer to delay screen redraw temporarily */ long restoretimer = GWPS_INSTANT_RESTORE; /* timer to delay screen redraw temporarily */
bool exit = false; bool exit = false;
bool bookmark = false; bool bookmark = false;
bool update_track = false; bool update_track = false;
int i; int i;
long last_left = 0, last_right = 0; long last_left = 0, last_right = 0;
int wpsbars, oldbars;
wps_state_init(); wps_state_init();
gwps_fix_statusbars();
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
status_set_audio(true); status_set_audio(true);
@ -197,8 +225,6 @@ long gui_wps_show(void)
ab_repeat_init(); ab_repeat_init();
ab_reset_markers(); ab_reset_markers();
#endif #endif
oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
if(audio_status() & AUDIO_STATUS_PLAY) if(audio_status() & AUDIO_STATUS_PLAY)
{ {
wps_state.id3 = audio_current_track(); wps_state.id3 = audio_current_track();
@ -210,8 +236,6 @@ long gui_wps_show(void)
restore = true; restore = true;
} }
wpsbars = fix_wps_bars();
viewportmanager_set_statusbar(wpsbars);
while ( 1 ) while ( 1 )
{ {
@ -270,12 +294,11 @@ long gui_wps_show(void)
/* The peak meter is disabled /* The peak meter is disabled
-> no additional screen updates needed */ -> no additional screen updates needed */
else { else
#endif
{
button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5);
} }
#else
button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5);
#endif
/* Exit if audio has stopped playing. This can happen if using the /* Exit if audio has stopped playing. This can happen if using the
sleep timer with the charger plugged or if starting a recording sleep timer with the charger plugged or if starting a recording
@ -310,28 +333,14 @@ long gui_wps_show(void)
{ {
case ACTION_WPS_CONTEXT: case ACTION_WPS_CONTEXT:
{ {
#if LCD_DEPTH > 1 gwps_leave_wps();
show_main_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_main_backdrop();
#endif
viewportmanager_set_statusbar(oldbars);
/* if music is stopped in the context menu we want to exit the wps */ /* if music is stopped in the context menu we want to exit the wps */
if (onplay(wps_state.id3->path, if (onplay(wps_state.id3->path,
FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU
|| !audio_status()) || !audio_status())
return GO_TO_ROOT; return GO_TO_ROOT;
viewportmanager_set_statusbar(wpsbars);
/* track might have changed */ /* track might have changed */
update_track = true; update_track = true;
#if LCD_DEPTH > 1
show_wps_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop();
#endif
restore = true; restore = true;
} }
break; break;
@ -577,23 +586,9 @@ long gui_wps_show(void)
#ifdef HAVE_QUICKSCREEN #ifdef HAVE_QUICKSCREEN
case ACTION_WPS_QUICKSCREEN: case ACTION_WPS_QUICKSCREEN:
{ {
viewportmanager_set_statusbar(oldbars); gwps_leave_wps();
#if LCD_DEPTH > 1
show_main_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_main_backdrop();
#endif
if (quick_screen_quick(button)) if (quick_screen_quick(button))
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
wpsbars = fix_wps_bars();
viewportmanager_set_statusbar(wpsbars);
#if LCD_DEPTH > 1
show_wps_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop();
#endif
restore = true; restore = true;
} }
break; break;
@ -603,18 +598,10 @@ long gui_wps_show(void)
#ifdef BUTTON_F3 #ifdef BUTTON_F3
case ACTION_F3: case ACTION_F3:
{ {
viewportmanager_set_statusbar(oldbars); gwps_leave_wps();
#if LCD_DEPTH > 1
show_main_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_main_backdrop();
#endif
if (quick_screen_f3(BUTTON_F3)) if (quick_screen_f3(BUTTON_F3))
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
restore = true; restore = true;
wpsbars = fix_wps_bars();
viewportmanager_set_statusbar(wpsbars);
} }
break; break;
#endif /* BUTTON_F3 */ #endif /* BUTTON_F3 */
@ -623,23 +610,10 @@ long gui_wps_show(void)
#ifdef HAVE_PITCHSCREEN #ifdef HAVE_PITCHSCREEN
case ACTION_WPS_PITCHSCREEN: case ACTION_WPS_PITCHSCREEN:
{ {
viewportmanager_set_statusbar(oldbars); gwps_leave_wps();
#if LCD_DEPTH > 1
show_main_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_main_backdrop();
#endif
if (1 == gui_syncpitchscreen_run()) if (1 == gui_syncpitchscreen_run())
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
#if LCD_DEPTH > 1
show_wps_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop();
#endif
restore = true; restore = true;
viewportmanager_set_statusbar(wpsbars);
} }
break; break;
#endif /* HAVE_PITCHSCREEN */ #endif /* HAVE_PITCHSCREEN */
@ -665,22 +639,9 @@ long gui_wps_show(void)
case ACTION_WPS_ID3SCREEN: case ACTION_WPS_ID3SCREEN:
{ {
viewportmanager_set_statusbar(oldbars); gwps_leave_wps();
#if LCD_DEPTH > 1
show_main_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_main_backdrop();
#endif
browse_id3(); browse_id3();
#if LCD_DEPTH > 1
show_wps_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop();
#endif
restore = true; restore = true;
viewportmanager_set_statusbar(wpsbars);
} }
break; break;
@ -697,13 +658,7 @@ long gui_wps_show(void)
break; break;
#endif #endif
case SYS_POWEROFF: case SYS_POWEROFF:
viewportmanager_set_statusbar(oldbars); gwps_leave_wps();
#if LCD_DEPTH > 1
show_main_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_main_backdrop();
#endif
default_event_handler(SYS_POWEROFF); default_event_handler(SYS_POWEROFF);
break; break;
@ -725,18 +680,26 @@ long gui_wps_show(void)
} }
if (restore && if (restore &&
((restoretimer == 0) || ((restoretimer == GWPS_INSTANT_RESTORE) ||
(restoretimer < current_tick))) TIME_AFTER(restore, current_tick)))
{ {
/* restore wps backrops and statusbars */
#if LCD_DEPTH > 1
show_wps_backdrop();
#endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop();
#endif
viewportmanager_set_statusbar(wpsbars);
restore = false; restore = false;
restoretimer = 0; restoretimer = GWPS_INSTANT_RESTORE;
if (gui_wps_display()) { if (gui_wps_display()) {
exit = true; exit = true;
} }
} }
if (exit) { if (exit) {
viewportmanager_set_statusbar(oldbars); gwps_leave_wps();
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
status_set_record(false); status_set_record(false);
status_set_audio(false); status_set_audio(false);

View file

@ -440,6 +440,9 @@ bool wps_data_load(struct wps_data *wps_data,
const char *buf, const char *buf,
bool isfile); bool isfile);
/* Sets up the statusbars for the wps and each screen */
void gwps_fix_statusbars(void);
/* Returns the index of the subline in the subline array /* Returns the index of the subline in the subline array
line - 0-based line number line - 0-based line number
subline - 0-based subline number within the line subline - 0-based subline number within the line

View file

@ -34,6 +34,7 @@
#include "statusbar.h" #include "statusbar.h"
#include "screen_access.h" #include "screen_access.h"
#include "appevents.h" #include "appevents.h"
#include "gwps.h"
static int statusbar_enabled = 0; static int statusbar_enabled = 0;
@ -123,6 +124,8 @@ void viewportmanager_draw_statusbars(void* data)
{ {
(void)data; (void)data;
int i; int i;
gwps_fix_statusbars();
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
if (showing_bars(i)) if (showing_bars(i))