1
0
Fork 0
forked from len0rd/rockbox

Statusbar handling fixes.

Fixes FS#9845 - %we/%wd wasnt working
WPS no longer resets the viewportmanger more than needed (was doing it twice/draw before)
screens can now enable/disable the statusbar easily ignoring the setting instead of needing special handling (fix for the radio screen coming soon)

minor glitch introduced in this commit... the statusbar in the WPS might disappear for a fraction of a second when it is entered, I need to track this down...


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19894 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2009-02-01 11:34:16 +00:00
parent e55f2329c0
commit 80cb3551eb
15 changed files with 91 additions and 84 deletions

View file

@ -2739,7 +2739,7 @@ static int menu_action_callback(int btn, struct gui_synclist *lists)
{ {
if (btn == ACTION_STD_OK) if (btn == ACTION_STD_OK)
{ {
bool oldbars = viewportmanager_set_statusbar(false); char oldbars = viewportmanager_set_statusbar(0);
menuitems[gui_synclist_get_sel_pos(lists)].function(); menuitems[gui_synclist_get_sel_pos(lists)].function();
btn = ACTION_REDRAW; btn = ACTION_REDRAW;
viewportmanager_set_statusbar(oldbars); viewportmanager_set_statusbar(oldbars);

View file

@ -62,6 +62,7 @@
#endif #endif
#include "backdrop.h" #include "backdrop.h"
#include "viewport.h" #include "viewport.h"
#include "pcmbuf.h"
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
/* 3% of 30min file == 54s step size */ /* 3% of 30min file == 54s step size */
@ -75,36 +76,6 @@
#define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */ #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
/* draws the statusbar on the given wps-screen */
#ifdef HAVE_LCD_BITMAP
static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force)
{
(void)force;
bool draw = global_settings.statusbar;
if (wps->data->wps_sb_tag)
draw = wps->data->show_sb_on_wps;
#if NB_SCREENS > 1
/* multi screen targets could show the bars on one screen but not both
* so the viewportmanager can't be used in its current form...
* Also, the WPS is a special screen so doing this is reasonable.
*/
if (draw)
{
struct gui_statusbar *bar;
bar = &statusbars.statusbars[wps->data->remote_wps?SCREEN_REMOTE:SCREEN_MAIN];
gui_statusbar_draw(bar, force);
}
#else
viewportmanager_set_statusbar(draw);
#endif
}
#else
#define gui_wps_statusbar_draw(wps, force) viewportmanager_set_statusbar(true)
#endif
#include "pcmbuf.h"
/* fades the volume */ /* fades the volume */
bool wps_fading_out = false; bool wps_fading_out = false;
void fade(bool fade_in, bool updatewps) void fade(bool fade_in, bool updatewps)
@ -170,7 +141,6 @@ void fade(bool fade_in, bool updatewps)
*/ */
bool update_onvol_change(struct gui_wps * gwps) bool update_onvol_change(struct gui_wps * gwps)
{ {
gui_wps_statusbar_draw(gwps, false);
gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC);
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
@ -366,7 +336,6 @@ bool gui_wps_display(void)
} }
#endif #endif
#endif #endif
gui_wps[i].display->clear_display(); gui_wps[i].display->clear_display();
if (!gui_wps[i].data->wps_loaded) { if (!gui_wps[i].data->wps_loaded) {
if ( !gui_wps[i].data->num_tokens ) { if ( !gui_wps[i].data->num_tokens ) {
@ -481,8 +450,6 @@ bool update(struct gui_wps *gwps)
gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC);
} }
gui_wps_statusbar_draw(gwps, false);
return retcode; return retcode;
} }
@ -1978,7 +1945,6 @@ bool gui_wps_refresh(struct gui_wps *gwps,
bool update_line, new_subline_refresh; bool update_line, new_subline_refresh;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
gui_wps_statusbar_draw(gwps, true);
/* to find out wether the peak meter is enabled we /* to find out wether the peak meter is enabled we
assume it wasn't until we find a line that contains assume it wasn't until we find a line that contains
@ -2195,7 +2161,8 @@ 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

@ -115,8 +115,24 @@ static void next_track(void)
audio_next(); audio_next();
} }
static char fix_wps_bars(void)
{
#ifdef HAVE_LCD_BITMAP
int i;
char wpsbars = 0;
FOR_NB_SCREENS(i)
{
bool draw = global_settings.statusbar;
if (gui_wps[i].data->wps_sb_tag)
draw = gui_wps[i].data->show_sb_on_wps;
if (draw)
wpsbars |= VP_IGNORE_SB_SETTING(i)|(1<<i);
}
return wpsbars;
#else
return 1;
#endif
}
long gui_wps_show(void) long gui_wps_show(void)
{ {
long button = 0; long button = 0;
@ -127,8 +143,8 @@ 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;
char wpsbars = 0, oldbars = 0;
viewportmanager_set_statusbar(false);
wps_state_init(); wps_state_init();
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
@ -149,6 +165,7 @@ long gui_wps_show(void)
ab_reset_markers(); ab_reset_markers();
#endif #endif
oldbars = viewportmanager_set_statusbar(0);
if(audio_status() & AUDIO_STATUS_PLAY) if(audio_status() & AUDIO_STATUS_PLAY)
{ {
wps_state.id3 = audio_current_track(); wps_state.id3 = audio_current_track();
@ -156,12 +173,13 @@ long gui_wps_show(void)
if (wps_state.id3) { if (wps_state.id3) {
if (gui_wps_display()) if (gui_wps_display())
return 0; return 0;
FOR_NB_SCREENS(i)
gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL);
} }
restore = true; restore = true;
} }
wpsbars = fix_wps_bars();
viewportmanager_set_statusbar(wpsbars);
while ( 1 ) while ( 1 )
{ {
bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
@ -259,20 +277,19 @@ long gui_wps_show(void)
{ {
case ACTION_WPS_CONTEXT: case ACTION_WPS_CONTEXT:
{ {
bool bars;
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
show_main_backdrop(); show_main_backdrop();
#endif #endif
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_main_backdrop(); show_remote_main_backdrop();
#endif #endif
bars = viewportmanager_set_statusbar(true); 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(bars); viewportmanager_set_statusbar(wpsbars);
/* track might have changed */ /* track might have changed */
update_track = true; update_track = true;
@ -527,7 +544,7 @@ long gui_wps_show(void)
#ifdef HAVE_QUICKSCREEN #ifdef HAVE_QUICKSCREEN
case ACTION_WPS_QUICKSCREEN: case ACTION_WPS_QUICKSCREEN:
{ {
bool bars = viewportmanager_set_statusbar(true); viewportmanager_set_statusbar(oldbars);
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
show_main_backdrop(); show_main_backdrop();
#endif #endif
@ -536,7 +553,8 @@ long gui_wps_show(void)
#endif #endif
if (quick_screen_quick(button)) if (quick_screen_quick(button))
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
viewportmanager_set_statusbar(bars); wpsbars = fix_wps_bars();
viewportmanager_set_statusbar(wpsbars);
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
show_wps_backdrop(); show_wps_backdrop();
#endif #endif
@ -552,7 +570,7 @@ long gui_wps_show(void)
#ifdef BUTTON_F3 #ifdef BUTTON_F3
case ACTION_F3: case ACTION_F3:
{ {
bool bars = viewportmanager_set_statusbar(true); viewportmanager_set_statusbar(oldbars);
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
show_main_backdrop(); show_main_backdrop();
#endif #endif
@ -562,7 +580,8 @@ long gui_wps_show(void)
if (quick_screen_f3(BUTTON_F3)) if (quick_screen_f3(BUTTON_F3))
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
restore = true; restore = true;
viewportmanager_set_statusbar(bars); wpsbars = fix_wps_bars();
viewportmanager_set_statusbar(wpsbars);
} }
break; break;
#endif /* BUTTON_F3 */ #endif /* BUTTON_F3 */
@ -571,7 +590,7 @@ long gui_wps_show(void)
#ifdef HAVE_PITCHSCREEN #ifdef HAVE_PITCHSCREEN
case ACTION_WPS_PITCHSCREEN: case ACTION_WPS_PITCHSCREEN:
{ {
bool bars = viewportmanager_set_statusbar(true); viewportmanager_set_statusbar(oldbars);
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
show_main_backdrop(); show_main_backdrop();
#endif #endif
@ -587,7 +606,7 @@ long gui_wps_show(void)
show_remote_wps_backdrop(); show_remote_wps_backdrop();
#endif #endif
restore = true; restore = true;
viewportmanager_set_statusbar(bars); viewportmanager_set_statusbar(wpsbars);
} }
break; break;
#endif /* HAVE_PITCHSCREEN */ #endif /* HAVE_PITCHSCREEN */
@ -613,7 +632,7 @@ long gui_wps_show(void)
case ACTION_WPS_ID3SCREEN: case ACTION_WPS_ID3SCREEN:
{ {
bool bars = viewportmanager_set_statusbar(true); viewportmanager_set_statusbar(oldbars);
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
show_main_backdrop(); show_main_backdrop();
#endif #endif
@ -628,7 +647,7 @@ long gui_wps_show(void)
show_remote_wps_backdrop(); show_remote_wps_backdrop();
#endif #endif
restore = true; restore = true;
viewportmanager_set_statusbar(bars); viewportmanager_set_statusbar(wpsbars);
} }
break; break;
@ -645,7 +664,7 @@ long gui_wps_show(void)
break; break;
#endif #endif
case SYS_POWEROFF: case SYS_POWEROFF:
viewportmanager_set_statusbar(true); viewportmanager_set_statusbar(oldbars);
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
show_main_backdrop(); show_main_backdrop();
#endif #endif
@ -681,13 +700,10 @@ long gui_wps_show(void)
if (gui_wps_display()) { if (gui_wps_display()) {
exit = true; exit = true;
} }
else if (wps_state.id3){
FOR_NB_SCREENS(i)
gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC);
}
} }
if (exit) { if (exit) {
viewportmanager_set_statusbar(oldbars);
#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

@ -845,7 +845,7 @@ bool simplelist_show_list(struct simplelist_info *info)
{ {
struct gui_synclist lists; struct gui_synclist lists;
int action, old_line_count = simplelist_line_count; int action, old_line_count = simplelist_line_count;
bool oldbars = viewportmanager_set_statusbar(true); char oldbars = viewportmanager_set_statusbar(VP_ALLSCREENS);
char* (*getname)(int item, void * data, char *buffer, size_t buffer_len); char* (*getname)(int item, void * data, char *buffer, size_t buffer_len);
int wrap = LIST_WRAP_UNLESS_HELD; int wrap = LIST_WRAP_UNLESS_HELD;
if (info->get_name) if (info->get_name)

View file

@ -35,7 +35,7 @@
#include "screen_access.h" #include "screen_access.h"
#include "appevents.h" #include "appevents.h"
static bool statusbar_enabled = true; static char statusbar_enabled = VP_ALLSCREENS;
int viewport_get_nb_lines(struct viewport *vp) int viewport_get_nb_lines(struct viewport *vp)
{ {
@ -47,13 +47,19 @@ int viewport_get_nb_lines(struct viewport *vp)
#endif #endif
} }
static bool showing_bars(enum screen_type screen)
{
if (statusbar_enabled&(1<<screen))
return global_settings.statusbar || (statusbar_enabled&(1<<(screen+4)));
return false;
}
void viewport_set_defaults(struct viewport *vp, enum screen_type screen) void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
{ {
vp->x = 0; vp->x = 0;
vp->width = screens[screen].lcdwidth; vp->width = screens[screen].lcdwidth;
vp->y = statusbar_enabled?gui_statusbar_height():0; vp->y = showing_bars(screen)?gui_statusbar_height():0;
vp->height = screens[screen].lcdheight - vp->y; vp->height = screens[screen].lcdheight - vp->y;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
vp->drawmode = DRMODE_SOLID; vp->drawmode = DRMODE_SOLID;
@ -87,17 +93,18 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
} }
/* returns true if it was enabled BEFORE this call */ /* returns true if it was enabled BEFORE this call */
bool viewportmanager_set_statusbar(bool enabled) char viewportmanager_set_statusbar(char enabled)
{ {
bool old = statusbar_enabled; char old = statusbar_enabled;
if (enabled if (enabled)
#ifdef HAVE_LCD_BITMAP
&& global_settings.statusbar
#endif
)
{ {
int i;
FOR_NB_SCREENS(i)
{
if (showing_bars(i))
gui_statusbar_draw(&statusbars.statusbars[i], true);
}
add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_draw_statusbars); add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_draw_statusbars);
gui_syncstatusbar_draw(&statusbars, true);
} }
else else
{ {
@ -110,8 +117,12 @@ bool viewportmanager_set_statusbar(bool enabled)
void viewportmanager_draw_statusbars(void* data) void viewportmanager_draw_statusbars(void* data)
{ {
(void)data; (void)data;
if (statusbar_enabled) int i;
gui_syncstatusbar_draw(&statusbars, false); FOR_NB_SCREENS(i)
{
if (showing_bars(i))
gui_statusbar_draw(&statusbars.statusbars[i], false);
}
} }
void viewportmanager_statusbar_changed(void* data) void viewportmanager_statusbar_changed(void* data)

View file

@ -41,7 +41,18 @@ int viewport_load_config(const char *config, struct viewport *vp);
void viewport_set_defaults(struct viewport *vp, enum screen_type screen); void viewport_set_defaults(struct viewport *vp, enum screen_type screen);
bool viewportmanager_set_statusbar(bool enabled); /* viewportmanager_set_statusbar() is used to specify which screens the statusbar
* should be displayed on.
* *usually* enabled will be VP_ALLSCREENS which means display the bar if the setting
* is enabled. (and it will be on both screens)
* For the WPS (and other possible exceptions) use VP_IGNORE_SB_SETTING() to
* FORCE the statusbar on for the given screen (i.e it will show regardless of the setting
*/
#define VP_SB_ONSCREEN(screen) (1<<screen) /* turn the SB on "screen" only */
#define VP_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) /* SB on for both screens */
#define VP_IGNORE_SB_SETTING(screen) (1<<(4+screen))
char viewportmanager_set_statusbar(char enabled);
/* callbacks for GUI_EVENT_* events */ /* callbacks for GUI_EVENT_* events */
void viewportmanager_draw_statusbars(void*data); void viewportmanager_draw_statusbars(void*data);
void viewportmanager_statusbar_changed(void* data); void viewportmanager_statusbar_changed(void* data);

View file

@ -138,7 +138,7 @@ static void app_main(void)
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN
touchscreen_set_mode(TOUCHSCREEN_BUTTON); touchscreen_set_mode(TOUCHSCREEN_BUTTON);
#endif #endif
viewportmanager_set_statusbar(true); viewportmanager_set_statusbar(VP_ALLSCREENS);
add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, add_event(GUI_EVENT_STATUSBAR_TOGGLE, false,
viewportmanager_statusbar_changed); viewportmanager_statusbar_changed);
#ifdef HAVE_USBSTACK #ifdef HAVE_USBSTACK

View file

@ -355,7 +355,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
const struct menu_item_ex *temp, *menu; const struct menu_item_ex *temp, *menu;
int ret = 0, i; int ret = 0, i;
bool redraw_lists; bool redraw_lists;
bool oldbars = viewportmanager_set_statusbar(!hide_bars); char oldbars = viewportmanager_set_statusbar(hide_bars?0:VP_ALLSCREENS);
const struct menu_item_ex *menu_stack[MAX_MENUS]; const struct menu_item_ex *menu_stack[MAX_MENUS];
int menu_stack_selected_item[MAX_MENUS]; int menu_stack_selected_item[MAX_MENUS];

View file

@ -392,7 +392,7 @@ bool eq_menu_graphical(void)
enum eq_type current_type; enum eq_type current_type;
char buf[24]; char buf[24];
int i, w, h, height, start_item, nb_eq_sliders[NB_SCREENS]; int i, w, h, height, start_item, nb_eq_sliders[NB_SCREENS];
bool barsenabled = viewportmanager_set_statusbar(false); char barsenabled = viewportmanager_set_statusbar(0);
FOR_NB_SCREENS(i) { FOR_NB_SCREENS(i) {

View file

@ -636,7 +636,7 @@ static const struct plugin_api rockbox_api = {
int plugin_load(const char* plugin, const void* parameter) int plugin_load(const char* plugin, const void* parameter)
{ {
int rc; int rc;
bool oldbars; char oldbars;
struct plugin_header *hdr; struct plugin_header *hdr;
#ifdef SIMULATOR #ifdef SIMULATOR
void *pd; void *pd;
@ -743,11 +743,11 @@ int plugin_load(const char* plugin, const void* parameter)
#endif #endif
invalidate_icache(); invalidate_icache();
oldbars = viewportmanager_set_statusbar(false); oldbars = viewportmanager_set_statusbar(0);
rc = hdr->entry_point(parameter); rc = hdr->entry_point(parameter);
viewportmanager_set_statusbar(true); viewportmanager_set_statusbar(oldbars);
button_clear_queue(); button_clear_queue();

View file

@ -126,12 +126,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 139 #define PLUGIN_API_VERSION 140
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 137 #define PLUGIN_MIN_API_VERSION 140
/* plugin return codes */ /* plugin return codes */
enum plugin_status { enum plugin_status {
@ -312,7 +312,7 @@ struct plugin_api {
int height); int height);
#endif #endif
void (*viewport_set_defaults)(struct viewport *vp, enum screen_type screen); void (*viewport_set_defaults)(struct viewport *vp, enum screen_type screen);
bool (*viewportmanager_set_statusbar)(bool enabled); char (*viewportmanager_set_statusbar)(char enabled);
/* list */ /* list */
void (*gui_synclist_init)(struct gui_synclist * lists, void (*gui_synclist_init)(struct gui_synclist * lists,
list_get_name callback_get_item_name, void * data, list_get_name callback_get_item_name, void * data,

View file

@ -94,6 +94,7 @@ int menu_show(int m)
bool exit = false; bool exit = false;
int key; int key;
char bars = rb->viewportmanager_set_statusbar(VP_ALLSCREENS);
rb->gui_synclist_draw(&(menus[m].synclist)); rb->gui_synclist_draw(&(menus[m].synclist));
while (!exit) { while (!exit) {
key = rb->get_action(CONTEXT_MAINMENU,HZ/2); key = rb->get_action(CONTEXT_MAINMENU,HZ/2);
@ -123,6 +124,7 @@ int menu_show(int m)
break; break;
} }
} }
rb->viewportmanager_set_statusbar(bars);
return MENU_SELECTED_EXIT; return MENU_SELECTED_EXIT;
} }

View file

@ -1030,7 +1030,7 @@ static int star_menu(void)
} }
while(!menu_quit) while(!menu_quit)
{ {
switch(rb->do_menu(&menu, &selection, vp, true)) switch(rb->do_menu(&menu, &selection, vp, false))
{ {
case 0: case 0:
menu_quit = true; menu_quit = true;

View file

@ -298,7 +298,7 @@ int kbd_input(char* text, int buflen)
int morse_tick = 0; int morse_tick = 0;
char buf[2]; char buf[2];
#endif #endif
bool oldbars = viewportmanager_set_statusbar(false); char oldbars = viewportmanager_set_statusbar(0);
FOR_NB_SCREENS(l) FOR_NB_SCREENS(l)
{ {
struct keyboard_parameters *pm = &param[l]; struct keyboard_parameters *pm = &param[l];

View file

@ -270,7 +270,7 @@ static int wpsscrn(void* param)
show_remote_main_backdrop(); show_remote_main_backdrop();
#endif #endif
/* always re-enable the statusbar after the WPS */ /* always re-enable the statusbar after the WPS */
viewportmanager_set_statusbar(true); viewportmanager_set_statusbar(VP_ALLSCREENS);
return ret_val; return ret_val;
} }
#if CONFIG_TUNER #if CONFIG_TUNER