From 83c60a1012f2db6c21c5779f7e11b2f3e479df85 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Tue, 3 Aug 2010 22:29:26 +0000 Subject: Theme Editor: Created the RBMovable abstract class for screen elements that can be moved around, began implementing it and making images, viewports, and album art children of it git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27685 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/graphics/rbviewport.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'utils/themeeditor/graphics/rbviewport.cpp') diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index f7b1bc4..fe17ebb 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp @@ -39,7 +39,7 @@ const double RBViewport::scrollRate = 30; RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) - : QGraphicsItem(info.screen()), foreground(info.screen()->foreground()), + : RBMovable(info.screen()), foreground(info.screen()->foreground()), background(info.screen()->background()), textOffset(0,0), screen(info.screen()), textAlign(Left), showStatusBar(false), statusBarTexture(":/render/statusbar.png"), @@ -178,6 +178,8 @@ void RBViewport::paint(QPainter *painter, if(showStatusBar) painter->fillRect(QRectF(0, 0, size.width(), 8), statusBarTexture); + + RBMovable::paint(painter, option, widget); } void RBViewport::newLine() @@ -297,24 +299,9 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start, } } -QVariant RBViewport::itemChange(GraphicsItemChange change, - const QVariant &value) +void RBViewport::saveGeometry() { - 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() -- cgit v1.1