[clutter/master-next: 41/51] actor: Make :allocation animatable



commit 1f25bd46ac413fd544d30588953da4e0fae4a577
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Fri Apr 20 18:06:02 2012 +0100

    actor: Make :allocation animatable
    
    Calling clutter_actor_allocate() should transition between the current
    allocation and the new allocation, by using the defined implementation
    of the easing state.
    
    This means that:
    
      clutter_actor_save_easing_state (actor);
      clutter_actor_allocate (actor, &new_alloc, flags);
      clutter_actor_restore_easing_state (actor);
    
    will cause "actor" to transition between the current allocation and the
    desired new allocation.
    
    The trick is to ensure that this happens without invalidating the
    entire actor tree, but only the portion of the tree that has the
    transitioned actor as the local root. For this reason, we just call the
    allocate() implementation from within the transition frame advancement,
    without invalidating flags: the actor, after all, *has* a valid
    allocation for the duration of the transition.

 clutter/clutter-actor.c |   57 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 43 insertions(+), 14 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 82b2243..16783ff 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -5848,7 +5848,9 @@ clutter_actor_class_init (ClutterActorClass *klass)
                         P_("Allocation"),
                         P_("The actor's allocation"),
                         CLUTTER_TYPE_ACTOR_BOX,
-                        CLUTTER_PARAM_READABLE);
+                        G_PARAM_READABLE |
+                        G_PARAM_STATIC_STRINGS |
+                        CLUTTER_PARAM_ANIMATABLE);
 
   /**
    * ClutterActor:request-mode:
@@ -8626,6 +8628,26 @@ clutter_actor_adjust_allocation (ClutterActor    *self,
   *allocation = adj_allocation;
 }
 
+static void
+clutter_actor_allocate_internal (ClutterActor           *self,
+                                 const ClutterActorBox  *allocation,
+                                 ClutterAllocationFlags  flags)
+{
+  ClutterActorClass *klass;
+
+  CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IN_RELAYOUT);
+
+  CLUTTER_NOTE (LAYOUT, "Calling %s::allocate()",
+                _clutter_actor_get_debug_name (self));
+
+  klass = CLUTTER_ACTOR_GET_CLASS (self);
+  klass->allocate (self, allocation, flags);
+
+  CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_IN_RELAYOUT);
+
+  clutter_actor_queue_redraw (self);
+}
+
 /**
  * clutter_actor_allocate:
  * @self: A #ClutterActor
@@ -8649,11 +8671,10 @@ clutter_actor_allocate (ClutterActor           *self,
                         const ClutterActorBox  *box,
                         ClutterAllocationFlags  flags)
 {
-  ClutterActorPrivate *priv;
-  ClutterActorClass *klass;
   ClutterActorBox old_allocation, real_allocation;
   gboolean origin_changed, child_moved, size_changed;
   gboolean stage_allocation_changed;
+  ClutterActorPrivate *priv;
 
   g_return_if_fail (CLUTTER_IS_ACTOR (self));
   if (G_UNLIKELY (_clutter_actor_get_stage_internal (self) == NULL))
@@ -8731,18 +8752,20 @@ clutter_actor_allocate (ClutterActor           *self,
   if (child_moved)
     flags |= CLUTTER_ABSOLUTE_ORIGIN_CHANGED;
 
-  CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IN_RELAYOUT);
-
-  CLUTTER_NOTE (LAYOUT, "Calling %s::allocate()",
-                _clutter_actor_get_debug_name (self));
-
-  klass = CLUTTER_ACTOR_GET_CLASS (self);
-  klass->allocate (self, &real_allocation, flags);
-
-  CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_IN_RELAYOUT);
+  /* store the flags here, so that they can be propagated by the
+   * transition code
+   */
+  self->priv->allocation_flags = flags;
 
-  if (stage_allocation_changed)
-    clutter_actor_queue_redraw (self);
+  if (_clutter_actor_get_transition (self, obj_props[PROP_ALLOCATION]) == NULL)
+    {
+      _clutter_actor_create_transition (self, obj_props[PROP_ALLOCATION],
+                                        &priv->allocation,
+                                        &real_allocation);
+    }
+  else
+    _clutter_actor_update_transition (self, obj_props[PROP_ALLOCATION],
+                                      &real_allocation);
 }
 
 /**
@@ -13334,6 +13357,12 @@ clutter_actor_set_animatable_property (ClutterActor *actor,
       clutter_actor_set_size_internal (actor, g_value_get_boxed (value));
       break;
 
+    case PROP_ALLOCATION:
+      clutter_actor_allocate_internal (actor,
+                                       g_value_get_boxed (value),
+                                       actor->priv->allocation_flags);
+      break;
+
     case PROP_DEPTH:
       clutter_actor_set_depth_internal (actor, g_value_get_float (value));
       break;



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