mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
property-transition: Verify the interval on compute_value()
By checking if the interval is valid inside compute_value() we can catch the cases where the interval values of a PropertyTransition are set after the transition has been added to an Animatable instance - i.e. the following code: let transition = new Clutter.PropertyTransition(); transition.set_property_name('opacity'); actor.add_transition('opacityAnim', transition); transition.set_to_value(0); should be equivalent to: let transition = new Clutter.PropertyTransition(); transition.set_property_name('opacity'); transition.set_to_value(0); actor.add_transition('opacityAnim', transition); instead of emitting a warning.
This commit is contained in:
parent
762053cd28
commit
b21cb29479
@ -62,6 +62,38 @@ static GParamSpec *obj_props[PROP_LAST] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE (ClutterPropertyTransition, clutter_property_transition, CLUTTER_TYPE_TRANSITION)
|
||||
|
||||
static inline void
|
||||
clutter_property_transition_ensure_interval (ClutterPropertyTransition *transition,
|
||||
ClutterAnimatable *animatable,
|
||||
ClutterInterval *interval)
|
||||
{
|
||||
ClutterPropertyTransitionPrivate *priv = transition->priv;
|
||||
GValue *value_p;
|
||||
|
||||
if (clutter_interval_is_valid (interval))
|
||||
return;
|
||||
|
||||
/* if no initial value has been set, use the current value */
|
||||
value_p = clutter_interval_peek_initial_value (interval);
|
||||
if (!G_IS_VALUE (value_p))
|
||||
{
|
||||
g_value_init (value_p, clutter_interval_get_value_type (interval));
|
||||
clutter_animatable_get_initial_state (animatable,
|
||||
priv->property_name,
|
||||
value_p);
|
||||
}
|
||||
|
||||
/* if no final value has been set, use the current value */
|
||||
value_p = clutter_interval_peek_final_value (interval);
|
||||
if (!G_IS_VALUE (value_p))
|
||||
{
|
||||
g_value_init (value_p, clutter_interval_get_value_type (interval));
|
||||
clutter_animatable_get_initial_state (animatable,
|
||||
priv->property_name,
|
||||
value_p);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_property_transition_attached (ClutterTransition *transition,
|
||||
ClutterAnimatable *animatable)
|
||||
@ -69,7 +101,6 @@ clutter_property_transition_attached (ClutterTransition *transition,
|
||||
ClutterPropertyTransition *self = CLUTTER_PROPERTY_TRANSITION (transition);
|
||||
ClutterPropertyTransitionPrivate *priv = self->priv;
|
||||
ClutterInterval *interval;
|
||||
GValue *value;
|
||||
|
||||
if (priv->property_name == NULL)
|
||||
return;
|
||||
@ -84,25 +115,7 @@ clutter_property_transition_attached (ClutterTransition *transition,
|
||||
if (interval == NULL)
|
||||
return;
|
||||
|
||||
/* if no initial value has been set, use the current value */
|
||||
value = clutter_interval_peek_initial_value (interval);
|
||||
if (!G_IS_VALUE (value))
|
||||
{
|
||||
g_value_init (value, clutter_interval_get_value_type (interval));
|
||||
clutter_animatable_get_initial_state (animatable,
|
||||
priv->property_name,
|
||||
value);
|
||||
}
|
||||
|
||||
/* if no final value has been set, use the current value */
|
||||
value = clutter_interval_peek_final_value (interval);
|
||||
if (!G_IS_VALUE (value))
|
||||
{
|
||||
g_value_init (value, clutter_interval_get_value_type (interval));
|
||||
clutter_animatable_get_initial_state (animatable,
|
||||
priv->property_name,
|
||||
value);
|
||||
}
|
||||
clutter_property_transition_ensure_interval (self, animatable, interval);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -130,6 +143,8 @@ clutter_property_transition_compute_value (ClutterTransition *transition,
|
||||
if (priv->pspec == NULL)
|
||||
return;
|
||||
|
||||
clutter_property_transition_ensure_interval (self, animatable, interval);
|
||||
|
||||
g_value_init (&value, clutter_interval_get_value_type (interval));
|
||||
|
||||
res = clutter_animatable_interpolate_value (animatable,
|
||||
|
Loading…
Reference in New Issue
Block a user