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
This commit is contained in:
parent
db2a8ffd30
commit
943de3ce49
5 changed files with 33 additions and 7 deletions
|
@ -1031,6 +1031,12 @@ static bool check_feature_tag(const int type)
|
|||
return true;
|
||||
#endif
|
||||
return false;
|
||||
case SKIN_TOKEN_HAVE_TOUCH:
|
||||
#ifdef HAVE_TOUCHSCREEN
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if CONFIG_TUNER
|
||||
case SKIN_TOKEN_HAVE_RDS:
|
||||
|
|
|
@ -1377,6 +1377,12 @@ const char *get_token_value(struct gui_wps *gwps,
|
|||
#endif
|
||||
}
|
||||
return NULL;
|
||||
case SKIN_TOKEN_HAVE_TOUCH:
|
||||
#ifdef HAVE_TOUCHSCREEN
|
||||
return "t";
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
case SKIN_TOKEN_SETTING:
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue