Rockbox Technical Forums

Support and General Use => Theming and Appearance Customization => Topic started by: daniel.weck on June 01, 2012, 08:14:36 AM

Title: [OptimalInfo] Theme: iPod Video 5G, Cowon D2
Post by: daniel.weck on June 01, 2012, 08:14:36 AM
Dear Rockbox'ers,

This is a follow-up from the Sansa Fuze theme, upon which this one is based:
http://forums.rockbox.org/index.php/topic,34471.0.html

I tried several themes from the gallery, but I could not find one that I enjoyed using on a daily basis. So I created my own, and I have now released it in the Rockbox gallery. The "source" is actually on Google Code as well, where it will be kept up to date.

Source code on GitHub:
https://github.com/danielweck/Rockbox-theme-OptimalInfo

Gallery link (iPod 5G Video):
http://themes.rockbox.org/index.php?themeid=1626&target=ipodvideo

Gallery link (Cowon D2):
http://themes.rockbox.org/index.php?themeid=1626&target=cowond2

(note that the scrolling lines in the screendumps are displayed with jagged fonts due to how Rockbox captures the LCD data, the text is perfectly smooth in real life)

Quote
OptimalInfo is a high-contrast coloured theme with minimalist graphics, which displays an optimal amount of information using an easy-to-read 9-line layout (or 10 lines + 2 extra blank spacing for taller displays) based on a legible font. Layout tricks such as alternating line text, as well as separate screens for volume and seek controls, are used to maximise usability whilst reserving screen real estate for high-priority information.

The 10-line layout (+ 2 blank lines) is composed of:

1) a red-ish heading at the top, alternating between the date/time and the battery level
2) the track number (out of total playlist items)
3) track title
4) track album
5) track artist
6) full file path (dimmed)
7) audio codec details (dimmed)
BLANK
8) next track information
BLANK
9) playback progress information (current time / track duration) (percentage, remaining time only in dedicated "seeking - rewind/fast-forward" screen)
10) progress bar

Additionally, there are discrete vertical volume level indicators on either side of the screen (live peak meters for the left and right audio channels).

Main screen, paused (note the white highlight to indicate the playback state):

(http://themes.rockbox.org/themes/320x240/optimalinfo_ipodvideo5g/wps-Rockbox_OptimalInfo_iPodVideo5G_Screen-1.png)

The main screen, playing (note the stereo peak meters):

(http://themes.rockbox.org/themes/320x240/optimalinfo_ipodvideo5g/1-Rockbox_OptimalInfo_iPodVideo5G_Screen-2.png)

The menu style is in keeping with the "while playing screen", nothing fancy (note that the image background is actually not used in the WPS, a similar gradient is drawn instead):

(http://themes.rockbox.org/themes/320x240/optimalinfo_ipodvideo5g/menu-Rockbox_OptimalInfo_iPodVideo5G_Screen-4.png)

The color scheme works well with the black iPod Video / 5G:

(http://rockbox-themes.googlecode.com/svn/trunk/iPodVideo5G/screenshots/Rockbox_OptimalInfo_iPodVideo5G_SMALL.jpg)

I hope you enjoy it as much as I do!
Cheers, Daniel
Title: Re: [OptimalInfo] Theme: iPod Video 5G, Cowon D2
Post by: daniel.weck on March 06, 2015, 12:53:36 PM

FYI, I moved the source code to GitHub:
https://github.com/danielweck/Rockbox-theme-OptimalInfo

I need to figure-out why the scrolling text is all messed up in more recent versions of Rockbox (I'm not sure what revision broke my design, it must have been some time ago!)
Title: Re: [OptimalInfo] Theme: iPod Video 5G, Cowon D2
Post by: [Saint] on March 07, 2015, 06:56:06 PM
Was this theme scratch built, or piggy-backed off a "donor" theme?

The reason I ask, is there appears to be a fair amount of (rather weird) commented out sections and hunks of what seem like leftover code hanging around.

I would have to say the thing I find most interesting about this theme is the fact that it shouldn't actually function at all. The parser should be spitting this out due to invalid syntax, but it isn't (apparently?).

There's a reasonable amount of weird stuff going on in this theme, but the one that should make it barf completely is the misuse of the %X tag. That tag is supposed to be used for the sole purpose of loading a backdrop, and it accepts only a single parameter, the file name of the backdrop bitmap to load. Whereas you have:
Code: [Select]
# No background image
%X(d)

The comment appears to imply that the intention is to not load a backdrop image? Or, that you wanted to, but it didn't work? I'm confused either way. Regardless, its invalid syntax and the parser should be choking on it.

There's a host of other weirdness in the theme code, if you're wanting to sort it out, I'm happy to have questions and ideas bounced off me.


[Saint] - some form of theme expert type guy
Title: Re: [OptimalInfo] Theme: iPod Video 5G, Cowon D2
Post by: daniel.weck on March 08, 2015, 01:37:09 PM

Thanks for the feedback!  :D

However I believe %X(d) is legit syntax:

http://www.rockbox.org/wiki/CustomWPS#X_45_Load_a_background_image
"
if %X(d) is used NO background image will be used (so only the flat background colour will be used)
"


By the way, this was my first (and only) WPS theme, designed just to fulfil my own personal needs. It has worked great for me, until a particular Rockbox revision when the horizontal scrolling text started to leave a "ghost trace", making it unreadable.

What other oddities do you think this WPS contains?

https://github.com/danielweck/Rockbox-theme-OptimalInfo/blob/master/iPodVideo5G/.rockbox/wps/OptimalInfo.wps#L1

Code: [Select]
# Background and foreground default colours
%Vb(000000)
%Vf(FFFFFF)
#
# Default font (pixel-perfect vertical screen alignment!)
%Fl(2,20-Profont-basil.fnt,256)
#
# Status bar disabled
%wd
#
# No background image
%X(d)
#
# ---------------------------------
# If volume is changing, then volume indicator, otherwise main screen
%?mv<%Vd(v)|%?mp<%Vd(m)|%Vd(m)|%Vd(m)|%Vd(s)|%Vd(s)>>
#
# ---------------------------------
# Background
%V(0,0,-,-,2)%VB
%Vb(B53042)
%Vf(000000)

#
# DOES NOT WORK?! %dr(0,0,-,-,1,333333,000000)
#
%Vg(666666,000000,333333)%Vs(gradient,9)%al.%ar.
##2
%al.%ar.
##3
%al.%ar.
##4
%al.%ar.
##5
%al.%ar.
##6
%al.%ar.
##7
%al.%ar.
##8
%al.%ar.
##9
%al.%ar.
#
# ---------------------------------
# Vertical volume peak meter (left)
%V(0,0,5,-,2)
%Vb(000000)
%Vf(333333)
#
# If playing, then foreground set to specific colour
# %?mp<Stop|Play|Pause|Ffwd|Rew|Rec|Rec pause|FM|FM pause>
%?mp<%Vf(333333)|%Vf(887777)|%Vf(333333)|%Vf(333333)|%Vf(333333)>
#|%Vf(333333)|%Vf(333333)|%Vf(333333)|%Vf(333333)>
#
%pL(0,0,5,-,-,vertical)
# ---------------------------------
# Vertical volume peak meter (right)
%V(-5,0,5,-,2)
%Vb(000000)
%Vf(333333)
#
# If playing, then foreground set to specific colour
# %?mp<Stop|Play|Pause|Ffwd|Rew|Rec|Rec pause|FM|FM pause>
%?mp<%Vf(333333)|%Vf(887777)|%Vf(333333)|%Vf(333333)|%Vf(333333)>
#|%Vf(333333)|%Vf(333333)|%Vf(333333)|%Vf(333333)>
#
%pR(0,0,5,-,-,vertical)
# ---------------------------------
# Main screen
%Vl(m,5,0,310,-,2)
%Vb(000000)
%Vf(FFFFFF)
#
#
# Two alternating centred scrolling lines (5s + 2s), first with date / time, second with the battery charge level in percentage, and estimated remaining battery time.
%Vs(color,003333)%t(5)%s%ac%ca %cb %cd %cH:%cM;%Vs(color,003333)%t(2)%s%ac%Sx(Battery): %bl%% %(~%bt%)
## :%cS
#
# Centred line indicating the current track number (out of total)
%Vs(color,FFFFFF)%ac%pp/%pe
## %Sx(Tracknum)
#
# Two alternating centred scrolling lines (5s + 1s), second with "Title" (localised string), first with the actual track title.
%Vs(color,FFFFFF)%t(5)%s%ac%?it<%it|%Sx(Title) %(?%)>;%Vs(color,FFFFFF)%t(1)%ac%Sx(Title)
#
# Two alternating centred scrolling lines (5s + 1s), second with "Album" (localised string), first with the actual track album.
%t(5)%s%ac%?id<%id|%Sx(Album) %(?%)>;%t(1)%ac%Sx(Album)
#
# Two alternating centred scrolling lines (5s + 1s), second with "Artist" (localised string), first with the actual track artist.
%t(5)%s%ac%?ia<%ia|%Sx(Artist) %(?%)>;%t(1)%ac%Sx(Artist)
#
# Centred scrolling line with the full track file path
%Vs(color,777777)%s%al%fp
#
# Centred scrolling line: audio codec (e.g. MP3), bitrate (in kilo bits per seconds), and file size (in kilo bytes).
%Vs(color,777777)%s%ac%fc %(%fsKB%) @ %fbKbps%fv / %fkKHz
#
#
# Centred scrolling line displaying information about the next track (duration, title, album, artist, full path)

%Vs(clear)%s%ac%Sx(Next:) %Sx(Title)=%?It<%It|%Sx(Title) %(?%)> %Sx(Album)=%?Id<%Id|%Sx(Album) %(?%)> %Sx(Artist)=%?Ia<%Ia|%Sx(Artist) %(?%)> %(%Fp%)

#
#
# Line that displays playback progress information,
# with left-aligned part: "elapsed / total (percentage)"
# and right-aligned part: "-remaining"
# %?mp<Stop|Play|Pause|Ffwd|Rew|Rec|Rec pause|FM|FM pause>
%?mp<%Vs(invert)|%Vs(color,FFFFFF)|%Vs(invert)>%al%pc/%pt %(%px%%%) %ar-%pr
#
# Playback progress bar
%pb(-,-,-,8,-)
#
# ---------------------------------
# Volume screen
%Vl(v,5,0,310,-,2)
%Vb(000000)
%Vf(FFFFFF)
#
#
# Two alternating centred scrolling lines (5s + 2s), first with date / time, second with the battery charge level in percentage, and estimated remaining battery time.
%Vs(color,003333)%t(5)%s%ac%ca %cb %cd %cH:%cM;%Vs(color,003333)%t(2)%s%ac%Sx(Battery): %bl%% %(~%bt%)
## :%cS
#



%Vs(color,FFFFFF)%ac%Sx(Volume)
%pv(-,-,-,10,-)
#
#
# ---------------------------------
# Seek screen
%Vl(s,5,0,310,-,2)
%Vb(000000)
%Vf(FFFFFF)
#
#
# Two alternating centred scrolling lines (5s + 2s), first with date / time, second with the battery charge level in percentage, and estimated remaining battery time.
%Vs(color,003333)%t(5)%s%ac%ca %cb %cd %cH:%cM:%cS;%Vs(color,003333)%t(2)%s%ac%Sx(Battery): %bl%% %(~%bt%)
## :%cS
#



# Line that displays playback progress information,
# with left-aligned part: "elapsed / total (percentage)"
# and right-aligned part: "-remaining"
%Vs(color,FFFFFF)%al%pc/%pt %(%px%%%) %ar-%pr
#
# Playback progress bar
%pb(-,-,-,8,-)
#
#
#
#
#
#
# Rectangle
## %_dr(0,0,220,176,FFFFFF,FF0000)
Title: Re: [OptimalInfo] Theme: iPod Video 5G, Cowon D2
Post by: [Saint] on March 09, 2015, 12:45:13 AM
Hi, yeah, you're quite right - it is valid.

I remembered about it sometime after posting that, but you beat me to it in your response.

That'll learn me to run off memory instead of actually checking, well, never mind that then. I guess I forgot it (it being %X(d)) existed due to it being largely pointless. Doubly so in your case since you're drawing into the backdrop buffer anyway.

This will probably end up being a culmination of things. Things I find weird (very little, actually), possible optimizations, and readability and stylistic pointers.

  - At the very beginning of the theme you're setting background and foreground colours that are identical to those set in the theme .cfg
    These end up being superfluous.

  - hard-coding a single font which is also set by the theme .cfg
    I'm not sure why this is being done. I'm not sure offhand if the bufflib allocator is smart enough to realize that there's no point in buffering the same font twice, so this ends up (possibly) wasting a fairly non-trivial amount of skin buffer. It is only really useful or necessary to load fonts in this way if they differ to the font set in the theme.cfg. In your case you could specify that the font use the currently loaded userfont instead. Hard-coding the font in this fashion effectively forces the user into using a language that contains only those characters which your hard-coded font supports, which may or may not be their native language and (in my mind) generally goes against the very essence of Rockbox themes being allowing the user to choose .wps, .sbs, .fms, font, etc. at their discretion. The major caveat being that this also allows a user to screw up the formatting of the theme by loading a smaller or larger font than you intended, but this can be partially mitigated by using viewports for vertical text alignment like you're doing, but in a more controlled fashion.

  - This is a readability/stylistic and optimization change worth mentioning. The %if tag is a themer's friend:
Code: [Select]
%?mv<%Vd(v)|%?mp<%Vd(m)|%Vd(m)|%Vd(m)|%Vd(s)|%Vd(s)>>    Could easily be:
Code: [Select]
%?mv<%Vd(v)|%?if(%mp,>,2)<%Vd(s)|%Vd(m)>>    Or:
Code: [Select]
%?mv<%Vd(v)|%?if(%mp,<,3)<%Vd(m)|%Vd(s)>>    The guts of which is essentially "if $tag is greater/less than $value; do $foo; else $bar". But this is really neither here nor there in the greater scheme of things, it just ends up being less code to parse, and easier to read in the long run.

  - %dr (draw rectangle)
    I notice this is commented out in your theme with the comment "DOES NOT WORK?!", it does actually work, but you've included an extra parameter (font perhaps?) which will break the expected syntax.

  - Another readability/stylistic and optimization point:
Code: [Select]
%?mp<%Vf(333333)|%Vf(887777)|%Vf(333333)|%Vf(333333)|%Vf(333333)>    Could easily be:
Code: [Select]
%?if(%mp,=,1)<%Vf(887777)|%Vf(333333)>    (Note: most, but not all (yeah, I know its confusing, but its a bugger to fix) tags are 0 based. So 0 is the first tuple, 1 the second, 2 the third, and so on.)

  - The above code snippet, why is this duplicated (lines 65 and 77)?
    You could do this in a single declaration to be parsed before both viewports that require it.

  - Foreground and background colours
    These will be adopted from the theme .cfg, so there's no specific requirement for each viewport to have its own foreground and background declarations if they are to be identical to those given in the theme .cfg.

  - Line formatting tags
    These are largely untested and (putting my speculation hat on here) almost certainly what's screwing up your scrolling. I've been pulling my hair out trying to think of a sensible way to do this that won't screw up your intended formatting and the obvious answer seems to be conditional viewports. This of course means that there will be some code duplication, but I think that is better in the long run that unreadable text when scrolling.

  - Identifiers
    There's no way for you to know this really, as we don't make it particularly clear that these are considered deprecated. I mean, they still work, but for the sake of readability it is much better to use descriptive identifiers in your code. For example, someone looking at your code needs to go through and review what each identifier is by the associated code. Using descriptive identifiers makes this job a lot easier. Especially in the case of conditional statements and bitmap sub-images (which you're not actually using).
    To be clear:

    Old style:
Code: [Select]
%xl(A,bitmap.bmp,0,0,100,200,2)
%Vl(A,0,0,-,-,-)
%?xx<%xd(Aa)|%xd(Ab)>
%Vd(B)
    New style:
Code: [Select]
%xl(this_is_a_bitmap_with_two_subimages,bitmap.bmp,0,0,100,200,2)
%Vl(this_is_a_viewport,0,0,-,-,-)
%?xx<%xd(this_is_a_bitmap_with_two_subimages,1)|%xd(this_is_a_bitmap_with_two_subimages,2)>
%Vd(this_is_a_viewport)
    My given example identifiers are pretty lame but one can (hopefully) see how this can be used to one's advantage for the sake of readability.


There's probably more I could think of if I really put my mind to it, but this ends up reading like a shopping list for the screwup factory - which isn't my intention at all. The really important thing is, if what you have works for you, and you're comfortable with it, then that's the best solution. There's very few people interested in this side of Rockbox these days, so in some ways I feel a certain obligation to pass on the somewhat limited knowledge I do have while its still relevant.

I'm happy to have ideas or further queries bounced off me, be yelled at for overstepping boundaries, or, to be ignored completely.

 ;)


[Saint]