summaryrefslogtreecommitdiffstats
path: root/utils/themeeditor
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-29 05:23:22 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-29 05:23:22 +0000
commitaa13a5377ce4b982110fc44f2f9a6636d81e8d8d (patch)
tree229b5ef2b2af9339e22c4b24476dbc9e4320f117 /utils/themeeditor
parent942e427ef00acd38e0657d82b4c52188a1fd0b76 (diff)
downloadrockbox-aa13a5377ce4b982110fc44f2f9a6636d81e8d8d.tar.gz
rockbox-aa13a5377ce4b982110fc44f2f9a6636d81e8d8d.tar.bz2
rockbox-aa13a5377ce4b982110fc44f2f9a6636d81e8d8d.zip
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
Diffstat (limited to 'utils/themeeditor')
-rw-r--r--utils/themeeditor/models/parsetreenode.cpp253
-rw-r--r--utils/themeeditor/models/parsetreenode.h5
2 files changed, 137 insertions, 121 deletions
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp
index 7b355687bb..45cd62f8a6 100644
--- a/utils/themeeditor/models/parsetreenode.cpp
+++ b/utils/themeeditor/models/parsetreenode.cpp
@@ -525,150 +525,161 @@ 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 */
+ }
+}
- QString filename;
- QString id;
- int x, y, tiles, tile;
- char c;
- RBImage* image;
+bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
+{
- /* Two switch statements to narrow down the tag name */
- switch(element->tag->name[0])
- {
+ QString filename;
+ QString id;
+ int x, y, tiles, tile;
+ char c;
+ RBImage* image;
- case 'x':
- switch(element->tag->name[1])
- {
- case 'd':
- /* %xd */
- id = "";
- id.append(element->params[0].data.text[0]);
- c = element->params[0].data.text[1];
+ /* Two switch statements to narrow down the tag name */
+ switch(element->tag->name[0])
+ {
- if(c == '\0')
- {
- tile = 1;
- }
- else
- {
- if(isupper(c))
- tile = c - 'A' + 25;
- else
- tile = c - 'a';
- }
+ case 'x':
+ switch(element->tag->name[1])
+ {
+ case 'd':
+ /* %xd */
+ id = "";
+ id.append(element->params[0].data.text[0]);
+ c = element->params[0].data.text[1];
- image = info.screen()->getImage(id);
- if(image)
- {
- image->setTile(tile);
- image->show();
- }
- break;
-
- case 'l':
- /* %xl */
- id = element->params[0].data.text;
- filename = info.settings()->value("imagepath", "") + "/" +
- element->params[1].data.text;
- x = element->params[2].data.numeric;
- y = element->params[3].data.numeric;
- if(element->params_count > 4)
- tiles = element->params[4].data.numeric;
+ if(c == '\0')
+ {
+ tile = 1;
+ }
+ else
+ {
+ if(isupper(c))
+ tile = c - 'A' + 25;
else
- tiles = 1;
-
- info.screen()->loadImage(id, new RBImage(filename, tiles, x, y,
- viewport));
- break;
-
- case '\0':
- /* %x */
- id = element->params[0].data.text;
- filename = info.settings()->value("imagepath", "") + "/" +
- element->params[1].data.text;
- x = element->params[2].data.numeric;
- y = element->params[3].data.numeric;
- image = new RBImage(filename, 1, x, y, viewport);
- info.screen()->loadImage(id, new RBImage(filename, 1, x, y,
- viewport));
- info.screen()->getImage(id)->show();
- break;
-
+ tile = c - 'a';
}
- break;
+ image = info.screen()->getImage(id);
+ if(image)
+ {
+ image->setTile(tile);
+ image->show();
+ }
+ return true;
+
+ case 'l':
+ /* %xl */
+ id = element->params[0].data.text;
+ filename = info.settings()->value("imagepath", "") + "/" +
+ element->params[1].data.text;
+ x = element->params[2].data.numeric;
+ y = element->params[3].data.numeric;
+ if(element->params_count > 4)
+ tiles = element->params[4].data.numeric;
+ else
+ tiles = 1;
+
+ info.screen()->loadImage(id, new RBImage(filename, tiles, x, y,
+ viewport));
+ return true;
+
+ case '\0':
+ /* %x */
+ id = element->params[0].data.text;
+ filename = info.settings()->value("imagepath", "") + "/" +
+ element->params[1].data.text;
+ x = element->params[2].data.numeric;
+ y = element->params[3].data.numeric;
+ image = new RBImage(filename, 1, x, y, viewport);
+ info.screen()->loadImage(id, new RBImage(filename, 1, x, y,
+ viewport));
+ info.screen()->getImage(id)->show();
+ return true;
- case 'F':
+ }
- switch(element->tag->name[1])
- {
+ return true;
- case 'l':
- /* %Fl */
- x = element->params[0].data.numeric;
- filename = info.settings()->value("themebase", "") + "/fonts/" +
- element->params[1].data.text;
- info.screen()->loadFont(x, new RBFont(filename));
- break;
+ case 'F':
- }
+ switch(element->tag->name[1])
+ {
- break;
+ case 'l':
+ /* %Fl */
+ x = element->params[0].data.numeric;
+ filename = info.settings()->value("themebase", "") + "/fonts/" +
+ element->params[1].data.text;
+ info.screen()->loadFont(x, new RBFont(filename));
+ return true;
- case 'V':
+ }
- switch(element->tag->name[1])
- {
+ return true;
- case 'b':
- /* %Vb */
- viewport->setBGColor(RBScreen::
- stringToColor(QString(element->params[0].
- data.text),
- Qt::white));
- break;
-
- case 'd':
- /* %Vd */
- id = element->params[0].data.text;
- info.screen()->showViewport(id);
- break;
-
- case 'f':
- /* %Vf */
- viewport->setFGColor(RBScreen::
- stringToColor(QString(element->params[0].
- data.text),
- Qt::black));
- break;
-
- case 'I':
- /* %VI */
- info.screen()->makeCustomUI(element->params[0].data.text);
- break;
+ case 'V':
- }
+ switch(element->tag->name[1])
+ {
- break;
+ case 'b':
+ /* %Vb */
+ viewport->setBGColor(RBScreen::
+ stringToColor(QString(element->params[0].
+ data.text),
+ Qt::white));
+ return true;
+
+ case 'd':
+ /* %Vd */
+ id = element->params[0].data.text;
+ info.screen()->showViewport(id);
+ return true;
+
+ case 'f':
+ /* %Vf */
+ viewport->setFGColor(RBScreen::
+ stringToColor(QString(element->params[0].
+ data.text),
+ Qt::black));
+ return true;
+
+ case 'I':
+ /* %VI */
+ info.screen()->makeCustomUI(element->params[0].data.text);
+ return true;
- case 'X':
+ }
- switch(element->tag->name[1])
- {
- case '\0':
- /* %X */
- filename = QString(element->params[0].data.text);
- info.screen()->setBackdrop(filename);
- break;
- }
+ return true;
- break;
+ case 'X':
+ switch(element->tag->name[1])
+ {
+ case '\0':
+ /* %X */
+ filename = QString(element->params[0].data.text);
+ info.screen()->setBackdrop(filename);
+ return true;
}
+
+ return true;
+
}
+
+ return false;
+
+}
+
+QVariant ParseTreeNode::evalTag(const RBRenderInfo& info, bool conditional,
+ int branches)
+{
+ return info.device()->data(QString(element->tag->name));
}
diff --git a/utils/themeeditor/models/parsetreenode.h b/utils/themeeditor/models/parsetreenode.h
index 127cd78e1e..f85460d93d 100644
--- a/utils/themeeditor/models/parsetreenode.h
+++ b/utils/themeeditor/models/parsetreenode.h
@@ -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;