1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Modified parser to integrate the %V tag into the VIEWPORT element, in the same style as CONDITIONAL

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26762 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-11 08:03:32 +00:00
parent 2f7bb96c3d
commit 1b613f583d
2 changed files with 33 additions and 19 deletions

View file

@ -56,6 +56,7 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
} }
break; break;
case VIEWPORT:
case CONDITIONAL: case CONDITIONAL:
for(int i = 0; i < element->params_count; i++) for(int i = 0; i < element->params_count; i++)
children.append(new ParseTreeNode(&data->params[i], this)); children.append(new ParseTreeNode(&data->params[i], this));
@ -70,7 +71,6 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
} }
break; break;
case VIEWPORT:
case LINE: case LINE:
for(int i = 0; i < data->children_count; i++) for(int i = 0; i < data->children_count; i++)
{ {
@ -104,10 +104,23 @@ QString ParseTreeNode::genCode() const
{ {
case VIEWPORT: case VIEWPORT:
buffer.append(children[0]->genCode()); /* Generating the Viewport tag, if necessary */
if(children[0]->element->type == TAG) if(element->tag)
{
buffer.append(TAGSYM);
buffer.append(element->tag->name);
buffer.append(ARGLISTOPENSYM);
for(int i = 0; i < element->params_count; i++)
{
buffer.append(children[i]->genCode());
if(i != element->params_count - 1)
buffer.append(ARGLISTSEPERATESYM);
}
buffer.append(ARGLISTCLOSESYM);
buffer.append('\n'); buffer.append('\n');
for(int i = 1; i < children.count(); i++) }
for(int i = element->params_count; i < children.count(); i++)
buffer.append(children[i]->genCode()); buffer.append(children[i]->genCode());
break; break;

View file

@ -124,24 +124,19 @@ static struct skin_element* skin_parse_viewport(char** document)
/* Parsing out the viewport tag if there is one */ /* Parsing out the viewport tag if there is one */
if(check_viewport(cursor)) if(check_viewport(cursor))
{ {
retval->children_count = 2; skin_parse_tag(retval, &cursor);
retval->children = skin_alloc_children(2);
retval->children[0] = skin_alloc_element();
skin_parse_tag(retval->children[0], &cursor);
if(*cursor == '\n') if(*cursor == '\n')
{ {
cursor++; cursor++;
skin_line++; skin_line++;
} }
} }
else
{ retval->children_count = 1;
retval->children_count = 1; retval->children = skin_alloc_children(1);
retval->children = skin_alloc_children(1);
}
while(*cursor != '\0' && !(check_viewport(cursor) && cursor != *document)) do
{ {
/* First, we check to see if this line will contain sublines */ /* First, we check to see if this line will contain sublines */
@ -217,10 +212,11 @@ static struct skin_element* skin_parse_viewport(char** document)
skin_line++; skin_line++;
} }
} }
while(*cursor != '\0' && !(check_viewport(cursor) && cursor != *document));
*document = cursor; *document = cursor;
retval->children[retval->children_count - 1] = root; retval->children[0] = root;
return retval; return retval;
} }
@ -253,8 +249,11 @@ static struct skin_element* skin_parse_line_optional(char** document,
retval = skin_alloc_element(); retval = skin_alloc_element();
retval->type = LINE; retval->type = LINE;
retval->line = skin_line; retval->line = skin_line;
retval->children_count = 1; if(*cursor != '\0')
retval->children = skin_alloc_children(1); retval->children_count = 1;
else retval->children_count = 0;
if(retval->children_count > 0)
retval->children = skin_alloc_children(1);
while(*cursor != '\n' && *cursor != '\0' && *cursor != MULTILINESYM while(*cursor != '\n' && *cursor != '\0' && *cursor != MULTILINESYM
&& !((*cursor == ARGLISTSEPERATESYM && !((*cursor == ARGLISTSEPERATESYM
@ -302,7 +301,8 @@ static struct skin_element* skin_parse_line_optional(char** document,
/* Moving up the calling function's pointer */ /* Moving up the calling function's pointer */
*document = cursor; *document = cursor;
retval->children[0] = root; if(root)
retval->children[0] = root;
return retval; return retval;
} }
@ -432,7 +432,7 @@ static int skin_parse_tag(struct skin_element* element, char** document)
} }
/* Copying basic tag info */ /* Copying basic tag info */
if(element->type != CONDITIONAL) if(element->type != CONDITIONAL && element->type != VIEWPORT)
element->type = TAG; element->type = TAG;
element->tag = tag; element->tag = tag;
tag_args = tag->params; tag_args = tag->params;
@ -851,6 +851,7 @@ struct skin_element* skin_alloc_element()
struct skin_element* retval = (struct skin_element*) struct skin_element* retval = (struct skin_element*)
skin_alloc(sizeof(struct skin_element)); skin_alloc(sizeof(struct skin_element));
retval->next = NULL; retval->next = NULL;
retval->tag = NULL;
retval->params_count = 0; retval->params_count = 0;
retval->children_count = 0; retval->children_count = 0;