Skip to main content
Topic: playlist alternate colors (Read 2762 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

playlist alternate colors


I was wondering if it's possible to find out the alternate row color which is used e.g. in playlists in the default UI?

I've tried to thoroughly search the SDK but so far I have only found the other color (ui_color_background, if I remember correctly) but not the "alternate color".

It would be nice to find out the correct color for ui_element implementations.


P.S. foo_facets seems to use correct colors, so I wonder what's the way to do it?

playlist alternate colors

Reply #1
Unfortunately the alternate row color is not directly available. You'll have to calculate it in the same way as the Default UI elements. I don't know the exact formula, so try asking Peter.

playlist alternate colors

Reply #2
Code: [Select]
<DEATH>   double Luminance(t_uint32 color) {
<DEATH>     double r = extractbyte(color,0), g = extractbyte(color,1), b = extractbyte(color,2);
<DEATH>     return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255.0;
<DEATH>     //return (r * 0.3 + g * 0.59 + b * 0.11) / 255.0;
<DEATH>   }
<DEATH>   t_uint32 DetermineTextColor(t_uint32 bk) {
<DEATH>     return Luminance(bk) > 0.6 ? 0 : 0xFFFFFF;
<DEATH>   }
<DEATH> I use DetermineTextColor() for text color when the item is selected, instead of the user-configured text color.
<bubbleguuum> thanks i'll use it
<Neptune> If you could share your formula for alternating list background while you're at it?
<DEATH>   t_uint32 DriftColor(t_uint32 p_color,unsigned p_delta,bool p_direction) throw() {
<DEATH>     t_uint32 ret = 0;
<DEATH>     for(t_size walk = 0; walk < 3; ++walk) {
<DEATH>       unsigned val = extractbyte(p_color,walk);
<DEATH>       if (p_direction) val = 0xFF - val;
<DEATH>       if (val < p_delta) val = p_delta;
<DEATH>       val += p_delta;
<DEATH>       if (val > 0xFF) val = 0xFF;
<DEATH>       if (p_direction) val = 0xFF - val;
<DEATH>       ret |= (t_uint32)val << (walk * 8);
<DEATH>     }
<DEATH>     return ret;
<DEATH>   }
<DEATH> const DWORD bkColor = DriftColor(bkColor_base,4, (p_item&1) != 0);

playlist alternate colors

Reply #3
Thanks, the code worked great!

I needed to change the luminance threshold to 0.7 though since it didn't work it some of the default themes with 0.6.

Here's the extractbyte code (for completeness) if someone reads this thread.. Should work as expected.

Code: [Select]
    static t_uint16 extractbyte(t_uint32 word, t_uint16 pos){        
        t_uint16 result;
        if(pos == 0) {
            result = word & 0xFF;
            result = (word >> 8*pos) & 0xFF;

        return result;


SimplePortal 1.0.0 RC1 © 2008-2020