diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/themeeditor/graphics/rbalbumart.cpp | 13 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbalbumart.h | 7 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbimage.cpp | 11 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbimage.h | 7 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbmovable.cpp | 71 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbmovable.h | 53 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbscreen.h | 1 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 21 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.h | 5 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 6 |
10 files changed, 166 insertions, 29 deletions
diff --git a/utils/themeeditor/graphics/rbalbumart.cpp b/utils/themeeditor/graphics/rbalbumart.cpp index bd3a8791fb..1dbe2855f8 100644 --- a/utils/themeeditor/graphics/rbalbumart.cpp +++ b/utils/themeeditor/graphics/rbalbumart.cpp | |||
@@ -22,17 +22,17 @@ | |||
22 | #include "rbalbumart.h" | 22 | #include "rbalbumart.h" |
23 | 23 | ||
24 | #include <QPainter> | 24 | #include <QPainter> |
25 | #include <QDebug> | ||
26 | 25 | ||
27 | RBAlbumArt::RBAlbumArt(QGraphicsItem *parent, int x, int y, int maxWidth, | 26 | RBAlbumArt::RBAlbumArt(QGraphicsItem *parent, int x, int y, int maxWidth, |
28 | int maxHeight, int artWidth, int artHeight, char hAlign, | 27 | int maxHeight, int artWidth, int artHeight, char hAlign, |
29 | char vAlign) | 28 | char vAlign) |
30 | : QGraphicsItem(parent), size(x, y, maxWidth, | 29 | : RBMovable(parent), size(0, 0, maxWidth, |
31 | maxHeight), | 30 | maxHeight), |
32 | artWidth(artWidth), artHeight(artHeight), | 31 | artWidth(artWidth), artHeight(artHeight), |
33 | hAlign(hAlign), vAlign(vAlign), | 32 | hAlign(hAlign), vAlign(vAlign), |
34 | texture(":/render/albumart.png") | 33 | texture(":/render/albumart.png") |
35 | { | 34 | { |
35 | setPos(x, y); | ||
36 | hide(); | 36 | hide(); |
37 | } | 37 | } |
38 | 38 | ||
@@ -92,4 +92,11 @@ void RBAlbumArt::paint(QPainter *painter, | |||
92 | } | 92 | } |
93 | 93 | ||
94 | painter->fillRect(drawArea, texture); | 94 | painter->fillRect(drawArea, texture); |
95 | |||
96 | RBMovable::paint(painter, option, widget); | ||
97 | } | ||
98 | |||
99 | void RBAlbumArt::saveGeometry() | ||
100 | { | ||
101 | |||
95 | } | 102 | } |
diff --git a/utils/themeeditor/graphics/rbalbumart.h b/utils/themeeditor/graphics/rbalbumart.h index f32c5f9bb1..8baf7a2198 100644 --- a/utils/themeeditor/graphics/rbalbumart.h +++ b/utils/themeeditor/graphics/rbalbumart.h | |||
@@ -24,7 +24,9 @@ | |||
24 | 24 | ||
25 | #include <QGraphicsItem> | 25 | #include <QGraphicsItem> |
26 | 26 | ||
27 | class RBAlbumArt : public QGraphicsItem | 27 | #include "rbmovable.h" |
28 | |||
29 | class RBAlbumArt : public RBMovable | ||
28 | { | 30 | { |
29 | public: | 31 | public: |
30 | RBAlbumArt(QGraphicsItem* parent, int x, int y, int maxWidth, int maxHeight, | 32 | RBAlbumArt(QGraphicsItem* parent, int x, int y, int maxWidth, int maxHeight, |
@@ -37,6 +39,9 @@ public: | |||
37 | 39 | ||
38 | void position(){ this->setPos(size.x(), size.y()); } | 40 | void position(){ this->setPos(size.x(), size.y()); } |
39 | 41 | ||
42 | protected: | ||
43 | void saveGeometry(); | ||
44 | |||
40 | private: | 45 | private: |
41 | QRectF size; | 46 | QRectF size; |
42 | int artWidth; | 47 | int artWidth; |
diff --git a/utils/themeeditor/graphics/rbimage.cpp b/utils/themeeditor/graphics/rbimage.cpp index ce92d2fcde..954983eae2 100644 --- a/utils/themeeditor/graphics/rbimage.cpp +++ b/utils/themeeditor/graphics/rbimage.cpp | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "rbimage.h" | 26 | #include "rbimage.h" |
27 | 27 | ||
28 | RBImage::RBImage(QString file, int tiles, int x, int y, QGraphicsItem* parent) | 28 | RBImage::RBImage(QString file, int tiles, int x, int y, QGraphicsItem* parent) |
29 | : QGraphicsItem(parent), tiles(tiles), currentTile(0) | 29 | : RBMovable(parent), tiles(tiles), currentTile(0) |
30 | { | 30 | { |
31 | if(QFile::exists(file)) | 31 | if(QFile::exists(file)) |
32 | { | 32 | { |
@@ -56,7 +56,7 @@ RBImage::RBImage(QString file, int tiles, int x, int y, QGraphicsItem* parent) | |||
56 | } | 56 | } |
57 | 57 | ||
58 | RBImage::RBImage(const RBImage &other, QGraphicsItem* parent) | 58 | RBImage::RBImage(const RBImage &other, QGraphicsItem* parent) |
59 | : QGraphicsItem(parent), tiles(other.tiles), currentTile(other.currentTile) | 59 | : RBMovable(parent), tiles(other.tiles), currentTile(other.currentTile) |
60 | { | 60 | { |
61 | if(other.image) | 61 | if(other.image) |
62 | image = new QPixmap(*(other.image)); | 62 | image = new QPixmap(*(other.image)); |
@@ -86,4 +86,11 @@ void RBImage::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | |||
86 | painter->drawPixmap(size, *image, QRect(0, currentTile * image->height() | 86 | painter->drawPixmap(size, *image, QRect(0, currentTile * image->height() |
87 | / tiles, image->width(), | 87 | / tiles, image->width(), |
88 | image->height() / tiles)); | 88 | image->height() / tiles)); |
89 | |||
90 | RBMovable::paint(painter, option, widget); | ||
91 | } | ||
92 | |||
93 | void RBImage::saveGeometry() | ||
94 | { | ||
95 | |||
89 | } | 96 | } |
diff --git a/utils/themeeditor/graphics/rbimage.h b/utils/themeeditor/graphics/rbimage.h index abfe8eb052..f9562b82e9 100644 --- a/utils/themeeditor/graphics/rbimage.h +++ b/utils/themeeditor/graphics/rbimage.h | |||
@@ -25,7 +25,9 @@ | |||
25 | #include <QPixmap> | 25 | #include <QPixmap> |
26 | #include <QGraphicsItem> | 26 | #include <QGraphicsItem> |
27 | 27 | ||
28 | class RBImage: public QGraphicsItem | 28 | #include "rbmovable.h" |
29 | |||
30 | class RBImage: public RBMovable | ||
29 | { | 31 | { |
30 | public: | 32 | public: |
31 | RBImage(QString file, int tiles, int x, int y, QGraphicsItem* parent = 0); | 33 | RBImage(QString file, int tiles, int x, int y, QGraphicsItem* parent = 0); |
@@ -44,6 +46,9 @@ public: | |||
44 | } | 46 | } |
45 | 47 | ||
46 | 48 | ||
49 | protected: | ||
50 | void saveGeometry(); | ||
51 | |||
47 | private: | 52 | private: |
48 | QPixmap* image; | 53 | QPixmap* image; |
49 | int tiles; | 54 | int tiles; |
diff --git a/utils/themeeditor/graphics/rbmovable.cpp b/utils/themeeditor/graphics/rbmovable.cpp new file mode 100644 index 0000000000..11b3a6812f --- /dev/null +++ b/utils/themeeditor/graphics/rbmovable.cpp | |||
@@ -0,0 +1,71 @@ | |||
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 <QDebug> | ||
24 | |||
25 | #include "rbmovable.h" | ||
26 | |||
27 | RBMovable::RBMovable(QGraphicsItem* parent) | ||
28 | : QGraphicsItem(parent) | ||
29 | { | ||
30 | setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges); | ||
31 | } | ||
32 | |||
33 | RBMovable::~RBMovable() | ||
34 | { | ||
35 | } | ||
36 | |||
37 | void RBMovable::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | ||
38 | QWidget *widget) | ||
39 | { | ||
40 | if(isSelected()) | ||
41 | { | ||
42 | painter->setBrush(Qt::NoBrush); | ||
43 | QPen pen; | ||
44 | pen.setStyle(Qt::DashLine); | ||
45 | pen.setColor(Qt::green); | ||
46 | painter->setPen(pen); | ||
47 | painter->drawRect(boundingRect()); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | QVariant RBMovable::itemChange(GraphicsItemChange change, const QVariant &value) | ||
52 | { | ||
53 | if(change == ItemPositionChange) | ||
54 | { | ||
55 | QPointF pos = value.toPointF(); | ||
56 | QRectF bound = parentItem()->boundingRect(); | ||
57 | |||
58 | pos.setX(qMax(0., pos.x())); | ||
59 | pos.setX(qMin(pos.x(), bound.width() - boundingRect().width())); | ||
60 | |||
61 | pos.setY(qMax(0., pos.y())); | ||
62 | pos.setY(qMin(pos.y(), bound.height() - boundingRect().height())); | ||
63 | |||
64 | saveGeometry(); | ||
65 | |||
66 | return pos; | ||
67 | } | ||
68 | |||
69 | return QGraphicsItem::itemChange(change, value); | ||
70 | } | ||
71 | |||
diff --git a/utils/themeeditor/graphics/rbmovable.h b/utils/themeeditor/graphics/rbmovable.h new file mode 100644 index 0000000000..e8ef69b5bd --- /dev/null +++ b/utils/themeeditor/graphics/rbmovable.h | |||
@@ -0,0 +1,53 @@ | |||
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 RBMOVABLE_H | ||
23 | #define RBMOVABLE_H | ||
24 | |||
25 | #include <QGraphicsItem> | ||
26 | |||
27 | /* | ||
28 | * This is a base class for scene elements that can be moved around and | ||
29 | * resized. It adds some basic functionality for showing a border around | ||
30 | * selected items and ensuring that they don't get moved out of their parent's | ||
31 | * bounding rect, as well as resizing them. It includes one pure virtual | ||
32 | * function, saveGeometry(), that is responsible for syncing the changed | ||
33 | * geometry back to the parse tree to be code gen'd into the file. | ||
34 | */ | ||
35 | |||
36 | class RBMovable : public QGraphicsItem | ||
37 | { | ||
38 | public: | ||
39 | RBMovable(QGraphicsItem* parent); | ||
40 | ~RBMovable(); | ||
41 | |||
42 | virtual void paint(QPainter *painter, | ||
43 | const QStyleOptionGraphicsItem *option, QWidget *widget); | ||
44 | |||
45 | protected: | ||
46 | virtual QVariant itemChange(GraphicsItemChange change, | ||
47 | const QVariant &value); | ||
48 | /* Responsible for updating the parse tree */ | ||
49 | virtual void saveGeometry() = 0; | ||
50 | |||
51 | }; | ||
52 | |||
53 | #endif // RBMOVABLE_H | ||
diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h index 5bb8ab1602..c2417aa1b4 100644 --- a/utils/themeeditor/graphics/rbscreen.h +++ b/utils/themeeditor/graphics/rbscreen.h | |||
@@ -81,7 +81,6 @@ public: | |||
81 | if(albumArt) | 81 | if(albumArt) |
82 | { | 82 | { |
83 | albumArt->setParentItem(view); | 83 | albumArt->setParentItem(view); |
84 | albumArt->position(); | ||
85 | albumArt->show(); | 84 | albumArt->show(); |
86 | } | 85 | } |
87 | } | 86 | } |
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index f7b1bc4ca2..fe17ebbeef 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp | |||
@@ -39,7 +39,7 @@ | |||
39 | const double RBViewport::scrollRate = 30; | 39 | const double RBViewport::scrollRate = 30; |
40 | 40 | ||
41 | RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | 41 | RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) |
42 | : QGraphicsItem(info.screen()), foreground(info.screen()->foreground()), | 42 | : RBMovable(info.screen()), foreground(info.screen()->foreground()), |
43 | background(info.screen()->background()), textOffset(0,0), | 43 | background(info.screen()->background()), textOffset(0,0), |
44 | screen(info.screen()), textAlign(Left), showStatusBar(false), | 44 | screen(info.screen()), textAlign(Left), showStatusBar(false), |
45 | statusBarTexture(":/render/statusbar.png"), | 45 | statusBarTexture(":/render/statusbar.png"), |
@@ -178,6 +178,8 @@ void RBViewport::paint(QPainter *painter, | |||
178 | 178 | ||
179 | if(showStatusBar) | 179 | if(showStatusBar) |
180 | painter->fillRect(QRectF(0, 0, size.width(), 8), statusBarTexture); | 180 | painter->fillRect(QRectF(0, 0, size.width(), 8), statusBarTexture); |
181 | |||
182 | RBMovable::paint(painter, option, widget); | ||
181 | } | 183 | } |
182 | 184 | ||
183 | void RBViewport::newLine() | 185 | void RBViewport::newLine() |
@@ -297,24 +299,9 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start, | |||
297 | } | 299 | } |
298 | } | 300 | } |
299 | 301 | ||
300 | QVariant RBViewport::itemChange(GraphicsItemChange change, | 302 | void RBViewport::saveGeometry() |
301 | const QVariant &value) | ||
302 | { | 303 | { |
303 | if(change == ItemPositionChange) | ||
304 | { | ||
305 | QPointF pos = value.toPointF(); | ||
306 | QRectF bound = parentItem()->boundingRect(); | ||
307 | |||
308 | pos.setX(qMax(0., pos.x())); | ||
309 | pos.setX(qMin(pos.x(), bound.width() - boundingRect().width())); | ||
310 | |||
311 | pos.setY(qMax(0., pos.y())); | ||
312 | pos.setY(qMin(pos.y(), bound.height() - boundingRect().height())); | ||
313 | |||
314 | return pos; | ||
315 | } | ||
316 | 304 | ||
317 | return QGraphicsItem::itemChange(change, value); | ||
318 | } | 305 | } |
319 | 306 | ||
320 | void RBViewport::alignLeft() | 307 | void RBViewport::alignLeft() |
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index ea47225f09..b9bafe47d1 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h | |||
@@ -24,13 +24,14 @@ | |||
24 | 24 | ||
25 | #include "skin_parser.h" | 25 | #include "skin_parser.h" |
26 | #include "rbfont.h" | 26 | #include "rbfont.h" |
27 | #include "rbmovable.h" | ||
27 | 28 | ||
28 | class RBScreen; | 29 | class RBScreen; |
29 | class RBRenderInfo; | 30 | class RBRenderInfo; |
30 | 31 | ||
31 | #include <QGraphicsItem> | 32 | #include <QGraphicsItem> |
32 | 33 | ||
33 | class RBViewport : public QGraphicsItem | 34 | class RBViewport : public RBMovable |
34 | { | 35 | { |
35 | public: | 36 | public: |
36 | enum Alignment | 37 | enum Alignment |
@@ -78,7 +79,7 @@ public: | |||
78 | skin_element* noId3); | 79 | skin_element* noId3); |
79 | 80 | ||
80 | protected: | 81 | protected: |
81 | QVariant itemChange(GraphicsItemChange change, const QVariant &value); | 82 | void saveGeometry(); |
82 | 83 | ||
83 | private: | 84 | private: |
84 | 85 | ||
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index bf2be3abd8..da5fe4156b 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -106,7 +106,8 @@ HEADERS += models/parsetreemodel.h \ | |||
106 | qtfindreplacedialog/finddialog.h \ | 106 | qtfindreplacedialog/finddialog.h \ |
107 | gui/projectexporter.h \ | 107 | gui/projectexporter.h \ |
108 | gui/targetdownloader.h \ | 108 | gui/targetdownloader.h \ |
109 | gui/syntaxcompleter.h | 109 | gui/syntaxcompleter.h \ |
110 | graphics/rbmovable.h | ||
110 | SOURCES += main.cpp \ | 111 | SOURCES += main.cpp \ |
111 | models/parsetreemodel.cpp \ | 112 | models/parsetreemodel.cpp \ |
112 | models/parsetreenode.cpp \ | 113 | models/parsetreenode.cpp \ |
@@ -147,7 +148,8 @@ SOURCES += main.cpp \ | |||
147 | qtfindreplacedialog/finddialog.cpp \ | 148 | qtfindreplacedialog/finddialog.cpp \ |
148 | gui/projectexporter.cpp \ | 149 | gui/projectexporter.cpp \ |
149 | gui/targetdownloader.cpp \ | 150 | gui/targetdownloader.cpp \ |
150 | gui/syntaxcompleter.cpp | 151 | gui/syntaxcompleter.cpp \ |
152 | graphics/rbmovable.cpp | ||
151 | OTHER_FILES += README \ | 153 | OTHER_FILES += README \ |
152 | resources/windowicon.png \ | 154 | resources/windowicon.png \ |
153 | resources/appicon.xcf \ | 155 | resources/appicon.xcf \ |