9d949670ee8038e31c2c3bfef3c2ee653f78c5d1
1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Robert Bieber
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include <QPainterPath>
25 #include "rbviewport.h"
27 #include "rbrenderinfo.h"
28 #include "parsetreemodel.h"
29 #include "tag_table.h"
30 #include "skin_parser.h"
32 RBViewport::RBViewport(skin_element
* node
, const RBRenderInfo
& info
)
33 : QGraphicsItem(info
.screen())
37 /* Default viewport takes up the entire screen */
38 size
= QRectF(0, 0, info
.screen()->getWidth(),
39 info
.screen()->getHeight());
41 if(info
.model()->rowCount(QModelIndex()) > 1)
43 /* If there is more than one viewport in the document */
56 /* Rendering one of the other types of viewport */
57 switch(node
->tag
->name
[1])
65 /* A preloaded viewport definition */
66 ident
= node
->params
[0].data
.text
;
69 info
.screen()->loadViewport(ident
, this);
74 /* Custom UI Viewport */
77 if(node
->params
[0].type
== skin_tag_parameter::DEFAULT
)
84 info
.screen()->loadViewport(ident
, this);
88 /* Now we grab the info common to all viewports */
89 x
= node
->params
[param
++].data
.numeric
;
90 y
= node
->params
[param
++].data
.numeric
;
92 if(node
->params
[param
].type
== skin_tag_parameter::DEFAULT
)
93 w
= info
.screen()->getWidth() - x
;
95 w
= node
->params
[param
].data
.numeric
;
97 if(node
->params
[++param
].type
== skin_tag_parameter::DEFAULT
)
98 h
= info
.screen()->getHeight() - y
;
100 h
= node
->params
[param
].data
.numeric
;
102 size
= QRectF(x
, y
, w
, h
);
106 RBViewport::~RBViewport()
110 QPainterPath
RBViewport::shape() const
113 retval
.addRect(size
);
117 QRectF
RBViewport::boundingRect() const
122 void RBViewport::paint(QPainter
*painter
,
123 const QStyleOptionGraphicsItem
*option
, QWidget
*widget
)
125 QColor color
= customUI
? Qt::blue
: Qt::red
;
126 painter
->fillRect(size
, color
);
129 /* Called at the end of a logical line */
130 void RBViewport::newline()