transition: Use current values if no interval is defined
Once a ClutterPropertyTransition is attached to a ClutterAnimatable, if no interval is set we can simply use the current state of the property to define the from and to values. This allows the creation of property transitions from the current state of the Animatable instance without excessive verbosity.
This commit is contained in:
parent
189a93677f
commit
7660f5d0c6
@ -68,12 +68,41 @@ 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;
|
||||
|
||||
priv->pspec = clutter_animatable_find_property (animatable,
|
||||
priv->property_name);
|
||||
priv->pspec =
|
||||
clutter_animatable_find_property (animatable, priv->property_name);
|
||||
|
||||
if (priv->pspec == NULL)
|
||||
return;
|
||||
|
||||
interval = clutter_transition_get_interval (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);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -469,10 +469,9 @@ clutter_transition_set_value (ClutterTransition *transition,
|
||||
if (priv->interval == NULL)
|
||||
{
|
||||
priv->interval = clutter_interval_new_with_values (G_VALUE_TYPE (value),
|
||||
value,
|
||||
value);
|
||||
NULL,
|
||||
NULL);
|
||||
g_object_ref_sink (priv->interval);
|
||||
return;
|
||||
}
|
||||
|
||||
interval_type = clutter_interval_get_value_type (priv->interval);
|
||||
|
Loading…
x
Reference in New Issue
Block a user