From 8afb091f56c8f4c15c587f79bb683cfcdb998f5a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 5 May 2010 13:58:15 +0100 Subject: [PATCH] animator: retain ease-in/interpolation when changing first key Duplicate the existing ease-in/interpolation mode for the property when removing, replacing the first key for a property or adding a new first key for a property. --- clutter/clutter-animator.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-animator.c b/clutter/clutter-animator.c index 80e08fb..4f6d8ed 100644 --- a/clutter/clutter-animator.c +++ b/clutter/clutter-animator.c @@ -1242,7 +1242,24 @@ clutter_animator_set_key_internal (ClutterAnimator *animator, ClutterAnimatorKey *key) { ClutterAnimatorPrivate *priv = animator->priv; - GList *old_item; + GList *old_item; + GList *initial_item; + ClutterAnimatorKey *initial_key = NULL; + + if ((initial_item = g_list_find_custom (animator->priv->score, key, + sort_actor_prop_func))) + initial_key = initial_item->data; + + /* The first key for a property specifies ease-in and interpolation, + * if we are replacing; or becoming a new first key we should + * inherit the old flags. + */ + if (initial_key && + initial_key->progress >= key->progress) + { + key->interpolation = initial_key->interpolation; + key->ease_in = initial_key->ease_in; + } old_item = g_list_find_custom (priv->score, key, sort_actor_prop_progress_func); @@ -1400,11 +1417,30 @@ clutter_animator_remove_key (ClutterAnimator *animator, (progress < 0 || fabs (progress - key->progress) < PROGRESS_EPSILON) ) { + ClutterAnimatorKey *prev_key = NULL; key->is_inert = TRUE; clutter_animator_key_free (key); /* FIXME: non performant since we reiterate the list many times */ + + prev_key = k->prev ? k->prev->data : NULL; + + if (!prev_key || prev_key->object != key->object || + prev_key->property_name != key->property_name) + { /* We are removing the first key for a property ... */ + ClutterAnimatorKey *next_key = k->next ? k->next->data : NULL; + if (next_key && next_key->object == key->object && + next_key->property_name == key->property_name) + { + /* ... and there is a key of our own type following us, + * copy interpolation/ease_in flags to the new first key + */ + next_key->interpolation = key->interpolation; + next_key->ease_in = key->ease_in; + } + } + k = priv->score = g_list_remove (priv->score, key); } } -- 2.7.4