[clutter/master-next: 39/43] actor: Make :allocation animatable
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/master-next: 39/43] actor: Make :allocation animatable
- Date: Fri, 20 Apr 2012 17:34:56 +0000 (UTC)
commit c62ff5848604b756dd26703178b2a7dcfd24a4d6
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 7a33158..b198030 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -5853,7 +5853,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:
@@ -8631,6 +8633,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
@@ -8654,11 +8676,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))
@@ -8736,18 +8757,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);
}
/**
@@ -13339,6 +13362,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]