Scrollbar::trackColourId request


#1

I think this might be deprecated … since setting it (with LookAndFeel) does nothing.

LookAndFeel::drawScrollbar(…) doesn’t seem to use it at all.

Any chance that could be put in there instead of the gradient fill that currently takes the thumb colour and darken/fades it in the track?


#2

I think that was a colour used in an older juce look+feel. It’d actually be a bit tricky to change the code without messing up people’s apps (e.g. if I swapped the thumb colour for track colour then people who had set a custom thumb colour would find their scrollbars looked different).


#3

I’ve noticed this recently too. There seemed to be very few colours that actually work with the scrollbar to give a visible track. I was quite surprised that you couldn’t just say “no, seriously, i want the track to be this colour”.


#4

Yes, it would certainly make more sense to use the value for that, but it would break it for anyone who’d used a custom thumb colour and was expecting the track to also use a matching colour.


#5

But surely there could be a default. Something to do what it currently does if no color is specified.


#6

Not so easy to have a default colour - you’d have to pick a particular magic colour value, and that’s a bit of a messy way to do it…


#7

What about using something like this in the default void LookAndFeel::drawScrollbar (Graphics& g …) method :


                const Colour thumbColour (scrollbar.findColour (ScrollBar::thumbColourId));
		
		// override if the track colours is specificed
		if (isColourSpecified(ScrollBar::trackColourId))
		{
			Colour trackColour (scrollbar.findColour (ScrollBar::trackColourId));
			g.setGradientFill (ColourGradient (trackColour, gx1, gy1,
										   trackColour, gx2, gy2, false));
		
      } else { // by default, use a darker version of the thumbColour
			
                        g.setGradientFill (ColourGradient (thumbColour.overlaidWith (Colour (0x44000000)), gx1, gy1,
											   thumbColour.overlaidWith (Colour (0x19000000)), gx2, gy2, false));
		}
		
		g.fillPath (slotPath);

That way, if the user has specified a track color, it will appear … and otherwise it will do what it is doing now.


#8

ah yes, I forgot it had an isColourSpecified method. Ok, that makes sense. We’d need to also remove that colour id setting from the lookandfeel constructor, of course.


#9

Looks like this never got implemented ?

At least, the background color is still set via darkening the thumb color instead of using the track.

Ping me if you implement, so I can remove my overrides.