summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-08-02 12:50:23 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-08-02 12:50:23 +0000
commitee4f8a9a6bc313cd878f84a6c9832b6094685460 (patch)
tree2f2e77e7467dafb9a21218d23bad59798f813481
parentbc046ff899b472279bf56b38f6f27ad6f225d2e1 (diff)
Allow viewport labels to be mostly free text instead of only one character. If this is useful the same will be done for images
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27665 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/skin_engine/skin_display.c2
-rw-r--r--apps/gui/skin_engine/skin_parser.c17
-rw-r--r--apps/gui/skin_engine/skin_render.c14
-rw-r--r--apps/gui/skin_engine/wps_internals.h9
-rw-r--r--apps/gui/statusbar-skinned.c16
-rw-r--r--apps/gui/statusbar-skinned.h2
-rw-r--r--apps/gui/wps.c3
7 files changed, 35 insertions, 28 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 6b6db68023..b5b9b4d7a6 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -98,7 +98,7 @@ void skin_statusbar_changed(struct gui_wps *skin)
const struct screen *display = skin->display;
const int screen = display->screen_type;
- struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, data)->vp;
+ struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, false, data)->vp;
viewport_set_defaults(vp, screen);
if (data->wps_sb_tag)
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index d0194c669b..a3cb68915b 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -132,13 +132,14 @@ struct gui_img* find_image(char label, struct wps_data *data)
#endif
/* traverse the viewport linked list for a viewport */
-struct skin_viewport* find_viewport(char label, struct wps_data *data)
+struct skin_viewport* find_viewport(char *label, bool uivp, struct wps_data *data)
{
struct skin_element *list = data->tree;
while (list)
{
struct skin_viewport *vp = (struct skin_viewport *)list->data;
- if (vp->label == label)
+ if (vp->label && (vp->is_infovp == uivp) &&
+ !strcmp(vp->label, label))
return vp;
list = list->next;
}
@@ -1086,7 +1087,8 @@ static int convert_viewport(struct wps_data *data, struct skin_element* element)
return CALLBACK_ERROR;
skin_vp->hidden_flags = 0;
- skin_vp->label = VP_NO_LABEL;
+ skin_vp->label = NULL;
+ skin_vp->is_infovp = false;
element->data = skin_vp;
curr_vp = skin_vp;
curr_viewport_element = element;
@@ -1118,21 +1120,22 @@ static int convert_viewport(struct wps_data *data, struct skin_element* element)
{
if (element->tag->type == SKIN_TOKEN_UIVIEWPORT_LOAD)
{
+ skin_vp->is_infovp = true;
if (isdefault(param))
{
skin_vp->hidden_flags = VP_NEVER_VISIBLE;
- skin_vp->label = VP_INFO_LABEL|VP_DEFAULT_LABEL;
+ skin_vp->label = VP_DEFAULT_LABEL;
}
else
{
skin_vp->hidden_flags = VP_NEVER_VISIBLE;
- skin_vp->label = VP_INFO_LABEL|param->data.text[0];
+ skin_vp->label = param->data.text;
}
}
else
{
skin_vp->hidden_flags = VP_DRAW_HIDEABLE|VP_DRAW_HIDDEN;
- skin_vp->label = param->data.text[0];
+ skin_vp->label = param->data.text;
}
param++;
}
@@ -1269,7 +1272,7 @@ static int skin_element_callback(struct skin_element* element, void* data)
break;
case SKIN_TOKEN_VIEWPORT_ENABLE:
case SKIN_TOKEN_UIVIEWPORT_ENABLE:
- token->value.i = element->params[0].data.text[0];
+ token->value.data = element->params[0].data.text;
break;
case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY:
function = parse_image_display;
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
index b56fabeaa0..895746370e 100644
--- a/apps/gui/skin_engine/skin_render.c
+++ b/apps/gui/skin_engine/skin_render.c
@@ -92,13 +92,14 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
#endif
case SKIN_TOKEN_VIEWPORT_ENABLE:
{
- char label = token->value.i;
+ char *label = token->value.data;
char temp = VP_DRAW_HIDEABLE;
struct skin_element *viewport = gwps->data->tree;
while (viewport)
{
struct skin_viewport *skinvp = (struct skin_viewport*)viewport->data;
- if (skinvp->label == label)
+ if (skinvp->label && !skinvp->is_infovp &&
+ !strcmp(skinvp->label, label))
{
if (skinvp->hidden_flags&VP_DRAW_HIDDEN)
{
@@ -113,7 +114,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
#ifdef HAVE_LCD_BITMAP
case SKIN_TOKEN_UIVIEWPORT_ENABLE:
sb_set_info_vp(gwps->display->screen_type,
- token->value.i|VP_INFO_LABEL);
+ token->value.data);
break;
case SKIN_TOKEN_PEAKMETER:
data->peak_meter_enabled = true;
@@ -238,14 +239,14 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch,
}
else if (token->type == SKIN_TOKEN_VIEWPORT_ENABLE)
{
- char label = token->value.i&0x7f;
+ char *label = token->value.data;
struct skin_element *viewport;
for (viewport = data->tree;
viewport;
viewport = viewport->next)
{
struct skin_viewport *skin_viewport = (struct skin_viewport*)viewport->data;
- if ((skin_viewport->label&0x7f) != label)
+ if (skin_viewport->label && strcmp(skin_viewport->label, label))
continue;
if (skin_viewport->hidden_flags&VP_NEVER_VISIBLE)
{
@@ -564,7 +565,8 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode)
#endif
viewport = data->tree;
skin_viewport = (struct skin_viewport *)viewport->data;
- if (skin_viewport->label == VP_DEFAULT_LABEL && viewport->next)
+ if (skin_viewport->label && viewport->next &&
+ !strcmp(skin_viewport->label,VP_DEFAULT_LABEL))
refresh_mode = 0;
for (viewport = data->tree;
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index f8e025956e..709dbc6ff7 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -151,13 +151,12 @@ enum wps_parse_error {
#define VP_DRAW_WASHIDDEN 0x4
/* these are never drawn, nor cleared, i.e. just ignored */
#define VP_NEVER_VISIBLE 0x8
-#define VP_DEFAULT_LABEL '|'
-#define VP_NO_LABEL '-'
-#define VP_INFO_LABEL 0x80
+#define VP_DEFAULT_LABEL "|"
struct skin_viewport {
struct viewport vp; /* The LCD viewport struct */
char hidden_flags;
- char label;
+ bool is_infovp;
+ char* label;
unsigned start_fgcolour;
unsigned start_bgcolour;
};
@@ -340,7 +339,7 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
#endif
struct gui_img* find_image(char label, struct wps_data *data);
-struct skin_viewport* find_viewport(char label, struct wps_data *data);
+struct skin_viewport* find_viewport(char *label, bool uivp, struct wps_data *data);
#ifdef SIMULATOR
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index 4df87c0de5..81eb92923d 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -109,7 +109,7 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
/* hide the sb's default viewport because it has nasty effect with stuff
* not part of the statusbar,
* hence .sbs's without any other vps are unsupported*/
- struct skin_viewport *vp = find_viewport(VP_DEFAULT_LABEL, data);
+ struct skin_viewport *vp = find_viewport(VP_DEFAULT_LABEL, false, data);
struct skin_element *next_vp = data->tree->next;
if (vp)
@@ -121,29 +121,30 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
/* hide this viewport, forever */
vp->hidden_flags = VP_NEVER_VISIBLE;
}
- sb_set_info_vp(screen, VP_INFO_LABEL|VP_DEFAULT_LABEL);
+ sb_set_info_vp(screen, VP_DEFAULT_LABEL);
}
if (!success && isfile)
sb_create_from_settings(screen);
}
-static char infovp_label[NB_SCREENS];
-static char oldinfovp_label[NB_SCREENS];
-void sb_set_info_vp(enum screen_type screen, char label)
+static char *infovp_label[NB_SCREENS];
+static char *oldinfovp_label[NB_SCREENS];
+void sb_set_info_vp(enum screen_type screen, char *label)
{
infovp_label[screen] = label;
}
struct viewport *sb_skin_get_info_vp(enum screen_type screen)
{
- if (oldinfovp_label[screen] != infovp_label[screen])
+ if (oldinfovp_label[screen] &&
+ strcmp(oldinfovp_label[screen], infovp_label[screen]))
{
/* UI viewport changed, so force a redraw */
oldinfovp_label[screen] = infovp_label[screen];
viewportmanager_theme_enable(screen, false, NULL);
viewportmanager_theme_undo(screen, true);
}
- return &find_viewport(infovp_label[screen], sb_skin[screen].data)->vp;
+ return &find_viewport(infovp_label[screen], true, sb_skin[screen].data)->vp;
}
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
@@ -301,6 +302,7 @@ void sb_skin_init(void)
int i;
FOR_NB_SCREENS(i)
{
+ oldinfovp_label[i] = NULL;
#ifdef HAVE_ALBUMART
sb_skin_data[i].albumart = NULL;
sb_skin_data[i].playback_aa_slot = -1;
diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h
index 7925aa8093..893d48941d 100644
--- a/apps/gui/statusbar-skinned.h
+++ b/apps/gui/statusbar-skinned.h
@@ -36,7 +36,7 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile);
void sb_create_from_settings(enum screen_type screen);
void sb_skin_init(void) INIT_ATTR;
-void sb_set_info_vp(enum screen_type screen, char label);
+void sb_set_info_vp(enum screen_type screen, char *label);
struct viewport *sb_skin_get_info_vp(enum screen_type screen);
void sb_skin_update(enum screen_type screen, bool force);
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 6840c16f28..7d583a82b4 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -652,7 +652,8 @@ static void gwps_enter_wps(void)
#if LCD_DEPTH > 1
if (display->depth > 1)
{
- struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, gwps->data)->vp;
+ struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL,
+ false, gwps->data)->vp;
vp->fg_pattern = display->get_foreground();
vp->bg_pattern = display->get_background();
}