summaryrefslogtreecommitdiffstats
path: root/lib/skin_parser
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-10-28 11:00:36 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-10-28 11:00:36 +0000
commit943de3ce49e3ff4bbdefa7459dbc3b885fe145ad (patch)
tree4d0791456aa944700570e7207f6f8717e8c1a667 /lib/skin_parser
parentdb2a8ffd30f3c1b5a17f318d4acbbeab54bab4c3 (diff)
downloadrockbox-943de3ce49e3ff4bbdefa7459dbc3b885fe145ad.tar.gz
rockbox-943de3ce49e3ff4bbdefa7459dbc3b885fe145ad.tar.bz2
rockbox-943de3ce49e3ff4bbdefa7459dbc3b885fe145ad.zip
skin_parser: Change the way hardware conditionals are done (i.e %?cc)
They now only parse the correct branch (so only the true branch, or only the false branch). This shuold allow you to load different images/backdrops with the same id's depending on the targets hardware. Add a new %Tp - "touchscreen present?" tag to check if the target has a touchscreen git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28370 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'lib/skin_parser')
-rw-r--r--lib/skin_parser/skin_parser.c14
-rw-r--r--lib/skin_parser/tag_table.c7
-rw-r--r--lib/skin_parser/tag_table.h7
3 files changed, 21 insertions, 7 deletions
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c
index 64ac462c2c..f574d3f7a2 100644
--- a/lib/skin_parser/skin_parser.c
+++ b/lib/skin_parser/skin_parser.c
@@ -877,6 +877,7 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc
#ifdef ROCKBOX
bool feature_available = true;
const char *false_branch = NULL;
+ const char *conditional_end = NULL;
#endif
/* Some conditional tags allow for target feature checking,
@@ -955,6 +956,12 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc
false_branch = cursor+1;
children--;
}
+ if (element->tag->flags&FEATURE_TAG)
+ {
+ if (feature_available)
+ children--;
+ }
+ conditional_end = cursor;
/* if we are skipping the true branch fix that up */
cursor = false_branch ? false_branch : bookmark;
#else
@@ -969,7 +976,13 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc
for(i = 0; i < children; i++)
{
element->children[i] = skin_parse_code_as_arg(&cursor);
+ if (element->children[i] == NULL)
+ return 0;
skip_whitespace(&cursor);
+#ifdef ROCKBOX
+ if ((element->tag->flags&FEATURE_TAG) && feature_available)
+ cursor = conditional_end;
+#endif
if(i < children - 1 && *cursor != ENUMLISTSEPERATESYM)
{
@@ -986,7 +999,6 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc
cursor++;
}
}
-
*document = cursor;
return 1;
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index 8b31adab2c..9a68834589 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -44,7 +44,7 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_USB_POWERED, "bu", "", SKIN_REFRESH_DYNAMIC },
- { SKIN_TOKEN_RTC_PRESENT, "cc", "", SKIN_REFRESH_STATIC },
+ { SKIN_TOKEN_RTC_PRESENT, "cc", "", FEATURE_TAG },
{ SKIN_TOKEN_RTC_DAY_OF_MONTH, "cd", "", SKIN_RTC_REFRESH },
{ SKIN_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED, "ce", "", SKIN_RTC_REFRESH },
{ SKIN_TOKEN_RTC_12HOUR_CFG, "cf", "", SKIN_RTC_REFRESH },
@@ -146,7 +146,7 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_REPLAYGAIN, "rg", "", SKIN_REFRESH_STATIC },
{ SKIN_TOKEN_CROSSFADE, "xf", "", SKIN_REFRESH_DYNAMIC },
- { SKIN_TOKEN_HAVE_TUNER, "tp", "", SKIN_REFRESH_STATIC },
+ { SKIN_TOKEN_HAVE_TUNER, "tp", "", FEATURE_TAG },
{ SKIN_TOKEN_TUNER_TUNED, "tt", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_TUNER_SCANMODE, "tm", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_TUNER_STEREO, "ts", "", SKIN_REFRESH_DYNAMIC },
@@ -200,8 +200,9 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_LASTTOUCH, "Tl" , "|D", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_CURRENT_SCREEN, "cs", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_TOUCHREGION, "T" , "IIIIS|S", 0|NOBREAK },
+ { SKIN_TOKEN_HAVE_TOUCH, "Tp", "", FEATURE_TAG },
- { SKIN_TOKEN_HAVE_RECORDING, "Rp" , "", SKIN_REFRESH_STATIC },
+ { SKIN_TOKEN_HAVE_RECORDING, "Rp" , "", FEATURE_TAG },
{ SKIN_TOKEN_IS_RECORDING, "Rr" , "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_REC_FREQ, "Rf" , "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_REC_ENCODER, "Re" , "", SKIN_REFRESH_DYNAMIC },
diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h
index f16709d133..a7ac164e10 100644
--- a/lib/skin_parser/tag_table.h
+++ b/lib/skin_parser/tag_table.h
@@ -29,9 +29,8 @@ extern "C"
#define MAX_TAG_PARAMS 12
-
- /* Flag to tell the renderer not to insert a line break */
-#define NOBREAK 0x1
+#define NOBREAK 0x1 /* Flag to tell the renderer not to insert a line break */
+#define FEATURE_TAG 0x2 /* Parse time conditional for feature checks (e.g HAVE_RTC) */
/* constants used in line_type and as refresh_mode for wps_refresh */
#define SKIN_REFRESH_SHIFT 16
@@ -214,6 +213,8 @@ enum skin_token_type {
SKIN_TOKEN_BUTTON_VOLUME,
SKIN_TOKEN_LASTTOUCH,
SKIN_TOKEN_TOUCHREGION,
+ SKIN_TOKEN_HAVE_TOUCH,
+
/* Virtual LED */
SKIN_TOKEN_VLED_HDD,
/* Volume level */