Animation in Gtk+



Hello devel list,

during the last months I looked for a way to bring animation into Gtk+. The last few weeks I looked especially into an idea timj came up with. I try to give a briefly overview over it here.


The idea

The main idea is to obtain the pixmap representation of a widget in the main loop. Why in the main loop? Every expose event has to pass it and because of the double buffering code it's easy to obtain the new pixmap with "gdk_window_redirect_to_drawable ()".

So the animation process can look like this:
1) Widget state changes: the widget exposes its area and sets an "animation flag"

2) Expose event arrives at the main loop: the new pixmap representation is obtained and an timer starts when the "animation flag" of the widget connected to the expose event is set

3) Timer event is running: this timer calls a callback that defines the change between the old and the new pixmap representation of the widget

This is a very briefly description of how it can work but it is only for the sake of giving an idea.


The problems

1) Many widgets are containers and an animation of a container can imply the animation of its children.

Example: You have a GtkBox and you add an additional widget then there is maybe an animation which smoothly slides in the new widget and scales down the others (see http://video.google.de/videoplay?docid=-5544546765623963617 for an example).

That means that you have to obtain the new representation of children before you start the animation but in the main loop you would get the representation of the entire widget hierarchy.

A possible solution would be to queue the children instead of passing the expose event down the widget hierarchy. The main loop can work on the queue and control that all pixmap representations are obtained. With "g_object_set_data ()" it can also connect the new pixmap with the widget.

2) Not all elements of a widget are in turn widgets. This makes it difficult to apply the stated method on them.

This would concern e.g. the tabs of the GkNotebook or the elements of a GtkTreeView.

There are at least 2 possible solutions to this problem:

- These elements become widgets,
- The widget obtains the pixmap representation and the connection to the child elements by itself.
 

That's it! I hope that this mail gives a good overview of the idea. Questions, comments, additional ideas or problems are appreciated!

Best regards,
Hagen


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]