diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-08-06 20:06:56 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-08-06 20:06:56 +0000 |
commit | 76d1377d0495f92ab10310018f05c11183ddc560 (patch) | |
tree | bacdc2f10824b003a600498fd85aef9cbc7301f5 /utils | |
parent | 87d2590bab021d0686cebdf0a105ecaf79651809 (diff) | |
download | rockbox-76d1377d0495f92ab10310018f05c11183ddc560.tar.gz 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.cpp | 18 |
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 @@ | |||
23 | #include <QPainter> | 23 | #include <QPainter> |
24 | #include <QDebug> | 24 | #include <QDebug> |
25 | 25 | ||
26 | #include <cmath> | ||
27 | |||
26 | #include "rbmovable.h" | 28 | #include "rbmovable.h" |
27 | 29 | ||
28 | const double RBMovable::handleSize = 7; | 30 | const double RBMovable::handleSize = 7; |
@@ -63,10 +65,10 @@ QVariant RBMovable::itemChange(GraphicsItemChange change, const QVariant &value) | |||
63 | QPointF pos = value.toPointF(); | 65 | QPointF pos = value.toPointF(); |
64 | QRectF bound = parentItem()->boundingRect(); | 66 | QRectF bound = parentItem()->boundingRect(); |
65 | 67 | ||
66 | pos.setX(qMax(0., pos.x())); | 68 | pos.setX(qMax(0., floor(pos.x()))); |
67 | pos.setX(qMin(pos.x(), bound.width() - boundingRect().width())); | 69 | pos.setX(qMin(pos.x(), bound.width() - boundingRect().width())); |
68 | 70 | ||
69 | pos.setY(qMax(0., pos.y())); | 71 | pos.setY(qMax(0., floor(pos.y()))); |
70 | pos.setY(qMin(pos.y(), bound.height() - boundingRect().height())); | 72 | pos.setY(qMin(pos.y(), bound.height() - boundingRect().height())); |
71 | 73 | ||
72 | 74 | ||
@@ -172,7 +174,8 @@ void RBMovable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | |||
172 | case TopLeft: | 174 | case TopLeft: |
173 | /* Dragging from the top left corner */ | 175 | /* Dragging from the top left corner */ |
174 | absPos = event->pos() + pos(); | 176 | absPos = event->pos() + pos(); |
175 | dMouse = absPos - dragStartClick; | 177 | dMouse = QPointF(floor(absPos.x() - dragStartClick.x()), |
178 | floor(absPos.y() - dragStartClick.y())); | ||
176 | 179 | ||
177 | dPos.setX(qMin(dMouse.x(), dWidthMax)); | 180 | dPos.setX(qMin(dMouse.x(), dWidthMax)); |
178 | dPos.setX(qMax(dPos.x(), dWidthMin)); | 181 | dPos.setX(qMax(dPos.x(), dWidthMin)); |
@@ -192,7 +195,8 @@ void RBMovable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | |||
192 | case TopRight: | 195 | case TopRight: |
193 | /* Dragging from the top right corner */ | 196 | /* Dragging from the top right corner */ |
194 | absPos = event->pos() + pos(); | 197 | absPos = event->pos() + pos(); |
195 | dMouse = absPos - dragStartClick; | 198 | dMouse = QPointF(floor(absPos.x() - dragStartClick.x()), |
199 | floor(absPos.y() - dragStartClick.y())); | ||
196 | 200 | ||
197 | dPos.setX(qMin(dMouse.x(), dWidthMax)); | 201 | dPos.setX(qMin(dMouse.x(), dWidthMax)); |
198 | dPos.setX(qMax(dPos.x(), dWidthMin)); | 202 | dPos.setX(qMax(dPos.x(), dWidthMin)); |
@@ -212,7 +216,8 @@ void RBMovable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | |||
212 | case BottomLeft: | 216 | case BottomLeft: |
213 | /* Dragging from the bottom left corner */ | 217 | /* Dragging from the bottom left corner */ |
214 | absPos = event->pos() + pos(); | 218 | absPos = event->pos() + pos(); |
215 | dMouse = absPos - dragStartClick; | 219 | dMouse = QPointF(floor(absPos.x() - dragStartClick.x()), |
220 | floor(absPos.y() - dragStartClick.y())); | ||
216 | 221 | ||
217 | dPos.setX(qMin(dMouse.x(), dWidthMax)); | 222 | dPos.setX(qMin(dMouse.x(), dWidthMax)); |
218 | dPos.setX(qMax(dPos.x(), dWidthMin)); | 223 | dPos.setX(qMax(dPos.x(), dWidthMin)); |
@@ -230,7 +235,8 @@ void RBMovable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | |||
230 | case BottomRight: | 235 | case BottomRight: |
231 | /* Dragging from the bottom right corner */ | 236 | /* Dragging from the bottom right corner */ |
232 | absPos = event->pos() + pos(); | 237 | absPos = event->pos() + pos(); |
233 | dMouse = absPos - dragStartClick; | 238 | dMouse = QPointF(floor(absPos.x() - dragStartClick.x()), |
239 | floor(absPos.y() - dragStartClick.y())); | ||
234 | 240 | ||
235 | dPos.setX(qMin(dMouse.x(), dWidthMax)); | 241 | dPos.setX(qMin(dMouse.x(), dWidthMax)); |
236 | dPos.setX(qMax(dPos.x(), dWidthMin)); | 242 | dPos.setX(qMax(dPos.x(), dWidthMin)); |