forked from len0rd/rockbox
Theme Editor: Implemented saveGeometry() in RBAlbumArt
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27713 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2ea1a34f98
commit
265ee156f2
4 changed files with 25 additions and 6 deletions
|
@ -23,15 +23,19 @@
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
#include "parsetreenode.h"
|
||||||
|
|
||||||
RBAlbumArt::RBAlbumArt(QGraphicsItem *parent, int x, int y, int maxWidth,
|
RBAlbumArt::RBAlbumArt(QGraphicsItem *parent, int x, int y, int maxWidth,
|
||||||
int maxHeight, int artWidth, int artHeight, char hAlign,
|
int maxHeight, int artWidth, int artHeight,
|
||||||
char vAlign)
|
ParseTreeNode* node, char hAlign, char vAlign)
|
||||||
: RBMovable(parent), size(0, 0, maxWidth,
|
: RBMovable(parent), size(0, 0, maxWidth,
|
||||||
maxHeight),
|
maxHeight),
|
||||||
artWidth(artWidth), artHeight(artHeight),
|
artWidth(artWidth), artHeight(artHeight),
|
||||||
hAlign(hAlign), vAlign(vAlign),
|
hAlign(hAlign), vAlign(vAlign),
|
||||||
texture(":/render/albumart.png")
|
texture(":/render/albumart.png"), node(node)
|
||||||
{
|
{
|
||||||
|
setFlag(ItemSendsGeometryChanges, false);
|
||||||
|
|
||||||
setPos(x, y);
|
setPos(x, y);
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
@ -99,4 +103,11 @@ void RBAlbumArt::paint(QPainter *painter,
|
||||||
void RBAlbumArt::saveGeometry()
|
void RBAlbumArt::saveGeometry()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
QPointF origin = pos();
|
||||||
|
QRectF bounds = boundingRect();
|
||||||
|
|
||||||
|
node->modParam(static_cast<int>(origin.x()), 0);
|
||||||
|
node->modParam(static_cast<int>(origin.y()), 1);
|
||||||
|
node->modParam(static_cast<int>(bounds.width()), 2);
|
||||||
|
node->modParam(static_cast<int>(bounds.height()), 3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,18 +26,23 @@
|
||||||
|
|
||||||
#include "rbmovable.h"
|
#include "rbmovable.h"
|
||||||
|
|
||||||
|
class ParseTreeNode;
|
||||||
|
|
||||||
class RBAlbumArt : public RBMovable
|
class RBAlbumArt : public RBMovable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RBAlbumArt(QGraphicsItem* parent, int x, int y, int maxWidth, int maxHeight,
|
RBAlbumArt(QGraphicsItem* parent, int x, int y, int maxWidth, int maxHeight,
|
||||||
int artWidth, int artHeight, char hAlign = 'c',
|
int artWidth, int artHeight, ParseTreeNode* node,
|
||||||
char vAlign = 'c');
|
char hAlign = 'c', char vAlign = 'c');
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
void position(){ this->setPos(size.x(), size.y()); }
|
void position(){ this->setPos(size.x(), size.y()); }
|
||||||
|
void enableMove(){
|
||||||
|
setFlag(ItemSendsGeometryChanges, true);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void saveGeometry();
|
void saveGeometry();
|
||||||
|
@ -49,6 +54,8 @@ private:
|
||||||
char hAlign;
|
char hAlign;
|
||||||
char vAlign;
|
char vAlign;
|
||||||
QPixmap texture;
|
QPixmap texture;
|
||||||
|
|
||||||
|
ParseTreeNode* node;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RBALBUMART_H
|
#endif // RBALBUMART_H
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
{
|
{
|
||||||
albumArt->setParentItem(view);
|
albumArt->setParentItem(view);
|
||||||
albumArt->show();
|
albumArt->show();
|
||||||
|
albumArt->enableMove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -819,7 +819,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
|
||||||
height = info.device()->data("artheight").toInt();
|
height = info.device()->data("artheight").toInt();
|
||||||
info.screen()->setAlbumArt(new RBAlbumArt(viewport, x, y, maxWidth,
|
info.screen()->setAlbumArt(new RBAlbumArt(viewport, x, y, maxWidth,
|
||||||
maxHeight, width, height,
|
maxHeight, width, height,
|
||||||
hAlign, vAlign));
|
this, hAlign, vAlign));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue