summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-06-23 13:20:35 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-06-23 13:20:35 +0000
commitbdbdb97f19655a635a2d37f81f9fe1e31f9162b2 (patch)
treeea5672478b70e550910bc179a7644afa70c0d057 /apps/gui
parentc1b8df05e1def3096ff6d2ea55f23b2e72936fce (diff)
downloadrockbox-bdbdb97f19655a635a2d37f81f9fe1e31f9162b2.zip
rockbox-bdbdb97f19655a635a2d37f81f9fe1e31f9162b2.tar.gz
rockbox-bdbdb97f19655a635a2d37f81f9fe1e31f9162b2.tar.bz2
rockbox-bdbdb97f19655a635a2d37f81f9fe1e31f9162b2.tar.xz
FS#9051 - remove LCD margins... use viewports if you need them...
NOTE to WPS people.... %m has been removed, but (i think) because of the other %m tags it wont fail if you try loading a wps with %m|..|, it will just be ignored. Also note that if the statusbar is enabled the default viewport is 8 pixels shorter than when its not, i.e (0,0) is really (0,8) if the statusbar is shown... I dont think this will be a major issue because almost no WPS show the bar and use bitmaps... text only WPS shouldnt be affected. Please report problem screens in http://forums.rockbox.org/index.php?topic=17358.0 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17763 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps-common.c23
-rw-r--r--apps/gui/gwps.c69
-rw-r--r--apps/gui/gwps.h1
-rw-r--r--apps/gui/icon.c2
-rw-r--r--apps/gui/statusbar.h5
-rw-r--r--apps/gui/viewport.c2
-rw-r--r--apps/gui/wps_debug.c5
-rw-r--r--apps/gui/wps_parser.c69
8 files changed, 59 insertions, 117 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 6e159b8..b53d68d 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -345,7 +345,6 @@ bool gui_wps_display(void)
/* Update the values in the first (default) viewport - in case the user
has modified the statusbar or colour settings */
#ifdef HAVE_LCD_BITMAP
- gui_wps[i].data->viewports[0].vp.ymargin = gui_wps[i].display->getymargin();
#if LCD_DEPTH > 1
if (gui_wps[i].display->depth > 1)
{
@@ -1408,14 +1407,6 @@ static char *get_token_value(struct gui_wps *gwps,
else
return NULL;
#endif
-
-#ifdef HAVE_LCD_BITMAP
- case WPS_TOKEN_LEFTMARGIN:
- gwps->display->setmargins(token->value.i,
- gwps->display->getymargin());
- return NULL;
-#endif
-
default:
return NULL;
}
@@ -1529,11 +1520,6 @@ static bool get_line(struct gui_wps *gwps,
align->center = NULL;
align->right = NULL;
-#ifdef HAVE_LCD_BITMAP
- /* Reset margins - only bitmap targets modify them */
- gwps->display->setmargins(0, gwps->display->getymargin());
-#endif
-
/* Process all tokens of the desired subline */
last_token_idx = wps_last_token_index(data, line, subline);
for (i = wps_first_token_index(data, line, subline);
@@ -1800,7 +1786,7 @@ static void write_line(struct screen *display,
&center_width, &string_height);
}
- left_xpos = display->getxmargin();
+ left_xpos = 0;
right_xpos = (display->getwidth() - right_width);
center_xpos = (display->getwidth() + left_xpos - center_width) / 2;
@@ -1885,7 +1871,7 @@ static void write_line(struct screen *display,
right_width = 0;
}
- ypos = (line * string_height) + display->getymargin();
+ ypos = (line * string_height);
if (scroll && ((left_width > scroll_width) ||
@@ -1968,7 +1954,8 @@ bool gui_wps_refresh(struct gui_wps *gwps,
/* reset to first subline if refresh all flag is set */
if (refresh_mode == WPS_REFRESH_ALL)
{
- display->clear_display();
+ display->set_viewport(&data->viewports[0].vp);
+ display->clear_viewport();
for (i = 0; i <= data->num_lines; i++)
{
@@ -2063,7 +2050,7 @@ bool gui_wps_refresh(struct gui_wps *gwps,
update_line = false;
int h = font_get(data->viewports[v].vp.font)->height;
- int peak_meter_y = display->getymargin() + (line - data->viewports[v].first_line)* h;
+ int peak_meter_y = (line - data->viewports[v].first_line)* h;
/* The user might decide to have the peak meter in the last
line so that it is only displayed if no status bar is
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 5426c93..31b1989 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -77,19 +77,6 @@ static void gui_wps_set_disp(struct gui_wps *gui_wps, struct screen *display);
/* connects a wps with a statusbar*/
static void gui_wps_set_statusbar(struct gui_wps *gui_wps, struct gui_statusbar *statusbar);
-#ifdef HAVE_LCD_BITMAP
-static void gui_wps_set_margin(struct gui_wps *gwps)
-{
- int offset = 0;
- struct wps_data *data = gwps->data;
- if(data->wps_sb_tag && data->show_sb_on_wps)
- offset = STATUSBAR_HEIGHT;
- else if ( global_settings.statusbar && !data->wps_sb_tag)
- offset = STATUSBAR_HEIGHT;
- gwps->display->setmargins(0, offset);
-}
-#endif
-
static void prev_track(unsigned skip_thresh)
{
if (!wps_state.id3 || (wps_state.id3->elapsed < skip_thresh*1000)) {
@@ -152,10 +139,6 @@ long gui_wps_show(void)
status_set_audio(true);
status_set_param(false);
#else
- FOR_NB_SCREENS(i)
- {
- gui_wps_set_margin(&gui_wps[i]);
- }
#if LCD_DEPTH > 1
show_wps_backdrop();
#endif /* LCD_DEPTH > 1 */
@@ -299,12 +282,6 @@ long gui_wps_show(void)
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop();
#endif
-#ifdef HAVE_LCD_BITMAP
- FOR_NB_SCREENS(i)
- {
- gui_wps_set_margin(&gui_wps[i]);
- }
-#endif
restore = true;
break;
@@ -558,12 +535,6 @@ long gui_wps_show(void)
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop();
#endif
-#ifdef HAVE_LCD_BITMAP
- FOR_NB_SCREENS(i)
- {
- gui_wps_set_margin(&gui_wps[i]);
- }
-#endif
restore = true;
break;
#endif /* HAVE_QUICKSCREEN */
@@ -579,12 +550,6 @@ long gui_wps_show(void)
#endif
if (quick_screen_f3(BUTTON_F3))
return SYS_USB_CONNECTED;
-#ifdef HAVE_LCD_BITMAP
- FOR_NB_SCREENS(i)
- {
- gui_wps_set_margin(&gui_wps[i]);
- }
-#endif
restore = true;
break;
#endif /* BUTTON_F3 */
@@ -643,12 +608,6 @@ long gui_wps_show(void)
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
show_remote_wps_backdrop();
#endif
-#ifdef HAVE_LCD_BITMAP
- FOR_NB_SCREENS(i)
- {
- gui_wps_set_margin(&gui_wps[i]);
- }
-#endif
restore = true;
break;
@@ -812,7 +771,32 @@ void gui_sync_wps_screen_init(void)
FOR_NB_SCREENS(i)
gui_wps_set_disp(&gui_wps[i], &screens[i]);
}
+#ifdef HAVE_LCD_BITMAP
+static void statusbar_toggle_handler(void *data)
+{
+ (void)data;
+ int i;
+ bool draw = global_settings.statusbar;
+ FOR_NB_SCREENS(i)
+ {
+ struct wps_viewport *vp = &gui_wps[i].data->viewports[0];
+ if (gui_wps[i].data->wps_sb_tag)
+ draw = gui_wps[i].data->show_sb_on_wps;
+ if (!global_settings.statusbar && !draw)
+ {
+ vp->vp.y = 0;
+ vp->vp.height = screens[i].height;
+ }
+ else
+ {
+ vp->vp.y = STATUSBAR_HEIGHT;
+ vp->vp.height = screens[i].height - STATUSBAR_HEIGHT;
+ }
+ }
+}
+#endif
+
void gui_sync_wps_init(void)
{
int i;
@@ -826,6 +810,9 @@ void gui_sync_wps_init(void)
gui_wps_set_data(&gui_wps[i], &wps_datas[i]);
gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]);
}
+#ifdef HAVE_LCD_BITMAP
+ add_event(STATUSBAR_TOGGLE_EVENT, false, statusbar_toggle_handler);
+#endif
#if LCD_DEPTH > 1
unload_wps_backdrop();
#endif
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index 25cfc08..ad0c4a5 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -136,7 +136,6 @@ enum wps_token_type {
WPS_TOKEN_ALIGN_LEFT,
WPS_TOKEN_ALIGN_CENTER,
WPS_TOKEN_ALIGN_RIGHT,
- WPS_TOKEN_LEFTMARGIN,
/* Sublines */
WPS_TOKEN_SUBLINE_TIMEOUT,
diff --git a/apps/gui/icon.c b/apps/gui/icon.c
index 968d835..c8ac48d 100644
--- a/apps/gui/icon.c
+++ b/apps/gui/icon.c
@@ -103,7 +103,7 @@ void screen_put_icon_with_offset(struct screen * display,
int screen = display->screen_type;
display->getstringsize((unsigned char *)"M", &width, &height);
xpos = x*ICON_WIDTH(screen) + off_x;
- ypos = y*height + display->getymargin() + off_y;
+ ypos = y*height + off_y;
if ( height > ICON_HEIGHT(screen) )/* center the cursor */
ypos += (height - ICON_HEIGHT(screen)) / 2;
diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h
index 989d1cb..57be2b1 100644
--- a/apps/gui/statusbar.h
+++ b/apps/gui/statusbar.h
@@ -22,11 +22,16 @@
#include "status.h"
#include "screen_access.h"
+#include "events.h"
#define STATUSBAR_X_POS 0
#define STATUSBAR_Y_POS 0 /* MUST be a multiple of 8 */
#define STATUSBAR_HEIGHT 8
+/* possibly a horrible misuse of the event system.
+ This is triggered when the statusbar setting changes */
+#define STATUSBAR_TOGGLE_EVENT (EVENT_CLASS_GUI|1)
+
struct status_info {
int battlevel;
int batt_charge_step;
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index fbf520e..8f9998b 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -45,8 +45,6 @@ int viewport_get_nb_lines(struct viewport *vp)
void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
{
- vp->xmargin = 0;
- vp->ymargin = 0;
vp->x = 0;
vp->width = screens[screen].width;
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c
index 4fa1216..f5ac27a 100644
--- a/apps/gui/wps_debug.c
+++ b/apps/gui/wps_debug.c
@@ -79,11 +79,6 @@ static char *get_token_desc(struct wps_token *token, struct wps_data *data,
case WPS_TOKEN_ALIGN_RIGHT:
snprintf(buf, bufsize, "align right");
break;
-
- case WPS_TOKEN_LEFTMARGIN:
- snprintf(buf, bufsize, "left margin, value: %d",
- token->value.i);
- break;
#endif
case WPS_TOKEN_SUBLINE_TIMEOUT:
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c
index c6b0d44..8053791 100644
--- a/apps/gui/wps_parser.c
+++ b/apps/gui/wps_parser.c
@@ -133,8 +133,6 @@ static int parse_viewport_display(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
static int parse_viewport(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
-static int parse_leftmargin(const char *wps_bufptr,
- struct wps_token *token, struct wps_data *wps_data);
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,
@@ -273,10 +271,6 @@ static const struct wps_tag all_tags[] = {
{ WPS_TOKEN_PLAYBACK_STATUS, "mp", WPS_REFRESH_DYNAMIC, NULL },
#ifdef HAVE_LCD_BITMAP
- { WPS_TOKEN_LEFTMARGIN, "m", 0, parse_leftmargin },
-#endif
-
-#ifdef HAVE_LCD_BITMAP
{ WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL },
#else
{ WPS_TOKEN_PLAYER_PROGRESSBAR, "pf",
@@ -368,6 +362,11 @@ static int parse_statusbar_enable(const char *wps_bufptr,
(void)token; /* Kill warnings */
wps_data->wps_sb_tag = true;
wps_data->show_sb_on_wps = true;
+ if (wps_data->viewports[0].vp.y == 0)
+ {
+ wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT;
+ wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT;
+ }
return skip_end_of_line(wps_bufptr);
}
@@ -378,6 +377,11 @@ static int parse_statusbar_disable(const char *wps_bufptr,
(void)token; /* Kill warnings */
wps_data->wps_sb_tag = true;
wps_data->show_sb_on_wps = false;
+ if (wps_data->viewports[0].vp.y == STATUSBAR_HEIGHT)
+ {
+ wps_data->viewports[0].vp.y = 0;
+ wps_data->viewports[0].vp.height += STATUSBAR_HEIGHT;
+ }
return skip_end_of_line(wps_bufptr);
}
@@ -616,8 +620,6 @@ static int parse_viewport(const char *wps_bufptr,
/* Set the defaults for fields not user-specified */
vp->drawmode = DRMODE_SOLID;
- vp->xmargin = 0;
- vp->ymargin = 0;
/* Work out the depth of this display */
#ifdef HAVE_REMOTE_LCD
@@ -818,16 +820,6 @@ static int parse_progressbar(const char *wps_bufptr,
int line_y_pos = font_height*(wps_data->num_lines -
wps_data->viewports[wps_data->num_viewports].first_line);
- /** Remove this bit when the remove lcd margins patch goes in **/
- bool draw_sb = global_settings.statusbar;
-
- if (wps_data->wps_sb_tag)
- draw_sb = wps_data->show_sb_on_wps;
-
- if (wps_data->num_viewports == 0 && draw_sb)
- line_y_pos += STATUSBAR_HEIGHT;
- /** Remove the above bit when the remove lcd margins patch goes in **/
-
if (wps_data->progressbar_count +1 >= MAX_PROGRESSBARS)
return WPS_ERROR_INVALID_PARAM;
@@ -1106,33 +1098,6 @@ static int parse_albumart_conditional(const char *wps_bufptr,
};
#endif /* HAVE_ALBUMART */
-#ifdef HAVE_LCD_BITMAP
-static int parse_leftmargin(const char *wps_bufptr, struct wps_token *token,
- struct wps_data *wps_data)
-{
- const char* p;
- const char* pend;
- const char *newline;
-
- (void)wps_data; /* Kill the warning */
-
- /* valid tag looks like %m|12| */
- if(*wps_bufptr == '|')
- {
- p = wps_bufptr + 1;
- newline = strchr(wps_bufptr, '\n');
- if(isdigit(*p) && (pend = strchr(p, '|')) && pend < newline)
- {
- token->value.i = atoi(p);
- return pend - wps_bufptr + 1;
- }
- }
-
- /* invalid tag syntax */
- return WPS_ERROR_INVALID_PARAM;
-}
-#endif
-
/* Parse a generic token from the given string. Return the length read */
static int parse_token(const char *wps_bufptr, struct wps_data *wps_data)
@@ -1583,15 +1548,21 @@ bool wps_data_load(struct wps_data *wps_data,
/* Initialise the first (default) viewport */
wps_data->viewports[0].vp.x = 0;
- wps_data->viewports[0].vp.y = 0;
wps_data->viewports[0].vp.width = display->width;
- wps_data->viewports[0].vp.height = display->height;
+ if (!global_settings.statusbar)
+ {
+ wps_data->viewports[0].vp.y = 0;
+ wps_data->viewports[0].vp.height = display->height;
+ }
+ else
+ {
+ wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT;
+ wps_data->viewports[0].vp.height = display->height - STATUSBAR_HEIGHT;
+ }
#ifdef HAVE_LCD_BITMAP
wps_data->viewports[0].vp.font = FONT_UI;
wps_data->viewports[0].vp.drawmode = DRMODE_SOLID;
#endif
- wps_data->viewports[0].vp.xmargin = display->getxmargin();
- wps_data->viewports[0].vp.ymargin = display->getymargin();
#if LCD_DEPTH > 1
if (display->depth > 1)
{