actor: Provide a better default pick() behaviour

The default pick() behaviour does not take into consideration the
children of a ClutterActor because the existing containter actors
usually override pick(), chain up, and then paint their children.

With ClutterActor now a concrete class, though, we need a way to pick
its children without requiring a sub-class; we could simply iterate over
the children inside the default pick() implementation, but this would
lead to double painting, which is not acceptable.

A moderately gross hack is to check if the Actor instance did override
the pick() implementation, and if it is not the case, paint the children
in pick mode.
This commit is contained in:
Emmanuele Bassi 2012-01-17 16:13:55 +00:00
parent 0f39f20db6
commit 629ded568e

View File

@ -1703,6 +1703,23 @@ clutter_actor_real_pick (ClutterActor *self,
cogl_rectangle (0, 0, width, height); cogl_rectangle (0, 0, width, height);
} }
/* XXX - this thoroughly sucks, but we need to maintain compatibility
* with existing container classes that override the pick() virtual
* and chain up to the default implementation - otherwise we'll end up
* painting our children twice.
*
* this has to go away for 2.0; hopefully along the pick() itself.
*/
if (CLUTTER_ACTOR_GET_CLASS (self)->pick == clutter_actor_real_pick)
{
ClutterActor *iter;
for (iter = self->priv->first_child;
iter != NULL;
iter = iter->priv->next_sibling)
clutter_actor_paint (iter);
}
} }
/** /**