June 25, 2010, 12:17:29 Last Edit: June 25, 2010, 15:16:19 by bucaneer
I can't seem to find a way to have the album art size vary depending on the group's size, similar to how it's done in SongList. Here's the relevant bits from my group skin configuration:

pic: +aapic(y=title:y,picsize=if($nbsongs<3,picsize/2,picsize),ypad=2)
pic2: -aapic(y=title:y,picsize=picsize/2,ypad=2)

picsize : OptionNumber(default=100,min=0,max=1000,step=10)


It should display a half-sized cover picture if there are less than 3 songs in the group when expanded, and always half-sized when collapsed. However, the check for $nbsongs in that particular context seems to break the player, it refuses to start, throwing:
Can't use an undefined value as an ARRAY reference at (eval 86) line 5.

If I remove the 'if' clause (or just change $nbsongs to some independent variable), it starts and works normally, including rendering a half-sized picture when collapsed (so the actual size change must be possible). I'm using latest build from git.

So, is this just not implemented yet, or did I miss some way around the problem?

EDIT: nevermind, fixed it by setting "init_picsize". Should've looked better at the SongTree documentation before messing too much. (Though on that note: the wiki page doesn't mention that $nbsongs is available for groups, had to look into source to find it.)

Yes, you need to use the init_ prefix, as currently the size of the group (more precisely the space added around the songs) can not depend on the group contents, so $nbsongs is not available.
(the error messages need improvement :()

About $nbsongs not mentioned in the wiki, you're welcome to add it, or I'll do it.

To make a group similar to the album_cover column in songlist, something like this can be used :

{Group pic_varsize}
left=width
pic: aapic(picsize=if($_h>left,left,$_h))
width : OptionNumber(default=100,min=0,max=1000,step=10)


except you need to configure the group to resize it (I'll probably make the group columns optionally resizable at some point).
This will display a picture which size is the smallest of the configured width or the group's actual height $_h (the space added around the songs, in this case head+tail=0, and the total height of the song rows)

I already had figured out a way to get the image size about right, but that looks much more elegant, thanks.

Might as well share the complete group skin, if anyone's interested:
{Group length}
title= with length
head=title:h+2
vcollapse=head
left=picsize
tail=3
title: text(pad=2, x=picsize+10, markup='<span font_desc="'.if($_expanded,normalfont,collapsedfont).'">\
<b>'.if(showartist,pesc($artist).'</b> - <b>').pesc($title).'</b><small>'.\
if(showyear && $year,' ('.pesc($year).')').\
if(showcount,' - '.pesc($nbsongs).' song'.if($nbsongs>1,'s')).\
if(showlength,'  '.pesc($length)).'</small></span>',\
init_markup='<span font_desc="'.normalfont.'"> </span>',)
pic: aapic(xalign=1, w=picsize, y=title:y, init_picsize=picsize, picsize=min(left,$_h), ypad=2)

picsize : OptionNumber(default=120,min=0,max=1000,step=10)
showyear : OptionBoolean(default=1,name='show year')
showlength : OptionBoolean(default=1,name='show length')
showcount : OptionBoolean(default=1,name='show song count')
showartist : OptionBoolean(default=1,name='show artist')
normalfont : OptionFont(default='URW Palladio L 16',name='font')
collapsedfont : OptionFont(default='URW Palladio L Italic 14',name='collapsed font')