The basic idea is to have some animated widgets that sit in a container, quite similar to Qt (the only actual difference is that my widgets are animated).
The animation is in some cases dependent on the current "time" (e.g. frame number) and it has some "events". To better explain this, let's take for example a line. To create an interesting effect, I may want in the first 100 frames to have the line "growing" from left to right, and then to stay still. So the line animation is basically split into an intro and the main loop.
The problem is how to build the architecture of this animation/event handling? My current approach is to have a class Animated that keeps track of time (it has a counter incremented each time the widget is redrawn - basically at each frame). Also, it has some methods that set up the events of the animation (i.e. for 100 frames, intro, then the main loop) and some which increment the frame counter and retrieve the current event. The events are stored in an array and they have a name/id and a duration (so getting the current event is quite easy, based on the current frame number). Then, I have widgets which inherit Animated, and when they are drawn, they check the current event and take specific action.
I don't mind the fact that the animation is defined in this way by the object itself, but I do not like the Animated class, since basically each object has a different "clock". Also, I would like to be able to control the animation of each widget (i.e. be able to shorten/lengthen the duration of the events). In the current approach, I can do this, but I must setup the events from the exterior (the main issue is that I need to know the name of the events and their meaning).
Is there a better way of doing this?