diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-06-21 20:11:58 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-06-21 20:11:58 +0000 |
commit | e1d8a3dc63391098f9381a3cb33d73e69b46c006 (patch) | |
tree | 0f503320d4fda330a003fe88ae7482537037db85 /utils/themeeditor/graphics | |
parent | bd380b399323d15a1572cdc017e0f95b1b9db151 (diff) | |
download | rockbox-e1d8a3dc63391098f9381a3cb33d73e69b46c006.tar.gz rockbox-e1d8a3dc63391098f9381a3cb33d73e69b46c006.zip |
Theme Editor: Reworked information passing among render functions, now loads all viewports and shows Custom UI viewport in blue
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27026 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/graphics')
-rw-r--r-- | utils/themeeditor/graphics/rbrenderinfo.cpp | 9 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbrenderinfo.h | 8 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbscreen.cpp | 52 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbscreen.h | 16 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 60 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.h | 1 |
6 files changed, 92 insertions, 54 deletions
diff --git a/utils/themeeditor/graphics/rbrenderinfo.cpp b/utils/themeeditor/graphics/rbrenderinfo.cpp index 468533628f..ca9f2b632d 100644 --- a/utils/themeeditor/graphics/rbrenderinfo.cpp +++ b/utils/themeeditor/graphics/rbrenderinfo.cpp | |||
@@ -21,15 +21,17 @@ | |||
21 | 21 | ||
22 | #include "rbrenderinfo.h" | 22 | #include "rbrenderinfo.h" |
23 | 23 | ||
24 | RBRenderInfo::RBRenderInfo(ParseTreeModel* model, | 24 | RBRenderInfo::RBRenderInfo(ParseTreeModel* model, ProjectModel* project, |
25 | ProjectModel* project, RBScreen* screen) | 25 | QMap<QString, QString>* settings, RBScreen* screen) |
26 | :mProject(project), mScreen(screen), mModel(model) | 26 | :mProject(project), mSettings(settings), |
27 | mScreen(screen), mModel(model) | ||
27 | { | 28 | { |
28 | } | 29 | } |
29 | 30 | ||
30 | RBRenderInfo::RBRenderInfo(const RBRenderInfo &other) | 31 | RBRenderInfo::RBRenderInfo(const RBRenderInfo &other) |
31 | { | 32 | { |
32 | mProject = other.mProject; | 33 | mProject = other.mProject; |
34 | mSettings = other.mSettings; | ||
33 | mScreen = other.mScreen; | 35 | mScreen = other.mScreen; |
34 | mModel = other.mModel; | 36 | mModel = other.mModel; |
35 | } | 37 | } |
@@ -37,6 +39,7 @@ RBRenderInfo::RBRenderInfo(const RBRenderInfo &other) | |||
37 | const RBRenderInfo& RBRenderInfo::operator=(const RBRenderInfo& other) | 39 | const RBRenderInfo& RBRenderInfo::operator=(const RBRenderInfo& other) |
38 | { | 40 | { |
39 | mProject = other.mProject; | 41 | mProject = other.mProject; |
42 | mSettings = other.mSettings; | ||
40 | mScreen = other.mScreen; | 43 | mScreen = other.mScreen; |
41 | mModel = other.mModel; | 44 | mModel = other.mModel; |
42 | 45 | ||
diff --git a/utils/themeeditor/graphics/rbrenderinfo.h b/utils/themeeditor/graphics/rbrenderinfo.h index c99de7beaa..c80cb00a9d 100644 --- a/utils/themeeditor/graphics/rbrenderinfo.h +++ b/utils/themeeditor/graphics/rbrenderinfo.h | |||
@@ -22,6 +22,8 @@ | |||
22 | #ifndef RBRENDERINFO_H | 22 | #ifndef RBRENDERINFO_H |
23 | #define RBRENDERINFO_H | 23 | #define RBRENDERINFO_H |
24 | 24 | ||
25 | #include <QMap> | ||
26 | |||
25 | class RBScreen; | 27 | class RBScreen; |
26 | class ProjectModel; | 28 | class ProjectModel; |
27 | class ParseTreeModel; | 29 | class ParseTreeModel; |
@@ -29,19 +31,21 @@ class ParseTreeModel; | |||
29 | class RBRenderInfo | 31 | class RBRenderInfo |
30 | { | 32 | { |
31 | public: | 33 | public: |
32 | RBRenderInfo(ParseTreeModel* model, | 34 | RBRenderInfo(ParseTreeModel* model, ProjectModel* project, |
33 | ProjectModel* project, RBScreen* screen); | 35 | QMap<QString, QString>* settings, RBScreen* screen); |
34 | RBRenderInfo(const RBRenderInfo& other); | 36 | RBRenderInfo(const RBRenderInfo& other); |
35 | virtual ~RBRenderInfo(); | 37 | virtual ~RBRenderInfo(); |
36 | 38 | ||
37 | const RBRenderInfo& operator=(const RBRenderInfo& other); | 39 | const RBRenderInfo& operator=(const RBRenderInfo& other); |
38 | 40 | ||
39 | ProjectModel* project() const{ return mProject; } | 41 | ProjectModel* project() const{ return mProject; } |
42 | QMap<QString, QString>* settings() const{ return mSettings; } | ||
40 | RBScreen* screen() const{ return mScreen; } | 43 | RBScreen* screen() const{ return mScreen; } |
41 | ParseTreeModel* model() const{ return mModel; } | 44 | ParseTreeModel* model() const{ return mModel; } |
42 | 45 | ||
43 | private: | 46 | private: |
44 | ProjectModel* mProject; | 47 | ProjectModel* mProject; |
48 | QMap<QString, QString>* mSettings; | ||
45 | RBScreen* mScreen; | 49 | RBScreen* mScreen; |
46 | ParseTreeModel* mModel; | 50 | ParseTreeModel* mModel; |
47 | }; | 51 | }; |
diff --git a/utils/themeeditor/graphics/rbscreen.cpp b/utils/themeeditor/graphics/rbscreen.cpp index 8d3ef86ad0..065bea61cd 100644 --- a/utils/themeeditor/graphics/rbscreen.cpp +++ b/utils/themeeditor/graphics/rbscreen.cpp | |||
@@ -20,44 +20,42 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "rbscreen.h" | 22 | #include "rbscreen.h" |
23 | #include "rbviewport.h" | ||
23 | 24 | ||
24 | #include <QPainter> | 25 | #include <QPainter> |
25 | #include <QFile> | 26 | #include <QFile> |
26 | 27 | ||
27 | RBScreen::RBScreen(ProjectModel* project, QGraphicsItem *parent) : | 28 | RBScreen::RBScreen(const RBRenderInfo& info, QGraphicsItem *parent) : |
28 | QGraphicsItem(parent), backdrop(0), project(project) | 29 | QGraphicsItem(parent), backdrop(0), project(project) |
29 | { | 30 | { |
30 | 31 | ||
31 | width = safeSetting(project, "#screenwidth", "300").toInt(); | 32 | width = info.settings()->value("#screenwidth", "300").toInt(); |
32 | height = safeSetting(project, "#screenheight", "200").toInt(); | 33 | height = info.settings()->value("#screenheight", "200").toInt(); |
33 | 34 | ||
34 | QString bg = safeSetting(project, "background color", "FFFFFF"); | 35 | QString bg = info.settings()->value("background color", "000000"); |
35 | bgColor = stringToColor(bg, Qt::white); | 36 | bgColor = stringToColor(bg, Qt::white); |
36 | 37 | ||
37 | QString fg = safeSetting(project, "foreground color", "FFFFFF"); | 38 | QString fg = info.settings()->value("foreground color", "FFFFFF"); |
38 | fgColor = stringToColor(fg, Qt::black); | 39 | fgColor = stringToColor(fg, Qt::black); |
39 | 40 | ||
40 | /* Loading backdrop if available */ | 41 | /* Loading backdrop if available */ |
41 | if(project) | 42 | QString base = info.settings()->value("themebase", ""); |
43 | QString backdropFile = info.settings()->value("backdrop", ""); | ||
44 | |||
45 | if(QFile::exists(base + "/backdrops/" + backdropFile)) | ||
42 | { | 46 | { |
43 | QString base = project->getSetting("themebase", ""); | 47 | backdrop = new QPixmap(base + "/backdrops/" + backdropFile); |
44 | QString backdropFile = project->getSetting("backdrop", ""); | ||
45 | 48 | ||
46 | if(QFile::exists(base + "/backdrops/" + backdropFile)) | 49 | /* If a backdrop has been found, use its width and height */ |
50 | if(!backdrop->isNull()) | ||
47 | { | 51 | { |
48 | backdrop = new QPixmap(base + "/backdrops/" + backdropFile); | 52 | width = backdrop->width(); |
49 | 53 | height = backdrop->height(); | |
50 | /* If a backdrop has been found, use its width and height */ | 54 | } |
51 | if(!backdrop->isNull()) | 55 | else |
52 | { | 56 | { |
53 | width = backdrop->width(); | 57 | delete backdrop; |
54 | height = backdrop->height(); | 58 | backdrop = 0; |
55 | } | ||
56 | else | ||
57 | { | ||
58 | delete backdrop; | ||
59 | backdrop = 0; | ||
60 | } | ||
61 | } | 59 | } |
62 | } | 60 | } |
63 | } | 61 | } |
@@ -93,6 +91,16 @@ void RBScreen::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | |||
93 | } | 91 | } |
94 | } | 92 | } |
95 | 93 | ||
94 | void RBScreen::showViewport(QString name) | ||
95 | { | ||
96 | if(namedViewports.value(name, 0) == 0) | ||
97 | return; | ||
98 | |||
99 | namedViewports.value(name)->show(); | ||
100 | update(); | ||
101 | } | ||
102 | |||
103 | |||
96 | QColor RBScreen::stringToColor(QString str, QColor fallback) | 104 | QColor RBScreen::stringToColor(QString str, QColor fallback) |
97 | { | 105 | { |
98 | 106 | ||
diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h index 78bbcfd8b2..6a9da2fcda 100644 --- a/utils/themeeditor/graphics/rbscreen.h +++ b/utils/themeeditor/graphics/rbscreen.h | |||
@@ -25,12 +25,15 @@ | |||
25 | #include <QGraphicsItem> | 25 | #include <QGraphicsItem> |
26 | 26 | ||
27 | #include "projectmodel.h" | 27 | #include "projectmodel.h" |
28 | #include "rbrenderinfo.h" | ||
29 | |||
30 | class RBViewport; | ||
28 | 31 | ||
29 | class RBScreen : public QGraphicsItem | 32 | class RBScreen : public QGraphicsItem |
30 | { | 33 | { |
31 | 34 | ||
32 | public: | 35 | public: |
33 | RBScreen(ProjectModel* project = 0, QGraphicsItem *parent = 0); | 36 | RBScreen(const RBRenderInfo& info, QGraphicsItem *parent = 0); |
34 | virtual ~RBScreen(); | 37 | virtual ~RBScreen(); |
35 | 38 | ||
36 | QPainterPath shape() const; | 39 | QPainterPath shape() const; |
@@ -41,14 +44,11 @@ public: | |||
41 | int getWidth() const{ return width; } | 44 | int getWidth() const{ return width; } |
42 | int getHeight() const{ return height; } | 45 | int getHeight() const{ return height; } |
43 | 46 | ||
44 | static QString safeSetting(ProjectModel* project, QString key, | 47 | void loadViewport(QString name, RBViewport* view) |
45 | QString fallback) | ||
46 | { | 48 | { |
47 | if(project) | 49 | namedViewports.insert(name, view); |
48 | return project->getSetting(key, fallback); | ||
49 | else | ||
50 | return fallback; | ||
51 | } | 50 | } |
51 | void showViewport(QString name); | ||
52 | 52 | ||
53 | static QColor stringToColor(QString str, QColor fallback); | 53 | static QColor stringToColor(QString str, QColor fallback); |
54 | 54 | ||
@@ -62,6 +62,8 @@ private: | |||
62 | 62 | ||
63 | ProjectModel* project; | 63 | ProjectModel* project; |
64 | 64 | ||
65 | QMap<QString, RBViewport*> namedViewports; | ||
66 | |||
65 | }; | 67 | }; |
66 | 68 | ||
67 | #endif // RBSCREEN_H | 69 | #endif // RBSCREEN_H |
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index 1f1f02ce55..9045016533 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp | |||
@@ -50,38 +50,57 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | |||
50 | } | 50 | } |
51 | else | 51 | else |
52 | { | 52 | { |
53 | int x, y, w, h; | 53 | int param; |
54 | /* Parsing one of the other types of viewport */ | 54 | QString ident; |
55 | int x,y,w,h; | ||
56 | /* Rendering one of the other types of viewport */ | ||
55 | switch(node->tag->name[1]) | 57 | switch(node->tag->name[1]) |
56 | { | 58 | { |
57 | case '\0': | 59 | case '\0': |
58 | /* A normal viewport definition */ | 60 | customUI = false; |
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; | 61 | displayed = true; |
62 | param = 0; | ||
74 | break; | 63 | break; |
75 | 64 | ||
76 | case 'l': | 65 | case 'l': |
77 | /* Preloaded viewport */ | 66 | /* A preloaded viewport definition */ |
67 | ident = node->params[0].data.text; | ||
68 | customUI = false; | ||
69 | displayed = false; | ||
70 | info.screen()->loadViewport(ident, this); | ||
71 | param = 1; | ||
78 | break; | 72 | break; |
79 | 73 | ||
80 | case 'i': | 74 | case 'i': |
81 | /* Custom UI Viewport */ | 75 | /* Custom UI Viewport */ |
76 | customUI = true; | ||
77 | param = 1; | ||
78 | if(node->params[0].type == skin_tag_parameter::DEFAULT) | ||
79 | { | ||
80 | displayed = true; | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | displayed = false; | ||
85 | info.screen()->loadViewport(ident, this); | ||
86 | } | ||
82 | break; | 87 | break; |
83 | |||
84 | } | 88 | } |
89 | /* Now we grab the info common to all viewports */ | ||
90 | x = node->params[param++].data.numeric; | ||
91 | y = node->params[param++].data.numeric; | ||
92 | |||
93 | if(node->params[param].type == skin_tag_parameter::DEFAULT) | ||
94 | w = info.screen()->getWidth() - x; | ||
95 | else | ||
96 | w = node->params[param].data.numeric; | ||
97 | |||
98 | if(node->params[++param].type == skin_tag_parameter::DEFAULT) | ||
99 | h = info.screen()->getHeight() - y; | ||
100 | else | ||
101 | h = node->params[param].data.numeric; | ||
102 | |||
103 | size = QRectF(x, y, w, h); | ||
85 | } | 104 | } |
86 | } | 105 | } |
87 | 106 | ||
@@ -104,7 +123,8 @@ QRectF RBViewport::boundingRect() const | |||
104 | void RBViewport::paint(QPainter *painter, | 123 | void RBViewport::paint(QPainter *painter, |
105 | const QStyleOptionGraphicsItem *option, QWidget *widget) | 124 | const QStyleOptionGraphicsItem *option, QWidget *widget) |
106 | { | 125 | { |
126 | QColor color = customUI ? Qt::blue : Qt::red; | ||
107 | if(displayed) | 127 | if(displayed) |
108 | painter->fillRect(size, Qt::red); | 128 | painter->fillRect(size, color); |
109 | } | 129 | } |
110 | 130 | ||
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index 0ec377bc39..5d59ea4819 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h | |||
@@ -48,6 +48,7 @@ private: | |||
48 | QColor foreground; | 48 | QColor foreground; |
49 | 49 | ||
50 | bool displayed; | 50 | bool displayed; |
51 | bool customUI; | ||
51 | 52 | ||
52 | }; | 53 | }; |
53 | 54 | ||