I’m using a Viewport to show a timeline of audio clips in my plugin.
When the Component where I draw the clips is wider than the Viewport, horizontal scrollbars are shown and work as expected.
I also have a zoom slider, which will change the width of the underlying Component (by calling setBounds() on it), scaling its content to fit the new width.
But when I change the bounds of the viewed Component, the scrollbar (and view) of the Viewport will immediately jump all the way to the left.
This is obviously not what the user wants if they’re trying to zoom in on a particular part of a waveform.
So I would like the scrollbar to retain its relative position while the content size changes.
Is there a neat way to accomplish this using the Viewport class, or do I have to roll my own?