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.zip rockbox-15488a00eae8d10249015b88e4b7bdc47365b854.tar.gz rockbox-15488a00eae8d10249015b88e4b7bdc47365b854.tar.bz2 rockbox-15488a00eae8d10249015b88e4b7bdc47365b854.tar.xz | |
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 027520f..206a835 100644 --- a/utils/themeeditor/graphics/rbprogressbar.cpp +++ b/utils/themeeditor/graphics/rbprogressbar.cpp @@ -41,22 +41,22 @@ RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info, if(paramCount > 0 && params[0].type != skin_tag_parameter::DEFAULT) { - x = params[0].data.numeric; + x = params[0].data.number; } if(paramCount > 1 && params[1].type != skin_tag_parameter::DEFAULT) { - y = params[1].data.numeric; + y = params[1].data.number; } if(paramCount > 2 && params[2].type != skin_tag_parameter::DEFAULT) { - w = params[2].data.numeric; + w = params[2].data.number; } if(paramCount > 3 && params[3].type != skin_tag_parameter::DEFAULT) { - h = params[3].data.numeric; + h = params[3].data.number; } 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 96d7e8b..e9c58eb 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) break; } /* Now we grab the info common to all viewports */ - x = node->params[param++].data.numeric; + x = node->params[param++].data.number; if(x < 0) x = info.screen()->boundingRect().right() + x; - y = node->params[param++].data.numeric; + y = node->params[param++].data.number; if(y < 0) y = info.screen()->boundingRect().bottom() + y; if(node->params[param].type == skin_tag_parameter::DEFAULT) w = info.screen()->getWidth() - x; else - w = node->params[param].data.numeric; + w = node->params[param].data.number; if(w < 0) w = info.screen()->getWidth() + w - x; if(node->params[++param].type == skin_tag_parameter::DEFAULT) h = info.screen()->getHeight() - y; else - h = node->params[param].data.numeric; + h = node->params[param].data.number; if(h < 0) h = info.screen()->getHeight() + h - y; @@ -128,7 +128,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) if(node->params[++param].type == skin_tag_parameter::DEFAULT) font = screen->getFont(1); else - font = screen->getFont(node->params[param].data.numeric); + font = screen->getFont(node->params[param].data.number); setPos(x, y); size = QRectF(0, 0, w, h); diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp index 89985bf..e766a64 100644 --- a/utils/themeeditor/gui/devicestate.cpp +++ b/utils/themeeditor/gui/devicestate.cpp @@ -225,7 +225,7 @@ QVariant DeviceState::data(QString tag, int paramCount, QString path = tag[0].isLower() ? data("file").toString() : data("nextfile").toString(); if(paramCount > 0) - return directory(path, params[0].data.numeric); + return directory(path, params[0].data.number); else return QVariant(); } @@ -255,7 +255,7 @@ QVariant DeviceState::data(QString tag, int paramCount, else if(tag == "pS") { double threshhold = paramCount > 0 - ? std::atof(params[0].data.text) : 10; + ? params[0].data.number / 10. : 10; if(data("?pc").toDouble() <= threshhold) return true; else @@ -264,7 +264,7 @@ QVariant DeviceState::data(QString tag, int paramCount, else if(tag == "pE") { double threshhold = paramCount > 0 - ? std::atof(params[0].data.text) : 10; + ? params[0].data.number / 10. : 10; if(data("?pt").toDouble() - data("?pc").toDouble() <= threshhold) return true; else diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp index a04a0d9..66c9621 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, if(!value.canConvert(QVariant::Int)) return false; - param->type = skin_tag_parameter::NUMERIC; - param->data.numeric = value.toInt(); + param->type = skin_tag_parameter::INTEGER; + param->data.number = value.toInt(); } else { diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index 1b894b7..fbb7b92 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp @@ -246,8 +246,12 @@ QString ParseTreeNode::genCode() const } break; - case skin_tag_parameter::NUMERIC: - buffer.append(QString::number(param->data.numeric, 10)); + case skin_tag_parameter::INTEGER: + buffer.append(QString::number(param->data.number, 10)); + break; + + case skin_tag_parameter::DECIMAL: + buffer.append(QString::number(param->data.number / 10., 'f', 1)); break; case skin_tag_parameter::DEFAULT: @@ -318,8 +322,8 @@ int ParseTreeNode::genHash() const case skin_tag_parameter::CODE: break; - case skin_tag_parameter::NUMERIC: - hash += param->data.numeric * (param->data.numeric / 4); + case skin_tag_parameter::INTEGER: + hash += param->data.number * (param->data.number / 4); break; case skin_tag_parameter::STRING: @@ -331,6 +335,10 @@ int ParseTreeNode::genHash() const hash += param->data.text[i]; } break; + + case skin_tag_parameter::DECIMAL: + hash += param->data.number; + break; } } @@ -396,8 +404,11 @@ QVariant ParseTreeNode::data(int column) const case skin_tag_parameter::STRING: return QObject::tr("String"); - case skin_tag_parameter::NUMERIC: - return QObject::tr("Number"); + case skin_tag_parameter::INTEGER: + return QObject::tr("Integer"); + + case skin_tag_parameter::DECIMAL: + return QObject::tr("Decimal"); case skin_tag_parameter::DEFAULT: return QObject::tr("Default Argument"); @@ -445,11 +456,15 @@ QVariant ParseTreeNode::data(int column) const case skin_tag_parameter::STRING: return QString(param->data.text); - case skin_tag_parameter::NUMERIC: - return QString::number(param->data.numeric, 10); + case skin_tag_parameter::INTEGER: + return QString::number(param->data.number, 10); + + case skin_tag_parameter::DECIMAL: + return QString::number(param->data.number / 10., 'f', 1); case skin_tag_parameter::CODE: return QObject::tr("Seriously, something's wrong here"); + } } else @@ -742,10 +757,10 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) id = element->params[0].data.text; filename = info.settings()->value("imagepath", "") + "/" + element->params[1].data.text; - x = element->params[2].data.numeric; - y = element->params[3].data.numeric; + x = element->params[2].data.number; + y = element->params[3].data.number; if(element->params_count > 4) - tiles = element->params[4].data.numeric; + tiles = element->params[4].data.number; else tiles = 1; @@ -758,8 +773,8 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) id = element->params[0].data.text; filename = info.settings()->value("imagepath", "") + "/" + element->params[1].data.text; - x = element->params[2].data.numeric; - y = element->params[3].data.numeric; + x = element->params[2].data.number; + y = element->params[3].data.number; image = new RBImage(filename, 1, x, y, viewport); info.screen()->loadImage(id, new RBImage(filename, 1, x, y, viewport)); @@ -780,10 +795,10 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) case 'l': /* %Cl */ - x = element->params[0].data.numeric; - y = element->params[1].data.numeric; - maxWidth = element->params[2].data.numeric; - maxHeight = element->params[3].data.numeric; + x = element->params[0].data.number; + y = element->params[1].data.number; + maxWidth = element->params[2].data.number; + maxHeight = element->params[3].data.number; hAlign = element->params_count > 4 ? element->params[4].data.text[0] : 'c'; vAlign = element->params_count > 5 @@ -805,7 +820,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) case 'l': /* %Fl */ - x = element->params[0].data.numeric; + x = element->params[0].data.number; filename = info.settings()->value("themebase", "") + "/fonts/" + element->params[1].data.text; info.screen()->loadFont(x, new RBFont(filename)); @@ -822,10 +837,10 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) /* %T */ if(element->params_count < 5) return false; - int x = element->params[0].data.numeric; - int y = element->params[1].data.numeric; - int width = element->params[2].data.numeric; - int height = element->params[3].data.numeric; + int x = element->params[0].data.number; + int y = element->params[1].data.number; + int width = element->params[2].data.number; + int height = element->params[3].data.number; QString action(element->params[4].data.text); RBTouchArea* temp = new RBTouchArea(width, height, action, info); temp->setPos(x, y); @@ -863,7 +878,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) case 'p': /* %Vp */ - viewport->showPlaylist(info, element->params[0].data.numeric, + viewport->showPlaylist(info, element->params[0].data.number, element->params[1].data.code, element->params[2].data.code); return true; @@ -1016,7 +1031,7 @@ double ParseTreeNode::findBranchTime(ParseTreeNode *branch, if(current->element->tag->name[0] == 't' && current->element->tag->name[1] == '\0') { - retval = atof(current->element->params[0].data.text); + retval = current->element->params[0].data.number / 10.; } } else if(current->element->type == CONDITIONAL) |