Is there a way of telling if the animator finished with all of the animations? If not, perhaps it could simply inherit from ChangeBroadcaster, so we could use a callback to get notified. While at it, maybe an isAnimating() would also be useful for someone.
In fact, it would be even better if, each step of the animation, the animator tries to dynamic_cast the component to an “AnimationCallback”.
If the cast works, then the animator should call the virtual method AnimationCallback::animationStep(const int currentStep, const int totalStep, const Rectangle & currentPos)
That way, the component could actually perform painting actions while animated depending on the current step of the animation (à la copy file in microsoft windows)…
//==============================================================================
/**
If your component implements this interface, then it'll be informed
each step of the animation.
*/
class JUCE_API AnimationCallback
{
public:
//==============================================================================
/** Main callback called each step of the animation
@param animationProgress This is a value between 0.0 (animation starting)
to 1.0 (animation ending)
@param currentBounds The current component bound */
virtual void animationStep(const double animationProgress,
const Rectangle & currentBounds) = 0;
/** Destructor. */
virtual ~AnimationCallback() {}
};
and in the cpp (only one liner does it well, in useTimeslice()):