diff options
-rw-r--r-- | utils/themeeditor/graphics/rbtext.cpp | 9 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbtext.h | 4 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 90 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.h | 6 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreenode.cpp | 20 |
5 files changed, 126 insertions, 3 deletions
diff --git a/utils/themeeditor/graphics/rbtext.cpp b/utils/themeeditor/graphics/rbtext.cpp index 4666f9ae99..8de5d57897 100644 --- a/utils/themeeditor/graphics/rbtext.cpp +++ b/utils/themeeditor/graphics/rbtext.cpp | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <QPainter> | 24 | #include <QPainter> |
25 | 25 | ||
26 | RBText::RBText(QImage* image, int maxWidth, QGraphicsItem *parent) | 26 | RBText::RBText(QImage* image, int maxWidth, QGraphicsItem *parent) |
27 | :QGraphicsItem(parent), image(image), maxWidth(maxWidth) | 27 | :QGraphicsItem(parent), image(image), maxWidth(maxWidth), offset(0) |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
@@ -39,8 +39,13 @@ QRectF RBText::boundingRect() const | |||
39 | void RBText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | 39 | void RBText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
40 | QWidget *widget) | 40 | QWidget *widget) |
41 | { | 41 | { |
42 | /* Making sure the offset is within bounds */ | ||
43 | if(image->width() > maxWidth) | ||
44 | if(offset > image->width() - maxWidth) | ||
45 | offset = image->width() - maxWidth; | ||
46 | |||
42 | if(image->width() < maxWidth) | 47 | if(image->width() < maxWidth) |
43 | painter->drawImage(0, 0, *image, 0, 0, image->width(), image->height()); | 48 | painter->drawImage(0, 0, *image, 0, 0, image->width(), image->height()); |
44 | else | 49 | else |
45 | painter->drawImage(0, 0, *image, 0, 0, maxWidth, image->height()); | 50 | painter->drawImage(0, 0, *image, offset, 0, maxWidth, image->height()); |
46 | } | 51 | } |
diff --git a/utils/themeeditor/graphics/rbtext.h b/utils/themeeditor/graphics/rbtext.h index 936a809f6c..b4d9ae3c54 100644 --- a/utils/themeeditor/graphics/rbtext.h +++ b/utils/themeeditor/graphics/rbtext.h | |||
@@ -34,9 +34,13 @@ public: | |||
34 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | 34 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
35 | QWidget *widget); | 35 | QWidget *widget); |
36 | 36 | ||
37 | int realWidth(){ return image->width(); } | ||
38 | void setOffset(int offset){ this->offset = offset; } | ||
39 | |||
37 | private: | 40 | private: |
38 | QImage* image; | 41 | QImage* image; |
39 | int maxWidth; | 42 | int maxWidth; |
43 | int offset; | ||
40 | 44 | ||
41 | }; | 45 | }; |
42 | 46 | ||
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index 18029a57f6..3a239c7f35 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <QPainter> | 22 | #include <QPainter> |
23 | #include <QPainterPath> | 23 | #include <QPainterPath> |
24 | #include <cmath> | ||
24 | 25 | ||
25 | #include "rbviewport.h" | 26 | #include "rbviewport.h" |
26 | #include "rbscreen.h" | 27 | #include "rbscreen.h" |
@@ -29,12 +30,17 @@ | |||
29 | #include "tag_table.h" | 30 | #include "tag_table.h" |
30 | #include "skin_parser.h" | 31 | #include "skin_parser.h" |
31 | 32 | ||
33 | /* Pause at beginning/end of scroll */ | ||
34 | const double RBViewport::scrollPause = 0.5; | ||
35 | /* Pixels/second of text scrolling */ | ||
36 | const double RBViewport::scrollRate = 30; | ||
37 | |||
32 | RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | 38 | RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) |
33 | : QGraphicsItem(info.screen()), foreground(info.screen()->foreground()), | 39 | : QGraphicsItem(info.screen()), foreground(info.screen()->foreground()), |
34 | background(info.screen()->background()), textOffset(0,0), | 40 | background(info.screen()->background()), textOffset(0,0), |
35 | screen(info.screen()), textAlign(Left), showStatusBar(false), | 41 | screen(info.screen()), textAlign(Left), showStatusBar(false), |
36 | statusBarTexture(":/render/statusbar.png"), | 42 | statusBarTexture(":/render/statusbar.png"), |
37 | leftGraphic(0), centerGraphic(0), rightGraphic(0) | 43 | leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0) |
38 | { | 44 | { |
39 | if(!node->tag) | 45 | if(!node->tag) |
40 | { | 46 | { |
@@ -191,6 +197,8 @@ void RBViewport::newLine() | |||
191 | leftGraphic = 0; | 197 | leftGraphic = 0; |
192 | centerGraphic = 0; | 198 | centerGraphic = 0; |
193 | rightGraphic = 0; | 199 | rightGraphic = 0; |
200 | |||
201 | scrollTime = 0; | ||
194 | } | 202 | } |
195 | 203 | ||
196 | void RBViewport::write(QString text) | 204 | void RBViewport::write(QString text) |
@@ -287,6 +295,32 @@ void RBViewport::alignLeft() | |||
287 | 295 | ||
288 | leftGraphic = font->renderText(leftText, foreground, size.width(), this); | 296 | leftGraphic = font->renderText(leftText, foreground, size.width(), this); |
289 | leftGraphic->setPos(0, y); | 297 | leftGraphic->setPos(0, y); |
298 | |||
299 | /* Setting scroll position if necessary */ | ||
300 | int difference = leftGraphic->realWidth() | ||
301 | - leftGraphic->boundingRect().width(); | ||
302 | if(difference > 0) | ||
303 | { | ||
304 | /* Subtracting out complete cycles */ | ||
305 | double totalTime = 2 * scrollPause + difference / scrollRate; | ||
306 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); | ||
307 | |||
308 | /* Calculating the offset */ | ||
309 | if(scrollTime < scrollPause) | ||
310 | { | ||
311 | return; | ||
312 | } | ||
313 | else if(scrollTime < scrollPause + difference / scrollRate) | ||
314 | { | ||
315 | scrollTime -= scrollPause; | ||
316 | int offset = scrollRate * scrollTime; | ||
317 | leftGraphic->setOffset(offset); | ||
318 | } | ||
319 | else | ||
320 | { | ||
321 | leftGraphic->setOffset(difference); | ||
322 | } | ||
323 | } | ||
290 | } | 324 | } |
291 | 325 | ||
292 | void RBViewport::alignCenter() | 326 | void RBViewport::alignCenter() |
@@ -311,6 +345,33 @@ void RBViewport::alignCenter() | |||
311 | } | 345 | } |
312 | 346 | ||
313 | centerGraphic->setPos(x, y); | 347 | centerGraphic->setPos(x, y); |
348 | |||
349 | /* Setting scroll position if necessary */ | ||
350 | int difference = centerGraphic->realWidth() | ||
351 | - centerGraphic->boundingRect().width(); | ||
352 | if(difference > 0) | ||
353 | { | ||
354 | /* Subtracting out complete cycles */ | ||
355 | double totalTime = 2 * scrollPause + difference / scrollRate; | ||
356 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); | ||
357 | |||
358 | /* Calculating the offset */ | ||
359 | if(scrollTime < scrollPause) | ||
360 | { | ||
361 | return; | ||
362 | } | ||
363 | else if(scrollTime < scrollPause + difference / scrollRate) | ||
364 | { | ||
365 | scrollTime -= scrollPause; | ||
366 | int offset = scrollRate * scrollTime; | ||
367 | centerGraphic->setOffset(offset); | ||
368 | } | ||
369 | else | ||
370 | { | ||
371 | centerGraphic->setOffset(difference); | ||
372 | } | ||
373 | } | ||
374 | |||
314 | } | 375 | } |
315 | 376 | ||
316 | void RBViewport::alignRight() | 377 | void RBViewport::alignRight() |
@@ -329,5 +390,32 @@ void RBViewport::alignRight() | |||
329 | x = 0; | 390 | x = 0; |
330 | 391 | ||
331 | rightGraphic->setPos(x, y); | 392 | rightGraphic->setPos(x, y); |
393 | |||
394 | /* Setting scroll position if necessary */ | ||
395 | int difference = rightGraphic->realWidth() | ||
396 | - rightGraphic->boundingRect().width(); | ||
397 | if(difference > 0) | ||
398 | { | ||
399 | /* Subtracting out complete cycles */ | ||
400 | double totalTime = 2 * scrollPause + difference / scrollRate; | ||
401 | scrollTime -= totalTime * std::floor(scrollTime / totalTime); | ||
402 | |||
403 | /* Calculating the offset */ | ||
404 | if(scrollTime < scrollPause) | ||
405 | { | ||
406 | return; | ||
407 | } | ||
408 | else if(scrollTime < scrollPause + difference / scrollRate) | ||
409 | { | ||
410 | scrollTime -= scrollPause; | ||
411 | int offset = scrollRate * scrollTime; | ||
412 | rightGraphic->setOffset(offset); | ||
413 | } | ||
414 | else | ||
415 | { | ||
416 | rightGraphic->setOffset(difference); | ||
417 | } | ||
418 | } | ||
419 | |||
332 | } | 420 | } |
333 | 421 | ||
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index c557632a40..eeeb7191ef 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h | |||
@@ -40,6 +40,9 @@ public: | |||
40 | Right | 40 | Right |
41 | }; | 41 | }; |
42 | 42 | ||
43 | static const double scrollRate; | ||
44 | static const double scrollPause; | ||
45 | |||
43 | RBViewport(skin_element* node, const RBRenderInfo& info); | 46 | RBViewport(skin_element* node, const RBRenderInfo& info); |
44 | virtual ~RBViewport(); | 47 | virtual ~RBViewport(); |
45 | 48 | ||
@@ -66,6 +69,7 @@ public: | |||
66 | alignRight(); | 69 | alignRight(); |
67 | alignCenter(); | 70 | alignCenter(); |
68 | } | 71 | } |
72 | void scrollText(double time){ scrollTime = time; } | ||
69 | 73 | ||
70 | void enableStatusBar(){ showStatusBar = true; } | 74 | void enableStatusBar(){ showStatusBar = true; } |
71 | 75 | ||
@@ -101,6 +105,8 @@ private: | |||
101 | RBText* leftGraphic; | 105 | RBText* leftGraphic; |
102 | RBText* centerGraphic; | 106 | RBText* centerGraphic; |
103 | RBText* rightGraphic; | 107 | RBText* rightGraphic; |
108 | |||
109 | double scrollTime; | ||
104 | }; | 110 | }; |
105 | 111 | ||
106 | #endif // RBVIEWPORT_H | 112 | #endif // RBVIEWPORT_H |
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index b2b5fbbdb4..e5eb9df9b3 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "rbprogressbar.h" | 29 | #include "rbprogressbar.h" |
30 | 30 | ||
31 | #include <iostream> | 31 | #include <iostream> |
32 | #include <cmath> | ||
32 | 33 | ||
33 | int ParseTreeNode::openConditionals = 0; | 34 | int ParseTreeNode::openConditionals = 0; |
34 | bool ParseTreeNode::breakFlag = false; | 35 | bool ParseTreeNode::breakFlag = false; |
@@ -552,8 +553,16 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport, | |||
552 | for(int i = 0; i < children.count() ; i++) | 553 | for(int i = 0; i < children.count() ; i++) |
553 | times.append(findBranchTime(children[i], info)); | 554 | times.append(findBranchTime(children[i], info)); |
554 | 555 | ||
556 | double totalTime = 0; | ||
557 | for(int i = 0; i < children.count(); i++) | ||
558 | totalTime += times[i]; | ||
559 | |||
555 | /* Now we figure out which branch to select */ | 560 | /* Now we figure out which branch to select */ |
556 | double timeLeft = info.device()->data(QString("simtime")).toDouble(); | 561 | double timeLeft = info.device()->data(QString("simtime")).toDouble(); |
562 | |||
563 | /* Skipping any full cycles */ | ||
564 | timeLeft -= totalTime * std::floor(timeLeft / totalTime); | ||
565 | |||
557 | int branch = 0; | 566 | int branch = 0; |
558 | while(timeLeft > 0) | 567 | while(timeLeft > 0) |
559 | { | 568 | { |
@@ -654,6 +663,17 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) | |||
654 | 663 | ||
655 | return false; | 664 | return false; |
656 | 665 | ||
666 | case 's': | ||
667 | switch(element->tag->name[1]) | ||
668 | { | ||
669 | case '\0': | ||
670 | /* %s */ | ||
671 | viewport->scrollText(info.device()->data("simtime").toDouble()); | ||
672 | return true; | ||
673 | } | ||
674 | |||
675 | return false; | ||
676 | |||
657 | case 'w': | 677 | case 'w': |
658 | switch(element->tag->name[1]) | 678 | switch(element->tag->name[1]) |
659 | { | 679 | { |