Viewport and centered component in it


Hi Jules,

Still fixing thing when moving from 1.46 to the tip :slight_smile:

I used to center horizontally a component in a viewport using setBoundsToFit Justification::centred on the viewed component after setting the viewport bounds, but now it works until I move the scrollbar then it moves the component on the top left of the viewport.

Am I missing something or is this broken ?



It was actually never supposed to work like that… When the component is smaller than the viewport, it always has to stay at the top-left, because otherwise there are all sorts of complicated problems about what the scrollbars should show e.g. if the component is smaller than the viewport but slightly off to the left, so you need to be able to scroll it right, but the scrollbars shouldn’t be visible because the content is smaller than the view…

I spent quite a while playing around with this, because I was using viewports in the new jucer and wanted the content to be centred, but finally decided that there are just too many edge-cases, and the viewport must be allowed to position its content without any interference.

Something I meant to add, but haven’t done yet, would be an option to set the positioning, so you could have it automatically centred, or top-right, etc. instead of always being top-left.


Oh I see.
Well I can do a proxy component in the meantime.

The position would be nice addition though.