summaryrefslogtreecommitdiffstats
path: root/utils/themeeditor
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-30 19:35:00 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-30 19:35:00 +0000
commit8114979e8e413caa876cda626fe0b6385bfc56ce (patch)
tree7b1a193dfbbc48941b93d7c5e2f21199d5bd2979 /utils/themeeditor
parent3e599f4d379aeaa7ce5861c9818028e6d02d4490 (diff)
downloadrockbox-8114979e8e413caa876cda626fe0b6385bfc56ce.tar.gz
rockbox-8114979e8e413caa876cda626fe0b6385bfc56ce.tar.bz2
rockbox-8114979e8e413caa876cda626fe0b6385bfc56ce.zip
Theme Editor: Added album art display
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27199 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor')
-rw-r--r--utils/themeeditor/graphics/rbalbumart.cpp95
-rw-r--r--utils/themeeditor/graphics/rbalbumart.h47
-rw-r--r--utils/themeeditor/graphics/rbscreen.cpp6
-rw-r--r--utils/themeeditor/graphics/rbscreen.h16
-rw-r--r--utils/themeeditor/models/parsetreenode.cpp42
-rw-r--r--utils/themeeditor/resources.qrc1
-rw-r--r--utils/themeeditor/resources/COPYING7
-rw-r--r--utils/themeeditor/resources/deviceoptions4
-rw-r--r--utils/themeeditor/resources/render/albumart.pngbin0 -> 230 bytes
-rw-r--r--utils/themeeditor/themeeditor.pro6
10 files changed, 207 insertions, 17 deletions
diff --git a/utils/themeeditor/graphics/rbalbumart.cpp b/utils/themeeditor/graphics/rbalbumart.cpp
new file mode 100644
index 0000000000..bd3a8791fb
--- /dev/null
+++ b/utils/themeeditor/graphics/rbalbumart.cpp
@@ -0,0 +1,95 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "rbalbumart.h"
+
+#include <QPainter>
+#include <QDebug>
+
+RBAlbumArt::RBAlbumArt(QGraphicsItem *parent, int x, int y, int maxWidth,
+ int maxHeight, int artWidth, int artHeight, char hAlign,
+ char vAlign)
+ : QGraphicsItem(parent), size(x, y, maxWidth,
+ maxHeight),
+ artWidth(artWidth), artHeight(artHeight),
+ hAlign(hAlign), vAlign(vAlign),
+ texture(":/render/albumart.png")
+{
+ hide();
+}
+
+QRectF RBAlbumArt::boundingRect() const
+{
+ return size;
+}
+
+void RBAlbumArt::paint(QPainter *painter,
+ const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QRectF drawArea;
+
+ /* Making sure the alignment flags are sane */
+ if(hAlign != 'c' && hAlign != 'l' && hAlign != 'r')
+ hAlign = 'c';
+ if(vAlign != 'c' && vAlign != 't' && vAlign != 'b')
+ vAlign = 'c';
+
+ if(artWidth <= size.width() && artHeight <= size.height())
+ {
+ /* If the art is smaller than the viewport, just center it up */
+ drawArea.setX((size.width() - artWidth) / 2);
+ drawArea.setY((size.height() - artHeight) / 2);
+ drawArea.setWidth(artWidth);
+ drawArea.setHeight(artHeight);
+ }
+ else
+ {
+ /* Otherwise, figure out our scale factor, and which dimension needs
+ * to be scaled, and how to align said dimension
+ */
+ double xScale = size.width() / artWidth;
+ double yScale = size.height() / artHeight;
+ double scale = xScale < yScale ? xScale : yScale;
+
+ double scaleWidth = artWidth * scale;
+ double scaleHeight = artHeight * scale;
+
+ if(hAlign == 'l')
+ drawArea.setX(0);
+ else if(hAlign == 'c')
+ drawArea.setX((size.width() - scaleWidth) / 2 );
+ else
+ drawArea.setX(size.width() - scaleWidth);
+
+ if(vAlign == 't')
+ drawArea.setY(0);
+ else if(vAlign == 'c')
+ drawArea.setY((size.height() - scaleHeight) / 2);
+ else
+ drawArea.setY(size.height() - scaleHeight);
+
+ drawArea.setWidth(scaleWidth);
+ drawArea.setHeight(scaleHeight);
+
+ }
+
+ painter->fillRect(drawArea, texture);
+}
diff --git a/utils/themeeditor/graphics/rbalbumart.h b/utils/themeeditor/graphics/rbalbumart.h
new file mode 100644
index 0000000000..381b715525
--- /dev/null
+++ b/utils/themeeditor/graphics/rbalbumart.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef RBALBUMART_H
+#define RBALBUMART_H
+
+#include <QGraphicsItem>
+
+class RBAlbumArt : public QGraphicsItem
+{
+public:
+ RBAlbumArt(QGraphicsItem* parent, int x, int y, int maxWidth, int maxHeight,
+ int artWidth, int artHeight, char hAlign = 'c',
+ char vAlign = 'c');
+
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget);
+
+private:
+ QRectF size;
+ int artWidth;
+ int artHeight;
+ char hAlign;
+ char vAlign;
+ QPixmap texture;
+};
+
+#endif // RBALBUMART_H
diff --git a/utils/themeeditor/graphics/rbscreen.cpp b/utils/themeeditor/graphics/rbscreen.cpp
index f82c60ce6c..924a37406e 100644
--- a/utils/themeeditor/graphics/rbscreen.cpp
+++ b/utils/themeeditor/graphics/rbscreen.cpp
@@ -28,7 +28,8 @@
RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
QGraphicsItem *parent)
- :QGraphicsItem(parent), backdrop(0), project(project)
+ :QGraphicsItem(parent), backdrop(0), project(project),
+ albumArt(0)
{
if(remote)
@@ -80,6 +81,9 @@ RBScreen::~RBScreen()
if(backdrop)
delete backdrop;
+ if(albumArt)
+ delete albumArt;
+
QMap<int, RBFont*>::iterator i;
for(i = fonts.begin(); i != fonts.end(); i++)
delete (*i);
diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h
index 7b8b83060a..358a49e4a7 100644
--- a/utils/themeeditor/graphics/rbscreen.h
+++ b/utils/themeeditor/graphics/rbscreen.h
@@ -28,8 +28,8 @@
#include "rbrenderinfo.h"
#include "rbimage.h"
#include "rbfont.h"
-
-class RBViewport;
+#include "rbalbumart.h"
+#include "rbviewport.h"
class RBScreen : public QGraphicsItem
{
@@ -73,6 +73,16 @@ public:
QColor foreground(){ return fgColor; }
QColor background(){ return bgColor; }
+ void setAlbumArt(RBAlbumArt* art){ albumArt = art; }
+ void showAlbumArt(RBViewport* view)
+ {
+ if(albumArt)
+ {
+ albumArt->setParentItem(view);
+ albumArt->show();
+ }
+ }
+
private:
int width;
@@ -90,6 +100,8 @@ private:
QMap<int, RBFont*> fonts;
QList<QString> displayedViewports;
+ RBAlbumArt* albumArt;
+
};
#endif // RBSCREEN_H
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp
index c56592e2de..3b334a6f99 100644
--- a/utils/themeeditor/models/parsetreenode.cpp
+++ b/utils/themeeditor/models/parsetreenode.cpp
@@ -582,8 +582,8 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
QString filename;
QString id;
- int x, y, tiles, tile;
- char c;
+ int x, y, tiles, tile, maxWidth, maxHeight, width, height;
+ char c, hAlign, vAlign;
RBImage* image;
/* Two switch statements to narrow down the tag name */
@@ -609,7 +609,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
return true;
}
- break;
+ return false;
case 'x':
switch(element->tag->name[1])
@@ -672,7 +672,35 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
}
- return true;
+ return false;
+
+ case 'C':
+ switch(element->tag->name[1])
+ {
+ case 'd':
+ /* %Cd */
+ info.screen()->showAlbumArt(viewport);
+ return true;
+
+ case 'l':
+ /* %Cl */
+ x = element->params[0].data.numeric;
+ y = element->params[1].data.numeric;
+ maxWidth = element->params[2].data.numeric;
+ maxHeight = element->params[3].data.numeric;
+ hAlign = element->params_count > 4
+ ? element->params[4].data.text[0] : 'c';
+ vAlign = element->params_count > 5
+ ? element->params[5].data.text[0] : 'c';
+ width = info.device()->data("artwidth").toInt();
+ height = info.device()->data("artheight").toInt();
+ info.screen()->setAlbumArt(new RBAlbumArt(viewport, x, y, maxWidth,
+ maxHeight, width, height,
+ hAlign, vAlign));
+ return true;
+ }
+
+ return false;
case 'F':
@@ -689,7 +717,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
}
- return true;
+ return false;
case 'V':
@@ -725,7 +753,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
}
- return true;
+ return false;
case 'X':
@@ -738,7 +766,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
return true;
}
- return true;
+ return false;
}
diff --git a/utils/themeeditor/resources.qrc b/utils/themeeditor/resources.qrc
index dbaeea3185..a1c545bbb1 100644
--- a/utils/themeeditor/resources.qrc
+++ b/utils/themeeditor/resources.qrc
@@ -12,5 +12,6 @@
</qresource>
<qresource prefix="/render">
<file alias="scenebg.png">resources/render/scenebg.png</file>
+ <file alias="albumart.png">resources/render/albumart.png</file>
</qresource>
</RCC>
diff --git a/utils/themeeditor/resources/COPYING b/utils/themeeditor/resources/COPYING
index 2b6a94c0e4..231018b661 100644
--- a/utils/themeeditor/resources/COPYING
+++ b/utils/themeeditor/resources/COPYING
@@ -1,6 +1,5 @@
-The files appicon.xcf and windowicon.png, and all the magnifying glass
-graphics are authored by Robert Bieber, and made available in the public domain.
-
The files document-new.png, document-open.png, and document-save.png came from
-the Tango Desktop Project (http://www.tango.freedesktop.org) and are also in
+the Tango Desktop Project (http://www.tango.freedesktop.org) and are in
the public domain.
+
+All other graphics are authored by Robert Bieber, and also in the public domain.
diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions
index 5d3c5fcdaa..10a1a89d75 100644
--- a/utils/themeeditor/resources/deviceoptions
+++ b/utils/themeeditor/resources/deviceoptions
@@ -35,7 +35,7 @@ screenwidth ; Screen Width ; spin(0,800) ; 300
screenheight ; Screen Height ; spin(0,800) ; 200
remotewidth ; Remote Width ; spin(0,800) ; 100
remoteheight ; Remote Height ; spin(0,800); 50
-showviewports ; Show Viewports ; check ; true
+showviewports ; Show Viewports ; check ; false
[ID3 Info]
ia ; Artist ; text ; Current Artist
@@ -112,6 +112,8 @@ rp ; Song Playcount ; spin(0,10000) ; 20
rr ; Song Rating ; spin(0,10) ; 5
ra ; Autoscore ; spin(0,10) ; 7
?C ; Album Art Available ; check ; true
+artwidth ; Album Art Width ; spin(0,500) ; 100
+artheight; Album Art Height ; spin(0,500) ; 100
[Hardware Status]
bl ; Battery Level (-1 for unknown) ; spin(-1,100) ; 50
diff --git a/utils/themeeditor/resources/render/albumart.png b/utils/themeeditor/resources/render/albumart.png
new file mode 100644
index 0000000000..6c69b276af
--- /dev/null
+++ b/utils/themeeditor/resources/render/albumart.png
Binary files differ
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 329500e350..a46c40b451 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -43,7 +43,8 @@ HEADERS += models/parsetreemodel.h \
graphics/rbfont.h \
gui/devicestate.h \
findreplace/findreplaceform.h \
- findreplace/findreplacedialog.h
+ findreplace/findreplacedialog.h \
+ graphics/rbalbumart.h
SOURCES += main.cpp \
models/parsetreemodel.cpp \
models/parsetreenode.cpp \
@@ -62,7 +63,8 @@ SOURCES += main.cpp \
graphics/rbfont.cpp \
gui/devicestate.cpp \
findreplace/findreplaceform.cpp \
- findreplace/findreplacedialog.cpp
+ findreplace/findreplacedialog.cpp \
+ graphics/rbalbumart.cpp
OTHER_FILES += README \
resources/windowicon.png \
resources/appicon.xcf \