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: Different colours for artists (Read 2830 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Different colours for artists

Hi everyone,
Always managed to find answers and solutions without bothering the community too much. This time after a lot of searching I couldn’t find any help.
What I.m trying to figure out is how to assign a different color to certain artists in my filter panel, vs the “standard one” provided in my color scheme.

Is this something feasible?
Maybe it could be done assigning a different color to preferred artists... but Ik’m lost as how to do it

Thanks a lot,
RJ

Re: Different colours for artists

Reply #1
Anyone?

 :)) 

Re: Different colours for artists

Reply #2
Well, assuming you are talking about Columns UI filters, it's pretty straightforward: use the conditional statement $if() combined with the $rgb() function.
For example, if you want to set the font colour to red for all artists whose name begins with an "A", you can write in the field description something like:
Code: [Select]
$ifequal($strcmp($left(%artist%,1),A),1,$rgb(255,0,0),)%artist%
I'm late

Re: Different colours for artists

Reply #3
Thank you so much!

Yes, it's CUI filters.
Looked so easy (after your advice - before I had been playing randomly with the machine for days  :)) )

Now (and excuse me once more for my noobieness).

Suppose I want to turn in red a number of artists of my choice, which have nothing in common (they don't all begin with the A).

This string turns in red Bach
Code: [Select]
$ifequal($stricmp($left(%artist%,3),bac),1,$rgb(255,0,0),)%artist%
How can I add after "bac" - "cho" for chopin and "vel" for velvet underground?

I've tried with the $or and $xor functions but didn't manage to get it working.

Will seem again a super simple question for you - not for me tho!  O:)

Thanks again

Roberto

Re: Different colours for artists

Reply #4
Will seem again a super simple question for you - not for me tho!  O:)

Not really, I actually realized that the $rgb() function alters the sort order, as if there was a number in front of the artist name, therefore, all the names in red are sorted after those beginning with a special characters and before those beginning with a number. I never noticed something similar before and I actually don't know how to handle it. Does that happen to you, too?

Anyway, sort order issue aside, to compare the whole field with specific values I would use the $strstr() function rather than $strcmp(), for example:
Code: [Select]
$ifequal($strstr(%artist%,Bach),1,$rgb(255,0,0),
$ifequal($strstr(%artist%,Chopin),1,$rgb(255,0,0),
$ifequal($strstr(%artist%,Velvet Underground),1,$rgb(255,0,0),
)))%artist%

The above is just to get the idea, but to make it work properly in real life you need to manage capital letters and prefixes, like this:
Code: [Select]
$puts(ar,$stripprefix($lower(%artist%)))
$ifequal($strstr($get(ar),bach),1,$rgb(255,0,0),
$ifequal($strstr($get(ar),chopin),1,$rgb(255,0,0),
$ifequal($strstr($get(ar),velvet underground),1,$rgb(255,0,0),
)))$swapprefix(%artist%)
I'm late

Re: Different colours for artists

Reply #5
Quote
I actually realized that the $rgb() function alters the sort order, as if there was a number in front of the artist name
I had not noticed it as bach and chopin were my first entries as artists (I was playing within my "classical" collection)  :o

Setting that aside, it also happens that with your code (which by the way works perfectly for everything else) the artists that go "red" are not just bach but say also "BACHi da pietra". But anyway - that's just a detail. Am now trying to solve the "order" issue (which with my infallible trial and error strategy will take months to be sorted out  :'(

thank you davideleo

Re: Different colours for artists

Reply #6
Setting that aside, it also happens that with your code (which by the way works perfectly for everything else) the artists that go "red" are not just bach but say also "BACHi da pietra".
Sorry, I didn't understand you wanted it that way. The $stricmp() than is what you need.
I'm late

Re: Different colours for artists

Reply #7
Will seem again a super simple question for you - not for me tho!  O:)

Not really, I actually realized that the $rgb() function alters the sort order, as if there was a number in front of the artist name, therefore, all the names in red are sorted after those beginning with a special characters and before those beginning with a number. I never noticed something similar before and I actually don't know how to handle it. Does that happen to you, too?


Hi, I have bee trying to solve this issue, but all the tricks I could think of just didn't work. E.g. I tried redefining the colors of all the lines, but color (I really can't imagine why) mess with the sorting order.

I wonder if there's anyone out there that could take a look at that ?

Thank you

Re: Different colours for artists

Reply #8
That is a limitation of CUI Filter panels and some other components as well.

They hide the color codes visually but the original code is still taken as literal for the purposes of the sorting operation. For example:
Code: [Select]
$rgb(200,200,200)Artist 1
$rgb(100,100,100)Artist 2
In the context of sorting, '$rgb(1' comes before '$rgb(2', therefore the second line will end up first on the CUI Filter panel list. If the sorting only compared 'Artist 1' vs 'Artist 2', the first line would win.

You can sometimes use this to your advantage to force-sort certain items. You can also do the same by inserting an increasing number of zero-width characters in front of strings.

The downside is that in your specific scenario you are stuck with the unintended force-sorting.

Re: Different colours for artists

Reply #9

The downside is that in your specific scenario you are stuck with the unintended force-sorting.


So just to understand I got it right: there’s nothing I can do, correct?

Re: Different colours for artists

Reply #10
I believe that is the case.

Re: Different colours for artists

Reply #11
A couple of months have passed, but I'm wondering if there's a workaround for this.
What about linking the colour scheme to a tag?

What about creating a tag  "preferred" and attributing a red colour to the artists whose songs carries a positive value fot the "preferred" tag?

Would you help me in creating a string for this?
Sorry, of course I've been trying to do it, but with no success.

The rule should say "attribute a rgb code IF %preferred% is positive" .

Would it be possible?

RJ

Re: Different colours for artists

Reply #12
I really like that idea.

A couple of months have passed, but I'm wondering if there's a workaround for this.

If this is the case
That is a limitation of CUI Filter panels and some other components as well.
you can try to bring the developers attention to this, maybe he has an idea or there is a simple way to fix this w/o loosing backwardscompabilities...


This is only a dumb idea of a workaround, but maybe it helps?

You can add a new column, make it very small and put in only [%ARTIST%] or $cut([%ARTIST%],1) (only display first letter) or whatever you want to sort, in the Display Script. Then, when you want to sort, you click on that column-header, instead of the header for the colored-column.
That way, the $rgb will not interfer the sorting.

Just an idea, dunno, if it is useful in practical use.


Another approach is to use a Style script for colouring:
Code: [Select]
$set_style(text,$rgb($mod($crc32(%ARTIST%),256),128,128) ,0)
and leave the Display script as simple as [%ARTIST%]
The above code will generate kinda "random" colours for artists, you can always use your own colour code.

Re: Different colours for artists

Reply #13
Thank you fuffi,

Quote
You can add a new column

This is interesting. My "use case" is that I would like to mark some artists (by changing their colour in the filter tab) in my classical music collection (the idea is to highlight the major composers vs minor ones). So if a custom colour for some of them is not possible, having something like a green V in a column for the major composers would be great.

Still, I wouldn't know how to do it  :))

Quote
Another approach is to use a Style script for colouring:

As you said, this would generate random colours. I'm wondering if I can use your idea to reach the scenario where every artist is in the default column except some of them

RJ

Re: Different colours for artists

Reply #14
EDIT (I don't know how to edit my own message above!)

Quote
As you said, this would generate random colours. I'm wondering if I can use your idea to reach the scenario where every artist is in the default column except some of them


should have been:  the scenario where every artist is in the default COLOUR except some of them

 

Re: Different colours for artists

Reply #15
As you said, this would generate random colours.
What is stopping you from replacing my random color code with yours, or the code you'd like to use?
Try to search/read/learn about $set_style.
You can seperate the code for sorting from the code for colouring. (IMHO + AFAIK + fingers crossed)