summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-06-14 10:00:22 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-06-14 10:00:22 +0000
commitb49577b3815d1cd3a657a709c81f1ff7d0c07ae4 (patch)
tree3c76a11c72eac723655e6d5d94144768a692289e
parentd827d20416cbb0afc0bcb25468579f8f61639982 (diff)
downloadrockbox-b49577b3815d1cd3a657a709c81f1ff7d0c07ae4.tar.gz
rockbox-b49577b3815d1cd3a657a709c81f1ff7d0c07ae4.tar.bz2
rockbox-b49577b3815d1cd3a657a709c81f1ff7d0c07ae4.zip
some tags need special handling when they are in the wrong branch of a conditional, so go ahead and make that work :p
also replace malloc with skin_alloc git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26842 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/newparser/handle_tags.c12
-rw-r--r--utils/newparser/skin_render.c53
-rw-r--r--utils/newparser/skin_structs.h4
3 files changed, 65 insertions, 4 deletions
diff --git a/utils/newparser/handle_tags.c b/utils/newparser/handle_tags.c
index a725a52396..28c4548549 100644
--- a/utils/newparser/handle_tags.c
+++ b/utils/newparser/handle_tags.c
@@ -132,7 +132,7 @@ int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line)
if (element->tag && next->type == LINE &&
element->line == next->line)
{
- struct line *line = (struct line*)malloc(sizeof(struct line));
+ struct line *line = (struct line*)skin_alloc(sizeof(struct line));
line->update_mode = 0;
line->eat_line_ending = true;
next->data = line;
@@ -140,7 +140,7 @@ int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line)
}
else if (element->type == LINE && !element->data)
{
- struct line *line = (struct line*)malloc(sizeof(struct line));
+ struct line *line = (struct line*)skin_alloc(sizeof(struct line));
line->update_mode = 0;
line->eat_line_ending = false;
element->data = line;
@@ -148,11 +148,17 @@ int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line)
}
else if (element->type == SUBLINES)
{
- struct subline *subline = malloc(sizeof(struct subline));
+ struct subline *subline = skin_alloc(sizeof(struct subline));
subline->current_line = -1;
subline->last_change_tick = 0;
element->data = subline;
}
+ else if (element->type == CONDITIONAL)
+ {
+ struct conditional *cond = skin_alloc(sizeof(struct conditional));
+ cond->last_value = element->children_count;
+ element->data = cond;
+ }
else if (element->type == TAG)
{
int i;
diff --git a/utils/newparser/skin_render.c b/utils/newparser/skin_render.c
index f39e6f6c45..d8facb03f6 100644
--- a/utils/newparser/skin_render.c
+++ b/utils/newparser/skin_render.c
@@ -40,11 +40,55 @@ typedef void (*skin_render_func)(struct skin_element* alternator,
void skin_render_alternator(struct skin_element* alternator,
char* buf, size_t buf_size, int line_number);
+static void do_tags_in_hidden_conditional(struct skin_element* branch)
+{
+ /* Tags here are ones which need to be "turned off" or cleared
+ * if they are in a conditional branch which isnt being used */
+ if (branch->type == SUBLINES)
+ {
+ int i;
+ for (i=0; i<branch->children_count; i++)
+ {
+ do_tags_in_hidden_conditional(branch->children[i]);
+ }
+ }
+ else if (branch->type == LINE)
+ {
+ struct skin_element *child = branch->children[0];
+ while (child)
+ {
+ if (child->type != TAG)
+ {
+ child = child->next;
+ continue;
+ }
+ switch (child->tag->type)
+ {
+ case SKIN_TOKEN_PEAKMETER:
+ /* stop the peak meter */
+ break;
+ case SKIN_TOKEN_ALBUMART_DISPLAY:
+ /* clear the AA image */
+ break;
+ case SKIN_TOKEN_IMAGE_DISPLAY:
+ case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY:
+ printf("disable image\n");
+ /* clear images */
+ break;
+ default:
+ break;
+ }
+ child = child->next;
+ }
+ }
+}
+
+
/* Draw a LINE element onto the display */
void skin_render_line(struct skin_element* line,
char* buf, size_t buf_size, int line_number)
{
- int value;
+ int last_value, value;
if (line->children_count == 0)
return; /* empty line, do nothing */
struct skin_element *child = line->children[0];
@@ -56,9 +100,16 @@ void skin_render_line(struct skin_element* line,
switch (child->type)
{
case CONDITIONAL:
+ last_value = ((struct conditional*)(child->data))->last_value;
value = 0; /* actually get it from the token :p */
if (value >= child->children_count)
value = child->children_count-1;
+
+ /* some tags need handling if they are being disabled */
+ if (value != last_value && last_value < child->children_count)
+ do_tags_in_hidden_conditional(child->children[last_value]);
+ last_value = value;
+
if (child->children[value]->type == SUBLINES)
func = skin_render_alternator;
else if (child->children[value]->type == LINE)
diff --git a/utils/newparser/skin_structs.h b/utils/newparser/skin_structs.h
index 5755120e74..4fc333c500 100644
--- a/utils/newparser/skin_structs.h
+++ b/utils/newparser/skin_structs.h
@@ -62,5 +62,9 @@ struct subline {
unsigned long last_change_tick;
};
+struct conditional {
+ int last_value;
+};
+
#endif