summaryrefslogtreecommitdiff
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.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)
132 if (element->tag && next->type == LINE && 132 if (element->tag && next->type == LINE &&
133 element->line == next->line) 133 element->line == next->line)
134 { 134 {
135 struct line *line = (struct line*)malloc(sizeof(struct line)); 135 struct line *line = (struct line*)skin_alloc(sizeof(struct line));
136 line->update_mode = 0; 136 line->update_mode = 0;
137 line->eat_line_ending = true; 137 line->eat_line_ending = true;
138 next->data = line; 138 next->data = line;
@@ -140,7 +140,7 @@ int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line)
140 } 140 }
141 else if (element->type == LINE && !element->data) 141 else if (element->type == LINE && !element->data)
142 { 142 {
143 struct line *line = (struct line*)malloc(sizeof(struct line)); 143 struct line *line = (struct line*)skin_alloc(sizeof(struct line));
144 line->update_mode = 0; 144 line->update_mode = 0;
145 line->eat_line_ending = false; 145 line->eat_line_ending = false;
146 element->data = line; 146 element->data = line;
@@ -148,11 +148,17 @@ int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line)
148 } 148 }
149 else if (element->type == SUBLINES) 149 else if (element->type == SUBLINES)
150 { 150 {
151 struct subline *subline = malloc(sizeof(struct subline)); 151 struct subline *subline = skin_alloc(sizeof(struct subline));
152 subline->current_line = -1; 152 subline->current_line = -1;
153 subline->last_change_tick = 0; 153 subline->last_change_tick = 0;
154 element->data = subline; 154 element->data = subline;
155 } 155 }
156 else if (element->type == CONDITIONAL)
157 {
158 struct conditional *cond = skin_alloc(sizeof(struct conditional));
159 cond->last_value = element->children_count;
160 element->data = cond;
161 }
156 else if (element->type == TAG) 162 else if (element->type == TAG)
157 { 163 {
158 int i; 164 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,
40void skin_render_alternator(struct skin_element* alternator, 40void skin_render_alternator(struct skin_element* alternator,
41 char* buf, size_t buf_size, int line_number); 41 char* buf, size_t buf_size, int line_number);
42 42
43static void do_tags_in_hidden_conditional(struct skin_element* branch)
44{
45 /* Tags here are ones which need to be "turned off" or cleared
46 * if they are in a conditional branch which isnt being used */
47 if (branch->type == SUBLINES)
48 {
49 int i;
50 for (i=0; i<branch->children_count; i++)
51 {
52 do_tags_in_hidden_conditional(branch->children[i]);
53 }
54 }
55 else if (branch->type == LINE)
56 {
57 struct skin_element *child = branch->children[0];
58 while (child)
59 {
60 if (child->type != TAG)
61 {
62 child = child->next;
63 continue;
64 }
65 switch (child->tag->type)
66 {
67 case SKIN_TOKEN_PEAKMETER:
68 /* stop the peak meter */
69 break;
70 case SKIN_TOKEN_ALBUMART_DISPLAY:
71 /* clear the AA image */
72 break;
73 case SKIN_TOKEN_IMAGE_DISPLAY:
74 case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY:
75 printf("disable image\n");
76 /* clear images */
77 break;
78 default:
79 break;
80 }
81 child = child->next;
82 }
83 }
84}
85
86
43/* Draw a LINE element onto the display */ 87/* Draw a LINE element onto the display */
44void skin_render_line(struct skin_element* line, 88void skin_render_line(struct skin_element* line,
45 char* buf, size_t buf_size, int line_number) 89 char* buf, size_t buf_size, int line_number)
46{ 90{
47 int value; 91 int last_value, value;
48 if (line->children_count == 0) 92 if (line->children_count == 0)
49 return; /* empty line, do nothing */ 93 return; /* empty line, do nothing */
50 struct skin_element *child = line->children[0]; 94 struct skin_element *child = line->children[0];
@@ -56,9 +100,16 @@ void skin_render_line(struct skin_element* line,
56 switch (child->type) 100 switch (child->type)
57 { 101 {
58 case CONDITIONAL: 102 case CONDITIONAL:
103 last_value = ((struct conditional*)(child->data))->last_value;
59 value = 0; /* actually get it from the token :p */ 104 value = 0; /* actually get it from the token :p */
60 if (value >= child->children_count) 105 if (value >= child->children_count)
61 value = child->children_count-1; 106 value = child->children_count-1;
107
108 /* some tags need handling if they are being disabled */
109 if (value != last_value && last_value < child->children_count)
110 do_tags_in_hidden_conditional(child->children[last_value]);
111 last_value = value;
112
62 if (child->children[value]->type == SUBLINES) 113 if (child->children[value]->type == SUBLINES)
63 func = skin_render_alternator; 114 func = skin_render_alternator;
64 else if (child->children[value]->type == LINE) 115 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 {
62 unsigned long last_change_tick; 62 unsigned long last_change_tick;
63}; 63};
64 64
65struct conditional {
66 int last_value;
67};
68
65 69
66#endif 70#endif