summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/graphics/rbrenderinfo.cpp46
-rw-r--r--utils/themeeditor/graphics/rbrenderinfo.h49
-rw-r--r--utils/themeeditor/graphics/rbscreen.h4
-rw-r--r--utils/themeeditor/graphics/rbviewport.cpp110
-rw-r--r--utils/themeeditor/graphics/rbviewport.h54
-rw-r--r--utils/themeeditor/gui/skindocument.cpp2
-rw-r--r--utils/themeeditor/gui/skinviewer.cpp4
-rw-r--r--utils/themeeditor/models/parsetreemodel.cpp8
-rw-r--r--utils/themeeditor/models/parsetreenode.cpp32
-rw-r--r--utils/themeeditor/models/parsetreenode.h6
-rw-r--r--utils/themeeditor/themeeditor.pro8
11 files changed, 317 insertions, 6 deletions
diff --git a/utils/themeeditor/graphics/rbrenderinfo.cpp b/utils/themeeditor/graphics/rbrenderinfo.cpp
new file mode 100644
index 0000000000..c2612373c8
--- /dev/null
+++ b/utils/themeeditor/graphics/rbrenderinfo.cpp
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "rbrenderinfo.h"
23
24RBRenderInfo::RBRenderInfo(ParseTreeModel* model,
25 ProjectModel* project, RBScreen* screen)
26 :mProject(project), mScreen(screen), mModel(model)
27{
28}
29
30RBRenderInfo::RBRenderInfo(const RBRenderInfo &other)
31{
32 mProject = other.mProject;
33 mScreen = other.mScreen;
34 mModel = other.mModel;
35}
36
37const RBRenderInfo& RBRenderInfo::operator=(const RBRenderInfo& other)
38{
39 mProject = other.mProject;
40 mScreen = other.mScreen;
41 mModel = other.mModel;
42}
43
44RBRenderInfo::~RBRenderInfo()
45{
46}
diff --git a/utils/themeeditor/graphics/rbrenderinfo.h b/utils/themeeditor/graphics/rbrenderinfo.h
new file mode 100644
index 0000000000..c99de7beaa
--- /dev/null
+++ b/utils/themeeditor/graphics/rbrenderinfo.h
@@ -0,0 +1,49 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef RBRENDERINFO_H
23#define RBRENDERINFO_H
24
25class RBScreen;
26class ProjectModel;
27class ParseTreeModel;
28
29class RBRenderInfo
30{
31public:
32 RBRenderInfo(ParseTreeModel* model,
33 ProjectModel* project, RBScreen* screen);
34 RBRenderInfo(const RBRenderInfo& other);
35 virtual ~RBRenderInfo();
36
37 const RBRenderInfo& operator=(const RBRenderInfo& other);
38
39 ProjectModel* project() const{ return mProject; }
40 RBScreen* screen() const{ return mScreen; }
41 ParseTreeModel* model() const{ return mModel; }
42
43private:
44 ProjectModel* mProject;
45 RBScreen* mScreen;
46 ParseTreeModel* mModel;
47};
48
49#endif // RBRENDERINFO_H
diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h
index f244089b2d..78bbcfd8b2 100644
--- a/utils/themeeditor/graphics/rbscreen.h
+++ b/utils/themeeditor/graphics/rbscreen.h
@@ -38,6 +38,9 @@ public:
38 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 38 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
39 QWidget *widget); 39 QWidget *widget);
40 40
41 int getWidth() const{ return width; }
42 int getHeight() const{ return height; }
43
41 static QString safeSetting(ProjectModel* project, QString key, 44 static QString safeSetting(ProjectModel* project, QString key,
42 QString fallback) 45 QString fallback)
43 { 46 {
@@ -49,6 +52,7 @@ public:
49 52
50 static QColor stringToColor(QString str, QColor fallback); 53 static QColor stringToColor(QString str, QColor fallback);
51 54
55
52private: 56private:
53 int width; 57 int width;
54 int height; 58 int height;
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp
new file mode 100644
index 0000000000..1f1f02ce55
--- /dev/null
+++ b/utils/themeeditor/graphics/rbviewport.cpp
@@ -0,0 +1,110 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <QPainter>
23#include <QPainterPath>
24
25#include "rbviewport.h"
26#include "rbscreen.h"
27#include "rbrenderinfo.h"
28#include "parsetreemodel.h"
29#include "tag_table.h"
30#include "skin_parser.h"
31
32RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
33 : QGraphicsItem(info.screen())
34{
35 if(!node->tag)
36 {
37 /* Default viewport takes up the entire screen */
38 size = QRectF(0, 0, info.screen()->getWidth(),
39 info.screen()->getHeight());
40
41 if(info.model()->rowCount(QModelIndex()) > 1)
42 {
43 /* If there is more than one viewport in the document */
44 displayed = false;
45 }
46 else
47 {
48 displayed = true;
49 }
50 }
51 else
52 {
53 int x, y, w, h;
54 /* Parsing one of the other types of viewport */
55 switch(node->tag->name[1])
56 {
57 case '\0':
58 /* A normal viewport definition */
59 x = node->params[0].data.numeric;
60 y = node->params[1].data.numeric;
61
62 if(node->params[2].type == skin_tag_parameter::DEFAULT)
63 w = info.screen()->getWidth() - x;
64 else
65 w = node->params[2].data.numeric;
66
67 if(node->params[3].type == skin_tag_parameter::DEFAULT)
68 h = info.screen()->getHeight() - y;
69 else
70 h = node->params[3].data.numeric;
71
72 size = QRectF(x, y, w, h);
73 displayed = true;
74 break;
75
76 case 'l':
77 /* Preloaded viewport */
78 break;
79
80 case 'i':
81 /* Custom UI Viewport */
82 break;
83
84 }
85 }
86}
87
88RBViewport::~RBViewport()
89{
90}
91
92QPainterPath RBViewport::shape() const
93{
94 QPainterPath retval;
95 retval.addRect(size);
96 return retval;
97}
98
99QRectF RBViewport::boundingRect() const
100{
101 return size;
102}
103
104void RBViewport::paint(QPainter *painter,
105 const QStyleOptionGraphicsItem *option, QWidget *widget)
106{
107 if(displayed)
108 painter->fillRect(size, Qt::red);
109}
110
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h
new file mode 100644
index 0000000000..0ec377bc39
--- /dev/null
+++ b/utils/themeeditor/graphics/rbviewport.h
@@ -0,0 +1,54 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef RBVIEWPORT_H
23#define RBVIEWPORT_H
24
25#include "skin_parser.h"
26
27class RBScreen;
28class RBRenderInfo;
29
30#include <QGraphicsItem>
31
32class RBViewport : public QGraphicsItem
33{
34public:
35 RBViewport(skin_element* node, const RBRenderInfo& info);
36 virtual ~RBViewport();
37
38 QPainterPath shape() const;
39 QRectF boundingRect() const;
40 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
41 QWidget *widget);
42
43 void show(){ displayed = true; }
44
45private:
46 QRectF size;
47 QColor background;
48 QColor foreground;
49
50 bool displayed;
51
52};
53
54#endif // RBVIEWPORT_H
diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp
index aeefcc38f4..6d28de38a8 100644
--- a/utils/themeeditor/gui/skindocument.cpp
+++ b/utils/themeeditor/gui/skindocument.cpp
@@ -257,6 +257,8 @@ void SkinDocument::codeChanged()
257 else 257 else
258 emit titleChanged(titleText); 258 emit titleChanged(titleText);
259 259
260 model->render(project);
261
260 cursorChanged(); 262 cursorChanged();
261 263
262} 264}
diff --git a/utils/themeeditor/gui/skinviewer.cpp b/utils/themeeditor/gui/skinviewer.cpp
index 152450e149..cabe788d47 100644
--- a/utils/themeeditor/gui/skinviewer.cpp
+++ b/utils/themeeditor/gui/skinviewer.cpp
@@ -32,6 +32,8 @@ SkinViewer::SkinViewer(QWidget *parent) :
32 this, SLOT(zoomOut())); 32 this, SLOT(zoomOut()));
33 QObject::connect(ui->zoomInButton, SIGNAL(pressed()), 33 QObject::connect(ui->zoomInButton, SIGNAL(pressed()),
34 this, SLOT(zoomIn())); 34 this, SLOT(zoomIn()));
35
36 ui->viewer->setDragMode(QGraphicsView::ScrollHandDrag);
35} 37}
36 38
37SkinViewer::~SkinViewer() 39SkinViewer::~SkinViewer()
@@ -53,7 +55,7 @@ void SkinViewer::changeEvent(QEvent *e)
53 55
54void SkinViewer::setScene(QGraphicsScene *scene) 56void SkinViewer::setScene(QGraphicsScene *scene)
55{ 57{
56 ui->viewer->setScene(scene); 58 ui->viewer->setScene(scene);z
57} 59}
58 60
59void SkinViewer::zoomIn() 61void SkinViewer::zoomIn()
diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp
index 762443f4a5..41cecc4c20 100644
--- a/utils/themeeditor/models/parsetreemodel.cpp
+++ b/utils/themeeditor/models/parsetreemodel.cpp
@@ -23,6 +23,7 @@
23#include "parsetreemodel.h" 23#include "parsetreemodel.h"
24#include "symbols.h" 24#include "symbols.h"
25#include "rbscreen.h" 25#include "rbscreen.h"
26#include "rbrenderinfo.h"
26 27
27#include <cstdlib> 28#include <cstdlib>
28 29
@@ -280,5 +281,12 @@ QGraphicsScene* ParseTreeModel::render(ProjectModel* project)
280 RBScreen* screen = new RBScreen(project); 281 RBScreen* screen = new RBScreen(project);
281 scene->addItem(screen); 282 scene->addItem(screen);
282 283
284 RBRenderInfo info(this, project, screen);
285
286 /* Rendering the tree */
287 if(root)
288 root->render(info);
289
290
283 return scene; 291 return scene;
284} 292}
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp
index 397031aee1..97beca4c3d 100644
--- a/utils/themeeditor/models/parsetreenode.cpp
+++ b/utils/themeeditor/models/parsetreenode.cpp
@@ -98,6 +98,12 @@ ParseTreeNode::ParseTreeNode(skin_tag_parameter *data, ParseTreeNode *parent)
98 98
99} 99}
100 100
101ParseTreeNode::~ParseTreeNode()
102{
103 for(int i = 0; i < children.count(); i++)
104 delete children[i];
105}
106
101QString ParseTreeNode::genCode() const 107QString ParseTreeNode::genCode() const
102{ 108{
103 QString buffer = ""; 109 QString buffer = "";
@@ -467,8 +473,28 @@ ParseTreeNode* ParseTreeNode::getParent() const
467 return parent; 473 return parent;
468} 474}
469 475
470ParseTreeNode::~ParseTreeNode() 476void ParseTreeNode::render(const RBRenderInfo& info)
471{ 477{
472 for(int i = 0; i < children.count(); i++) 478 /* Parameters don't get rendered */
473 delete children[i]; 479 if(!element && param)
480 return;
481
482 /* If we're at the root, we need to render each viewport */
483 if(!element && !param)
484 {
485 for(int i = 0; i < children.count(); i++)
486 {
487 children[i]->render(info);
488 }
489
490 return;
491 }
492
493 switch(element->type)
494 {
495 case VIEWPORT:
496 rendered = new RBViewport(element, info);
497 break;
498 }
474} 499}
500
diff --git a/utils/themeeditor/models/parsetreenode.h b/utils/themeeditor/models/parsetreenode.h
index 7a0807bb0d..bfbd5968d3 100644
--- a/utils/themeeditor/models/parsetreenode.h
+++ b/utils/themeeditor/models/parsetreenode.h
@@ -23,6 +23,9 @@
23#define PARSETREENODE_H 23#define PARSETREENODE_H
24 24
25#include "skin_parser.h" 25#include "skin_parser.h"
26#include "rbviewport.h"
27#include "rbscreen.h"
28#include "rbrenderinfo.h"
26 29
27#include <QString> 30#include <QString>
28#include <QVariant> 31#include <QVariant>
@@ -56,6 +59,8 @@ public:
56 return 0; 59 return 0;
57 } 60 }
58 61
62 void render(const RBRenderInfo& info);
63
59private: 64private:
60 ParseTreeNode* parent; 65 ParseTreeNode* parent;
61 struct skin_element* element; 66 struct skin_element* element;
@@ -63,6 +68,7 @@ private:
63 QList<ParseTreeNode*> children; 68 QList<ParseTreeNode*> children;
64 69
65 static int openConditionals; 70 static int openConditionals;
71 QGraphicsItem* rendered;
66 72
67}; 73};
68 74
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 157433ef55..ba3efa92db 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -35,7 +35,9 @@ HEADERS += models/parsetreemodel.h \
35 gui/tabcontent.h \ 35 gui/tabcontent.h \
36 gui/configdocument.h \ 36 gui/configdocument.h \
37 gui/skinviewer.h \ 37 gui/skinviewer.h \
38 graphics/rbscreen.h 38 graphics/rbscreen.h \
39 graphics/rbviewport.h \
40 graphics/rbrenderinfo.h
39SOURCES += main.cpp \ 41SOURCES += main.cpp \
40 models/parsetreemodel.cpp \ 42 models/parsetreemodel.cpp \
41 models/parsetreenode.cpp \ 43 models/parsetreenode.cpp \
@@ -47,7 +49,9 @@ SOURCES += main.cpp \
47 models/projectmodel.cpp \ 49 models/projectmodel.cpp \
48 gui/configdocument.cpp \ 50 gui/configdocument.cpp \
49 gui/skinviewer.cpp \ 51 gui/skinviewer.cpp \
50 graphics/rbscreen.cpp 52 graphics/rbscreen.cpp \
53 graphics/rbviewport.cpp \
54 graphics/rbrenderinfo.cpp
51OTHER_FILES += README \ 55OTHER_FILES += README \
52 resources/windowicon.png \ 56 resources/windowicon.png \
53 resources/appicon.xcf \ 57 resources/appicon.xcf \