Viewport visibleAreaChanged callback not always called


The documentation says:

A subclass of the viewport can be created which will receive calls to its visibleAreaChanged() method when the subcomponent changes position or size.

But it seems that when a subcomponent is bigger than the visible area and changes to another size, still bigger, that the callback visibleAreaChanged() is not called.

It looks like this code in juce_Viewport.cpp is responsible for that because it uses the jmin macro:

    const Rectangle<int> visibleArea (visibleOrigin.x, visibleOrigin.y,
                                      jmin (contentBounds.getWidth()  - visibleOrigin.x, contentArea.getWidth()),
                                      jmin (contentBounds.getHeight() - visibleOrigin.y, contentArea.getHeight()));

    if (lastVisibleArea != visibleArea)
        lastVisibleArea = visibleArea;
        visibleAreaChanged (visibleArea);

Is this intentional? I expected to receive the callback on all size changes of the subcomponent.


Well... I don't really think it's wrong. True, the comment you quoted isn't very well-phrased, and I should improve that, but if you look at the actual method:

    /** Callback method that is called when the visible area changes.
        This will be called when the visible area is moved either be scrolling or
        by calls to setViewPosition(), etc.
    virtual void visibleAreaChanged (const Rectangle<int>& newVisibleArea);

..this correctly describes what it's intended to do. In the case you're describing, the visible area isn't changing, it's the child component's bounds that are changing, which is something you can use a ComponentListener or other callbacks to detect. I don't think it makes sense for that method to be called unless the rectangle it provides as its parameter has actually changed.