Theme Editor: Made progress bars fully movable/savable from the preview panel
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27726 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e4dc4f8913
commit
c5025c7c78
4 changed files with 46 additions and 13 deletions
|
@ -21,14 +21,17 @@
|
|||
|
||||
#include <QPainter>
|
||||
|
||||
#include "parsetreenode.h"
|
||||
#include "rbprogressbar.h"
|
||||
#include "projectmodel.h"
|
||||
|
||||
RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info,
|
||||
int paramCount, skin_tag_parameter *params,
|
||||
bool pv)
|
||||
:RBMovable(parent)
|
||||
ParseTreeNode* node, bool pv)
|
||||
:RBMovable(parent), node(node)
|
||||
{
|
||||
int paramCount = node->getElement()->params_count;
|
||||
skin_tag_parameter* params = node->getElement()->params;
|
||||
|
||||
/* First we set everything to defaults */
|
||||
bitmap = 0;
|
||||
color = parent->getFGColor();
|
||||
|
@ -70,7 +73,7 @@ RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info,
|
|||
bitmap = 0;
|
||||
}
|
||||
}
|
||||
|
||||
size = QRectF(0, 0, w, h);
|
||||
|
||||
/* Finally, we scale the width according to the amount played */
|
||||
int percent;
|
||||
|
@ -89,7 +92,7 @@ RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info,
|
|||
|
||||
w = w * percent / 100;
|
||||
|
||||
size = QRectF(0, 0, w, h);
|
||||
renderSize = QRectF(0, 0, w, h);
|
||||
setPos(x, y);
|
||||
parent->addTextOffset(h);
|
||||
}
|
||||
|
@ -111,11 +114,11 @@ void RBProgressBar::paint(QPainter *painter,
|
|||
{
|
||||
if(bitmap && !bitmap->isNull())
|
||||
{
|
||||
painter->drawPixmap(size, *bitmap, size);
|
||||
painter->drawPixmap(renderSize, *bitmap, renderSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->fillRect(size, color);
|
||||
painter->fillRect(renderSize, color);
|
||||
}
|
||||
|
||||
RBMovable::paint(painter, option, widget);
|
||||
|
@ -123,5 +126,14 @@ void RBProgressBar::paint(QPainter *painter,
|
|||
|
||||
void RBProgressBar::saveGeometry()
|
||||
{
|
||||
QPointF origin = pos();
|
||||
QRectF bounds = boundingRect();
|
||||
|
||||
node->modParam(static_cast<int>(origin.x()), 0);
|
||||
node->modParam(static_cast<int>(origin.y()), 1);
|
||||
node->modParam(static_cast<int>(bounds.width()), 2);
|
||||
node->modParam(static_cast<int>(bounds.height()), 3);
|
||||
|
||||
if(!bitmap)
|
||||
node->modParam(QVariant(), 4);
|
||||
}
|
||||
|
|
|
@ -31,11 +31,13 @@
|
|||
#include "devicestate.h"
|
||||
#include "skin_parser.h"
|
||||
|
||||
class ParseTreeNode;
|
||||
|
||||
class RBProgressBar : public RBMovable
|
||||
{
|
||||
public:
|
||||
RBProgressBar(RBViewport* parent, const RBRenderInfo& info,
|
||||
int paramCount, skin_tag_parameter* params, bool pv = 0);
|
||||
ParseTreeNode* node, bool pv = 0);
|
||||
virtual ~RBProgressBar();
|
||||
|
||||
QRectF boundingRect() const;
|
||||
|
@ -49,6 +51,9 @@ private:
|
|||
QPixmap* bitmap;
|
||||
QColor color;
|
||||
QRectF size;
|
||||
QRectF renderSize;
|
||||
|
||||
ParseTreeNode* node;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -682,16 +682,14 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
|
|||
{
|
||||
case 'b':
|
||||
/* %pb */
|
||||
new RBProgressBar(viewport, info, element->params_count,
|
||||
element->params);
|
||||
new RBProgressBar(viewport, info, this);
|
||||
return true;
|
||||
|
||||
case 'v':
|
||||
/* %pv */
|
||||
if(element->params_count > 0)
|
||||
{
|
||||
new RBProgressBar(viewport, info, element->params_count,
|
||||
element->params, true);
|
||||
new RBProgressBar(viewport, info, this, true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -1075,8 +1073,24 @@ void ParseTreeNode::modParam(QVariant value, int index)
|
|||
{
|
||||
if(element)
|
||||
{
|
||||
if(index < 0 || index >= children.count())
|
||||
if(index < 0)
|
||||
return;
|
||||
while(index >= children.count())
|
||||
{
|
||||
/* Padding children with defaults until we make the necessary
|
||||
* parameter available
|
||||
*/
|
||||
skin_tag_parameter* newParam = new skin_tag_parameter;
|
||||
newParam->type = skin_tag_parameter::DEFAULT;
|
||||
/* We'll need to manually delete the extra parameters in the
|
||||
* destructor
|
||||
*/
|
||||
extraParams.append(children.count());
|
||||
|
||||
children.append(new ParseTreeNode(newParam, this, model));
|
||||
element->params_count++;
|
||||
}
|
||||
|
||||
children[index]->modParam(value);
|
||||
}
|
||||
else if(param)
|
||||
|
|
|
@ -88,6 +88,8 @@ private:
|
|||
|
||||
ParseTreeModel* model;
|
||||
|
||||
QList<int> extraParams;
|
||||
|
||||
};
|
||||
|
||||
#endif // PARSETREENODE_H
|
||||
|
|
Loading…
Reference in a new issue