mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
Theme Editor: Made %pv tag display bar and select from conditional branches correctly
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27398 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bae1836337
commit
64af2b3a16
4 changed files with 48 additions and 4 deletions
|
@ -25,7 +25,8 @@
|
||||||
#include "projectmodel.h"
|
#include "projectmodel.h"
|
||||||
|
|
||||||
RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info,
|
RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info,
|
||||||
int paramCount, skin_tag_parameter *params)
|
int paramCount, skin_tag_parameter *params,
|
||||||
|
bool pv)
|
||||||
:QGraphicsItem(parent)
|
:QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
/* First we set everything to defaults */
|
/* First we set everything to defaults */
|
||||||
|
@ -72,7 +73,20 @@ RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info,
|
||||||
|
|
||||||
|
|
||||||
/* Finally, we scale the width according to the amount played */
|
/* Finally, we scale the width according to the amount played */
|
||||||
int percent = info.device()->data("px").toInt();
|
int percent;
|
||||||
|
if(pv)
|
||||||
|
{
|
||||||
|
percent = (info.device()->data("pv").toInt() + 50) * 100 / 56;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
percent = info.device()->data("px").toInt();
|
||||||
|
}
|
||||||
|
if(percent > 100)
|
||||||
|
percent = 100;
|
||||||
|
if(percent < 0)
|
||||||
|
percent = 0;
|
||||||
|
|
||||||
w = w * percent / 100;
|
w = w * percent / 100;
|
||||||
|
|
||||||
size = QRectF(0, 0, w, h);
|
size = QRectF(0, 0, w, h);
|
||||||
|
|
|
@ -34,7 +34,7 @@ class RBProgressBar : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RBProgressBar(RBViewport* parent, const RBRenderInfo& info,
|
RBProgressBar(RBViewport* parent, const RBRenderInfo& info,
|
||||||
int paramCount, skin_tag_parameter* params);
|
int paramCount, skin_tag_parameter* params, bool pv = 0);
|
||||||
virtual ~RBProgressBar();
|
virtual ~RBProgressBar();
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
|
|
@ -660,6 +660,17 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
|
||||||
new RBProgressBar(viewport, info, element->params_count,
|
new RBProgressBar(viewport, info, element->params_count,
|
||||||
element->params);
|
element->params);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case 'v':
|
||||||
|
/* %pv */
|
||||||
|
if(element->params_count > 0)
|
||||||
|
{
|
||||||
|
new RBProgressBar(viewport, info, element->params_count,
|
||||||
|
element->params, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -928,6 +939,26 @@ QVariant ParseTreeNode::evalTag(const RBRenderInfo& info, bool conditional,
|
||||||
child = ((branches - 1) * child / 100) + 1;
|
child = ((branches - 1) * child / 100) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(QString(element->tag->name) == "pv")
|
||||||
|
{
|
||||||
|
/* ?pv gets scaled to the number of available children, sandwiched
|
||||||
|
* in between mute and 0/>0dB. I assume a floor of -50dB for the
|
||||||
|
* time being
|
||||||
|
*/
|
||||||
|
int dB = val.toInt();
|
||||||
|
|
||||||
|
if(dB < -50)
|
||||||
|
child = 0;
|
||||||
|
else if(dB == 0)
|
||||||
|
child = branches - 2;
|
||||||
|
else if(dB > 0)
|
||||||
|
child = branches - 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int options = branches - 3;
|
||||||
|
child = (options * (dB + 50)) / 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(QString(element->tag->name) == "px")
|
else if(QString(element->tag->name) == "px")
|
||||||
{
|
{
|
||||||
child = val.toInt();
|
child = val.toInt();
|
||||||
|
|
|
@ -105,7 +105,6 @@ artheight; Album Art Height ; spin(0,500) ; 100
|
||||||
|
|
||||||
[Hardware Status]
|
[Hardware Status]
|
||||||
pv ; Current Volume (dB) ; spin(-100,100) ; 0
|
pv ; Current Volume (dB) ; spin(-100,100) ; 0
|
||||||
?pv ; Current Volume (Conditional) ; combo(Mute, Below 0 dB, 0 dB, Above 0 dB) ; 0 dB
|
|
||||||
bl ; Battery Level (-1 for unknown) ; spin(-1,100) ; 50
|
bl ; Battery Level (-1 for unknown) ; spin(-1,100) ; 50
|
||||||
bv ; Battery Volts ; spin(0,20) ; 5
|
bv ; Battery Volts ; spin(0,20) ; 5
|
||||||
bt ; Time Left (-1 for unknown) ; spin(-1,500); 100
|
bt ; Time Left (-1 for unknown) ; spin(-1,500); 100
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue