summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics/rbviewport.cpp
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-25 05:14:13 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-25 05:14:13 +0000
commit273b9d60502eb5b6c13cc773403fd51d9c7adf75 (patch)
treedd99f1e4afc17829210643744d1817fba632423c /utils/themeeditor/graphics/rbviewport.cpp
parent691d049177d646861a52e96146ad880d9dc18bbe (diff)
downloadrockbox-273b9d60502eb5b6c13cc773403fd51d9c7adf75.zip
rockbox-273b9d60502eb5b6c13cc773403fd51d9c7adf75.tar.gz
rockbox-273b9d60502eb5b6c13cc773403fd51d9c7adf75.tar.bz2
rockbox-273b9d60502eb5b6c13cc773403fd51d9c7adf75.tar.xz
Theme Editor: Fixed some compiler warnings and a segfault. Got some basic text rendering working (only with plaintext elements, no font support yet) as well as Viewport background color support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27126 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/graphics/rbviewport.cpp')
-rw-r--r--utils/themeeditor/graphics/rbviewport.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp
index c5b88b3..03a7604 100644
--- a/utils/themeeditor/graphics/rbviewport.cpp
+++ b/utils/themeeditor/graphics/rbviewport.cpp
@@ -30,7 +30,10 @@
#include "skin_parser.h"
RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
- : QGraphicsItem(info.screen())
+ : QGraphicsItem(info.screen()), font(info.screen()->getFont(0)),
+ foreground(info.screen()->foreground()),
+ background(info.screen()->background()), textOffset(0,0),
+ screen(info.screen())
{
if(!node->tag)
{
@@ -51,7 +54,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
}
else
{
- int param;
+ int param = 0;
QString ident;
int x,y,w,h;
/* Rendering one of the other types of viewport */
@@ -102,6 +105,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
setPos(x, y);
size = QRectF(0, 0, w, h);
+
}
}
@@ -124,13 +128,29 @@ QRectF RBViewport::boundingRect() const
void RBViewport::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget)
{
+ if(!screen->hasBackdrop() && background != screen->background())
+ {
+ painter->fillRect(size, QBrush(background));
+ }
+
painter->setBrush(Qt::NoBrush);
painter->setPen(customUI ? Qt::blue : Qt::red);
painter->drawRect(size);
}
-/* Called at the end of a logical line */
-void RBViewport::newline()
+void RBViewport::newLine()
{
+ if(textOffset.x() > 0)
+ {
+ textOffset.setY(textOffset.y() + lineHeight);
+ textOffset.setX(0);
+ }
+}
+void RBViewport::write(QString text)
+{
+ QGraphicsItem* graphic = font->renderText(text, foreground, this);
+ graphic->setPos(textOffset.x(), textOffset.y());
+ textOffset.setX(textOffset.x() + graphic->boundingRect().width());
+ lineHeight = font->lineHeight();
}