Table of Contents

This page describe how to customize the SongTree, a new widget introduced in version 0.962
An example of a SongTree can be seen in this screenshot.

Very rough and incomplete draft, better than nothing

Overview

Groups

In a SongTree, the songs are grouped together when they share a common tag (example : same album). Groups can be in turn grouped together (example : same artist).

Groups appearances are customizable by “skins”. A skin defines how much space is put around a group of songs by the options head, tail, left, and right. In addition the option vmin defines a minimum height that the group will have, and the option vcollapse defines the height of the group when it is collapsed (ie : its songs or inner groups are hidden). The width of a group is not controllable by the skin, it depends on the width of the displayed columns and of the left and right option of its inner groups.

All groups of a level share the same values for these six options (head, tail, left, right, vmin, vcollapse), they are evaluated only once, after the grouping configuration is changed.

The skin also defines objects, that will be drawn around the songs/inner groups.

Columns

The columns in a SongTree are also customizable in much the same way as groups. But instead of the head/tail/left/right/vmin/vcollapse options, columns have the hreq option that defines the minimum height that the column wants for its rows.

General syntax

These definitions can be put in any layout file, ie : a .layout text file in ~/.gmusicbrowser/layouts/. The use {} instead of [] to differentiate them from layouts definitions.

{Group mygroupid}
opt1 = value1
opt2 = value2
object1_name : type(opt1=val1,opt2=val2)
object2_name : type(opt1=val1,opt2=val2)
option1_name : type(opt1=val1,opt2=val2)

or

{Column mycolumnid}
opt1 = value1
opt2 = value2
object1_name : type(opt1=val1,opt2=val2)
object2_name : type(opt1=val1,opt2=val2)

Examples can be seen in the 'layouts' file of the current devel version.

Groups

{Group NameOfTheSkin}

options :

define the number of pixel around the songs

all 6 values default to 0, they are expression evaluated at group initialization

Columns

{Column NameOfTheSkin}

options :

all options are optional except title

Objects

For Group skin definitions, the type can be preceded by + or - to only draw the object when the group is expanded (+) or collapsed (-), this is just a convenience, the same can be achieved with the hide option and the $_expanded variable

All objects options, except “children”, are expressions evaluated before drawing Some of the options may also be evaluated at group/column initialization if they are needed (to evaluate head,… for groups and hreq and baseline calculation for columns). At initialization if option “init_name” exists it will be used instead of option “name”. For example : the height of a text with markup='<big>'.pesc($title).'</big>' won't be correctly computed at init because $title (and pesc($title)) will be an empty string. Using init_markup='<big>anything</big>' will correct this.

Most options have a reasonable default value, they also compute some other values that can be used, for example text/aapic/picture/icon have the values xd, yd, wd, hd wich are the position and size where the actual drawing will be, taking into account the padding and the alignement.

align/pack objects and their options

Apart from blalign, they are for convenience only as the same result can be achieved without them. they have a special option : children, which contains a |-separated list of objects. This option is a constant string, it is not evaluated.

xpack and ypack are used to pack objects horizontally or vertically, start at x, and separated by a padding of pad pixels. example : xpack(x=5,pad=2,children=text1|icon1)

xalign and yalign are used to align objects together, for example, xalign(x=100,align=1,children=text1|text2) will compute a x value for text1 and text2 such that they are right-aligned at x=100, align=.5 would center them around x=100. The option ref is by default equal to align, it defines where is the x. For example align(x=100,align=1,ref=0,children=text1|text2) will right-align text1 and text2 but rather than ending at x=100 as before, the wider will begin at x=100.

blalign is used to align text object so that their baseline is align even if the text have different font/size. example : blalign(y=10,children=text1|text2) will compute a y for text1 and text2 so that their baseline are aligned, the heighest text will have a y of 10. The option ref default to 0, it defines the reference point of the y value, ref=0 means the top of the string, ref=1 means the bottom.

drawn objects and their options

common options :

text

draws text

aapic

draws the artist or album picture

picture

draws a picture, can be cropped and resized

icon

draws an icon or multiple icons

rect

draws a rectangle at x,y of width w and height h, filled if “filled” is true, with the color “color” which can be a color name or hexadecimal (#000 or #000000), the line width is width, 1 by default

line

draws a line from x1,y1 to x2,y2 with color “color” (same as above)

user-editable group settings

Groups can define some settings that can easily be changed by user, for example for choosing a color, font, text … There are different types of settings, the type only affect the interface that the user will use to edit it. the syntax is :

option1_name : type(default='default value',name='an optional name',opt1=val1)

example :

mytext : OptionText(default='some text',name='name of the option')
text1: text(text=mytext)

will allow the user to change the text that the object 'text1' will display.

more complex example :

mytext  : OptionText(default='some text',name='some text')
mycolor : OptionColor(default='blue',name='Title color')
myfont  : OptionFont(default='Arial 20',name='font')
myhide  : OptionBoolean(default=0,name='hide')
title: text( markup='<span font_desc="'.myfont.'" foreground="'.mycolor.'">'.pesc(mytext).'</span>', hide=myhide)

Expressions

(not finished, lots of variable and functions to add)
They consist of “values” separated by “operators”.
Values can be one of the 4 kinds of variables, a function, a numerical value, or a string. Variables and functions can be preceded by -(negative) or ! (not). Functions are followed by a list of ,-separated arguments between “()”. Strings are delimited by simple quotes ('), there is no variable interpolation for now. Values between [ ] will create an array reference.

operators are : != == ⇐ >= - + . % * / < > && || x eq lt gt cmp le ge ne or xor and ,
functions :

currently allowed perl functions (more to come) : ucfirst uc lc abs int sprintf substr length index join warn

examples:

'year is '.if($year>2000,'after 2000 : ', 'before 2000 :').$year

4 kinds of variable :