[animatable] Allow validation in ::animate_property

The Animatable interface implementation will always have the computed
value applied, whilst the non-Animatable objects go through the
interval validation first to avoid incurring in assertions and
warnings.

The Animatable::animate_property() should also be able to validate the
property it's supposed to interpolate, and eventually discard it. This
requires adding a return value to the virtual function (and its wrapper
function).

The Animation code will then apply the computed value only if the
animate_property() returns TRUE -- unifying the code path with the
non-Animatable objects.
This commit is contained in:
Emmanuele Bassi
2009-05-27 13:01:31 +01:00
parent 7edaf8ece8
commit 6fff1bcdc6
3 changed files with 52 additions and 40 deletions

View File

@ -778,6 +778,7 @@ on_alpha_notify (GObject *gobject,
const gchar *p_name = p->data;
ClutterInterval *interval;
GValue value = { 0, };
gboolean apply;
interval = g_hash_table_lookup (priv->properties, p_name);
g_assert (CLUTTER_IS_INTERVAL (interval));
@ -791,20 +792,22 @@ on_alpha_notify (GObject *gobject,
initial = clutter_interval_peek_initial_value (interval);
final = clutter_interval_peek_final_value (interval);
clutter_animatable_animate_property (animatable, animation,
p_name,
initial, final,
alpha_value,
&value);
g_object_set_property (priv->object, p_name, &value);
apply = clutter_animatable_animate_property (animatable, animation,
p_name,
initial, final,
alpha_value,
&value);
}
else
{
if (clutter_interval_compute_value (interval, alpha_value, &value))
g_object_set_property (priv->object, p_name, &value);
apply = clutter_interval_compute_value (interval,
alpha_value,
&value);
}
if (apply)
g_object_set_property (priv->object, p_name, &value);
g_value_unset (&value);
}