cleanup statusbar+base skin relationship...

* remove the "custom" option from the statusbar setting. if a sbs file is set then statusbar setting is ignored, no other user visible change there.
* new tag, %wi  - use to draw the inbuilt statusbar in the current viewport


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25038 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2010-03-06 00:29:46 +00:00
parent 43ed678b46
commit a9b5f4d810
10 changed files with 65 additions and 54 deletions

View file

@ -510,18 +510,14 @@ int ft_enter(struct tree_context* c)
#ifdef HAVE_LCD_BITMAP
case FILE_ATTR_SBS:
splash(0, ID2P(LANG_WAIT));
set_file(buf, (char *)global_settings.sbs_file,
MAX_FILENAME);
global_settings.statusbar = STATUSBAR_CUSTOM;
set_file(buf, (char *)global_settings.sbs_file, MAX_FILENAME);
settings_apply_skins();
break;
#endif
#ifdef HAVE_REMOTE_LCD
case FILE_ATTR_RSBS:
splash(0, ID2P(LANG_WAIT));
set_file(buf, (char *)global_settings.rsbs_file,
MAX_FILENAME);
global_settings.remote_statusbar = STATUSBAR_CUSTOM;
set_file(buf, (char *)global_settings.rsbs_file, MAX_FILENAME);
settings_apply_skins();
break;
#endif

View file

@ -630,7 +630,8 @@ static bool get_line(struct gui_wps *gwps,
struct skin_subline *subline,
struct align_pos *align,
char *linebuf,
int linebuf_size)
int linebuf_size,
unsigned refresh_mode)
{
struct wps_data *data = gwps->data;
@ -639,6 +640,7 @@ static bool get_line(struct gui_wps *gwps,
char *linebuf_end = linebuf + linebuf_size - 1;
bool update = false;
int i;
(void)refresh_mode; /* silence warning on charcell */
/* alignment-related variables */
int cur_align;
@ -676,6 +678,11 @@ static bool get_line(struct gui_wps *gwps,
img->display = subimage;
break;
}
case WPS_TOKEN_DRAW_INBUILTBAR:
gui_statusbar_draw(&(statusbars.statusbars[gwps->display->screen_type]),
refresh_mode == WPS_REFRESH_ALL,
data->tokens[i].value.data);
break;
#endif
case WPS_TOKEN_ALIGN_LEFT:
@ -1176,8 +1183,8 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
|| new_subline_refresh || hidden_vp)
{
/* get_line tells us if we need to update the line */
update_line = get_line(gwps, subline,
&align, linebuf, sizeof(linebuf));
update_line = get_line(gwps, subline, &align,
linebuf, sizeof(linebuf), vp_refresh_mode);
}
#ifdef HAVE_LCD_BITMAP
/* peakmeter */

View file

@ -154,6 +154,8 @@ static int parse_statusbar_enable(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
static int parse_statusbar_disable(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
static int parse_statusbar_inbuilt(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
static int parse_image_display(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
static int parse_image_load(const char *wps_bufptr,
@ -349,6 +351,7 @@ static const struct wps_tag all_tags[] = {
#ifdef HAVE_LCD_BITMAP
{ WPS_NO_TOKEN, "we", 0, parse_statusbar_enable },
{ WPS_NO_TOKEN, "wd", 0, parse_statusbar_disable },
{ WPS_TOKEN_DRAW_INBUILTBAR, "wi", WPS_REFRESH_DYNAMIC, parse_statusbar_inbuilt },
{ WPS_NO_TOKEN, "xl", 0, parse_image_load },
@ -562,6 +565,14 @@ static int parse_statusbar_disable(const char *wps_bufptr,
return skip_end_of_line(wps_bufptr);
}
static int parse_statusbar_inbuilt(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data)
{
(void)wps_data;
token->value.data = (void*)&curr_vp->vp;
return skip_end_of_line(wps_bufptr);
}
static int get_image_id(int c)
{
if(c >= 'a' && c <= 'z')

View file

@ -189,6 +189,7 @@ enum wps_token_type {
/* buttons */
TOKEN_MARKER_MISC,
WPS_TOKEN_DRAW_INBUILTBAR,
WPS_TOKEN_LIST_TITLE_TEXT,
WPS_TOKEN_LIST_TITLE_ICON,
WPS_TOKEN_BUTTON_VOLUME,

View file

@ -173,10 +173,23 @@ void sb_create_from_settings(enum screen_type screen)
{
char buf[128], *ptr, *ptr2;
int len, remaining = sizeof(buf);
int bar_position = statusbar_position(screen);
ptr = buf;
ptr[0] = '\0';
/* setup the inbuilt statusbar */
if (bar_position != STATUSBAR_OFF)
{
int y = 0, height = STATUSBAR_HEIGHT;
if (bar_position == STATUSBAR_BOTTOM)
{
y = screens[screen].lcdheight - STATUSBAR_HEIGHT;
}
len = snprintf(ptr, remaining, "%%V|0|%d|-|%d|0|-|-|\n%%wi\n",
y, height);
remaining -= len;
ptr += len;
}
/* %Vi viewport, colours handled by the parser */
#if NB_SCREENS > 1
if (screen == SCREEN_REMOTE)
@ -194,7 +207,7 @@ void sb_create_from_settings(enum screen_type screen)
else
{
int y = 0, height;
switch (statusbar_position(screen))
switch (bar_position)
{
case STATUSBAR_TOP:
y = STATUSBAR_HEIGHT;

View file

@ -184,7 +184,7 @@ static void gui_statusbar_init(struct gui_statusbar * bar)
(vp).y = (display)->lcdheight - STATUSBAR_HEIGHT; \
} while(0)
void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct viewport *vp)
{
struct screen * display = bar->display;
@ -194,6 +194,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
#ifdef HAVE_LCD_CHARCELLS
int val;
(void)force_redraw; /* The Player always has "redraw" */
(void)vp;
#endif /* HAVE_LCD_CHARCELLS */
bar->info.battlevel = battery_level();
@ -277,10 +278,16 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
#endif
memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info)))
{
struct viewport vp;
GET_RECT(vp,statusbar_position(display->screen_type),display);
display->set_viewport(&vp);
if (vp == NULL)
{
struct viewport viewport;
GET_RECT(viewport,statusbar_position(display->screen_type),display);
display->set_viewport(&viewport);
}
else
{
display->set_viewport(vp);
}
display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
display->fillrect(0, 0, display->getwidth(), STATUSBAR_HEIGHT);
display->set_drawmode(DRMODE_SOLID);
@ -823,30 +830,10 @@ void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars,
#endif /* HAVE_LCD_BITMAP */
int i;
FOR_NB_SCREENS(i) {
gui_statusbar_draw( &(bars->statusbars[i]), force_redraw );
gui_statusbar_draw( &(bars->statusbars[i]), force_redraw, NULL );
}
}
#ifdef HAVE_LCD_BITMAP
void gui_statusbar_changed( enum screen_type screen,
enum statusbar_values old)
{
/* clear and update the statusbar area to remove old parts */
enum statusbar_values bar = statusbar_position(screen);
struct screen *display = &screens[screen];
struct viewport vp;
if (old != STATUSBAR_OFF && old != bar)
{
GET_RECT(vp, old, display);
display->set_viewport(&vp);
display->clear_viewport();
display->update_viewport();
display->set_viewport(NULL);
}
}
#endif
#ifdef HAVE_REMOTE_LCD
enum statusbar_values statusbar_position(int screen)

View file

@ -55,8 +55,7 @@ struct status_info {
};
/* statusbar visibility/position, used for settings also */
enum statusbar_values { STATUSBAR_OFF = 0, STATUSBAR_TOP, STATUSBAR_BOTTOM,
STATUSBAR_CUSTOM };
enum statusbar_values { STATUSBAR_OFF = 0, STATUSBAR_TOP, STATUSBAR_BOTTOM };
struct gui_statusbar
{
@ -92,7 +91,8 @@ extern struct gui_syncstatusbar statusbars;
* Draws the status bar on the attached screen
* - bar : the statusbar structure
*/
extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw);
extern void gui_statusbar_draw(struct gui_statusbar * bar,
bool force_redraw, struct viewport *vp);
struct gui_syncstatusbar
@ -103,8 +103,6 @@ struct gui_syncstatusbar
extern void gui_syncstatusbar_init(struct gui_syncstatusbar * bars) INIT_ATTR;
extern void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars,
bool force_redraw);
void gui_statusbar_changed(enum screen_type screen,
enum statusbar_values old);
#if !defined(HAVE_REMOTE_LCD) || defined(__PCTOOL__)
#include "settings.h"
#define statusbar_position(a) ((enum statusbar_values)global_settings.statusbar)

View file

@ -229,11 +229,10 @@ static void viewportmanager_redraw(void* data)
FOR_NB_SCREENS(i)
{
#ifdef HAVE_LCD_BITMAP
if (statusbar_position(i) == STATUSBAR_CUSTOM)
sb_skin_update(i, NULL != data);
else if (statusbar_position(i) != STATUSBAR_OFF)
sb_skin_update(i, NULL != data);
#else
gui_statusbar_draw(&statusbars.statusbars[i], NULL, NULL);
#endif
gui_statusbar_draw(&statusbars.statusbars[i], NULL != data);
}
}

View file

@ -162,8 +162,7 @@ static int statusbar_callback_ex(int action,const struct menu_item_ex *this_item
old_bar[screen] = statusbar_position(screen);
break;
case ACTION_EXIT_MENUITEM:
if (statusbar_position(screen) == STATUSBAR_CUSTOM
&& old_bar[screen] != statusbar_position(screen))
if (old_bar[screen] != statusbar_position(screen))
settings_apply_skins();
break;
}

View file

@ -624,14 +624,14 @@ const struct settings_list settings[] = {
ID2P(LANG_INVERT_CURSOR_BAR)),
#endif
CHOICE_SETTING(F_THEMESETTING|F_TEMPVAR, statusbar,
LANG_STATUS_BAR, STATUSBAR_TOP, "statusbar","off,top,bottom,custom",
NULL, 4, ID2P(LANG_OFF), ID2P(LANG_STATUSBAR_TOP),
ID2P(LANG_STATUSBAR_BOTTOM), ID2P(LANG_STATUSBAR_CUSTOM)),
LANG_STATUS_BAR, STATUSBAR_TOP, "statusbar","off,top,bottom",
NULL, 3, ID2P(LANG_OFF), ID2P(LANG_STATUSBAR_TOP),
ID2P(LANG_STATUSBAR_BOTTOM)),
#ifdef HAVE_REMOTE_LCD
CHOICE_SETTING(F_THEMESETTING|F_TEMPVAR, remote_statusbar,
LANG_REMOTE_STATUSBAR, STATUSBAR_TOP, "remote statusbar","off,top,bottom,custom",
NULL, 4, ID2P(LANG_OFF), ID2P(LANG_STATUSBAR_TOP),
ID2P(LANG_STATUSBAR_BOTTOM), ID2P(LANG_STATUSBAR_CUSTOM)),
LANG_REMOTE_STATUSBAR, STATUSBAR_TOP, "remote statusbar","off,top,bottom",
NULL, 3, ID2P(LANG_OFF), ID2P(LANG_STATUSBAR_TOP),
ID2P(LANG_STATUSBAR_BOTTOM)),
#endif
CHOICE_SETTING(F_THEMESETTING|F_TEMPVAR, scrollbar,
LANG_SCROLL_BAR, SCROLLBAR_LEFT, "scrollbar","off,left,right",