Custom scrollbars in Viewport


I would like to have a scrollbar with extended functionality so I can give it custom parameters and use it in the same way as similar components in the application, which I derive from a common base class. I can think of ways around it, but those are not the best solutions in terms of code maintainability. Would it be possible to have such custom scrollbars, specifically in Viewport?



I had a similar issue, and my solution was:

First hide the scrollbars of the viewport ((...)->setScrollBarsShown(false, false);)

Then make whatever scrollbar you like, and use it's changes (as broadcasted to listeners) to update the viewport yourself.

You need to implement your own scrollBarMoved and componentMovedOrResized (calling updatevisibleArea) functions to suit your needs.

Then you add a componentlistener to the viewedcomponent, and also listen to the scrollbar...

Sorry I'm a bit vague and don't post example code, my current code is too specific for my use case and convoluted...

Just look at how Juce handles this and you will figure it out, at least that's what I did.



Ilias B.


Or Jules could add a method to the LookAndFeel called 'createViewportScrollbar' same as he did for 'createSliderTextBox'