1
0
Fork 0
forked from len0rd/rockbox

Fix up statusbar drawing in the wps a bit, fixing most, if not all, (re-)draw issues.

a) remove the temporary work around in gui_wps_display
b) let the  wps-statusbars redraw if it's masked (i.e. WPS_REFRESH_ALL or WPS_REFRESH_STATUSBAR)
c) fix a bug of mine, I attached re-fixing the bars to the wrong event
d) unify the decision whether to draw bars at all
e) some other style/code minor cleanups

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20400 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2009-03-20 16:12:09 +00:00
parent ce6b116bc1
commit ad59f6ed22
4 changed files with 33 additions and 35 deletions

View file

@ -353,16 +353,6 @@ bool gui_wps_display(void)
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL); gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL);
#ifdef HAVE_LCD_BITMAP
/* temporary work around so the statusbar doesnt disappear when the WPS
* is first entered. This should be removed when the
* WPS-statusbar handling is fixed up a bit more */
bool draw = global_settings.statusbar;
if (gui_wps[i].data->wps_sb_tag)
draw = gui_wps[i].data->show_sb_on_wps;
if (draw)
gui_statusbar_draw(&statusbars.statusbars[i], true);
#endif
} }
return false; return false;
} }
@ -2114,6 +2104,10 @@ bool gui_wps_refresh(struct gui_wps *gwps,
data->peak_meter_enabled = enable_pm; data->peak_meter_enabled = enable_pm;
#endif #endif
if (refresh_mode & WPS_REFRESH_STATUSBAR)
{
gwps_draw_statusbars();
}
/* Restore the default viewport */ /* Restore the default viewport */
display->set_viewport(NULL); display->set_viewport(NULL);
@ -2152,7 +2146,5 @@ bool gui_wps_refresh(struct gui_wps *gwps,
remote_backlight_on(); remote_backlight_on();
} }
#endif #endif
/* force a bars update if they are being displayed */
viewportmanager_draw_statusbars(NULL);
return true; return true;
} }

View file

@ -151,7 +151,7 @@ static void play_hop(int direction)
#endif #endif
} }
void gwps_fix_statusbars(void) static void gwps_fix_statusbars(void)
{ {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
int i; int i;
@ -161,9 +161,11 @@ void gwps_fix_statusbars(void)
bool draw = false; 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;
else if (global_settings.statusbar)
wpsbars |= VP_SB_ONSCREEN(i);
if (draw) if (draw)
wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i));
} }
#else #else
wpsbars = VP_SB_ALLSCREENS; wpsbars = VP_SB_ALLSCREENS;
#endif #endif
@ -188,6 +190,11 @@ static void gwps_leave_wps(void)
viewportmanager_set_statusbar(oldbars); viewportmanager_set_statusbar(oldbars);
} }
void gwps_draw_statusbars(void)
{
viewportmanager_set_statusbar(wpsbars);
}
/* The WPS can be left in two ways: /* The WPS can be left in two ways:
* a) call a function, which draws over the wps. In this case, the wps * 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) * will be still active (i.e. the below function didn't return)
@ -207,7 +214,6 @@ long gui_wps_show(void)
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;
wps_state_init(); wps_state_init();
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
@ -685,7 +691,7 @@ long gui_wps_show(void)
if (restore && if (restore &&
((restoretimer == RESTORE_WPS_INSTANTLY) || ((restoretimer == RESTORE_WPS_INSTANTLY) ||
TIME_AFTER(restore, current_tick))) TIME_AFTER(current_tick, restoretimer)))
{ {
/* restore wps backrops and statusbars */ /* restore wps backrops and statusbars */
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
@ -694,7 +700,6 @@ long gui_wps_show(void)
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop(); show_remote_wps_backdrop();
#endif #endif
viewportmanager_set_statusbar(wpsbars);
restore = false; restore = false;
restoretimer = RESTORE_WPS_INSTANTLY; restoretimer = RESTORE_WPS_INSTANTLY;
if (gui_wps_display()) { if (gui_wps_display()) {
@ -751,22 +756,21 @@ static void statusbar_toggle_handler(void *data)
{ {
(void)data; (void)data;
int i; int i;
bool draw = global_settings.statusbar; gwps_fix_statusbars();
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
struct wps_viewport *vp = &gui_wps[i].data->viewports[0]; struct viewport *vp = &gui_wps[i].data->viewports[0].vp;
if (gui_wps[i].data->wps_sb_tag) bool draw = wpsbars & (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i));
draw = gui_wps[i].data->show_sb_on_wps;
if (!draw) if (!draw)
{ {
vp->vp.y = 0; vp->y = 0;
vp->vp.height = screens[i].lcdheight; vp->height = screens[i].lcdheight;
} }
else else
{ {
vp->vp.y = STATUSBAR_HEIGHT; vp->y = STATUSBAR_HEIGHT;
vp->vp.height = screens[i].lcdheight - STATUSBAR_HEIGHT; vp->height = screens[i].lcdheight - STATUSBAR_HEIGHT;
} }
} }
} }

View file

@ -26,15 +26,18 @@
#include "metadata.h" #include "metadata.h"
/* constants used in line_type and as refresh_mode for wps_refresh */ /* constants used in line_type and as refresh_mode for wps_refresh */
#define WPS_REFRESH_STATIC 1 /* line doesn't change over time */ #define WPS_REFRESH_STATIC (1<<0) /* line doesn't change over time */
#define WPS_REFRESH_DYNAMIC 2 /* line may change (e.g. time flag) */ #define WPS_REFRESH_DYNAMIC (1<<1) /* line may change (e.g. time flag) */
#define WPS_REFRESH_SCROLL 4 /* line scrolls */ #define WPS_REFRESH_SCROLL (1<<2) /* line scrolls */
#define WPS_REFRESH_PLAYER_PROGRESS 8 /* line contains a progress bar */ #define WPS_REFRESH_PLAYER_PROGRESS (1<<3) /* line contains a progress bar */
#define WPS_REFRESH_PEAK_METER 16 /* line contains a peak meter */ #define WPS_REFRESH_PEAK_METER (1<<4) /* line contains a peak meter */
#define WPS_REFRESH_STATUSBAR (1<<5) /* refresh statusbar */
#define WPS_REFRESH_ALL 0xff /* to refresh all line types */ #define WPS_REFRESH_ALL 0xff /* to refresh all line types */
/* to refresh only those lines that change over time */
#define WPS_REFRESH_NON_STATIC (WPS_REFRESH_ALL & ~WPS_REFRESH_STATIC & ~WPS_REFRESH_SCROLL)
/* to refresh only those lines that change over time */
#define WPS_REFRESH_NON_STATIC (WPS_REFRESH_DYNAMIC| \
WPS_REFRESH_PLAYER_PROGRESS| \
WPS_REFRESH_PEAK_METER)
/* alignments */ /* alignments */
#define WPS_ALIGN_RIGHT 32 #define WPS_ALIGN_RIGHT 32
#define WPS_ALIGN_CENTER 64 #define WPS_ALIGN_CENTER 64
@ -440,8 +443,8 @@ 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 */ /* Redraw statusbars if necessary */
void gwps_fix_statusbars(void); void gwps_draw_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

View file

@ -125,7 +125,6 @@ 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))