diff options
| author | Robert Bieber <robby@bieberphoto.com> | 2010-07-07 06:50:30 +0000 |
|---|---|---|
| committer | Robert Bieber <robby@bieberphoto.com> | 2010-07-07 06:50:30 +0000 |
| commit | 3214e3710ad0d73c1b775b8af002763cbb42382c (patch) | |
| tree | 67355953e4e3079d0a3ab4ff688dfa6d413d6f36 /utils/themeeditor/graphics/rbviewport.cpp | |
| parent | ce5ee193d41061a6b8c9a2b87dc8a43303f82ab9 (diff) | |
| download | rockbox-3214e3710ad0d73c1b775b8af002763cbb42382c.zip rockbox-3214e3710ad0d73c1b775b8af002763cbb42382c.tar.gz rockbox-3214e3710ad0d73c1b775b8af002763cbb42382c.tar.bz2 rockbox-3214e3710ad0d73c1b775b8af002763cbb42382c.tar.xz | |
Theme Editor: Made all lines of text render as a single graphic, viewport size limits now enforced on text width
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27327 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/graphics/rbviewport.cpp')
| -rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index 3b8a02d..77fe346 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp @@ -33,7 +33,8 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) : QGraphicsItem(info.screen()), foreground(info.screen()->foreground()), background(info.screen()->background()), textOffset(0,0), screen(info.screen()), textAlign(Left), showStatusBar(false), - statusBarTexture(":/render/statusbar.png") + statusBarTexture(":/render/statusbar.png"), + leftGraphic(0), centerGraphic(0), rightGraphic(0) { if(!node->tag) { @@ -173,26 +174,31 @@ void RBViewport::newLine() textOffset.setY(textOffset.y() + lineHeight); textOffset.setX(0); textAlign = Left; + leftText.clear(); rightText.clear(); centerText.clear(); + + leftGraphic = 0; + centerGraphic = 0; + rightGraphic = 0; } void RBViewport::write(QString text) { if(textAlign == Left) { - leftText.append(font->renderText(text, foreground, this)); + leftText.append(text); alignLeft(); } else if(textAlign == Center) { - centerText.append(font->renderText(text, foreground, this)); + centerText.append(text); alignCenter(); } else if(textAlign == Right) { - rightText.append(font->renderText(text, foreground, this)); + rightText.append(text); alignRight(); } } @@ -269,50 +275,53 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start, void RBViewport::alignLeft() { int y = textOffset.y(); - int x = 0; - for(int i = 0; i < leftText.count(); i++) - { - leftText[i]->setPos(x, y); - x += leftText[i]->boundingRect().width(); - } + if(leftGraphic) + delete leftGraphic; + + leftGraphic = font->renderText(leftText, foreground, size.width(), this); + leftGraphic->setPos(0, y); } void RBViewport::alignCenter() { int y = textOffset.y(); int x = 0; - int width = 0; - for(int i = 0; i < centerText.count(); i++) - width += centerText[i]->boundingRect().width(); + if(centerGraphic) + delete centerGraphic; - x = (size.width() - width) / 2; + centerGraphic = font->renderText(centerText, foreground, size.width(), + this); - for(int i = 0; i < centerText.count(); i++) + if(centerGraphic->boundingRect().width() < size.width()) + { + x = size.width() - centerGraphic->boundingRect().width(); + x /= 2; + } + else { - centerText[i]->setPos(x, y); - x += centerText[i]->boundingRect().width(); + x = 0; } + + centerGraphic->setPos(x, y); } void RBViewport::alignRight() { - int y = textOffset.y(); int x = 0; - int width = 0; - for(int i = 0; i < rightText.count(); i++) - width += rightText[i]->boundingRect().width(); + if(rightGraphic) + delete rightGraphic; - x = size.width() - width; + rightGraphic = font->renderText(rightText, foreground, size.width(), this); - for(int i = 0; i < rightText.count(); i++) - { - rightText[i]->setPos(x, y); - x += rightText[i]->boundingRect().width(); - } + if(rightGraphic->boundingRect().width() < size.width()) + x = size.width() - rightGraphic->boundingRect().width(); + else + x = 0; + rightGraphic->setPos(x, y); } |