From 49d38b1e21eb868f64f213d9d5b4c6fbedd63bb2 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 8 Mar 2011 19:23:34 +0000 Subject: [PATCH] box: Implement the correct paint volume The allocation of the ClutterBox is not enough to be used as the paint volume, because children might decide to paint outside that area. Instead, we should use the allocation if the Box has a background color and then do what Group does, and union all the paint volumes of the children. http://bugzilla.clutter-project.org/show_bug.cgi?id=2600 --- clutter/clutter-box.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/clutter/clutter-box.c b/clutter/clutter-box.c index 2aef12100..0d922b1de 100644 --- a/clutter/clutter-box.c +++ b/clutter/clutter-box.c @@ -302,9 +302,40 @@ static gboolean clutter_box_real_get_paint_volume (ClutterActor *actor, ClutterPaintVolume *volume) { - return _clutter_actor_set_default_paint_volume (actor, - CLUTTER_TYPE_BOX, - volume); + ClutterBoxPrivate *priv = CLUTTER_BOX (actor)->priv; + gboolean retval = FALSE; + GList *l; + + /* if we have a background color, and an allocation, then we need to + * set it as the base of our paint volume + */ + if (priv->color_set) + retval = clutter_paint_volume_set_from_allocation (volume, actor); + + /* bail out early if we don't have any child */ + if (priv->children == NULL) + return retval; + else + retval = TRUE; + + /* otherwise, union the paint volumes of our children, in case + * any one of them decides to paint outside the parent's allocation + */ + for (l = priv->children; l != NULL; l = l->next) + { + ClutterActor *child = l->data; + const ClutterPaintVolume *child_volume; + + /* This gets the paint volume of the child transformed into the + * group's coordinate space... */ + child_volume = clutter_actor_get_transformed_paint_volume (child, actor); + if (!child_volume) + return FALSE; + + clutter_paint_volume_union (volume, child_volume); + } + + return retval; } static void