diff options
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 3b8a02dd87..77fe346090 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) | |||
33 | : QGraphicsItem(info.screen()), foreground(info.screen()->foreground()), | 33 | : QGraphicsItem(info.screen()), foreground(info.screen()->foreground()), |
34 | background(info.screen()->background()), textOffset(0,0), | 34 | background(info.screen()->background()), textOffset(0,0), |
35 | screen(info.screen()), textAlign(Left), showStatusBar(false), | 35 | screen(info.screen()), textAlign(Left), showStatusBar(false), |
36 | statusBarTexture(":/render/statusbar.png") | 36 | statusBarTexture(":/render/statusbar.png"), |
37 | leftGraphic(0), centerGraphic(0), rightGraphic(0) | ||
37 | { | 38 | { |
38 | if(!node->tag) | 39 | if(!node->tag) |
39 | { | 40 | { |
@@ -173,26 +174,31 @@ void RBViewport::newLine() | |||
173 | textOffset.setY(textOffset.y() + lineHeight); | 174 | textOffset.setY(textOffset.y() + lineHeight); |
174 | textOffset.setX(0); | 175 | textOffset.setX(0); |
175 | textAlign = Left; | 176 | textAlign = Left; |
177 | |||
176 | leftText.clear(); | 178 | leftText.clear(); |
177 | rightText.clear(); | 179 | rightText.clear(); |
178 | centerText.clear(); | 180 | centerText.clear(); |
181 | |||
182 | leftGraphic = 0; | ||
183 | centerGraphic = 0; | ||
184 | rightGraphic = 0; | ||
179 | } | 185 | } |
180 | 186 | ||
181 | void RBViewport::write(QString text) | 187 | void RBViewport::write(QString text) |
182 | { | 188 | { |
183 | if(textAlign == Left) | 189 | if(textAlign == Left) |
184 | { | 190 | { |
185 | leftText.append(font->renderText(text, foreground, this)); | 191 | leftText.append(text); |
186 | alignLeft(); | 192 | alignLeft(); |
187 | } | 193 | } |
188 | else if(textAlign == Center) | 194 | else if(textAlign == Center) |
189 | { | 195 | { |
190 | centerText.append(font->renderText(text, foreground, this)); | 196 | centerText.append(text); |
191 | alignCenter(); | 197 | alignCenter(); |
192 | } | 198 | } |
193 | else if(textAlign == Right) | 199 | else if(textAlign == Right) |
194 | { | 200 | { |
195 | rightText.append(font->renderText(text, foreground, this)); | 201 | rightText.append(text); |
196 | alignRight(); | 202 | alignRight(); |
197 | } | 203 | } |
198 | } | 204 | } |
@@ -269,50 +275,53 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start, | |||
269 | void RBViewport::alignLeft() | 275 | void RBViewport::alignLeft() |
270 | { | 276 | { |
271 | int y = textOffset.y(); | 277 | int y = textOffset.y(); |
272 | int x = 0; | ||
273 | 278 | ||
274 | for(int i = 0; i < leftText.count(); i++) | 279 | if(leftGraphic) |
275 | { | 280 | delete leftGraphic; |
276 | leftText[i]->setPos(x, y); | 281 | |
277 | x += leftText[i]->boundingRect().width(); | 282 | leftGraphic = font->renderText(leftText, foreground, size.width(), this); |
278 | } | 283 | leftGraphic->setPos(0, y); |
279 | } | 284 | } |
280 | 285 | ||
281 | void RBViewport::alignCenter() | 286 | void RBViewport::alignCenter() |
282 | { | 287 | { |
283 | int y = textOffset.y(); | 288 | int y = textOffset.y(); |
284 | int x = 0; | 289 | int x = 0; |
285 | int width = 0; | ||
286 | 290 | ||
287 | for(int i = 0; i < centerText.count(); i++) | 291 | if(centerGraphic) |
288 | width += centerText[i]->boundingRect().width(); | 292 | delete centerGraphic; |
289 | 293 | ||
290 | x = (size.width() - width) / 2; | 294 | centerGraphic = font->renderText(centerText, foreground, size.width(), |
295 | this); | ||
291 | 296 | ||
292 | for(int i = 0; i < centerText.count(); i++) | 297 | if(centerGraphic->boundingRect().width() < size.width()) |
298 | { | ||
299 | x = size.width() - centerGraphic->boundingRect().width(); | ||
300 | x /= 2; | ||
301 | } | ||
302 | else | ||
293 | { | 303 | { |
294 | centerText[i]->setPos(x, y); | 304 | x = 0; |
295 | x += centerText[i]->boundingRect().width(); | ||
296 | } | 305 | } |
306 | |||
307 | centerGraphic->setPos(x, y); | ||
297 | } | 308 | } |
298 | 309 | ||
299 | void RBViewport::alignRight() | 310 | void RBViewport::alignRight() |
300 | { | 311 | { |
301 | |||
302 | int y = textOffset.y(); | 312 | int y = textOffset.y(); |
303 | int x = 0; | 313 | int x = 0; |
304 | int width = 0; | ||
305 | 314 | ||
306 | for(int i = 0; i < rightText.count(); i++) | 315 | if(rightGraphic) |
307 | width += rightText[i]->boundingRect().width(); | 316 | delete rightGraphic; |
308 | 317 | ||
309 | x = size.width() - width; | 318 | rightGraphic = font->renderText(rightText, foreground, size.width(), this); |
310 | 319 | ||
311 | for(int i = 0; i < rightText.count(); i++) | 320 | if(rightGraphic->boundingRect().width() < size.width()) |
312 | { | 321 | x = size.width() - rightGraphic->boundingRect().width(); |
313 | rightText[i]->setPos(x, y); | 322 | else |
314 | x += rightText[i]->boundingRect().width(); | 323 | x = 0; |
315 | } | ||
316 | 324 | ||
325 | rightGraphic->setPos(x, y); | ||
317 | } | 326 | } |
318 | 327 | ||