Theme Editor: Rearranged and separated tag execution and rendering code

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27167 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-29 05:23:22 +00:00
parent 942e427ef0
commit aa13a5377c
2 changed files with 160 additions and 144 deletions

View file

@ -525,11 +525,14 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
else if(element->type == TAG)
{
if(info.device()->data(QString(element->tag->name)).isValid())
viewport->write(info.device()->
data(QString(element->tag->name)).toString());
if(!execTag(info, viewport))
viewport->write(evalTag(info).toString());
/* These are for special cases */
}
}
bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
{
QString filename;
QString id;
@ -568,7 +571,7 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
image->setTile(tile);
image->show();
}
break;
return true;
case 'l':
/* %xl */
@ -584,7 +587,7 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
info.screen()->loadImage(id, new RBImage(filename, tiles, x, y,
viewport));
break;
return true;
case '\0':
/* %x */
@ -597,11 +600,11 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
info.screen()->loadImage(id, new RBImage(filename, 1, x, y,
viewport));
info.screen()->getImage(id)->show();
break;
return true;
}
break;
return true;
case 'F':
@ -614,11 +617,11 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
filename = info.settings()->value("themebase", "") + "/fonts/" +
element->params[1].data.text;
info.screen()->loadFont(x, new RBFont(filename));
break;
return true;
}
break;
return true;
case 'V':
@ -631,13 +634,13 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
stringToColor(QString(element->params[0].
data.text),
Qt::white));
break;
return true;
case 'd':
/* %Vd */
id = element->params[0].data.text;
info.screen()->showViewport(id);
break;
return true;
case 'f':
/* %Vf */
@ -645,16 +648,16 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
stringToColor(QString(element->params[0].
data.text),
Qt::black));
break;
return true;
case 'I':
/* %VI */
info.screen()->makeCustomUI(element->params[0].data.text);
break;
return true;
}
break;
return true;
case 'X':
@ -664,11 +667,19 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
/* %X */
filename = QString(element->params[0].data.text);
info.screen()->setBackdrop(filename);
break;
return true;
}
break;
return true;
}
}
return false;
}
QVariant ParseTreeNode::evalTag(const RBRenderInfo& info, bool conditional,
int branches)
{
return info.device()->data(QString(element->tag->name));
}

View file

@ -63,6 +63,11 @@ public:
void render(const RBRenderInfo &info, RBViewport* viewport);
private:
bool execTag(const RBRenderInfo& info, RBViewport* viewport);
QVariant evalTag(const RBRenderInfo& info, bool conditional = false,
int branches = 0);
ParseTreeNode* parent;
struct skin_element* element;
struct skin_tag_parameter* param;