From a83adc7d6d0a16d08687a903da8a992e3affedcc Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Tue, 3 Aug 2010 08:42:30 +0000 Subject: Theme Editor: Removed markup comments from CodeEditor files (it was originally a Nokia example, so it was marked up with comments for their documentation), implemented the beginnings of drag and drop editing. Viewports are now movable, but don't invoke code generation yet git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27675 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/graphics/rbviewport.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'utils/themeeditor/graphics/rbviewport.cpp') diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index e9c58eb..f7b1bc4 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp @@ -21,6 +21,11 @@ #include #include +#include +#include + +#include + #include #include "rbviewport.h" @@ -40,6 +45,8 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) statusBarTexture(":/render/statusbar.png"), leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0) { + setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); + if(!node->tag) { /* Default viewport takes up the entire screen */ @@ -290,6 +297,26 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start, } } +QVariant RBViewport::itemChange(GraphicsItemChange change, + const QVariant &value) +{ + if(change == ItemPositionChange) + { + QPointF pos = value.toPointF(); + QRectF bound = parentItem()->boundingRect(); + + pos.setX(qMax(0., pos.x())); + pos.setX(qMin(pos.x(), bound.width() - boundingRect().width())); + + pos.setY(qMax(0., pos.y())); + pos.setY(qMin(pos.y(), bound.height() - boundingRect().height())); + + return pos; + } + + return QGraphicsItem::itemChange(change, value); +} + void RBViewport::alignLeft() { int y = textOffset.y(); -- cgit v1.1