Applying Skin to ScrollBar


#1

Hi,

I’m working on a VST plugin using JUCE API. I’ve applied skin to all of the components of my plugin but I cant seem to figure out how to apply skin to the scrollbar. I have both vertical and horizontal scrollbars in my plugin but the image that I’m trying to apply just seem to be all over the place.

Here’s how I’m applying image on the overloaded paint () function of my class that I’ve inherited from ScrollBar.

		if (isVertical())
		{
			g.drawImage(scrollbarImage, 0, getCurrentRangeStart(), 
				ImageWidth, getCurrentRangeSize(),
				0, 0, ImageWidth, ImageHeight);
		}
		else
		{
			g.drawImage(scrollbarImage, getCurrentRangeStart(), 0, 
				getCurrentRangeSize(), ImageHeight,
				0, 0, ImageWidth, ImageHeight);
		}

Am I using correct functions or strategy to work this through? Any pointers to articles or expert advice?

Thanks!


#2

…no, not really. The best way to do it is by creating a custom lookandfeel, not by overriding component’s paint methods.


#3

Is there a code snippet somewhere? How do I resize my image to fit the length and position of the thumb? This is the part that I’m having trouble with.

Thanks!


#4

Not a great deal of example code for lookandfeels, I’m afraid, but if you look in the actual lookandfeel for a scrollbar you’ll see how it draws the thumb.