summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics/rbviewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/graphics/rbviewport.cpp')
-rw-r--r--utils/themeeditor/graphics/rbviewport.cpp110
1 files changed, 110 insertions, 0 deletions
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp
new file mode 100644
index 0000000000..1f1f02ce55
--- /dev/null
+++ b/utils/themeeditor/graphics/rbviewport.cpp
@@ -0,0 +1,110 @@
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#include <QPainterPath>
24
25#include "rbviewport.h"
26#include "rbscreen.h"
27#include "rbrenderinfo.h"
28#include "parsetreemodel.h"
29#include "tag_table.h"
30#include "skin_parser.h"
31
32RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
33 : QGraphicsItem(info.screen())
34{
35 if(!node->tag)
36 {
37 /* Default viewport takes up the entire screen */
38 size = QRectF(0, 0, info.screen()->getWidth(),
39 info.screen()->getHeight());
40
41 if(info.model()->rowCount(QModelIndex()) > 1)
42 {
43 /* If there is more than one viewport in the document */
44 displayed = false;
45 }
46 else
47 {
48 displayed = true;
49 }
50 }
51 else
52 {
53 int x, y, w, h;
54 /* Parsing one of the other types of viewport */
55 switch(node->tag->name[1])
56 {
57 case '\0':
58 /* A normal viewport definition */
59 x = node->params[0].data.numeric;
60 y = node->params[1].data.numeric;
61
62 if(node->params[2].type == skin_tag_parameter::DEFAULT)
63 w = info.screen()->getWidth() - x;
64 else
65 w = node->params[2].data.numeric;
66
67 if(node->params[3].type == skin_tag_parameter::DEFAULT)
68 h = info.screen()->getHeight() - y;
69 else
70 h = node->params[3].data.numeric;
71
72 size = QRectF(x, y, w, h);
73 displayed = true;
74 break;
75
76 case 'l':
77 /* Preloaded viewport */
78 break;
79
80 case 'i':
81 /* Custom UI Viewport */
82 break;
83
84 }
85 }
86}
87
88RBViewport::~RBViewport()
89{
90}
91
92QPainterPath RBViewport::shape() const
93{
94 QPainterPath retval;
95 retval.addRect(size);
96 return retval;
97}
98
99QRectF RBViewport::boundingRect() const
100{
101 return size;
102}
103
104void RBViewport::paint(QPainter *painter,
105 const QStyleOptionGraphicsItem *option, QWidget *widget)
106{
107 if(displayed)
108 painter->fillRect(size, Qt::red);
109}
110