forked from len0rd/rockbox
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
This commit is contained in:
parent
d827d20416
commit
b49577b381
3 changed files with 65 additions and 4 deletions
|
|
@ -132,7 +132,7 @@ int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line)
|
||||||
if (element->tag && next->type == LINE &&
|
if (element->tag && next->type == LINE &&
|
||||||
element->line == next->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->update_mode = 0;
|
||||||
line->eat_line_ending = true;
|
line->eat_line_ending = true;
|
||||||
next->data = line;
|
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)
|
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->update_mode = 0;
|
||||||
line->eat_line_ending = false;
|
line->eat_line_ending = false;
|
||||||
element->data = line;
|
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)
|
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->current_line = -1;
|
||||||
subline->last_change_tick = 0;
|
subline->last_change_tick = 0;
|
||||||
element->data = subline;
|
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)
|
else if (element->type == TAG)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,55 @@ typedef void (*skin_render_func)(struct skin_element* alternator,
|
||||||
void skin_render_alternator(struct skin_element* alternator,
|
void skin_render_alternator(struct skin_element* alternator,
|
||||||
char* buf, size_t buf_size, int line_number);
|
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 */
|
/* Draw a LINE element onto the display */
|
||||||
void skin_render_line(struct skin_element* line,
|
void skin_render_line(struct skin_element* line,
|
||||||
char* buf, size_t buf_size, int line_number)
|
char* buf, size_t buf_size, int line_number)
|
||||||
{
|
{
|
||||||
int value;
|
int last_value, value;
|
||||||
if (line->children_count == 0)
|
if (line->children_count == 0)
|
||||||
return; /* empty line, do nothing */
|
return; /* empty line, do nothing */
|
||||||
struct skin_element *child = line->children[0];
|
struct skin_element *child = line->children[0];
|
||||||
|
|
@ -56,9 +100,16 @@ void skin_render_line(struct skin_element* line,
|
||||||
switch (child->type)
|
switch (child->type)
|
||||||
{
|
{
|
||||||
case CONDITIONAL:
|
case CONDITIONAL:
|
||||||
|
last_value = ((struct conditional*)(child->data))->last_value;
|
||||||
value = 0; /* actually get it from the token :p */
|
value = 0; /* actually get it from the token :p */
|
||||||
if (value >= child->children_count)
|
if (value >= child->children_count)
|
||||||
value = child->children_count-1;
|
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)
|
if (child->children[value]->type == SUBLINES)
|
||||||
func = skin_render_alternator;
|
func = skin_render_alternator;
|
||||||
else if (child->children[value]->type == LINE)
|
else if (child->children[value]->type == LINE)
|
||||||
|
|
|
||||||
|
|
@ -62,5 +62,9 @@ struct subline {
|
||||||
unsigned long last_change_tick;
|
unsigned long last_change_tick;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct conditional {
|
||||||
|
int last_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue