dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Upcoming New skin feature: skin variables (FS#11998)

Upcoming New skin feature: skin variables (FS#11998)

From: Jonathan Gordon <>
Date: Tue, 8 Mar 2011 23:18:38 +1100

Hi all,
I've been working on an idea which was originally implemented in
FS#11084 which adds alot of fun stuff to the skin code. This email is
to hopefully explain how to use it and get feedback incase anything
needs to be tweaked before it goes in (next few days probably).

What this patch adds is an ability to save some sort of state in the
skin, these can almost be thought of as variables in any programming
language or the x in algebra. You can arbitrarily set a value (any
number 1-2.1billion), increment (optionally rollover at a specific
value), decrement (with rollover backwards also), and finally, check
if the value changed in the last X seconds.

Why do we want/need this?
If you try any of the touchscreen cabbies you should see a popup
appear if you press the screen *anywhere*. This works but the popup
can only be controlled by using the tag which checks if a touch region
was pressed in the last few seconds. Now, if you want the popup to
stay and be able to press other buttons on it this gets very
complicated very quickly (you need to now check more than one region
to see if the popup should stay open).

Concrete example: When you press the volume button on the WPS you want
a display to appear with a nice slider to control the volume and to
stay open until 5s after not being changed. In svn today this is
incredibly difficult. With this patch it becomes much simpler.

Below is my test sbs. It is obviously a ridiculous example but I think
it shows off the functionality enough to get people started (or ask
questions if needed). This can be copied directly into a .sbs and run
on any touch target. What it does is count from one to seven then back
to one in an endless loop using two variables. One (dir in this case)
is to keep track of which direction we are counting, and the other (a)
keeps track of the actual count. Lastly, whenever the count changes
directions it will display "CHANGE PLACES!" for ~3 seconds.

%vs() is used to change the value, %vg() is used to get the value,
%vl() is used to check if time has elapsed since anything touched the

%?vg(a)<one%vs(dir, inc, 1, 2)|two|three|four|five|six|seven%vs(dir, inc, 1, 2)>
%?vl(dir, 3)<CHANGE PLACES!|>


The first 2 lines just set up viewports so ignore them.
The 3rd line checks the direction (the conditional), values are
arbitrary so '1' here means count up and '2' means count down.
The 4th line checks the value and prints out a number. the first and
last options also change the direction variable (both incremenet
because it rlls back to 1 after 2)
The 5th line just displays the value
The 6th line checks if it is less than 3 seconds since the direction
was changed, and if so display some text.

OK, finally, proper explanation of the 3 new tags:

%vs(label, action, value, [max]) : label is the unique id of this
variable. action is one of "set", "inc", "dec". "set" means "x=value",
"inc" is x = x+ value, "dec" is x = x - value. vars are always
initalised to 1 on load. max is optional and means the last value
before rolling back to 1 (or with the dec action the value to set to
after decrementing from 1).

%vg(label) : get the current value, use in a conditional.

%vl(label, [timeout]) : check if it is less than (optional) timeout
since the value was changed *by any %vs tag contorlling this

Not done yet but on the list is touch actions to control these vars
directly which should simplify things even more.

So, I hope this helps explain the feature. I'm not entirely happy with
the tag names and the "set/inc/dec" names so suggestions welcome.

Received on 2011-03-08

Page was last modified "Mon Nov 16 10:57:21 2020" The Rockbox Crew -- Privacy Policy