Hi all, I’m having an issue getting subcomponents to draw once they are hooked up in a Viewport.
I got the Viewport working using a very large button, so I know that works, but when I attach my own component, none of the subcomponents get drawn. Everything renders itself just fine when not using a Viewport, but its a dynamically generated list, so it will need to scroll.
I have a PlaylistPanel component that contains the playlistViewport (and other components). The PlaylistRoll component just manages rendering individual TrackItem components. Everything works fine until I add the playlistRoll as the viewable content for the Viewport like this:
addAndMakeVisible(playlistRoll);
addAndMakeVisible(playlistViewport);
playlistViewport.setViewedComponent(playlistRoll);
In my PlaylistPanel::resized I tried to force the playlist resized function to be called like so:
void PlaylistPanel::resized()
{
songSelectButton.setBounds(10, 5, 130, 40);
playlistViewport.setBounds(0, 50, getWidth(), getHeight() - 64);
if (playlistRoll != nullptr) {
playlistRoll->resized();
}
}
This causes the following code to be called, which sets Bounds and makes visible individual TrackItem components stored in the tracks OwnedArray (I’m only iterating to 10 here because right now its just test data and I know how big the array is).
void PlaylistRoll::resized()
{
for(int i=0; i<10; i++) {
tracks[i]->setBounds(0, i*tracks[i]->getHeight(), getWidth(), tracks[i]->getHeight());
addAndMakeVisible(tracks[i]);
tracks[i]->resized();
}
}
The last line where tracks[i]->resized() calls the tracks resized() function, which simply calls repaint(), but the paint() function in TrackItem is never called, so my Viewport renders blank.
When not using the Viewport, everything renders fine, and I don’t have to manually make calls to resized() to get things to try to draw themselves.
All this seems like a lot of hacky work to cascade drawing calls on a component viewed in a Viewport. Why won’t subcomponents draw themselves when viewed in a Viewport?
Is there something I’m missing or is this a bug in Juce?
Thanks in advance.
