FS#12277 - WPS tags for the list item number and the "divisible" operator

Attached to Project: Rockbox
Opened by Alexander Levin (fml2) - Tuesday, 13 September 2011, 21:29 GMT
Task Type Patches
Category Themes
Status New
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Release 3.9
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


The patch adds two new WPS tags:

1. %Ln yields the number of the list item currently being drawn

2. The operator "/?" (which can be used in the %if tag) yields the string "div" if the first operant is divisible by the second and NULL otherwise.

With these two additions it should be possible to create themes where list items are coloured alternately (as an example).

The whole work has been done by gevaerts on 2011-09-12 (and all the credits also go to him), I only placed the patch to the patch tracker, changed the operator from "/" to "/?", and changed the function name from "skinlist_get_item" to "skinlist_get_item_number".

He posted the patch on the binpaste and it would be pity if it got lost.
This task depends upon

Comment by Jonathan Gordon (jdgordon) - Tuesday, 13 September 2011, 22:51 GMT
I would much prefer a proper math tag which could do +,-,*,/,% instead.
Comment by Thomas Martitz (kugel.) - Wednesday, 14 September 2011, 07:18 GMT
I too.
Comment by Frank Gevaerts (fg) - Wednesday, 14 September 2011, 14:53 GMT
Yes, I really did the "is divisible" thing as a quick and dirty proof of concept. A full arithmetic tag is going to be a lot more flexible in the end.
Comment by Alexander Levin (fml2) - Sunday, 18 September 2011, 10:25 GMT
A proper math tag would be more flexible, yes. But what purpose would it serve? The tags implemented in the patch make it possible to implement a feature found in many UIs. But what would you do with a general math tag? Implement a calculator in WPS? I'm not generally against math tags, but I'm not for a increased complexity without a clear benefit.
Comment by Jonathan Gordon (jdgordon) - Sunday, 18 September 2011, 10:31 GMT
If alternate colouring is all you want then I tinhk a better solution is to tell the the list drawer how many list items are going to be drawn in the rectangle, then you'd use %LT(0) and %LT(1) and not need any extra logic.

This is something I want to do anyway becaus eI'd like to be able to put inline settings functionality into themes which probably needs something like this already.

If you want to have a go at this suggestion look at FS#8968, specifically the changes to add movement_size to the list struct. Then simply add another number param to the Lb() tag and you're set.
Comment by Frank Gevaerts (fg) - Sunday, 18 September 2011, 12:10 GMT
I think the list number tag itself is probably useful, so maybe we should commit that one right away?
Comment by Jonathan Gordon (jdgordon) - Sunday, 18 September 2011, 12:18 GMT
I don really see why, but sure... and it can actually be used with %ss to do the same thing as / would do (though with lots of %if use :)
Comment by Frank Gevaerts (fg) - Sunday, 18 September 2011, 12:39 GMT
I committed the %LN bit (capital N for consistency with %LT and %LI).

That leaves the divisibility patch to be discussed.