diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-06-29 19:59:33 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-06-29 19:59:33 +0000 |
commit | 3ecef7d8015bffb875f5da07c7bd74a30447d3c8 (patch) | |
tree | 251238b40ccfab3fa0a48eea65a503baf5c4eb22 /utils | |
parent | f641fc62d89040d72c7908dcf0985f571ddb0531 (diff) | |
download | rockbox-3ecef7d8015bffb875f5da07c7bd74a30447d3c8.tar.gz rockbox-3ecef7d8015bffb875f5da07c7bd74a30447d3c8.zip |
Theme Editor: Implemented subline rendering, including conditional subline times
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27182 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r-- | utils/themeeditor/graphics/rbrenderinfo.cpp | 5 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbrenderinfo.h | 1 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreenode.cpp | 72 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreenode.h | 4 | ||||
-rw-r--r-- | utils/themeeditor/resources/deviceoptions | 1 |
5 files changed, 83 insertions, 0 deletions
diff --git a/utils/themeeditor/graphics/rbrenderinfo.cpp b/utils/themeeditor/graphics/rbrenderinfo.cpp index 289d730600..311603495c 100644 --- a/utils/themeeditor/graphics/rbrenderinfo.cpp +++ b/utils/themeeditor/graphics/rbrenderinfo.cpp | |||
@@ -29,6 +29,11 @@ RBRenderInfo::RBRenderInfo(ParseTreeModel* model, ProjectModel* project, | |||
29 | { | 29 | { |
30 | } | 30 | } |
31 | 31 | ||
32 | RBRenderInfo::RBRenderInfo() | ||
33 | : mProject(0), mSettings(0), mDevice(0), mScreen(0), mModel(0) | ||
34 | { | ||
35 | } | ||
36 | |||
32 | RBRenderInfo::RBRenderInfo(const RBRenderInfo &other) | 37 | RBRenderInfo::RBRenderInfo(const RBRenderInfo &other) |
33 | { | 38 | { |
34 | mProject = other.mProject; | 39 | mProject = other.mProject; |
diff --git a/utils/themeeditor/graphics/rbrenderinfo.h b/utils/themeeditor/graphics/rbrenderinfo.h index c65c4deafa..0e219383e2 100644 --- a/utils/themeeditor/graphics/rbrenderinfo.h +++ b/utils/themeeditor/graphics/rbrenderinfo.h | |||
@@ -35,6 +35,7 @@ public: | |||
35 | RBRenderInfo(ParseTreeModel* model, ProjectModel* project, | 35 | RBRenderInfo(ParseTreeModel* model, ProjectModel* project, |
36 | QMap<QString, QString>* settings, DeviceState* device, | 36 | QMap<QString, QString>* settings, DeviceState* device, |
37 | RBScreen* screen); | 37 | RBScreen* screen); |
38 | RBRenderInfo(); | ||
38 | RBRenderInfo(const RBRenderInfo& other); | 39 | RBRenderInfo(const RBRenderInfo& other); |
39 | virtual ~RBRenderInfo(); | 40 | virtual ~RBRenderInfo(); |
40 | 41 | ||
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index 1cf750904c..a2781d237d 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp | |||
@@ -532,6 +532,47 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport) | |||
532 | int child = evalTag(info, true, element->children_count).toInt(); | 532 | int child = evalTag(info, true, element->children_count).toInt(); |
533 | children[child]->render(info, viewport); | 533 | children[child]->render(info, viewport); |
534 | } | 534 | } |
535 | else if(element->type == SUBLINES) | ||
536 | { | ||
537 | /* First we build a list of the times for each branch */ | ||
538 | QList<double> times; | ||
539 | for(int i = 0; i < children.count() ; i++) | ||
540 | times.append(findBranchTime(children[i], info)); | ||
541 | |||
542 | /* Now we figure out which branch to select */ | ||
543 | double timeLeft = info.device()->data(QString("?pc")).toDouble(); | ||
544 | int branch = 0; | ||
545 | while(timeLeft > 0) | ||
546 | { | ||
547 | timeLeft -= times[branch]; | ||
548 | if(timeLeft >= 0) | ||
549 | branch++; | ||
550 | else | ||
551 | break; | ||
552 | if(branch >= times.count()) | ||
553 | branch = 0; | ||
554 | } | ||
555 | |||
556 | /* In case we end up on a disabled branch, skip ahead. If we find that | ||
557 | * all the branches are disabled, don't render anything | ||
558 | */ | ||
559 | int originalBranch = branch; | ||
560 | while(times[branch] == 0) | ||
561 | { | ||
562 | branch++; | ||
563 | if(branch == originalBranch) | ||
564 | { | ||
565 | branch = -1; | ||
566 | break; | ||
567 | } | ||
568 | if(branch >= times.count()) | ||
569 | branch = 0; | ||
570 | } | ||
571 | |||
572 | /* ...and finally render the selected branch */ | ||
573 | if(branch >= 0) | ||
574 | children[branch]->render(info, viewport); | ||
575 | } | ||
535 | } | 576 | } |
536 | 577 | ||
537 | bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) | 578 | bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) |
@@ -756,3 +797,34 @@ QVariant ParseTreeNode::evalTag(const RBRenderInfo& info, bool conditional, | |||
756 | return branches - 1; | 797 | return branches - 1; |
757 | } | 798 | } |
758 | } | 799 | } |
800 | |||
801 | double ParseTreeNode::findBranchTime(ParseTreeNode *branch, | ||
802 | const RBRenderInfo& info) | ||
803 | { | ||
804 | double retval = 2; | ||
805 | for(int i = 0; i < branch->children.count(); i++) | ||
806 | { | ||
807 | ParseTreeNode* current = branch->children[i]; | ||
808 | if(current->element->type == TAG) | ||
809 | { | ||
810 | if(current->element->tag->name[0] == 't' | ||
811 | && current->element->tag->name[1] == '\0') | ||
812 | { | ||
813 | retval = atof(current->element->params[0].data.text); | ||
814 | } | ||
815 | } | ||
816 | else if(current->element->type == CONDITIONAL) | ||
817 | { | ||
818 | retval = findConditionalTime(current, info); | ||
819 | } | ||
820 | } | ||
821 | return retval; | ||
822 | } | ||
823 | |||
824 | double ParseTreeNode::findConditionalTime(ParseTreeNode *conditional, | ||
825 | const RBRenderInfo& info) | ||
826 | { | ||
827 | int child = conditional->evalTag(info, true, | ||
828 | conditional->children.count()).toInt(); | ||
829 | return findBranchTime(conditional->children[child], info); | ||
830 | } | ||
diff --git a/utils/themeeditor/models/parsetreenode.h b/utils/themeeditor/models/parsetreenode.h index f85460d93d..7d7154aba8 100644 --- a/utils/themeeditor/models/parsetreenode.h +++ b/utils/themeeditor/models/parsetreenode.h | |||
@@ -62,6 +62,10 @@ public: | |||
62 | void render(const RBRenderInfo& info); | 62 | void render(const RBRenderInfo& info); |
63 | void render(const RBRenderInfo &info, RBViewport* viewport); | 63 | void render(const RBRenderInfo &info, RBViewport* viewport); |
64 | 64 | ||
65 | double findBranchTime(ParseTreeNode* branch, const RBRenderInfo& info); | ||
66 | double findConditionalTime(ParseTreeNode* conditional, | ||
67 | const RBRenderInfo& info); | ||
68 | |||
65 | private: | 69 | private: |
66 | 70 | ||
67 | bool execTag(const RBRenderInfo& info, RBViewport* viewport); | 71 | bool execTag(const RBRenderInfo& info, RBViewport* viewport); |
diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions index b9081c6253..5d3c5fcdaa 100644 --- a/utils/themeeditor/resources/deviceoptions +++ b/utils/themeeditor/resources/deviceoptions | |||
@@ -96,6 +96,7 @@ D3 ; Next File cd up x3 ; text ; / | |||
96 | [Playlist/Song Info] | 96 | [Playlist/Song Info] |
97 | px ; Percent Played ; spin(0,100) ; 50 | 97 | px ; Percent Played ; spin(0,100) ; 50 |
98 | pc ; Current Time In Song ; text ; 1:00 | 98 | pc ; Current Time In Song ; text ; 1:00 |
99 | ?pc ; Time In Song (Conditional) ; fspin(0,5000) ; 60 | ||
99 | pe ; Playlist Entries ; spin(0,1000) ; 20 | 100 | pe ; Playlist Entries ; spin(0,1000) ; 20 |
100 | pn ; Playlist Name ; text ; Current Playlist | 101 | pn ; Playlist Name ; text ; Current Playlist |
101 | pp ; Playlist Position ; spin(0,1000) ; 10 | 102 | pp ; Playlist Position ; spin(0,1000) ; 10 |