summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-18 21:10:01 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-18 21:10:01 +0000
commitd8827b5ff10c66a065a210d8aaf1d88214ee1070 (patch)
tree26a23ff031105ee98cbba967a4554ebf8ac423a6 /utils/themeeditor/graphics
parent62622277dc2a11117605e5e7ff3d2a5f0423d8da (diff)
downloadrockbox-d8827b5ff10c66a065a210d8aaf1d88214ee1070.tar.gz
rockbox-d8827b5ff10c66a065a210d8aaf1d88214ee1070.zip
Theme Editor: Working on rendering viewports, display will now show %V(...) viewports as red rectangles over backdrop or background color
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26940 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/graphics')
-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
5 files changed, 263 insertions, 0 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