Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Columns UI: Some Help With IF Statements (Read 6000 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Columns UI: Some Help With IF Statements

My Foobar2k currently looks like this:


[Click To View Full-Size Version]


It isn't finished yet. There are some things I don't quite like regarding the layout (most notably the annoying messiness caused by the 'Artist Name' field), but it is getting there. One thing I am finding annoying, though, is how my current setting causes the second disc of records to appear as completely new 'sections' within the playlist. You can see from the example above how the second Kraftwerk disc appears like a completely new record entry.

Ideally, I'd like my layout script amended so that the entire row marking the beginning of the second disc (track number one) appears as the same colour as the current background colour for the record name/release date fields - the slightly darker grey that appears along the first two columns of the second track in each record. Basically I think this will still help distinguish each disc within a record, whilst also retaining the distinction between completely separate releases.

Is this clear?

So here is my current style code:


Column 1 + 2:

Code: [Select]
$ifequal(%tracknumber%,1,
$set_style(back,$rgb(220,220,220),$rgb(220,220,220))
,
)
$ifequal(%tracknumber%,2,
$set_style(back,$rgb(230,230,230),$rgb(220,220,220))
,
)

$if(%isplaying%,
$set_style(text,$rgb(255,255,255),$rgb(255,255,255))
$set_style(back,$rgb(39,61,126),$rgb(39,61,126))
$set_style(frame-top,1,$rgb(0,0,0))
$set_style(frame-bottom,1,$rgb(0,0,0))
,
)


Column 3 - 6:

Code: [Select]
$ifequal(%tracknumber%,1,
$set_style(back,$rgb(220,220,220),$rgb(220,220,220))
,
)

$if(%isplaying%,
$set_style(text,$rgb(255,255,255),$rgb(255,255,255))
$set_style(back,$rgb(39,61,126),$rgb(39,61,126))
$set_style(frame-top,1,$rgb(0,0,0))
$set_style(frame-bottom,1,$rgb(0,0,0))
,
)


I obviously need some kind of IF statement extension, but I cannot work the specifics out.

If anyone can help, I'd appreciate it hugely.

Columns UI: Some Help With IF Statements

Reply #1
OK, to some extent I have managed this, but my scripting is awful.

I've essentially just created a load of IFs and put them all together in the coding window. Not good.


Record Artist/Title Column:

Display

Code: [Select]
$if([%album%],,[%artist%])

$ifequal(%discnumber%,01,

$select(%tracknumber%,
[%albumartist%],
[%album%]$if([%disc%], '('Disc [%disc%]')',)$tab()[%date%]'  ',
)
,
)

$ifequal(%discnumber%,02,

$select(%tracknumber%,
[%album%]$if([%disc%], '('Disc [%disc%]')',)'  ',
)
,
)

$ifequal(%discnumber%,,

$select(%tracknumber%,
[%albumartist%],
[%album%]$if([%disc%], '('Disc [%disc%]')',)$tab()[%date%]'  ',
)
,
)

Style

Code: [Select]
$ifequal(%tracknumber%,1,$ifequal(%discnumber%,01,
$set_style(back,$rgb(220,220,220),$rgb(220,220,220))
,
)
,
)

$ifequal(%tracknumber%,1,$ifequal(%discnumber%,,
$set_style(back,$rgb(220,220,220),$rgb(220,220,220))
,
)
,
)

$ifequal(%tracknumber%,1,$ifequal(%discnumber%,02,
$set_style(back,$rgb(230,230,230),$rgb(220,220,220))
,
)
,
)

$ifequal(%tracknumber%,2,$ifequal(%discnumber%,01,
$set_style(back,$rgb(230,230,230),$rgb(220,220,220))
,
)
,
)

$ifequal(%tracknumber%,2,$ifequal(%discnumber%,,
$set_style(back,$rgb(230,230,230),$rgb(220,220,220))
,
)
,
)

$if(%isplaying%,
$set_style(text,$rgb(255,255,255),$rgb(255,255,255))
$set_style(back,$rgb(39,61,126),$rgb(39,61,126))
$set_style(frame-top,1,$rgb(0,0,0))
$set_style(frame-bottom,1,$rgb(0,0,0))
,
)


So that, rather messily, accounts for CDs with no DISCNUMBER field (only records with more than one disc have an item in that field) and it accounts for records with 2 discs, but what happens if I have a record with 3 or 5 discs? I can't keep adding IF statements.

Can someone help me clean this up, please?

Columns UI: Some Help With IF Statements

Reply #2
Try using the $greater() function i.e.
Code: [Select]
$if($greater(1,%discnumber%),set style,do nothing)

The $switch() function is also useful for this kind of formatting:
Code: [Select]
$switch(%tracknumber%,this is track 1,this is track 2,etc)


This wiki page is very useful.

Columns UI: Some Help With IF Statements

Reply #3
Aha, using that $ifgreater() function and the other control function explanations from that link I've managed to compress a lot of that code, and I've solved the disc number thing. I'm sure my code can still be improved, so if any one wants to give trying to come up with a nice way of expressing the above on their own, feel free.

Thanks very much.

Columns UI: Some Help With IF Statements

Reply #4
Is it possible to stop a specific column from highlighting the row information when clicking an item?

What I mean is, I now have this:


[Click To View Full-Size Version]

I don't want the Artist Name column on the left to highlight mouse click selections.

In the screenshot the song being played is highlighted in blue, and the current next selection is highlighted in a lighter grey-ish colour. This is fine, except for the Artist Name column. I don't want anything in that column to change colour when something has been selected.

Possible?

Columns UI: Some Help With IF Statements

Reply #5
Little rusty with the style scripts on CUI, put something like:
Code: [Select]
$set_style(back,%_back%,%_back%)
into the first line of the custom style script for the column (not sure if that breaks the alternating shading or not.)

Columns UI: Some Help With IF Statements

Reply #6
The $switch() function is also useful for this kind of formatting:
Code: [Select]
$switch(%tracknumber%,this is track 1,this is track 2,etc)


This wiki page is very useful.

The $switch() - do you have it confused with $select()? I cannot find it in http://wiki.hydrogenaudio.org/index.php?ti...ormat_Reference nor http://yuo.be/wiki/columns_ui:config:colour_string.

Columns UI: Some Help With IF Statements

Reply #7
Yes, apparently just a mistake. Switch is more common name for such construct in programming languages.
Full-quoting makes you scroll past the same junk over and over.

Columns UI: Some Help With IF Statements

Reply #8
Little rusty with the style scripts on CUI, put something like:
Code: [Select]
$set_style(back,%_back%,%_back%)
into the first line of the custom style script for the column (not sure if that breaks the alternating shading or not.)


It doesn't break the alternating shading, it works very well for overriding the style sheet for selected tracks.

The only thing is, it still shades the track currently playing very slightly with what I can only presume is a default colour value from somewhere. I've put the same code into an $isplaying function within the style section, but it makes no difference. I wonder if there is something else I can do to overcome this final obstacle.

Cheers for your help so far.

Columns UI: Some Help With IF Statements

Reply #9
The $switch() - do you have it confused with $select()?
Whoops, yea I mean select just been programming in other languages recently.

The only thing is, it still shades the track currently playing very slightly with what I can only presume is a default colour value from somewhere. I've put the same code into an $isplaying function within the style section, but it makes no difference. I wonder if there is something else I can do to overcome this final obstacle.

Cheers for your help so far.
Not sure about that, you may have to play with the values in Playlist View -> Globals -> style. However I'm not sure what would be the best way to change it.

Columns UI: Some Help With IF Statements

Reply #10
Not sure about that, you may have to play with the values in Playlist View -> Globals -> style. However I'm not sure what would be the best way to change it.

Yeah; there is quite a bit in there which governs the background colouring and behaviour, and I don't understand all of it:

Code: [Select]
$if(%_themed%,,$if(%_isplaying%,

$puts(back,$offset_colour(%_back%,$offset_colour($calculate_blend_target(%_back%),ff0000,20),25))
$puts(back-selected,$offset_colour(%_selected_back%,$offset_colour($calculate_blend_target(%_selected_back%),ff0000,20),25))
$puts(back-selected-no-focus,$offset_colour(%_selected_back_no_focus%,$offset_colour($calculate_blend_target(%_selected_back_no_focus%),ff0000,20),25))
,

$ifequal($mod(%_playlist_number%,2),0,
$puts(back,$offset_colour(%_back%,$calculate_blend_target(%_back%),12))
$puts(back-selected,%_selected_back%)
$puts(back-selected-no-focus,%_selected_back_no_focus%)
,
$puts(back-selected,$offset_colour(%_selected_back%,$calculate_blend_target(%_selected_back%),7))
$puts(back-selected-no-focus,$offset_colour(%_selected_back_no_focus%,$calculate_blend_target(%_selected_back_no_focus%),7))
$puts(back,%_back%)
)

)
$set_style(back,$get(back),$get(back-selected),$get(back-selected-no-focus)))


Somewhere in there is something which either needs to be removed, or amended.

Columns UI: Some Help With IF Statements

Reply #11
the style in the globals tab is for stripes and now playing item

if you don't need it you can delete it

here is custom public code for those two:

stripes
Code: [Select]
$if($strcmp($mod(%_playlist_number%,2),0),
$set_style(back,<background color>),
$set_style(back,<striped background color>),
)


now playing blink
Code: [Select]
$if($or(%_isplaying%,%_ispaused%),

$if($strcmp($mod(%_time_elapsed_seconds%,2),0),
$set_style(back,<blinking background color 1>),
$set_style(back,<blinking background color 2>),
)
)


this two formating lines (available through help), defines text and background colors for playlist items in columns

Code: [Select]
$set_style(text,<text color>,<selected text color>)
$set_style(back,<background color>,<selected background color>[,<selected background color - no focus>])


so, if you don't like some column to be highlighted use them in the style tab for the appropriate column and check on "use custom style script"

for example:
Code: [Select]
$set_style(back,$rbg(255,255,255),$rbg(255,255,255))


about the OP, i don't understand what is the problem

 

Columns UI: Some Help With IF Statements

Reply #12
Between all of you - and myself getting my hands dirty for once - I've solved all the issues I had.

Many thanks.


EDIT: Thought I'd include a final screenshot so you can see my current setup now:


[Click To View Full-Size Version]

Additions since the very beginning of this topic include the artist name column on the left (to make scrolling to find a particular artist easier) and the fact that my 'now playing' and 'selected item' selections do not highlight the rows in the far left column.