About viewport and very big components


I’m building a multitrack playlist, in which the user can do audio and midi editing of clips and events.
So I have this sort of grid and put it inside a viewport.
Everything works fine, but when I zoom in the grid (by using a slider which resizes the width of the component) and the grid’s width becomes very big - say 600.000 pixels - the viewport starts to respond slowly to its bars scrollings. Another source of slowing down is also represented by the great amount of vertical lines in the grid.
So I’m asking, is this the best approach in building such a thing? I mean, to have a huge component handled by a viewport?
Or should I make a “fake” viewport, where the viewed component is always big as the visible area, and all the child components (grid, clips, events) get constructed only when they are in the visible area?


The approach that I usually use is to keep the actual viewed component big, but only update the components inside it within the visible area. The ListBox component uses a similar trick to handle big lists. You can use the Viewport::visibleAreaChanged callback to update the components.

Obviously if you’ve got a paint routine that’s going to try drawing a million lines, then all those calls will get slow, even if they’re offscreen, so you’d have to be careful in your paint method to check the clip rectangle of the Graphics object.


Thank you, it worked like a charm.


Watch out for mouse interactions in a zoomed component. As far as I know, that bug is still there - you need to go to 100% to interact with child components on the view area.



You mean by using the magnifier component?
I’m not using it. I’m just resizing all the stuff.