summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/graphics')
-rw-r--r--utils/themeeditor/graphics/rbmovable.cpp18
-rw-r--r--utils/themeeditor/graphics/rbmovable.h4
-rw-r--r--utils/themeeditor/graphics/rbrenderinfo.cpp7
-rw-r--r--utils/themeeditor/graphics/rbrenderinfo.h8
-rw-r--r--utils/themeeditor/graphics/rbviewport.cpp23
-rw-r--r--utils/themeeditor/graphics/rbviewport.h10
6 files changed, 57 insertions, 13 deletions
diff --git a/utils/themeeditor/graphics/rbmovable.cpp b/utils/themeeditor/graphics/rbmovable.cpp
index 11b3a6812f..3eca8bd18c 100644
--- a/utils/themeeditor/graphics/rbmovable.cpp
+++ b/utils/themeeditor/graphics/rbmovable.cpp
@@ -25,7 +25,7 @@
25#include "rbmovable.h" 25#include "rbmovable.h"
26 26
27RBMovable::RBMovable(QGraphicsItem* parent) 27RBMovable::RBMovable(QGraphicsItem* parent)
28 : QGraphicsItem(parent) 28 : QGraphicsItem(parent), geomChanged(false)
29{ 29{
30 setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges); 30 setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges);
31} 31}
@@ -61,7 +61,7 @@ QVariant RBMovable::itemChange(GraphicsItemChange change, const QVariant &value)
61 pos.setY(qMax(0., pos.y())); 61 pos.setY(qMax(0., pos.y()));
62 pos.setY(qMin(pos.y(), bound.height() - boundingRect().height())); 62 pos.setY(qMin(pos.y(), bound.height() - boundingRect().height()));
63 63
64 saveGeometry(); 64 geomChanged = true;
65 65
66 return pos; 66 return pos;
67 } 67 }
@@ -69,3 +69,17 @@ QVariant RBMovable::itemChange(GraphicsItemChange change, const QVariant &value)
69 return QGraphicsItem::itemChange(change, value); 69 return QGraphicsItem::itemChange(change, value);
70} 70}
71 71
72void RBMovable::mousePressEvent(QGraphicsSceneMouseEvent *event)
73{
74 QGraphicsItem::mousePressEvent(event);
75}
76
77void RBMovable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
78{
79 QGraphicsItem::mouseReleaseEvent(event);
80 if(isSelected())
81 {
82 saveGeometry();
83 geomChanged = false;
84 }
85}
diff --git a/utils/themeeditor/graphics/rbmovable.h b/utils/themeeditor/graphics/rbmovable.h
index e8ef69b5bd..5b6330228d 100644
--- a/utils/themeeditor/graphics/rbmovable.h
+++ b/utils/themeeditor/graphics/rbmovable.h
@@ -41,6 +41,8 @@ public:
41 41
42 virtual void paint(QPainter *painter, 42 virtual void paint(QPainter *painter,
43 const QStyleOptionGraphicsItem *option, QWidget *widget); 43 const QStyleOptionGraphicsItem *option, QWidget *widget);
44 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
45 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
44 46
45protected: 47protected:
46 virtual QVariant itemChange(GraphicsItemChange change, 48 virtual QVariant itemChange(GraphicsItemChange change,
@@ -48,6 +50,8 @@ protected:
48 /* Responsible for updating the parse tree */ 50 /* Responsible for updating the parse tree */
49 virtual void saveGeometry() = 0; 51 virtual void saveGeometry() = 0;
50 52
53 bool geomChanged;
54
51}; 55};
52 56
53#endif // RBMOVABLE_H 57#endif // RBMOVABLE_H
diff --git a/utils/themeeditor/graphics/rbrenderinfo.cpp b/utils/themeeditor/graphics/rbrenderinfo.cpp
index 0b9ea41397..e39a4cea43 100644
--- a/utils/themeeditor/graphics/rbrenderinfo.cpp
+++ b/utils/themeeditor/graphics/rbrenderinfo.cpp
@@ -22,10 +22,11 @@
22#include "rbrenderinfo.h" 22#include "rbrenderinfo.h"
23 23
24RBRenderInfo::RBRenderInfo(ParseTreeModel* model, ProjectModel* project, 24RBRenderInfo::RBRenderInfo(ParseTreeModel* model, ProjectModel* project,
25 QMap<QString, QString>* settings, 25 SkinDocument* doc, QMap<QString, QString>* settings,
26 DeviceState* device, RBScreen* screen, 26 DeviceState* device, RBScreen* screen,
27 RBScreen* sbsScreen) 27 RBScreen* sbsScreen)
28 :mProject(project), mSettings(settings), 28 :mProject(project), mDoc(doc),
29 mSettings(settings),
29 mDevice(device), mScreen(screen), 30 mDevice(device), mScreen(screen),
30 mSbsScreen(sbsScreen), mModel(model) 31 mSbsScreen(sbsScreen), mModel(model)
31{ 32{
@@ -41,6 +42,7 @@ RBRenderInfo::RBRenderInfo(const RBRenderInfo &other)
41 mProject = other.mProject; 42 mProject = other.mProject;
42 mSettings = other.mSettings; 43 mSettings = other.mSettings;
43 mDevice = other.mDevice; 44 mDevice = other.mDevice;
45 mDoc = other.mDoc;
44 mScreen = other.mScreen; 46 mScreen = other.mScreen;
45 mSbsScreen = other.mSbsScreen; 47 mSbsScreen = other.mSbsScreen;
46 mModel = other.mModel; 48 mModel = other.mModel;
@@ -51,6 +53,7 @@ const RBRenderInfo& RBRenderInfo::operator=(const RBRenderInfo& other)
51 mProject = other.mProject; 53 mProject = other.mProject;
52 mSettings = other.mSettings; 54 mSettings = other.mSettings;
53 mDevice = other.mDevice; 55 mDevice = other.mDevice;
56 mDoc = other.mDoc;
54 mScreen = other.mScreen; 57 mScreen = other.mScreen;
55 mSbsScreen = other.mSbsScreen; 58 mSbsScreen = other.mSbsScreen;
56 mModel = other.mModel; 59 mModel = other.mModel;
diff --git a/utils/themeeditor/graphics/rbrenderinfo.h b/utils/themeeditor/graphics/rbrenderinfo.h
index 599a563da2..17b87dbb6b 100644
--- a/utils/themeeditor/graphics/rbrenderinfo.h
+++ b/utils/themeeditor/graphics/rbrenderinfo.h
@@ -28,13 +28,15 @@ class RBScreen;
28class ProjectModel; 28class ProjectModel;
29class ParseTreeModel; 29class ParseTreeModel;
30class DeviceState; 30class DeviceState;
31class SkinDocument;
31 32
32class RBRenderInfo 33class RBRenderInfo
33{ 34{
34public: 35public:
35 RBRenderInfo(ParseTreeModel* model, ProjectModel* project, 36 RBRenderInfo(ParseTreeModel* model, ProjectModel* project,
36 QMap<QString, QString>* settings, DeviceState* device, 37 SkinDocument* doc, QMap<QString, QString>* settings,
37 RBScreen* screen, RBScreen* sbsScreen = 0); 38 DeviceState* device, RBScreen* screen,
39 RBScreen* sbsScreen = 0);
38 RBRenderInfo(); 40 RBRenderInfo();
39 RBRenderInfo(const RBRenderInfo& other); 41 RBRenderInfo(const RBRenderInfo& other);
40 virtual ~RBRenderInfo(); 42 virtual ~RBRenderInfo();
@@ -43,6 +45,7 @@ public:
43 45
44 ProjectModel* project() const{ return mProject; } 46 ProjectModel* project() const{ return mProject; }
45 DeviceState* device() const{ return mDevice; } 47 DeviceState* device() const{ return mDevice; }
48 SkinDocument* document() const{ return mDoc; }
46 QMap<QString, QString>* settings() const{ return mSettings; } 49 QMap<QString, QString>* settings() const{ return mSettings; }
47 RBScreen* screen() const{ return mScreen; } 50 RBScreen* screen() const{ return mScreen; }
48 RBScreen* sbsScreen() const{ return mSbsScreen; } 51 RBScreen* sbsScreen() const{ return mSbsScreen; }
@@ -50,6 +53,7 @@ public:
50 53
51private: 54private:
52 ProjectModel* mProject; 55 ProjectModel* mProject;
56 SkinDocument* mDoc;
53 QMap<QString, QString>* mSettings; 57 QMap<QString, QString>* mSettings;
54 DeviceState* mDevice; 58 DeviceState* mDevice;
55 RBScreen* mScreen; 59 RBScreen* mScreen;
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp
index fe17ebbeef..33749fdb7f 100644
--- a/utils/themeeditor/graphics/rbviewport.cpp
+++ b/utils/themeeditor/graphics/rbviewport.cpp
@@ -34,16 +34,19 @@
34#include "parsetreemodel.h" 34#include "parsetreemodel.h"
35#include "tag_table.h" 35#include "tag_table.h"
36#include "skin_parser.h" 36#include "skin_parser.h"
37#include "skindocument.h"
37 38
38/* Pixels/second of text scrolling */ 39/* Pixels/second of text scrolling */
39const double RBViewport::scrollRate = 30; 40const double RBViewport::scrollRate = 30;
40 41
41RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) 42RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info,
43 ParseTreeNode* pNode)
42 : RBMovable(info.screen()), foreground(info.screen()->foreground()), 44 : RBMovable(info.screen()), foreground(info.screen()->foreground()),
43 background(info.screen()->background()), textOffset(0,0), 45 background(info.screen()->background()), textOffset(0,0),
44 screen(info.screen()), textAlign(Left), showStatusBar(false), 46 screen(info.screen()), textAlign(Left), showStatusBar(false),
45 statusBarTexture(":/render/statusbar.png"), 47 statusBarTexture(":/render/statusbar.png"),
46 leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0) 48 leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0),
49 node(pNode), doc(info.document())
47{ 50{
48 setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); 51 setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
49 52
@@ -67,7 +70,6 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
67 } 70 }
68 else 71 else
69 { 72 {
70 int param = 0;
71 QString ident; 73 QString ident;
72 int x,y,w,h; 74 int x,y,w,h;
73 /* Rendering one of the other types of viewport */ 75 /* Rendering one of the other types of viewport */
@@ -75,7 +77,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
75 { 77 {
76 case '\0': 78 case '\0':
77 customUI = false; 79 customUI = false;
78 param = 0; 80 baseParam= 0;
79 break; 81 break;
80 82
81 case 'l': 83 case 'l':
@@ -85,13 +87,13 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
85 if(!screen->viewPortDisplayed(ident)) 87 if(!screen->viewPortDisplayed(ident))
86 hide(); 88 hide();
87 info.screen()->loadViewport(ident, this); 89 info.screen()->loadViewport(ident, this);
88 param = 1; 90 baseParam= 1;
89 break; 91 break;
90 92
91 case 'i': 93 case 'i':
92 /* Custom UI Viewport */ 94 /* Custom UI Viewport */
93 customUI = true; 95 customUI = true;
94 param = 1; 96 baseParam= 1;
95 if(node->params[0].type == skin_tag_parameter::DEFAULT) 97 if(node->params[0].type == skin_tag_parameter::DEFAULT)
96 { 98 {
97 setVisible(true); 99 setVisible(true);
@@ -104,6 +106,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
104 break; 106 break;
105 } 107 }
106 /* Now we grab the info common to all viewports */ 108 /* Now we grab the info common to all viewports */
109 int param = baseParam;
107 x = node->params[param++].data.number; 110 x = node->params[param++].data.number;
108 if(x < 0) 111 if(x < 0)
109 x = info.screen()->boundingRect().right() + x; 112 x = info.screen()->boundingRect().right() + x;
@@ -301,7 +304,15 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start,
301 304
302void RBViewport::saveGeometry() 305void RBViewport::saveGeometry()
303{ 306{
307 QRectF bounds = boundingRect();
308 QPointF origin = pos();
304 309
310 node->modParam(static_cast<int>(origin.x()), baseParam);
311 node->modParam(static_cast<int>(origin.y()), baseParam + 1);
312 node->modParam(static_cast<int>(bounds.width()), baseParam + 2);
313 node->modParam(static_cast<int>(bounds.height()), baseParam + 3);
314
315 doc->genCode();
305} 316}
306 317
307void RBViewport::alignLeft() 318void RBViewport::alignLeft()
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h
index b9bafe47d1..691133beeb 100644
--- a/utils/themeeditor/graphics/rbviewport.h
+++ b/utils/themeeditor/graphics/rbviewport.h
@@ -28,9 +28,12 @@
28 28
29class RBScreen; 29class RBScreen;
30class RBRenderInfo; 30class RBRenderInfo;
31class ParseTreeNode;
31 32
32#include <QGraphicsItem> 33#include <QGraphicsItem>
33 34
35class SkinDocument;
36
34class RBViewport : public RBMovable 37class RBViewport : public RBMovable
35{ 38{
36public: 39public:
@@ -43,7 +46,8 @@ public:
43 46
44 static const double scrollRate; 47 static const double scrollRate;
45 48
46 RBViewport(skin_element* node, const RBRenderInfo& info); 49 RBViewport(skin_element* node, const RBRenderInfo& info,
50 ParseTreeNode* pNode);
47 virtual ~RBViewport(); 51 virtual ~RBViewport();
48 52
49 QPainterPath shape() const; 53 QPainterPath shape() const;
@@ -112,6 +116,10 @@ private:
112 RBText* rightGraphic; 116 RBText* rightGraphic;
113 117
114 double scrollTime; 118 double scrollTime;
119
120 int baseParam;
121 ParseTreeNode* node;
122 SkinDocument* doc;
115}; 123};
116 124
117#endif // RBVIEWPORT_H 125#endif // RBVIEWPORT_H