summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-08-05 07:28:01 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-08-05 07:28:01 +0000
commitbfc20975b068d707ad46a5f02d8561852e41f311 (patch)
treeb78cab1536f0266617201883cd99d33d022ed07a /utils
parent430eb651a2c39df6e5af99f4cdb14498fde59363 (diff)
downloadrockbox-bfc20975b068d707ad46a5f02d8561852e41f311.tar.gz
rockbox-bfc20975b068d707ad46a5f02d8561852e41f311.tar.bz2
rockbox-bfc20975b068d707ad46a5f02d8561852e41f311.zip
Theme Editor: Fixed image positioning bug, implemented saveGeometry() in RBImage
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27711 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/graphics/rbimage.cpp18
-rw-r--r--utils/themeeditor/graphics/rbimage.h12
-rw-r--r--utils/themeeditor/models/parsetreenode.cpp12
3 files changed, 33 insertions, 9 deletions
diff --git a/utils/themeeditor/graphics/rbimage.cpp b/utils/themeeditor/graphics/rbimage.cpp
index 954983eae2..83a564c465 100644
--- a/utils/themeeditor/graphics/rbimage.cpp
+++ b/utils/themeeditor/graphics/rbimage.cpp
@@ -24,10 +24,16 @@
#include <QBitmap>
#include "rbimage.h"
+#include "parsetreenode.h"
-RBImage::RBImage(QString file, int tiles, int x, int y, QGraphicsItem* parent)
- : RBMovable(parent), tiles(tiles), currentTile(0)
+RBImage::RBImage(QString file, int tiles, int x, int y, ParseTreeNode* node,
+ QGraphicsItem* parent)
+ : RBMovable(parent), tiles(tiles), currentTile(0),
+ node(node)
{
+ /* Prevents RBMovable from interfering with initial position setting */
+ setFlag(ItemSendsGeometryChanges, false);
+
if(QFile::exists(file))
{
image = new QPixmap(file);
@@ -56,7 +62,8 @@ RBImage::RBImage(QString file, int tiles, int x, int y, QGraphicsItem* parent)
}
RBImage::RBImage(const RBImage &other, QGraphicsItem* parent)
- : RBMovable(parent), tiles(other.tiles), currentTile(other.currentTile)
+ : RBMovable(parent), tiles(other.tiles), currentTile(other.currentTile),
+ node(other.node)
{
if(other.image)
image = new QPixmap(*(other.image));
@@ -90,7 +97,12 @@ void RBImage::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
RBMovable::paint(painter, option, widget);
}
+
+
void RBImage::saveGeometry()
{
+ QPointF origin = pos();
+ node->modParam(static_cast<int>(origin.x()), 2);
+ node->modParam(static_cast<int>(origin.y()), 3);
}
diff --git a/utils/themeeditor/graphics/rbimage.h b/utils/themeeditor/graphics/rbimage.h
index f9562b82e9..ba028de7e2 100644
--- a/utils/themeeditor/graphics/rbimage.h
+++ b/utils/themeeditor/graphics/rbimage.h
@@ -27,10 +27,13 @@
#include "rbmovable.h"
+class ParseTreeNode;
+
class RBImage: public RBMovable
{
public:
- RBImage(QString file, int tiles, int x, int y, QGraphicsItem* parent = 0);
+ RBImage(QString file, int tiles, int x, int y, ParseTreeNode* node,
+ QGraphicsItem* parent = 0);
RBImage(const RBImage& other, QGraphicsItem* parent);
virtual ~RBImage();
@@ -45,6 +48,11 @@ public:
currentTile = tiles -1;
}
+ void enableMovement()
+ {
+ setFlag(ItemSendsGeometryChanges, true);
+ }
+
protected:
void saveGeometry();
@@ -56,6 +64,8 @@ private:
QRectF size;
+ ParseTreeNode* node;
+
};
#endif // RBIMAGE_H
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp
index 9f802ae60f..f05bfea954 100644
--- a/utils/themeeditor/models/parsetreenode.cpp
+++ b/utils/themeeditor/models/parsetreenode.cpp
@@ -758,6 +758,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
image = new RBImage(*(info.screen()->getImage(id)), viewport);
image->setTile(tile);
image->show();
+ image->enableMovement();
}
return true;
@@ -775,7 +776,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
tiles = 1;
info.screen()->loadImage(id, new RBImage(filename, tiles, x, y,
- viewport));
+ this, viewport));
return true;
case '\0':
@@ -785,10 +786,11 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
element->params[1].data.text;
x = element->params[2].data.number;
y = element->params[3].data.number;
- image = new RBImage(filename, 1, x, y, viewport);
- info.screen()->loadImage(id, new RBImage(filename, 1, x, y,
- viewport));
- info.screen()->getImage(id)->show();
+ image = new RBImage(filename, 1, x, y, this, viewport);
+ info.screen()->loadImage(id, image);
+ image->show();
+ image->enableMovement();
+
return true;
}