summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "rbalbumart.h"
23
24#include <QPainter>
25#include <QDebug>
26
27RBAlbumArt::RBAlbumArt(QGraphicsItem *parent, int x, int y, int maxWidth,
28 int maxHeight, int artWidth, int artHeight, char hAlign,
29 char vAlign)
30 : QGraphicsItem(parent), size(x, y, maxWidth,
31 maxHeight),
32 artWidth(artWidth), artHeight(artHeight),
33 hAlign(hAlign), vAlign(vAlign),
34 texture(":/render/albumart.png")
35{
36 hide();
37}
38
39QRectF RBAlbumArt::boundingRect() const
40{
41 return size;
42}
43
44void RBAlbumArt::paint(QPainter *painter,
45 const QStyleOptionGraphicsItem *option, QWidget *widget)
46{
47 QRectF drawArea;
48
49 /* Making sure the alignment flags are sane */
50 if(hAlign != 'c' && hAlign != 'l' && hAlign != 'r')
51 hAlign = 'c';
52 if(vAlign != 'c' && vAlign != 't' && vAlign != 'b')
53 vAlign = 'c';
54
55 if(artWidth <= size.width() && artHeight <= size.height())
56 {
57 /* If the art is smaller than the viewport, just center it up */
58 drawArea.setX((size.width() - artWidth) / 2);
59 drawArea.setY((size.height() - artHeight) / 2);
60 drawArea.setWidth(artWidth);
61 drawArea.setHeight(artHeight);
62 }
63 else
64 {
65 /* Otherwise, figure out our scale factor, and which dimension needs
66 * to be scaled, and how to align said dimension
67 */
68 double xScale = size.width() / artWidth;
69 double yScale = size.height() / artHeight;
70 double scale = xScale < yScale ? xScale : yScale;
71
72 double scaleWidth = artWidth * scale;
73 double scaleHeight = artHeight * scale;
74
75 if(hAlign == 'l')
76 drawArea.setX(0);
77 else if(hAlign == 'c')
78 drawArea.setX((size.width() - scaleWidth) / 2 );
79 else
80 drawArea.setX(size.width() - scaleWidth);
81
82 if(vAlign == 't')
83 drawArea.setY(0);
84 else if(vAlign == 'c')
85 drawArea.setY((size.height() - scaleHeight) / 2);
86 else
87 drawArea.setY(size.height() - scaleHeight);
88
89 drawArea.setWidth(scaleWidth);
90 drawArea.setHeight(scaleHeight);
91
92 }
93
94 painter->fillRect(drawArea, texture);
95}
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef RBALBUMART_H
23#define RBALBUMART_H
24
25#include <QGraphicsItem>
26
27class RBAlbumArt : public QGraphicsItem
28{
29public:
30 RBAlbumArt(QGraphicsItem* parent, int x, int y, int maxWidth, int maxHeight,
31 int artWidth, int artHeight, char hAlign = 'c',
32 char vAlign = 'c');
33
34 QRectF boundingRect() const;
35 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
36 QWidget *widget);
37
38private:
39 QRectF size;
40 int artWidth;
41 int artHeight;
42 char hAlign;
43 char vAlign;
44 QPixmap texture;
45};
46
47#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 @@
28 28
29RBScreen::RBScreen(const RBRenderInfo& info, bool remote, 29RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
30 QGraphicsItem *parent) 30 QGraphicsItem *parent)
31 :QGraphicsItem(parent), backdrop(0), project(project) 31 :QGraphicsItem(parent), backdrop(0), project(project),
32 albumArt(0)
32{ 33{
33 34
34 if(remote) 35 if(remote)
@@ -80,6 +81,9 @@ RBScreen::~RBScreen()
80 if(backdrop) 81 if(backdrop)
81 delete backdrop; 82 delete backdrop;
82 83
84 if(albumArt)
85 delete albumArt;
86
83 QMap<int, RBFont*>::iterator i; 87 QMap<int, RBFont*>::iterator i;
84 for(i = fonts.begin(); i != fonts.end(); i++) 88 for(i = fonts.begin(); i != fonts.end(); i++)
85 delete (*i); 89 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 @@
28#include "rbrenderinfo.h" 28#include "rbrenderinfo.h"
29#include "rbimage.h" 29#include "rbimage.h"
30#include "rbfont.h" 30#include "rbfont.h"
31 31#include "rbalbumart.h"
32class RBViewport; 32#include "rbviewport.h"
33 33
34class RBScreen : public QGraphicsItem 34class RBScreen : public QGraphicsItem
35{ 35{
@@ -73,6 +73,16 @@ public:
73 QColor foreground(){ return fgColor; } 73 QColor foreground(){ return fgColor; }
74 QColor background(){ return bgColor; } 74 QColor background(){ return bgColor; }
75 75
76 void setAlbumArt(RBAlbumArt* art){ albumArt = art; }
77 void showAlbumArt(RBViewport* view)
78 {
79 if(albumArt)
80 {
81 albumArt->setParentItem(view);
82 albumArt->show();
83 }
84 }
85
76 86
77private: 87private:
78 int width; 88 int width;
@@ -90,6 +100,8 @@ private:
90 QMap<int, RBFont*> fonts; 100 QMap<int, RBFont*> fonts;
91 QList<QString> displayedViewports; 101 QList<QString> displayedViewports;
92 102
103 RBAlbumArt* albumArt;
104
93}; 105};
94 106
95#endif // RBSCREEN_H 107#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)
582 582
583 QString filename; 583 QString filename;
584 QString id; 584 QString id;
585 int x, y, tiles, tile; 585 int x, y, tiles, tile, maxWidth, maxHeight, width, height;
586 char c; 586 char c, hAlign, vAlign;
587 RBImage* image; 587 RBImage* image;
588 588
589 /* Two switch statements to narrow down the tag name */ 589 /* Two switch statements to narrow down the tag name */
@@ -609,7 +609,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
609 return true; 609 return true;
610 } 610 }
611 611
612 break; 612 return false;
613 613
614 case 'x': 614 case 'x':
615 switch(element->tag->name[1]) 615 switch(element->tag->name[1])
@@ -672,7 +672,35 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
672 672
673 } 673 }
674 674
675 return true; 675 return false;
676
677 case 'C':
678 switch(element->tag->name[1])
679 {
680 case 'd':
681 /* %Cd */
682 info.screen()->showAlbumArt(viewport);
683 return true;
684
685 case 'l':
686 /* %Cl */
687 x = element->params[0].data.numeric;
688 y = element->params[1].data.numeric;
689 maxWidth = element->params[2].data.numeric;
690 maxHeight = element->params[3].data.numeric;
691 hAlign = element->params_count > 4
692 ? element->params[4].data.text[0] : 'c';
693 vAlign = element->params_count > 5
694 ? element->params[5].data.text[0] : 'c';
695 width = info.device()->data("artwidth").toInt();
696 height = info.device()->data("artheight").toInt();
697 info.screen()->setAlbumArt(new RBAlbumArt(viewport, x, y, maxWidth,
698 maxHeight, width, height,
699 hAlign, vAlign));
700 return true;
701 }
702
703 return false;
676 704
677 case 'F': 705 case 'F':
678 706
@@ -689,7 +717,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
689 717
690 } 718 }
691 719
692 return true; 720 return false;
693 721
694 case 'V': 722 case 'V':
695 723
@@ -725,7 +753,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
725 753
726 } 754 }
727 755
728 return true; 756 return false;
729 757
730 case 'X': 758 case 'X':
731 759
@@ -738,7 +766,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
738 return true; 766 return true;
739 } 767 }
740 768
741 return true; 769 return false;
742 770
743 } 771 }
744 772
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 @@
12 </qresource> 12 </qresource>
13 <qresource prefix="/render"> 13 <qresource prefix="/render">
14 <file alias="scenebg.png">resources/render/scenebg.png</file> 14 <file alias="scenebg.png">resources/render/scenebg.png</file>
15 <file alias="albumart.png">resources/render/albumart.png</file>
15 </qresource> 16 </qresource>
16</RCC> 17</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 @@
1The files appicon.xcf and windowicon.png, and all the magnifying glass
2graphics are authored by Robert Bieber, and made available in the public domain.
3
4The files document-new.png, document-open.png, and document-save.png came from 1The files document-new.png, document-open.png, and document-save.png came from
5the Tango Desktop Project (http://www.tango.freedesktop.org) and are also in 2the Tango Desktop Project (http://www.tango.freedesktop.org) and are in
6the public domain. 3the public domain.
4
5All 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
35screenheight ; Screen Height ; spin(0,800) ; 200 35screenheight ; Screen Height ; spin(0,800) ; 200
36remotewidth ; Remote Width ; spin(0,800) ; 100 36remotewidth ; Remote Width ; spin(0,800) ; 100
37remoteheight ; Remote Height ; spin(0,800); 50 37remoteheight ; Remote Height ; spin(0,800); 50
38showviewports ; Show Viewports ; check ; true 38showviewports ; Show Viewports ; check ; false
39 39
40[ID3 Info] 40[ID3 Info]
41ia ; Artist ; text ; Current Artist 41ia ; Artist ; text ; Current Artist
@@ -112,6 +112,8 @@ rp ; Song Playcount ; spin(0,10000) ; 20
112rr ; Song Rating ; spin(0,10) ; 5 112rr ; Song Rating ; spin(0,10) ; 5
113ra ; Autoscore ; spin(0,10) ; 7 113ra ; Autoscore ; spin(0,10) ; 7
114?C ; Album Art Available ; check ; true 114?C ; Album Art Available ; check ; true
115artwidth ; Album Art Width ; spin(0,500) ; 100
116artheight; Album Art Height ; spin(0,500) ; 100
115 117
116[Hardware Status] 118[Hardware Status]
117bl ; Battery Level (-1 for unknown) ; spin(-1,100) ; 50 119bl ; 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 \
43 graphics/rbfont.h \ 43 graphics/rbfont.h \
44 gui/devicestate.h \ 44 gui/devicestate.h \
45 findreplace/findreplaceform.h \ 45 findreplace/findreplaceform.h \
46 findreplace/findreplacedialog.h 46 findreplace/findreplacedialog.h \
47 graphics/rbalbumart.h
47SOURCES += main.cpp \ 48SOURCES += main.cpp \
48 models/parsetreemodel.cpp \ 49 models/parsetreemodel.cpp \
49 models/parsetreenode.cpp \ 50 models/parsetreenode.cpp \
@@ -62,7 +63,8 @@ SOURCES += main.cpp \
62 graphics/rbfont.cpp \ 63 graphics/rbfont.cpp \
63 gui/devicestate.cpp \ 64 gui/devicestate.cpp \
64 findreplace/findreplaceform.cpp \ 65 findreplace/findreplaceform.cpp \
65 findreplace/findreplacedialog.cpp 66 findreplace/findreplacedialog.cpp \
67 graphics/rbalbumart.cpp
66OTHER_FILES += README \ 68OTHER_FILES += README \
67 resources/windowicon.png \ 69 resources/windowicon.png \
68 resources/appicon.xcf \ 70 resources/appicon.xcf \