summaryrefslogtreecommitdiffstats
path: root/utils/themeeditor
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-08-09 19:37:23 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-08-09 19:37:23 +0000
commitd1a392a0e95b10fe9603fbd379a70b4cc0ddf22f (patch)
treeb1ce5452aa5578c7cbc5e711373d73b52b797510 /utils/themeeditor
parent77b682571f80b0aec9a16182600678a1b553a4bb (diff)
downloadrockbox-d1a392a0e95b10fe9603fbd379a70b4cc0ddf22f.tar.gz
rockbox-d1a392a0e95b10fe9603fbd379a70b4cc0ddf22f.tar.bz2
rockbox-d1a392a0e95b10fe9603fbd379a70b4cc0ddf22f.zip
Theme Editor: Co Used a more efficient/less error-prone system for rendering SBS documents underneath WPS documents
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27765 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor')
-rw-r--r--utils/themeeditor/graphics/rbrenderinfo.cpp7
-rw-r--r--utils/themeeditor/graphics/rbrenderinfo.h5
-rw-r--r--utils/themeeditor/graphics/rbscene.cpp2
-rw-r--r--utils/themeeditor/graphics/rbscene.h2
-rw-r--r--utils/themeeditor/graphics/rbscreen.cpp26
-rw-r--r--utils/themeeditor/graphics/rbscreen.h5
-rw-r--r--utils/themeeditor/graphics/rbviewport.cpp16
-rw-r--r--utils/themeeditor/graphics/rbviewport.h2
-rw-r--r--utils/themeeditor/models/parsetreemodel.cpp36
-rw-r--r--utils/themeeditor/models/parsetreenode.cpp15
10 files changed, 71 insertions, 45 deletions
diff --git a/utils/themeeditor/graphics/rbrenderinfo.cpp b/utils/themeeditor/graphics/rbrenderinfo.cpp
index e39a4cea43..bcccc4c887 100644
--- a/utils/themeeditor/graphics/rbrenderinfo.cpp
+++ b/utils/themeeditor/graphics/rbrenderinfo.cpp
@@ -23,12 +23,11 @@
RBRenderInfo::RBRenderInfo(ParseTreeModel* model, ProjectModel* project,
SkinDocument* doc, QMap<QString, QString>* settings,
- DeviceState* device, RBScreen* screen,
- RBScreen* sbsScreen)
+ DeviceState* device, RBScreen* screen)
:mProject(project), mDoc(doc),
mSettings(settings),
mDevice(device), mScreen(screen),
- mSbsScreen(sbsScreen), mModel(model)
+ mModel(model)
{
}
@@ -44,7 +43,6 @@ RBRenderInfo::RBRenderInfo(const RBRenderInfo &other)
mDevice = other.mDevice;
mDoc = other.mDoc;
mScreen = other.mScreen;
- mSbsScreen = other.mSbsScreen;
mModel = other.mModel;
}
@@ -55,7 +53,6 @@ const RBRenderInfo& RBRenderInfo::operator=(const RBRenderInfo& other)
mDevice = other.mDevice;
mDoc = other.mDoc;
mScreen = other.mScreen;
- mSbsScreen = other.mSbsScreen;
mModel = other.mModel;
return *this;
diff --git a/utils/themeeditor/graphics/rbrenderinfo.h b/utils/themeeditor/graphics/rbrenderinfo.h
index 17b87dbb6b..e24603315a 100644
--- a/utils/themeeditor/graphics/rbrenderinfo.h
+++ b/utils/themeeditor/graphics/rbrenderinfo.h
@@ -35,8 +35,7 @@ class RBRenderInfo
public:
RBRenderInfo(ParseTreeModel* model, ProjectModel* project,
SkinDocument* doc, QMap<QString, QString>* settings,
- DeviceState* device, RBScreen* screen,
- RBScreen* sbsScreen = 0);
+ DeviceState* device, RBScreen* screen);
RBRenderInfo();
RBRenderInfo(const RBRenderInfo& other);
virtual ~RBRenderInfo();
@@ -48,7 +47,6 @@ public:
SkinDocument* document() const{ return mDoc; }
QMap<QString, QString>* settings() const{ return mSettings; }
RBScreen* screen() const{ return mScreen; }
- RBScreen* sbsScreen() const{ return mSbsScreen; }
ParseTreeModel* model() const{ return mModel; }
private:
@@ -57,7 +55,6 @@ private:
QMap<QString, QString>* mSettings;
DeviceState* mDevice;
RBScreen* mScreen;
- RBScreen* mSbsScreen;
ParseTreeModel* mModel;
};
diff --git a/utils/themeeditor/graphics/rbscene.cpp b/utils/themeeditor/graphics/rbscene.cpp
index 836abee489..206f68f184 100644
--- a/utils/themeeditor/graphics/rbscene.cpp
+++ b/utils/themeeditor/graphics/rbscene.cpp
@@ -20,6 +20,7 @@
****************************************************************************/
#include <QGraphicsSceneMouseEvent>
+#include <QGraphicsItem>
#include <QDebug>
@@ -33,4 +34,3 @@ RBScene::RBScene(QObject* parent)
RBScene::~RBScene()
{
}
-
diff --git a/utils/themeeditor/graphics/rbscene.h b/utils/themeeditor/graphics/rbscene.h
index 2c4e0ee193..4cb0dfc2a4 100644
--- a/utils/themeeditor/graphics/rbscene.h
+++ b/utils/themeeditor/graphics/rbscene.h
@@ -24,6 +24,8 @@
#include <QGraphicsScene>
+class RBScreen;
+
class RBScene : public QGraphicsScene
{
Q_OBJECT
diff --git a/utils/themeeditor/graphics/rbscreen.cpp b/utils/themeeditor/graphics/rbscreen.cpp
index 1b1adc8be4..2b63a6bdfe 100644
--- a/utils/themeeditor/graphics/rbscreen.cpp
+++ b/utils/themeeditor/graphics/rbscreen.cpp
@@ -32,7 +32,7 @@
RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
QGraphicsItem *parent)
:QGraphicsItem(parent), backdrop(0), project(project),
- albumArt(0), customUI(0)
+ albumArt(0), customUI(0), defaultView(0)
{
setAcceptHoverEvents(true);
@@ -221,11 +221,29 @@ void RBScreen::makeCustomUI(QString id)
}
}
+void RBScreen::endSbsRender()
+{
+ sbsChildren = children();
+
+ QList<int> keys = fonts.keys();
+ for(QList<int>::iterator i = keys.begin(); i != keys.end(); i++)
+ {
+ if(*i > 2)
+ fonts.remove(*i);
+ }
+
+ images.clear();
+ namedViewports.clear();
+ displayedViewports.clear();
+}
+
void RBScreen::breakSBS()
{
- width = fullWidth;
- height = fullHeight;
- setParentItem(0);
+ for(QList<QGraphicsItem*>::iterator i = sbsChildren.begin()
+ ; i != sbsChildren.end(); i++)
+ (*i)->hide();
+ if(defaultView)
+ defaultView->makeFullScreen();
}
QColor RBScreen::stringToColor(QString str, QColor fallback)
diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h
index c9f6ae2dbc..c9ae2cf350 100644
--- a/utils/themeeditor/graphics/rbscreen.h
+++ b/utils/themeeditor/graphics/rbscreen.h
@@ -86,6 +86,8 @@ public:
}
}
+ void setDefault(RBViewport* view){ defaultView = view; }
+ void endSbsRender();
void breakSBS();
protected:
@@ -111,6 +113,9 @@ private:
RBAlbumArt* albumArt;
RBViewport* customUI;
+ RBViewport* defaultView;
+
+ QList<QGraphicsItem*> sbsChildren;
};
#endif // RBSCREEN_H
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp
index 2c6fb9d7c3..a986127987 100644
--- a/utils/themeeditor/graphics/rbviewport.cpp
+++ b/utils/themeeditor/graphics/rbviewport.cpp
@@ -56,6 +56,16 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info,
customUI = false;
font = screen->getFont(1);
+ screen->setDefault(this);
+
+ if(screen->getCustomUI())
+ {
+ RBViewport* cui = screen->getCustomUI();
+ size = cui->boundingRect();
+ setPos(cui->pos());
+
+ }
+
/* Making sure the default viewport can't be graphically manipulated */
setFlag(ItemIsSelectable, false);
setFlag(ItemIsMovable, false);
@@ -299,6 +309,12 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start,
}
}
+void RBViewport::makeFullScreen()
+{
+ size = screen->boundingRect();
+ setPos(screen->pos());
+}
+
void RBViewport::saveGeometry()
{
QRectF bounds = boundingRect();
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h
index 9bbceb4065..8544ad3c1f 100644
--- a/utils/themeeditor/graphics/rbviewport.h
+++ b/utils/themeeditor/graphics/rbviewport.h
@@ -81,6 +81,8 @@ public:
void showPlaylist(const RBRenderInfo& info, int start, skin_element* id3,
skin_element* noId3);
+ void makeFullScreen();
+
protected:
void saveGeometry();
diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp
index fbedf10d45..a7f46acd5f 100644
--- a/utils/themeeditor/models/parsetreemodel.cpp
+++ b/utils/themeeditor/models/parsetreemodel.cpp
@@ -316,7 +316,7 @@ RBScene* ParseTreeModel::render(ProjectModel* project,
}
/* Rendering SBS, if necessary */
- RBScreen* sbsScreen = 0;
+ RBScreen* screen = 0;
if(wps && device->data("rendersbs").toBool())
{
QString sbsFile = settings.value(remote ? "rsbs" : "sbs", "");
@@ -334,49 +334,37 @@ RBScene* ParseTreeModel::render(ProjectModel* project,
if(sbsModel->root != 0)
{
RBRenderInfo sbsInfo(sbsModel, project, doc, &settings, device,
- sbsScreen);
+ screen);
- sbsScreen = new RBScreen(sbsInfo, remote);
- scene->addItem(sbsScreen);
+ screen = new RBScreen(sbsInfo, remote);
+ scene->addItem(screen);
sbsInfo = RBRenderInfo(sbsModel, project, doc, &settings,
- device, sbsScreen);
+ device, screen);
sbsModel->root->render(sbsInfo);
+ screen->endSbsRender();
- setChildrenUnselectable(sbsScreen);
+ setChildrenUnselectable(screen);
}
}
}
- RBScreen* screen = 0;
- RBRenderInfo info(this, project, doc, &settings, device, screen, sbsScreen);
+ RBRenderInfo info(this, project, doc, &settings, device, screen);
/* Adding the screen */
- if(sbsScreen)
- screen = new RBScreen(info, remote, sbsScreen->getCustomUI());
- else
+ if(!screen)
+ {
screen = new RBScreen(info, remote);
-
- if(!sbsScreen)
scene->addItem(screen);
+ }
- info = RBRenderInfo(this, project, doc, &settings, device, screen,
- sbsScreen);
+ info = RBRenderInfo(this, project, doc, &settings, device, screen);
/* Rendering the tree */
if(root)
root->render(info);
-// /* Making sure the Custom UI Viewport can't be selected */
-// if(sbsScreen)
-// {
-// sbsScreen->getCustomUI()->setFlag(QGraphicsItem::ItemIsSelectable,
-// false);
-// sbsScreen->getCustomUI()->setFlag(QGraphicsItem::ItemIsMovable,
-// false);
-// }
-//
return scene;
}
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp
index ac2556b17f..9cc73ce1c7 100644
--- a/utils/themeeditor/models/parsetreenode.cpp
+++ b/utils/themeeditor/models/parsetreenode.cpp
@@ -31,6 +31,9 @@
#include <iostream>
#include <cmath>
+#include <cassert>
+
+#include <QDebug>
int ParseTreeNode::openConditionals = 0;
bool ParseTreeNode::breakFlag = false;
@@ -571,9 +574,12 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport,
else if(element->type == CONDITIONAL)
{
int child = evalTag(info, true, element->children_count).toInt();
- if(child < children.count())
+ int max = children.count() - element->params_count;
+ if(child < max)
+ {
children[element->params_count + child]
->render(info, viewport, true);
+ }
}
else if(element->type == LINE_ALTERNATOR)
{
@@ -856,8 +862,6 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
int height = element->params[3].data.number;
QString action(element->params[4].data.text);
RBTouchArea* temp = new RBTouchArea(width, height, action, info);
- x += viewport->x();
- y += viewport->y();
temp->setPos(x, y);
return true;
}
@@ -914,10 +918,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
case '\0':
/* %X */
filename = QString(element->params[0].data.text);
- if(info.sbsScreen() && info.screen()->parentItem())
- info.sbsScreen()->setBackdrop(filename);
- else
- info.screen()->setBackdrop(filename);
+ info.screen()->setBackdrop(filename);
return true;
}