summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics/rbprogressbar.cpp
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-02 00:20:36 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-02 00:20:36 +0000
commit9742704070732aeaa9fa1287045a682db5cf4527 (patch)
treef459140aa86f7e61e574912fdba80241641feded /utils/themeeditor/graphics/rbprogressbar.cpp
parent5633ece5a85a933a45de3896eb52bb3804849c3b (diff)
downloadrockbox-9742704070732aeaa9fa1287045a682db5cf4527.tar.gz
rockbox-9742704070732aeaa9fa1287045a682db5cf4527.zip
Theme Editor: Altered tag table entry for %pb to make image optional, implemented progress bar rendering in theme editor
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27229 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/graphics/rbprogressbar.cpp')
-rw-r--r--utils/themeeditor/graphics/rbprogressbar.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/utils/themeeditor/graphics/rbprogressbar.cpp b/utils/themeeditor/graphics/rbprogressbar.cpp
new file mode 100644
index 0000000000..1c14acfc5a
--- /dev/null
+++ b/utils/themeeditor/graphics/rbprogressbar.cpp
@@ -0,0 +1,106 @@
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 <QPainter>
23
24#include "rbprogressbar.h"
25#include "projectmodel.h"
26
27RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info,
28 int paramCount, skin_tag_parameter *params)
29 :QGraphicsItem(parent)
30{
31 /* First we set everything to defaults */
32 bitmap = 0;
33 color = parent->getFGColor();
34 int x = 0;
35 int y = parent->getTextOffset();
36 int w = parent->boundingRect().width();
37 int h = 6;
38
39 /* Now we change defaults if the parameters are there */
40
41 if(paramCount > 0 && params[0].type != skin_tag_parameter::DEFAULT)
42 {
43 x = params[0].data.numeric;
44 }
45
46 if(paramCount > 1 && params[1].type != skin_tag_parameter::DEFAULT)
47 {
48 y = params[1].data.numeric;
49 }
50
51 if(paramCount > 2 && params[2].type != skin_tag_parameter::DEFAULT)
52 {
53 w = params[2].data.numeric;
54 }
55
56 if(paramCount > 3 && params[3].type != skin_tag_parameter::DEFAULT)
57 {
58 h = params[3].data.numeric;
59 }
60
61 if(paramCount > 4 && params[4].type != skin_tag_parameter::DEFAULT)
62 {
63 QString imPath(params[4].data.text);
64 imPath = info.settings()->value("imagepath", "") + "/" + imPath;
65 bitmap = new QPixmap(imPath);
66 if(bitmap->isNull())
67 {
68 delete bitmap;
69 bitmap = 0;
70 }
71 }
72
73
74 /* Finally, we scale the width according to the amount played */
75 int percent = info.device()->data("px").toInt();
76 w = w * percent / 100;
77
78 size = QRectF(0, 0, w, h);
79 setPos(x, y);
80 parent->addTextOffset(h);
81}
82
83RBProgressBar::~RBProgressBar()
84{
85 if(bitmap)
86 delete bitmap;
87}
88
89QRectF RBProgressBar::boundingRect() const
90{
91 return size;
92}
93
94void RBProgressBar::paint(QPainter *painter,
95 const QStyleOptionGraphicsItem *option,
96 QWidget *widget)
97{
98 if(bitmap && !bitmap->isNull())
99 {
100 painter->drawPixmap(size, *bitmap, size);
101 }
102 else
103 {
104 painter->fillRect(size, color);
105 }
106}