mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
[animation] Add Animation::update()
Currently, to update a property inside an animation you have to get the interval for that property and then call the set_final_value() method. We can provide a simpler, bind()-like method for the convenience of the developers that just validates everything and then calls the Interval.set_final_value().
This commit is contained in:
parent
4ca375e8fe
commit
899f051cd9
@ -765,6 +765,59 @@ clutter_animation_update_interval (ClutterAnimation *animation,
|
||||
clutter_animation_update_property_internal (animation, pspec, interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_animation_update:
|
||||
* @animation: a #ClutterAnimation
|
||||
* @property_name: name of the property
|
||||
* @final: The final value of the property
|
||||
*
|
||||
* Updates the @final value of the interval for @property_name
|
||||
*
|
||||
* Return value: (transfer none): The animation itself.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
ClutterAnimation *
|
||||
clutter_animation_update (ClutterAnimation *animation,
|
||||
const gchar *property_name,
|
||||
const GValue *final)
|
||||
{
|
||||
ClutterAnimationPrivate *priv;
|
||||
ClutterInterval *interval;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_ANIMATION (animation), NULL);
|
||||
g_return_val_if_fail (property_name != NULL, NULL);
|
||||
g_return_val_if_fail (final != NULL, NULL);
|
||||
g_return_val_if_fail (G_VALUE_TYPE (final) != G_TYPE_INVALID, NULL);
|
||||
|
||||
priv = animation->priv;
|
||||
|
||||
interval = clutter_animation_get_interval (animation, property_name);
|
||||
if (interval == NULL)
|
||||
{
|
||||
g_warning ("Cannot update property '%s': the animation has "
|
||||
"no bound property with that name",
|
||||
property_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!g_value_type_compatible (G_VALUE_TYPE (final),
|
||||
clutter_interval_get_value_type (interval)))
|
||||
{
|
||||
g_warning ("Cannot update property '%s': the interval value of "
|
||||
"type '%s' is not compatible with the property value "
|
||||
"of type '%s'",
|
||||
property_name,
|
||||
g_type_name (clutter_interval_get_value_type (interval)),
|
||||
g_type_name (G_VALUE_TYPE (final)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
clutter_interval_set_final_value (interval, final);
|
||||
|
||||
return animation;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_animation_get_interval:
|
||||
* @animation: a #ClutterAnimation
|
||||
|
@ -126,6 +126,9 @@ ClutterAnimation * clutter_animation_bind_interval (ClutterAnimation *an
|
||||
ClutterInterval *interval);
|
||||
gboolean clutter_animation_has_property (ClutterAnimation *animation,
|
||||
const gchar *property_name);
|
||||
ClutterAnimation * clutter_animation_update (ClutterAnimation *animation,
|
||||
const gchar *property_name,
|
||||
const GValue *final);
|
||||
void clutter_animation_update_interval (ClutterAnimation *animation,
|
||||
const gchar *property_name,
|
||||
ClutterInterval *interval);
|
||||
|
@ -1436,6 +1436,7 @@ clutter_animation_completed
|
||||
<SUBSECTION>
|
||||
clutter_animation_bind
|
||||
clutter_animation_bind_interval
|
||||
clutter_animation_update
|
||||
clutter_animation_update_interval
|
||||
clutter_animation_has_property
|
||||
clutter_animation_unbind_property
|
||||
|
Loading…
Reference in New Issue
Block a user