box: Implement the correct paint volume
authorEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 8 Mar 2011 19:23:34 +0000 (19:23 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 8 Mar 2011 19:27:07 +0000 (19:27 +0000)
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

index 2aef121..0d922b1 100644 (file)
@@ -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