diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-07-15 06:24:11 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-07-15 06:24:11 +0000 |
commit | 15488a00eae8d10249015b88e4b7bdc47365b854 (patch) | |
tree | 62439c56fa8a926b148c7a3cc843a0c60f3aac21 /utils/themeeditor | |
parent | 387af97a26105fce79e6a8726752cf183d40939e (diff) | |
download | rockbox-15488a00eae8d10249015b88e4b7bdc47365b854.tar.gz rockbox-15488a00eae8d10249015b88e4b7bdc47365b854.zip |
Theme Editor: Committed FS#11477 to add a DECIMAL parameter type in the parser and adapt the Theme Editor to accomodate the change by Johnathan Gordon. Fixed bug in the parser caused by the patch (error was thrown on zero value) and adapted tag rendering for new format
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27426 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor')
-rw-r--r-- | utils/themeeditor/graphics/rbprogressbar.cpp | 8 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 10 | ||||
-rw-r--r-- | utils/themeeditor/gui/devicestate.cpp | 6 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreemodel.cpp | 4 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreenode.cpp | 63 |
5 files changed, 53 insertions, 38 deletions
diff --git a/utils/themeeditor/graphics/rbprogressbar.cpp b/utils/themeeditor/graphics/rbprogressbar.cpp index 027520f4da..206a835252 100644 --- a/utils/themeeditor/graphics/rbprogressbar.cpp +++ b/utils/themeeditor/graphics/rbprogressbar.cpp | |||
@@ -41,22 +41,22 @@ RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info, | |||
41 | 41 | ||
42 | if(paramCount > 0 && params[0].type != skin_tag_parameter::DEFAULT) | 42 | if(paramCount > 0 && params[0].type != skin_tag_parameter::DEFAULT) |
43 | { | 43 | { |
44 | x = params[0].data.numeric; | 44 | x = params[0].data.number; |
45 | } | 45 | } |
46 | 46 | ||
47 | if(paramCount > 1 && params[1].type != skin_tag_parameter::DEFAULT) | 47 | if(paramCount > 1 && params[1].type != skin_tag_parameter::DEFAULT) |
48 | { | 48 | { |
49 | y = params[1].data.numeric; | 49 | y = params[1].data.number; |
50 | } | 50 | } |
51 | 51 | ||
52 | if(paramCount > 2 && params[2].type != skin_tag_parameter::DEFAULT) | 52 | if(paramCount > 2 && params[2].type != skin_tag_parameter::DEFAULT) |
53 | { | 53 | { |
54 | w = params[2].data.numeric; | 54 | w = params[2].data.number; |
55 | } | 55 | } |
56 | 56 | ||
57 | if(paramCount > 3 && params[3].type != skin_tag_parameter::DEFAULT) | 57 | if(paramCount > 3 && params[3].type != skin_tag_parameter::DEFAULT) |
58 | { | 58 | { |
59 | h = params[3].data.numeric; | 59 | h = params[3].data.number; |
60 | } | 60 | } |
61 | 61 | ||
62 | if(paramCount > 4 && params[4].type != skin_tag_parameter::DEFAULT) | 62 | if(paramCount > 4 && params[4].type != skin_tag_parameter::DEFAULT) |
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index 96d7e8b276..e9c58eb6fb 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp | |||
@@ -97,24 +97,24 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | |||
97 | break; | 97 | break; |
98 | } | 98 | } |
99 | /* Now we grab the info common to all viewports */ | 99 | /* Now we grab the info common to all viewports */ |
100 | x = node->params[param++].data.numeric; | 100 | x = node->params[param++].data.number; |
101 | if(x < 0) | 101 | if(x < 0) |
102 | x = info.screen()->boundingRect().right() + x; | 102 | x = info.screen()->boundingRect().right() + x; |
103 | y = node->params[param++].data.numeric; | 103 | y = node->params[param++].data.number; |
104 | if(y < 0) | 104 | if(y < 0) |
105 | y = info.screen()->boundingRect().bottom() + y; | 105 | y = info.screen()->boundingRect().bottom() + y; |
106 | 106 | ||
107 | if(node->params[param].type == skin_tag_parameter::DEFAULT) | 107 | if(node->params[param].type == skin_tag_parameter::DEFAULT) |
108 | w = info.screen()->getWidth() - x; | 108 | w = info.screen()->getWidth() - x; |
109 | else | 109 | else |
110 | w = node->params[param].data.numeric; | 110 | w = node->params[param].data.number; |
111 | if(w < 0) | 111 | if(w < 0) |
112 | w = info.screen()->getWidth() + w - x; | 112 | w = info.screen()->getWidth() + w - x; |
113 | 113 | ||
114 | if(node->params[++param].type == skin_tag_parameter::DEFAULT) | 114 | if(node->params[++param].type == skin_tag_parameter::DEFAULT) |
115 | h = info.screen()->getHeight() - y; | 115 | h = info.screen()->getHeight() - y; |
116 | else | 116 | else |
117 | h = node->params[param].data.numeric; | 117 | h = node->params[param].data.number; |
118 | if(h < 0) | 118 | if(h < 0) |
119 | h = info.screen()->getHeight() + h - y; | 119 | h = info.screen()->getHeight() + h - y; |
120 | 120 | ||
@@ -128,7 +128,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | |||
128 | if(node->params[++param].type == skin_tag_parameter::DEFAULT) | 128 | if(node->params[++param].type == skin_tag_parameter::DEFAULT) |
129 | font = screen->getFont(1); | 129 | font = screen->getFont(1); |
130 | else | 130 | else |
131 | font = screen->getFont(node->params[param].data.numeric); | 131 | font = screen->getFont(node->params[param].data.number); |
132 | 132 | ||
133 | setPos(x, y); | 133 | setPos(x, y); |
134 | size = QRectF(0, 0, w, h); | 134 | size = QRectF(0, 0, w, h); |
diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp index 89985bf730..e766a64835 100644 --- a/utils/themeeditor/gui/devicestate.cpp +++ b/utils/themeeditor/gui/devicestate.cpp | |||
@@ -225,7 +225,7 @@ QVariant DeviceState::data(QString tag, int paramCount, | |||
225 | QString path = tag[0].isLower() | 225 | QString path = tag[0].isLower() |
226 | ? data("file").toString() : data("nextfile").toString(); | 226 | ? data("file").toString() : data("nextfile").toString(); |
227 | if(paramCount > 0) | 227 | if(paramCount > 0) |
228 | return directory(path, params[0].data.numeric); | 228 | return directory(path, params[0].data.number); |
229 | else | 229 | else |
230 | return QVariant(); | 230 | return QVariant(); |
231 | } | 231 | } |
@@ -255,7 +255,7 @@ QVariant DeviceState::data(QString tag, int paramCount, | |||
255 | else if(tag == "pS") | 255 | else if(tag == "pS") |
256 | { | 256 | { |
257 | double threshhold = paramCount > 0 | 257 | double threshhold = paramCount > 0 |
258 | ? std::atof(params[0].data.text) : 10; | 258 | ? params[0].data.number / 10. : 10; |
259 | if(data("?pc").toDouble() <= threshhold) | 259 | if(data("?pc").toDouble() <= threshhold) |
260 | return true; | 260 | return true; |
261 | else | 261 | else |
@@ -264,7 +264,7 @@ QVariant DeviceState::data(QString tag, int paramCount, | |||
264 | else if(tag == "pE") | 264 | else if(tag == "pE") |
265 | { | 265 | { |
266 | double threshhold = paramCount > 0 | 266 | double threshhold = paramCount > 0 |
267 | ? std::atof(params[0].data.text) : 10; | 267 | ? params[0].data.number / 10. : 10; |
268 | if(data("?pt").toDouble() - data("?pc").toDouble() <= threshhold) | 268 | if(data("?pt").toDouble() - data("?pc").toDouble() <= threshhold) |
269 | return true; | 269 | return true; |
270 | else | 270 | else |
diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp index a04a0d9202..66c96213ab 100644 --- a/utils/themeeditor/models/parsetreemodel.cpp +++ b/utils/themeeditor/models/parsetreemodel.cpp | |||
@@ -246,8 +246,8 @@ bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value, | |||
246 | if(!value.canConvert(QVariant::Int)) | 246 | if(!value.canConvert(QVariant::Int)) |
247 | return false; | 247 | return false; |
248 | 248 | ||
249 | param->type = skin_tag_parameter::NUMERIC; | 249 | param->type = skin_tag_parameter::INTEGER; |
250 | param->data.numeric = value.toInt(); | 250 | param->data.number = value.toInt(); |
251 | } | 251 | } |
252 | else | 252 | else |
253 | { | 253 | { |
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index 1b894b7c33..fbb7b9279f 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp | |||
@@ -246,8 +246,12 @@ QString ParseTreeNode::genCode() const | |||
246 | } | 246 | } |
247 | break; | 247 | break; |
248 | 248 | ||
249 | case skin_tag_parameter::NUMERIC: | 249 | case skin_tag_parameter::INTEGER: |
250 | buffer.append(QString::number(param->data.numeric, 10)); | 250 | buffer.append(QString::number(param->data.number, 10)); |
251 | break; | ||
252 | |||
253 | case skin_tag_parameter::DECIMAL: | ||
254 | buffer.append(QString::number(param->data.number / 10., 'f', 1)); | ||
251 | break; | 255 | break; |
252 | 256 | ||
253 | case skin_tag_parameter::DEFAULT: | 257 | case skin_tag_parameter::DEFAULT: |
@@ -318,8 +322,8 @@ int ParseTreeNode::genHash() const | |||
318 | case skin_tag_parameter::CODE: | 322 | case skin_tag_parameter::CODE: |
319 | break; | 323 | break; |
320 | 324 | ||
321 | case skin_tag_parameter::NUMERIC: | 325 | case skin_tag_parameter::INTEGER: |
322 | hash += param->data.numeric * (param->data.numeric / 4); | 326 | hash += param->data.number * (param->data.number / 4); |
323 | break; | 327 | break; |
324 | 328 | ||
325 | case skin_tag_parameter::STRING: | 329 | case skin_tag_parameter::STRING: |
@@ -331,6 +335,10 @@ int ParseTreeNode::genHash() const | |||
331 | hash += param->data.text[i]; | 335 | hash += param->data.text[i]; |
332 | } | 336 | } |
333 | break; | 337 | break; |
338 | |||
339 | case skin_tag_parameter::DECIMAL: | ||
340 | hash += param->data.number; | ||
341 | break; | ||
334 | } | 342 | } |
335 | } | 343 | } |
336 | 344 | ||
@@ -396,8 +404,11 @@ QVariant ParseTreeNode::data(int column) const | |||
396 | case skin_tag_parameter::STRING: | 404 | case skin_tag_parameter::STRING: |
397 | return QObject::tr("String"); | 405 | return QObject::tr("String"); |
398 | 406 | ||
399 | case skin_tag_parameter::NUMERIC: | 407 | case skin_tag_parameter::INTEGER: |
400 | return QObject::tr("Number"); | 408 | return QObject::tr("Integer"); |
409 | |||
410 | case skin_tag_parameter::DECIMAL: | ||
411 | return QObject::tr("Decimal"); | ||
401 | 412 | ||
402 | case skin_tag_parameter::DEFAULT: | 413 | case skin_tag_parameter::DEFAULT: |
403 | return QObject::tr("Default Argument"); | 414 | return QObject::tr("Default Argument"); |
@@ -445,11 +456,15 @@ QVariant ParseTreeNode::data(int column) const | |||
445 | case skin_tag_parameter::STRING: | 456 | case skin_tag_parameter::STRING: |
446 | return QString(param->data.text); | 457 | return QString(param->data.text); |
447 | 458 | ||
448 | case skin_tag_parameter::NUMERIC: | 459 | case skin_tag_parameter::INTEGER: |
449 | return QString::number(param->data.numeric, 10); | 460 | return QString::number(param->data.number, 10); |
461 | |||
462 | case skin_tag_parameter::DECIMAL: | ||
463 | return QString::number(param->data.number / 10., 'f', 1); | ||
450 | 464 | ||
451 | case skin_tag_parameter::CODE: | 465 | case skin_tag_parameter::CODE: |
452 | return QObject::tr("Seriously, something's wrong here"); | 466 | return QObject::tr("Seriously, something's wrong here"); |
467 | |||
453 | } | 468 | } |
454 | } | 469 | } |
455 | else | 470 | else |
@@ -742,10 +757,10 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) | |||
742 | id = element->params[0].data.text; | 757 | id = element->params[0].data.text; |
743 | filename = info.settings()->value("imagepath", "") + "/" + | 758 | filename = info.settings()->value("imagepath", "") + "/" + |
744 | element->params[1].data.text; | 759 | element->params[1].data.text; |
745 | x = element->params[2].data.numeric; | 760 | x = element->params[2].data.number; |
746 | y = element->params[3].data.numeric; | 761 | y = element->params[3].data.number; |
747 | if(element->params_count > 4) | 762 | if(element->params_count > 4) |
748 | tiles = element->params[4].data.numeric; | 763 | tiles = element->params[4].data.number; |
749 | else | 764 | else |
750 | tiles = 1; | 765 | tiles = 1; |
751 | 766 | ||
@@ -758,8 +773,8 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) | |||
758 | id = element->params[0].data.text; | 773 | id = element->params[0].data.text; |
759 | filename = info.settings()->value("imagepath", "") + "/" + | 774 | filename = info.settings()->value("imagepath", "") + "/" + |
760 | element->params[1].data.text; | 775 | element->params[1].data.text; |
761 | x = element->params[2].data.numeric; | 776 | x = element->params[2].data.number; |
762 | y = element->params[3].data.numeric; | 777 | y = element->params[3].data.number; |
763 | image = new RBImage(filename, 1, x, y, viewport); | 778 | image = new RBImage(filename, 1, x, y, viewport); |
764 | info.screen()->loadImage(id, new RBImage(filename, 1, x, y, | 779 | info.screen()->loadImage(id, new RBImage(filename, 1, x, y, |
765 | viewport)); | 780 | viewport)); |
@@ -780,10 +795,10 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) | |||
780 | 795 | ||
781 | case 'l': | 796 | case 'l': |
782 | /* %Cl */ | 797 | /* %Cl */ |
783 | x = element->params[0].data.numeric; | 798 | x = element->params[0].data.number; |
784 | y = element->params[1].data.numeric; | 799 | y = element->params[1].data.number; |
785 | maxWidth = element->params[2].data.numeric; | 800 | maxWidth = element->params[2].data.number; |
786 | maxHeight = element->params[3].data.numeric; | 801 | maxHeight = element->params[3].data.number; |
787 | hAlign = element->params_count > 4 | 802 | hAlign = element->params_count > 4 |
788 | ? element->params[4].data.text[0] : 'c'; | 803 | ? element->params[4].data.text[0] : 'c'; |
789 | vAlign = element->params_count > 5 | 804 | vAlign = element->params_count > 5 |
@@ -805,7 +820,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) | |||
805 | 820 | ||
806 | case 'l': | 821 | case 'l': |
807 | /* %Fl */ | 822 | /* %Fl */ |
808 | x = element->params[0].data.numeric; | 823 | x = element->params[0].data.number; |
809 | filename = info.settings()->value("themebase", "") + "/fonts/" + | 824 | filename = info.settings()->value("themebase", "") + "/fonts/" + |
810 | element->params[1].data.text; | 825 | element->params[1].data.text; |
811 | info.screen()->loadFont(x, new RBFont(filename)); | 826 | info.screen()->loadFont(x, new RBFont(filename)); |
@@ -822,10 +837,10 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) | |||
822 | /* %T */ | 837 | /* %T */ |
823 | if(element->params_count < 5) | 838 | if(element->params_count < 5) |
824 | return false; | 839 | return false; |
825 | int x = element->params[0].data.numeric; | 840 | int x = element->params[0].data.number; |
826 | int y = element->params[1].data.numeric; | 841 | int y = element->params[1].data.number; |
827 | int width = element->params[2].data.numeric; | 842 | int width = element->params[2].data.number; |
828 | int height = element->params[3].data.numeric; | 843 | int height = element->params[3].data.number; |
829 | QString action(element->params[4].data.text); | 844 | QString action(element->params[4].data.text); |
830 | RBTouchArea* temp = new RBTouchArea(width, height, action, info); | 845 | RBTouchArea* temp = new RBTouchArea(width, height, action, info); |
831 | temp->setPos(x, y); | 846 | temp->setPos(x, y); |
@@ -863,7 +878,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) | |||
863 | 878 | ||
864 | case 'p': | 879 | case 'p': |
865 | /* %Vp */ | 880 | /* %Vp */ |
866 | viewport->showPlaylist(info, element->params[0].data.numeric, | 881 | viewport->showPlaylist(info, element->params[0].data.number, |
867 | element->params[1].data.code, | 882 | element->params[1].data.code, |
868 | element->params[2].data.code); | 883 | element->params[2].data.code); |
869 | return true; | 884 | return true; |
@@ -1016,7 +1031,7 @@ double ParseTreeNode::findBranchTime(ParseTreeNode *branch, | |||
1016 | if(current->element->tag->name[0] == 't' | 1031 | if(current->element->tag->name[0] == 't' |
1017 | && current->element->tag->name[1] == '\0') | 1032 | && current->element->tag->name[1] == '\0') |
1018 | { | 1033 | { |
1019 | retval = atof(current->element->params[0].data.text); | 1034 | retval = current->element->params[0].data.number / 10.; |
1020 | } | 1035 | } |
1021 | } | 1036 | } |
1022 | else if(current->element->type == CONDITIONAL) | 1037 | else if(current->element->type == CONDITIONAL) |