From 74ec011bb8df08b0fba3709cc590ce3842b1c973 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 19 Aug 2010 13:49:32 +0000 Subject: New skin tag: %if(, , [,option count]) which lets you do very simple logical comparissons on other tags. is the tag to check against is the comparisson to do, any one of... =, !=, >, >=, <, <= (when comparring against a string tag like %ia only = and != work, and it is done NOT case sensitive) is either another tag, a number, or text. [option count] is an optinal number to use for the few tags which scale to the amount of options when used as a conditional (i.e %?pv would have 4 options) example: %?if(%pv, >=, 0) That says "If the value from %pv (volume) is greater than or equal to 0 then display the warning line, otherwise the cool line." %?if(%ia, =, %Ia) <= this artist and next artist are the same. some tags might need a touch of tweaking to work better with this. experiment and have fun git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27846 a1c6a512-1295-4272-9138-f99709370657 --- lib/skin_parser/skin_parser.c | 6 ++++-- lib/skin_parser/tag_table.c | 2 ++ lib/skin_parser/tag_table.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 66deaab102..b3bc9856b9 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -621,11 +621,13 @@ static int skin_parse_tag(struct skin_element* element, const char** document) } temp_params[j] = '\0'; j = 0; - while (cursor[j] != ',' && cursor[j] != ')') + while (cursor[j] && cursor[j] != ',' && cursor[j] != ')') { haspercent = haspercent || (cursor[j] == '%'); hasdecimal = hasdecimal || (cursor[j] == '.'); - number = number && (isdigit(cursor[j]) || (cursor[j] == '.')); + number = number && (isdigit(cursor[j]) || + (cursor[j] == '.') || + (cursor[j] == '-')); j++; } type_code = '*'; diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c index 9924d06619..9c0b51dacf 100644 --- a/lib/skin_parser/tag_table.c +++ b/lib/skin_parser/tag_table.c @@ -33,6 +33,8 @@ static const struct tag_info legal_tags[] = { SKIN_TOKEN_ALIGN_RIGHT_RTL, "aR", "", 0 }, { SKIN_TOKEN_ALIGN_LANGDIRECTION, "ax", "", 0 }, + { SKIN_TOKEN_LOGICAL_IF, "if", "TS[ITS]|D", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_BATTERY_PERCENT, "bl" , BAR_PARAMS, SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_BATTERY_VOLTS, "bv", "", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_BATTERY_TIME, "bt", "", SKIN_REFRESH_DYNAMIC }, diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h index 4b7efaa835..f16709d133 100644 --- a/lib/skin_parser/tag_table.h +++ b/lib/skin_parser/tag_table.h @@ -73,6 +73,7 @@ enum skin_token_type { SKIN_TOKEN_SUBLINE_SCROLL, /* Conditional */ + SKIN_TOKEN_LOGICAL_IF, SKIN_TOKEN_CONDITIONAL, SKIN_TOKEN_CONDITIONAL_START, SKIN_TOKEN_CONDITIONAL_OPTION, -- cgit