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());
42 if(info
.model()->rowCount(QModelIndex()) > 1)
44 /* If there is more than one viewport in the document */
57 /* Rendering one of the other types of viewport */
58 switch(node
->tag
->name
[1])
66 /* A preloaded viewport definition */
67 ident
= node
->params
[0].data
.text
;
70 info
.screen()->loadViewport(ident
, this);
75 /* Custom UI Viewport */
78 if(node
->params
[0].type
== skin_tag_parameter::DEFAULT
)
85 info
.screen()->loadViewport(ident
, this);
89 /* Now we grab the info common to all viewports */
90 x
= node
->params
[param
++].data
.numeric
;
91 y
= node
->params
[param
++].data
.numeric
;
93 if(node
->params
[param
].type
== skin_tag_parameter::DEFAULT
)
94 w
= info
.screen()->getWidth() - x
;
96 w
= node
->params
[param
].data
.numeric
;
98 if(node
->params
[++param
].type
== skin_tag_parameter::DEFAULT
)
99 h
= info
.screen()->getHeight() - y
;
101 h
= node
->params
[param
].data
.numeric
;
103 size
= QRectF(x
, y
, w
, h
);
107 RBViewport::~RBViewport()
111 QPainterPath
RBViewport::shape() const
114 retval
.addRect(size
);
118 QRectF
RBViewport::boundingRect() const
123 void RBViewport::paint(QPainter
*painter
,
124 const QStyleOptionGraphicsItem
*option
, QWidget
*widget
)
126 painter
->setBrush(Qt::NoBrush
);
127 painter
->setPen(customUI
? Qt::blue
: Qt::red
);
128 painter
->drawRect(size
);
131 /* Called at the end of a logical line */
132 void RBViewport::newline()