summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-08-06 20:06:56 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-08-06 20:06:56 +0000
commit76d1377d0495f92ab10310018f05c11183ddc560 (patch)
treebacdc2f10824b003a600498fd85aef9cbc7301f5 /utils
parent87d2590bab021d0686cebdf0a105ecaf79651809 (diff)
downloadrockbox-76d1377d0495f92ab10310018f05c11183ddc560.tar.gz
rockbox-76d1377d0495f92ab10310018f05c11183ddc560.tar.bz2
rockbox-76d1377d0495f92ab10310018f05c11183ddc560.zip
Theme Editor: Restricted resizing/moving of graphical elements to integer coordinates
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27737 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/graphics/rbmovable.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/utils/themeeditor/graphics/rbmovable.cpp b/utils/themeeditor/graphics/rbmovable.cpp
index 5d493c61e7..1507c77a71 100644
--- a/utils/themeeditor/graphics/rbmovable.cpp
+++ b/utils/themeeditor/graphics/rbmovable.cpp
@@ -23,6 +23,8 @@
#include <QPainter>
#include <QDebug>
+#include <cmath>
+
#include "rbmovable.h"
const double RBMovable::handleSize = 7;
@@ -63,10 +65,10 @@ QVariant RBMovable::itemChange(GraphicsItemChange change, const QVariant &value)
QPointF pos = value.toPointF();
QRectF bound = parentItem()->boundingRect();
- pos.setX(qMax(0., pos.x()));
+ pos.setX(qMax(0., floor(pos.x())));
pos.setX(qMin(pos.x(), bound.width() - boundingRect().width()));
- pos.setY(qMax(0., pos.y()));
+ pos.setY(qMax(0., floor(pos.y())));
pos.setY(qMin(pos.y(), bound.height() - boundingRect().height()));
@@ -172,7 +174,8 @@ void RBMovable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
case TopLeft:
/* Dragging from the top left corner */
absPos = event->pos() + pos();
- dMouse = absPos - dragStartClick;
+ dMouse = QPointF(floor(absPos.x() - dragStartClick.x()),
+ floor(absPos.y() - dragStartClick.y()));
dPos.setX(qMin(dMouse.x(), dWidthMax));
dPos.setX(qMax(dPos.x(), dWidthMin));
@@ -192,7 +195,8 @@ void RBMovable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
case TopRight:
/* Dragging from the top right corner */
absPos = event->pos() + pos();
- dMouse = absPos - dragStartClick;
+ dMouse = QPointF(floor(absPos.x() - dragStartClick.x()),
+ floor(absPos.y() - dragStartClick.y()));
dPos.setX(qMin(dMouse.x(), dWidthMax));
dPos.setX(qMax(dPos.x(), dWidthMin));
@@ -212,7 +216,8 @@ void RBMovable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
case BottomLeft:
/* Dragging from the bottom left corner */
absPos = event->pos() + pos();
- dMouse = absPos - dragStartClick;
+ dMouse = QPointF(floor(absPos.x() - dragStartClick.x()),
+ floor(absPos.y() - dragStartClick.y()));
dPos.setX(qMin(dMouse.x(), dWidthMax));
dPos.setX(qMax(dPos.x(), dWidthMin));
@@ -230,7 +235,8 @@ void RBMovable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
case BottomRight:
/* Dragging from the bottom right corner */
absPos = event->pos() + pos();
- dMouse = absPos - dragStartClick;
+ dMouse = QPointF(floor(absPos.x() - dragStartClick.x()),
+ floor(absPos.y() - dragStartClick.y()));
dPos.setX(qMin(dMouse.x(), dWidthMax));
dPos.setX(qMax(dPos.x(), dWidthMin));