From cc6d0278ea8893cfae90342cc6795dd68b958219 Mon Sep 17 00:00:00 2001 From: bieber Date: Thu, 1 Jul 2010 21:49:55 +0000 Subject: [PATCH] Theme Editor: Fixed line numbering bug in parser. Implemented playlist display in renderer: playlist will use info for next track for all tracks other than the current track git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27227 a1c6a512-1295-4272-9138-f99709370657 --- lib/skin_parser/skin_parser.c | 2 + utils/themeeditor/graphics/rbviewport.cpp | 62 ++++++++++++++++++++++++++++++ utils/themeeditor/graphics/rbviewport.h | 3 ++ utils/themeeditor/models/parsetreenode.cpp | 7 ++++ utils/themeeditor/resources/deviceoptions | 1 + 5 files changed, 75 insertions(+) diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 2d439710d..5e4ef4907 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -463,6 +463,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) cursor++; if (*cursor) cursor++; + skin_line++; *document = cursor; return 1; } @@ -628,6 +629,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) cursor++; if (*cursor) cursor++; + skin_line++; } *document = cursor; diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index d4a8ede09..70c50f21c 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp @@ -183,6 +183,68 @@ void RBViewport::write(QString text) } } +void RBViewport::showPlaylist(const RBRenderInfo &info, int start, + skin_element *id3, skin_element *noId3) +{ + /* Determining whether ID3 info is available */ + skin_element* root = info.device()->data("id3available").toBool() + ? id3 : noId3; + + /* The line will be a linked list */ + root = root->children[0]; + + int song = start + info.device()->data("pp").toInt(); + int numSongs = info.device()->data("pe").toInt(); + + while(song <= numSongs && textOffset.y() + lineHeight < size.height()) + { + skin_element* current = root; + while(current) + { + + if(current->type == TEXT) + { + write(QString((char*)current->data)); + } + + if(current->type == TAG) + { + QString tag(current->tag->name); + if(tag == "pp") + { + write(QString::number(song)); + } + else if(tag == "pt") + { + write(QObject::tr("00:00")); + } + else if(tag[0] == 'i' || tag[0] == 'f') + { + if(song == info.device()->data("pp").toInt()) + { + write(info.device()->data(tag).toString()); + } + else + { + /* If we're not on the current track, use the next + * track info + */ + if(tag[0] == 'i') + tag = QString("I") + tag.right(1); + else + tag = QString("F") + tag.right(1); + write(info.device()->data(tag).toString()); + } + } + } + + current = current->next; + } + newLine(); + song++; + } +} + void RBViewport::alignLeft() { int y = textOffset.y(); diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index 2aff31587..70f52232a 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h @@ -59,6 +59,9 @@ public: void enableStatusBar(){ showStatusBar = true; } + void showPlaylist(const RBRenderInfo& info, int start, skin_element* id3, + skin_element* noId3); + private: void alignLeft(); diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index d10bb0893..e61c6552e 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp @@ -765,6 +765,13 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) Qt::black)); return true; + case 'p': + /* %Vp */ + viewport->showPlaylist(info, element->params[0].data.numeric, + element->params[1].data.code, + element->params[2].data.code); + return true; + case 'I': /* %VI */ info.screen()->makeCustomUI(element->params[0].data.text); diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions index 10a1a89d7..5417ca6b2 100644 --- a/utils/themeeditor/resources/deviceoptions +++ b/utils/themeeditor/resources/deviceoptions @@ -114,6 +114,7 @@ ra ; Autoscore ; spin(0,10) ; 7 ?C ; Album Art Available ; check ; true artwidth ; Album Art Width ; spin(0,500) ; 100 artheight; Album Art Height ; spin(0,500) ; 100 +id3available ; ID3 Info Available ; check ; true [Hardware Status] bl ; Battery Level (-1 for unknown) ; spin(-1,100) ; 50 -- 2.11.4.GIT