Request for Viewport


#1

Hi Jules,
could you add a virtual function to inform what Component is added in Viewport::setViewedComponent() ?
I’m asking this because I’m porting juced to the last juce’s changes, and in the past we used a ViewportListener class that needs to know when a Component is added to the Viewport.
Something like this would be great:

juce_Viewport.cpp

[code]void Viewport::setViewedComponent (Component* const newViewedComponent, const bool deleteComponentWhenNoLongerNeeded)
{
if (contentComp.get() != newViewedComponent)
{
deleteContentComp();
contentComp = newViewedComponent;
deleteContent = deleteComponentWhenNoLongerNeeded;

    if (contentComp != nullptr)
    {
        contentHolder.addAndMakeVisible (contentComp);
        setViewPosition (Point<int>());
        contentComp->addComponentListener (this);
    }
    
    componentAdded (newViewedComponent);  //THIS 

    updateVisibleArea();
}

}[/code]

juce_Viewport.h

Thank you,
masshacker


#2

Ok, will figure something out like that.