summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-08-18 05:30:59 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-08-18 05:30:59 +0000
commit36ca4967e0ced08ab8d262ba046189e6dfbe71da (patch)
tree4b441f67ac8f99af82f208a930de7f797d4bf712 /apps/gui
parentfed07312edff7c69f03946bf90f57f7b57f9be39 (diff)
move viewports into the skin buffer, no more viewport limit on the skin
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22403 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/skin_engine/skin_display.c95
-rw-r--r--apps/gui/skin_engine/skin_parser.c96
-rw-r--r--apps/gui/skin_engine/wps_debug.c9
-rw-r--r--apps/gui/skin_engine/wps_internals.h10
-rw-r--r--apps/gui/wps.c2
5 files changed, 123 insertions, 89 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 9f310073cb..1e88863307 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -100,8 +100,9 @@ bool gui_wps_display(struct gui_wps *gwps)
#if LCD_DEPTH > 1
if (display->depth > 1)
{
- gwps->data->viewports[0].vp.fg_pattern = display->get_foreground();
- gwps->data->viewports[0].vp.bg_pattern = display->get_background();
+ struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, gwps->data)->vp;
+ vp->fg_pattern = display->get_foreground();
+ vp->bg_pattern = display->get_background();
}
#endif
display->clear_display();
@@ -132,7 +133,7 @@ bool skin_update(struct gui_wps *gwps, unsigned int update_type)
#ifdef HAVE_LCD_BITMAP
static void draw_progressbar(struct gui_wps *gwps,
- struct wps_viewport *wps_vp)
+ struct skin_viewport *wps_vp)
{
struct screen *display = gwps->display;
struct wps_state *state = gwps->state;
@@ -490,6 +491,19 @@ struct gui_img* find_image(int n, struct wps_data *data)
return NULL;
}
#endif
+
+struct skin_viewport* find_viewport(char label, struct wps_data *data)
+{
+ struct skin_token_list *list = data->viewports;
+ while (list)
+ {
+ struct skin_viewport *vp = (struct skin_viewport *)list->token->value.data;
+ if (vp->label == label)
+ return vp;
+ list = list->next;
+ }
+ return NULL;
+}
/* Read a (sub)line to the given alignment format buffer.
@@ -590,18 +604,13 @@ static bool get_line(struct gui_wps *gwps,
case WPS_VIEWPORT_ENABLE:
{
char label = data->tokens[i].value.i;
- int j;
char temp = VP_DRAW_HIDEABLE;
- for(j=0;j<data->num_viewports;j++)
+ struct skin_viewport *vp = find_viewport(label, data);
+ if (vp)
{
- temp = VP_DRAW_HIDEABLE;
- if ((data->viewports[j].hidden_flags&VP_DRAW_HIDEABLE) &&
- (data->viewports[j].label == label))
- {
- if (data->viewports[j].hidden_flags&VP_DRAW_WASHIDDEN)
- temp |= VP_DRAW_WASHIDDEN;
- data->viewports[j].hidden_flags = temp;
- }
+ if (vp->hidden_flags&VP_DRAW_WASHIDDEN)
+ temp |= VP_DRAW_WASHIDDEN;
+ vp->hidden_flags = temp;
}
}
break;
@@ -926,7 +935,7 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
if (!id3)
return false;
- int v, line, i, subline_idx;
+ int line, i, subline_idx;
unsigned flags;
char linebuf[MAX_PATH];
@@ -953,7 +962,7 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
/* reset to first subline if refresh all flag is set */
if (refresh_mode == WPS_REFRESH_ALL)
{
- display->set_viewport(&data->viewports[0].vp);
+ display->set_viewport(&find_viewport(VP_DEFAULT_LABEL, data)->vp);
display->clear_viewport();
for (i = 0; i <= data->num_lines; i++)
@@ -971,21 +980,28 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
#endif
/* disable any viewports which are conditionally displayed */
- for (v = 0; v < data->num_viewports; v++)
+ struct skin_token_list *viewport_list;
+ for (viewport_list = data->viewports;
+ viewport_list; viewport_list = viewport_list->next)
{
- if (data->viewports[v].hidden_flags&VP_DRAW_HIDEABLE)
+ struct skin_viewport *skin_viewport =
+ (struct skin_viewport *)viewport_list->token->value.data;
+ if (skin_viewport->hidden_flags&VP_DRAW_HIDEABLE)
{
- if (data->viewports[v].hidden_flags&VP_DRAW_HIDDEN)
- data->viewports[v].hidden_flags |= VP_DRAW_WASHIDDEN;
+ if (skin_viewport->hidden_flags&VP_DRAW_HIDDEN)
+ skin_viewport->hidden_flags |= VP_DRAW_WASHIDDEN;
else
- data->viewports[v].hidden_flags |= VP_DRAW_HIDDEN;
+ skin_viewport->hidden_flags |= VP_DRAW_HIDDEN;
}
}
- for (v = 0; v < data->num_viewports; v++)
+
+ for (viewport_list = data->viewports;
+ viewport_list; viewport_list = viewport_list->next)
{
- struct wps_viewport *wps_vp = &(data->viewports[v]);
+ struct skin_viewport *skin_viewport =
+ (struct skin_viewport *)viewport_list->token->value.data;
unsigned vp_refresh_mode = refresh_mode;
- display->set_viewport(&wps_vp->vp);
+ display->set_viewport(&skin_viewport->vp);
#ifdef HAVE_LCD_BITMAP
/* Set images to not to be displayed */
@@ -998,27 +1014,27 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
}
#endif
/* dont redraw the viewport if its disabled */
- if ((wps_vp->hidden_flags&VP_DRAW_HIDDEN))
+ if ((skin_viewport->hidden_flags&VP_DRAW_HIDDEN))
{
- if (!(wps_vp->hidden_flags&VP_DRAW_WASHIDDEN))
- display->scroll_stop(&wps_vp->vp);
- wps_vp->hidden_flags |= VP_DRAW_WASHIDDEN;
+ if (!(skin_viewport->hidden_flags&VP_DRAW_WASHIDDEN))
+ display->scroll_stop(&skin_viewport->vp);
+ skin_viewport->hidden_flags |= VP_DRAW_WASHIDDEN;
continue;
}
- else if (((wps_vp->hidden_flags&
+ else if (((skin_viewport->hidden_flags&
(VP_DRAW_WASHIDDEN|VP_DRAW_HIDEABLE))
== (VP_DRAW_WASHIDDEN|VP_DRAW_HIDEABLE)))
{
vp_refresh_mode = WPS_REFRESH_ALL;
- wps_vp->hidden_flags = VP_DRAW_HIDEABLE;
+ skin_viewport->hidden_flags = VP_DRAW_HIDEABLE;
}
if (vp_refresh_mode == WPS_REFRESH_ALL)
{
display->clear_viewport();
}
- for (line = wps_vp->first_line;
- line <= wps_vp->last_line; line++)
+ for (line = skin_viewport->first_line;
+ line <= skin_viewport->last_line; line++)
{
memset(linebuf, 0, sizeof(linebuf));
update_line = false;
@@ -1044,8 +1060,8 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
/* the peakmeter should be alone on its line */
update_line = false;
- int h = font_get(wps_vp->vp.font)->height;
- int peak_meter_y = (line - wps_vp->first_line)* h;
+ int h = font_get(skin_viewport->vp.font)->height;
+ int peak_meter_y = (line - skin_viewport->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
@@ -1082,17 +1098,18 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
viewport there will be a blank line.
To get around this we dont allow any actual drawing to happen in the
deault vp if other vp's are defined */
- ((data->num_viewports>1 && v!=0) || data->num_viewports == 1))
+ ((skin_viewport->label != VP_DEFAULT_LABEL && viewport_list->next) ||
+ !viewport_list->next))
{
if (flags & WPS_REFRESH_SCROLL)
{
/* if the line is a scrolling one we don't want to update
too often, so that it has the time to scroll */
if ((vp_refresh_mode & WPS_REFRESH_SCROLL) || new_subline_refresh)
- write_line(display, &align, line - wps_vp->first_line, true);
+ write_line(display, &align, line - skin_viewport->first_line, true);
}
else
- write_line(display, &align, line - wps_vp->first_line, false);
+ write_line(display, &align, line - skin_viewport->first_line, false);
}
}
@@ -1100,13 +1117,13 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
/* progressbar */
if (vp_refresh_mode & WPS_REFRESH_PLAYER_PROGRESS)
{
- if (wps_vp->pb)
+ if (skin_viewport->pb)
{
- draw_progressbar(gwps, wps_vp);
+ draw_progressbar(gwps, skin_viewport);
}
}
/* Now display any images in this viewport */
- wps_display_images(gwps, &wps_vp->vp);
+ wps_display_images(gwps, &skin_viewport->vp);
#endif
}
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index d2b8fdc259..82083e8922 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -77,6 +77,9 @@ static int numoptions[WPS_MAX_COND_LEVEL];
/* the current line in the file */
static int line;
+/* the current viewport */
+static struct skin_viewport *curr_vp;
+
#ifdef HAVE_LCD_BITMAP
#if LCD_DEPTH > 1
@@ -419,10 +422,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)
+ struct skin_viewport *default_vp = find_viewport(VP_DEFAULT_LABEL, wps_data);
+ if (default_vp->vp.y == 0)
{
- wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT;
- wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT;
+ default_vp->vp.y = STATUSBAR_HEIGHT;
+ default_vp->vp.height -= STATUSBAR_HEIGHT;
}
return skip_end_of_line(wps_bufptr);
}
@@ -434,10 +438,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)
+ struct skin_viewport *default_vp = find_viewport(VP_DEFAULT_LABEL, wps_data);
+ if (default_vp->vp.y == STATUSBAR_HEIGHT)
{
- wps_data->viewports[0].vp.y = 0;
- wps_data->viewports[0].vp.height += STATUSBAR_HEIGHT;
+ default_vp->vp.y = 0;
+ default_vp->vp.height += STATUSBAR_HEIGHT;
}
return skip_end_of_line(wps_bufptr);
}
@@ -556,7 +561,7 @@ static int parse_image_load(const char *wps_bufptr,
img->always_display = false;
/* save current viewport */
- img->vp = &wps_data->viewports[wps_data->num_viewports].vp;
+ img->vp = &curr_vp->vp;
if (token->type == WPS_TOKEN_IMAGE_DISPLAY)
{
@@ -612,13 +617,13 @@ static int parse_viewport(const char *wps_bufptr,
#endif
SCREEN_MAIN;
- if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS)
- return WPS_ERROR_INVALID_PARAM;
+ struct skin_viewport *skin_vp = skin_buffer_alloc(sizeof(struct skin_viewport));
- wps_data->num_viewports++;
/* check for the optional letter to signify its a hideable viewport */
/* %Vl|<label>|<rest of tags>| */
- wps_data->viewports[wps_data->num_viewports].hidden_flags = 0;
+ skin_vp->hidden_flags = 0;
+ skin_vp->label = VP_NO_LABEL;
+ skin_vp->pb = NULL;
if (*ptr == 'l')
{
@@ -627,8 +632,8 @@ static int parse_viewport(const char *wps_bufptr,
char label = *(ptr+2);
if (label >= 'a' && label <= 'z')
{
- wps_data->viewports[wps_data->num_viewports].hidden_flags = VP_DRAW_HIDEABLE;
- wps_data->viewports[wps_data->num_viewports].label = label;
+ skin_vp->hidden_flags = VP_DRAW_HIDEABLE;
+ skin_vp->label = label;
}
else
return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */
@@ -639,7 +644,7 @@ static int parse_viewport(const char *wps_bufptr,
return WPS_ERROR_INVALID_PARAM;
ptr++;
- struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp;
+ struct viewport *vp = &skin_vp->vp;
/* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */
if (!(ptr = viewport_parse_viewport(vp, screen, ptr, '|')))
@@ -649,10 +654,9 @@ static int parse_viewport(const char *wps_bufptr,
if (*ptr != '|')
return WPS_ERROR_INVALID_PARAM;
+ curr_vp->last_line = wps_data->num_lines - 1;
- wps_data->viewports[wps_data->num_viewports-1].last_line = wps_data->num_lines - 1;
-
- wps_data->viewports[wps_data->num_viewports].first_line = wps_data->num_lines;
+ skin_vp->first_line = wps_data->num_lines;
if (wps_data->num_sublines < WPS_MAX_SUBLINES)
{
@@ -663,6 +667,11 @@ static int parse_viewport(const char *wps_bufptr,
wps_data->num_tokens;
}
+ struct skin_token_list *list = new_skin_token_list_item(NULL, skin_vp);
+ if (!list)
+ return WPS_ERROR_INVALID_PARAM;
+ add_to_ll_chain(&wps_data->viewports, list);
+ curr_vp = skin_vp;
/* Skip the rest of the line */
return skip_end_of_line(wps_bufptr);
}
@@ -818,14 +827,13 @@ static int parse_progressbar(const char *wps_bufptr,
if (!pb || !item)
return WPS_ERROR_INVALID_PARAM;
- struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp;
+ struct viewport *vp = &curr_vp->vp;
#ifndef __PCTOOL__
int font_height = font_get(vp->font)->height;
#else
int font_height = 8;
#endif
- int line_num = wps_data->num_lines -
- wps_data->viewports[wps_data->num_viewports].first_line;
+ int line_num = wps_data->num_lines - curr_vp->first_line;
pb->have_bitmap_pb = false;
pb->bm.data = NULL; /* no bitmap specified */
@@ -837,7 +845,7 @@ static int parse_progressbar(const char *wps_bufptr,
pb->height = SYSFONT_HEIGHT-2;
pb->y = -line_num - 1; /* Will be computed during the rendering */
- wps_data->viewports[wps_data->num_viewports].pb = pb;
+ curr_vp->pb = pb;
add_to_ll_chain(&wps_data->progressbars, item);
return 0;
}
@@ -882,7 +890,7 @@ static int parse_progressbar(const char *wps_bufptr,
else
pb->y = -line_num - 1; /* Will be computed during the rendering */
- wps_data->viewports[wps_data->num_viewports].pb = pb;
+ curr_vp->pb = pb;
add_to_ll_chain(&wps_data->progressbars, item);
/* Skip the rest of the line */
@@ -1154,7 +1162,7 @@ static int parse_touchregion(const char *wps_bufptr,
region->y = y;
region->width = w;
region->height = h;
- region->wvp = &wps_data->viewports[wps_data->num_viewports];
+ region->wvp = curr_vp;
if(!strncmp(pb_string, action, sizeof(pb_string)-1)
&& *(action + sizeof(pb_string)-1) == '|')
@@ -1282,7 +1290,6 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
level = -1;
while(*wps_bufptr && !fail && data->num_tokens < WPS_MAX_TOKENS - 1
- && data->num_viewports < WPS_MAX_VIEWPORTS
&& data->num_lines < WPS_MAX_LINES)
{
switch(*wps_bufptr++)
@@ -1481,10 +1488,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
/* one of the limits of the while loop was exceeded */
fail = PARSE_FAIL_LIMITS_EXCEEDED;
- data->viewports[data->num_viewports].last_line = data->num_lines - 1;
-
- /* We have finished with the last viewport, so increment count */
- data->num_viewports++;
+ curr_vp->last_line = data->num_lines - 1;
#if defined(DEBUG) || defined(SIMULATOR)
print_debug_info(data, fail, line);
@@ -1611,34 +1615,46 @@ bool skin_data_load(struct wps_data *wps_data,
return false;
wps_reset(wps_data);
+
+ curr_vp = skin_buffer_alloc(sizeof(struct skin_viewport));
+ if (!curr_vp)
+ return false;
+ struct skin_token_list *list = new_skin_token_list_item(NULL, curr_vp);
+ if (!list)
+ return false;
+ add_to_ll_chain(&wps_data->viewports, list);
+
/* Initialise the first (default) viewport */
- wps_data->viewports[0].vp.x = 0;
- wps_data->viewports[0].vp.width = display->getwidth();
- wps_data->viewports[0].vp.height = display->getheight();
+ curr_vp->label = VP_DEFAULT_LABEL;
+ curr_vp->vp.x = 0;
+ curr_vp->vp.width = display->getwidth();
+ curr_vp->vp.height = display->getheight();
+ curr_vp->pb = NULL;
+ curr_vp->hidden_flags = 0;
switch (statusbar_position(display->screen_type))
{
case STATUSBAR_OFF:
- wps_data->viewports[0].vp.y = 0;
+ curr_vp->vp.y = 0;
break;
case STATUSBAR_TOP:
- wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT;
- wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT;
+ curr_vp->vp.y = STATUSBAR_HEIGHT;
+ curr_vp->vp.height -= STATUSBAR_HEIGHT;
break;
case STATUSBAR_BOTTOM:
- wps_data->viewports[0].vp.y = 0;
- wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT;
+ curr_vp->vp.y = 0;
+ curr_vp->vp.height -= STATUSBAR_HEIGHT;
break;
}
#ifdef HAVE_LCD_BITMAP
- wps_data->viewports[0].vp.font = FONT_UI;
- wps_data->viewports[0].vp.drawmode = DRMODE_SOLID;
+ curr_vp->vp.font = FONT_UI;
+ curr_vp->vp.drawmode = DRMODE_SOLID;
#endif
#if LCD_DEPTH > 1
if (display->depth > 1)
{
- wps_data->viewports[0].vp.fg_pattern = display->get_foreground();
- wps_data->viewports[0].vp.bg_pattern = display->get_background();
+ curr_vp->vp.fg_pattern = display->get_foreground();
+ curr_vp->vp.bg_pattern = display->get_background();
}
#endif
if (!isfile)
diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c
index c4a73a7cfb..e3e6e960e6 100644
--- a/apps/gui/skin_engine/wps_debug.c
+++ b/apps/gui/skin_engine/wps_debug.c
@@ -495,12 +495,13 @@ static void dump_wps_tokens(struct wps_data *data)
}
}
+#if 0
+/* NOTE: this is probaly not even needed anymore */
static void print_line_info(struct wps_data *data)
{
int i, j, v;
struct wps_line *line;
struct wps_subline *subline;
-
if (wps_verbose_level > 0)
{
DEBUGF("Number of viewports : %d\n", data->num_viewports);
@@ -513,7 +514,7 @@ static void print_line_info(struct wps_data *data)
DEBUGF("Number of tokens : %d\n", data->num_tokens);
DEBUGF("\n");
}
-
+
if (wps_verbose_level > 1)
{
for (v = 0; v < data->num_viewports; v++)
@@ -549,8 +550,6 @@ static void print_line_info(struct wps_data *data)
DEBUGF("\n");
}
}
-#if 0
-/* NOTE: this is probaly not even needed anymore */
static void print_wps_strings(struct wps_data *data)
{
int i, len, total_len = 0, buf_used = 0;
@@ -588,7 +587,7 @@ void print_debug_info(struct wps_data *data, enum wps_parse_error fail, int line
{
dump_wps_tokens(data);
/* print_wps_strings(data); */
- print_line_info(data);
+ /* print_line_info(data); */
}
#endif /* SIMULATOR */
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 99b6e8ad9b..4136347a7b 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -191,7 +191,9 @@ struct wps_line {
#define VP_DRAW_HIDEABLE 0x1
#define VP_DRAW_HIDDEN 0x2
#define VP_DRAW_WASHIDDEN 0x4
-struct wps_viewport {
+#define VP_DEFAULT_LABEL '|'
+#define VP_NO_LABEL '-'
+struct skin_viewport {
struct viewport vp; /* The LCD viewport struct */
struct progressbar *pb;
/* Indexes of the first and last lines belonging to this viewport in the
@@ -203,7 +205,7 @@ struct wps_viewport {
#ifdef HAVE_TOUCHSCREEN
struct touchregion {
- struct wps_viewport* wvp;/* The viewport this region is in */
+ struct skin_viewport* wvp;/* The viewport this region is in */
short int x; /* x-pos */
short int y; /* y-pos */
short int width; /* width */
@@ -262,8 +264,7 @@ struct wps_data
int num_lines;
/* Number of viewports in the WPS */
- int num_viewports;
- struct wps_viewport viewports[WPS_MAX_VIEWPORTS];
+ struct skin_token_list *viewports;
struct wps_line lines[WPS_MAX_LINES];
@@ -346,5 +347,6 @@ const char *get_token_value(struct gui_wps *gwps,
struct gui_img* find_image(int n, struct wps_data *data);
+struct skin_viewport* find_viewport(char label, struct wps_data *data);
#endif
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 055f8d01e6..4553970422 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -1239,7 +1239,7 @@ static void statusbar_toggle_handler(void *data)
FOR_NB_SCREENS(i)
{
- struct viewport *vp = &gui_wps[i].data->viewports[0].vp;
+ struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, &wps_datas[i])->vp;
bool draw = wpsbars & (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i));
if (!draw)
{