[actor] Allow changing the transformations matrix
authorEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 1 Jul 2009 12:59:13 +0000 (13:59 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 1 Jul 2009 14:30:21 +0000 (15:30 +0100)
commit37bd35f592e13dfa8ded884fcf668409dec119f3
tree7d75d7e41be09588f9d02d2bceb33b8a97391b29
parent0414daf0fb64433cb168799bfec79d5996b05ddf
[actor] Allow changing the transformations matrix

Currently, the transformation matrix for an actor is constructed
from scenegraph-related accessors. An actor, though, can call COGL
API to add new transformations inside the paint() implementation,
for instance:

  static void
  my_foo_paint (ClutterActor *a)
  {
    ...
    cogl_translate (-scroll_x, -scroll_y, 0);
    ...
  }

Unfortunately these transformations will be completely ignored by
the scenegraph machinery; for instance, getting the actor-relative
coordinates from event coordinates is going to break badly because
of this.

In order to make the scenegraph aware of the potential of additional
transformations, we need a ::apply_transform() virtual function. This
vfunc will pass a CoglMatrix which can be used to apply additional
operations:

  static void
  my_foo_apply_transform (ClutterActor *a, CoglMatrix *m)
  {
    CLUTTER_ACTOR_CLASS (my_foo_parent_class)->apply_transform (a, m);
    ...
    cogl_matrix_translate (m, -scroll_x, -scroll_y, 0);
    ...
  }

The ::paint() implementation will be called with the actor already
using the newly applied transformation matrix, as expected:

  static void
  my_foo_paint (ClutterActor *a)
  {
    ...
  }

The ::apply_transform() implementations *must* chain up, so that the
various transformations of each class are preserved. The default
implementation inside ClutterActor applies all the transformations
defined by the scenegraph-related accessors.

Actors performing transformations inside the paint() function will
continue to work as previously.
clutter/clutter-actor.c
clutter/clutter-actor.h
doc/reference/clutter/clutter-sections.txt