mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
animatable: Allow passing a NULL animation
The Animatable interface was created specifically for the Animation class. It turns out that it might be fairly useful to others - such as ClutterAnimator and ClutterState. The newly-added API in this cycle for querying and accessing custom properties should not require that we pass a ClutterAnimation to the implementations: the Animatable itself should be enough. This is necessary to allow language bindings to wrap clutter_actor_animate() correctly and do type validation and demarshalling between native values and GValues; an Animation instance is not available until the animate() call returns, and validation must be performed before that happens. There is nothing we can do about the animate_property() virtual function - but in that case we might want to be able to access the animation from an Animatable implementation to get the Interval for the property, just like ClutterActor does in order to animate ClutterActorMeta objects.
This commit is contained in:
parent
c65c0f08d8
commit
c23b283968
@ -8613,7 +8613,6 @@ get_meta_from_animation_property (ClutterActor *actor,
|
|||||||
|
|
||||||
static GParamSpec *
|
static GParamSpec *
|
||||||
clutter_actor_find_property (ClutterAnimatable *animatable,
|
clutter_actor_find_property (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name)
|
const gchar *property_name)
|
||||||
{
|
{
|
||||||
ClutterActorMeta *meta = NULL;
|
ClutterActorMeta *meta = NULL;
|
||||||
@ -8645,7 +8644,6 @@ clutter_actor_find_property (ClutterAnimatable *animatable,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_actor_get_initial_state (ClutterAnimatable *animatable,
|
clutter_actor_get_initial_state (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name,
|
const gchar *property_name,
|
||||||
GValue *initial)
|
GValue *initial)
|
||||||
{
|
{
|
||||||
@ -8666,7 +8664,6 @@ clutter_actor_get_initial_state (ClutterAnimatable *animatable,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_actor_set_final_state (ClutterAnimatable *animatable,
|
clutter_actor_set_final_state (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name,
|
const gchar *property_name,
|
||||||
const GValue *final)
|
const GValue *final)
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,6 @@ clutter_animatable_animate_property (ClutterAnimatable *animatable,
|
|||||||
/**
|
/**
|
||||||
* clutter_animatable_find_property:
|
* clutter_animatable_find_property:
|
||||||
* @animatable: a #ClutterAnimatable
|
* @animatable: a #ClutterAnimatable
|
||||||
* @animation: a #ClutterAnimation
|
|
||||||
* @property_name: the name of the animatable property to find
|
* @property_name: the name of the animatable property to find
|
||||||
*
|
*
|
||||||
* Finds the #GParamSpec for @property_name
|
* Finds the #GParamSpec for @property_name
|
||||||
@ -140,20 +139,18 @@ clutter_animatable_animate_property (ClutterAnimatable *animatable,
|
|||||||
*/
|
*/
|
||||||
GParamSpec *
|
GParamSpec *
|
||||||
clutter_animatable_find_property (ClutterAnimatable *animatable,
|
clutter_animatable_find_property (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name)
|
const gchar *property_name)
|
||||||
{
|
{
|
||||||
ClutterAnimatableIface *iface;
|
ClutterAnimatableIface *iface;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ANIMATABLE (animatable), NULL);
|
g_return_val_if_fail (CLUTTER_IS_ANIMATABLE (animatable), NULL);
|
||||||
g_return_val_if_fail (CLUTTER_IS_ANIMATION (animation), NULL);
|
|
||||||
g_return_val_if_fail (property_name != NULL, NULL);
|
g_return_val_if_fail (property_name != NULL, NULL);
|
||||||
|
|
||||||
CLUTTER_NOTE (ANIMATION, "Looking for property '%s'", property_name);
|
CLUTTER_NOTE (ANIMATION, "Looking for property '%s'", property_name);
|
||||||
|
|
||||||
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
|
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
|
||||||
if (iface->find_property != NULL)
|
if (iface->find_property != NULL)
|
||||||
return iface->find_property (animatable, animation, property_name);
|
return iface->find_property (animatable, property_name);
|
||||||
|
|
||||||
return g_object_class_find_property (G_OBJECT_GET_CLASS (animatable),
|
return g_object_class_find_property (G_OBJECT_GET_CLASS (animatable),
|
||||||
property_name);
|
property_name);
|
||||||
@ -162,7 +159,6 @@ clutter_animatable_find_property (ClutterAnimatable *animatable,
|
|||||||
/**
|
/**
|
||||||
* clutter_animatable_get_initial_state:
|
* clutter_animatable_get_initial_state:
|
||||||
* @animatable: a #ClutterAnimatable
|
* @animatable: a #ClutterAnimatable
|
||||||
* @animation: a #ClutterAnimation
|
|
||||||
* @property_name: the name of the animatable property to retrieve
|
* @property_name: the name of the animatable property to retrieve
|
||||||
* @value: a #GValue initialized to the type of the property to retrieve
|
* @value: a #GValue initialized to the type of the property to retrieve
|
||||||
*
|
*
|
||||||
@ -172,21 +168,19 @@ clutter_animatable_find_property (ClutterAnimatable *animatable,
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
|
clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name,
|
const gchar *property_name,
|
||||||
GValue *value)
|
GValue *value)
|
||||||
{
|
{
|
||||||
ClutterAnimatableIface *iface;
|
ClutterAnimatableIface *iface;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
|
g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
|
||||||
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
|
|
||||||
g_return_if_fail (property_name != NULL);
|
g_return_if_fail (property_name != NULL);
|
||||||
|
|
||||||
CLUTTER_NOTE (ANIMATION, "Getting initial state of '%s'", property_name);
|
CLUTTER_NOTE (ANIMATION, "Getting initial state of '%s'", property_name);
|
||||||
|
|
||||||
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
|
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
|
||||||
if (iface->get_initial_state != NULL)
|
if (iface->get_initial_state != NULL)
|
||||||
iface->get_initial_state (animatable, animation, property_name, value);
|
iface->get_initial_state (animatable, property_name, value);
|
||||||
else
|
else
|
||||||
g_object_get_property (G_OBJECT (animatable), property_name, value);
|
g_object_get_property (G_OBJECT (animatable), property_name, value);
|
||||||
}
|
}
|
||||||
@ -194,7 +188,6 @@ clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
|
|||||||
/**
|
/**
|
||||||
* clutter_animatable_set_final_state:
|
* clutter_animatable_set_final_state:
|
||||||
* @animatable: a #ClutterAnimatable
|
* @animatable: a #ClutterAnimatable
|
||||||
* @animation: a #ClutterAnimation
|
|
||||||
* @property_name: the name of the animatable property to set
|
* @property_name: the name of the animatable property to set
|
||||||
* @value: the value of the animatable property to set
|
* @value: the value of the animatable property to set
|
||||||
*
|
*
|
||||||
@ -204,21 +197,19 @@ clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
clutter_animatable_set_final_state (ClutterAnimatable *animatable,
|
clutter_animatable_set_final_state (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name,
|
const gchar *property_name,
|
||||||
const GValue *value)
|
const GValue *value)
|
||||||
{
|
{
|
||||||
ClutterAnimatableIface *iface;
|
ClutterAnimatableIface *iface;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
|
g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
|
||||||
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
|
|
||||||
g_return_if_fail (property_name != NULL);
|
g_return_if_fail (property_name != NULL);
|
||||||
|
|
||||||
CLUTTER_NOTE (ANIMATION, "Setting state of property '%s'", property_name);
|
CLUTTER_NOTE (ANIMATION, "Setting state of property '%s'", property_name);
|
||||||
|
|
||||||
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
|
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
|
||||||
if (iface->set_final_state != NULL)
|
if (iface->set_final_state != NULL)
|
||||||
iface->set_final_state (animatable, animation, property_name, value);
|
iface->set_final_state (animatable, property_name, value);
|
||||||
else
|
else
|
||||||
g_object_set_property (G_OBJECT (animatable), property_name, value);
|
g_object_set_property (G_OBJECT (animatable), property_name, value);
|
||||||
}
|
}
|
||||||
|
@ -80,14 +80,11 @@ struct _ClutterAnimatableIface
|
|||||||
gdouble progress,
|
gdouble progress,
|
||||||
GValue *value);
|
GValue *value);
|
||||||
GParamSpec *(* find_property) (ClutterAnimatable *animatable,
|
GParamSpec *(* find_property) (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name);
|
const gchar *property_name);
|
||||||
void (* get_initial_state) (ClutterAnimatable *animatable,
|
void (* get_initial_state) (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name,
|
const gchar *property_name,
|
||||||
GValue *value);
|
GValue *value);
|
||||||
void (* set_final_state) (ClutterAnimatable *animatable,
|
void (* set_final_state) (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name,
|
const gchar *property_name,
|
||||||
const GValue *value);
|
const GValue *value);
|
||||||
};
|
};
|
||||||
@ -103,14 +100,11 @@ gboolean clutter_animatable_animate_property (ClutterAnimatable *animatable,
|
|||||||
GValue *value);
|
GValue *value);
|
||||||
|
|
||||||
GParamSpec *clutter_animatable_find_property (ClutterAnimatable *animatable,
|
GParamSpec *clutter_animatable_find_property (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name);
|
const gchar *property_name);
|
||||||
void clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
|
void clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name,
|
const gchar *property_name,
|
||||||
GValue *value);
|
GValue *value);
|
||||||
void clutter_animatable_set_final_state (ClutterAnimatable *animatable,
|
void clutter_animatable_set_final_state (ClutterAnimatable *animatable,
|
||||||
ClutterAnimation *animation,
|
|
||||||
const gchar *property_name,
|
const gchar *property_name,
|
||||||
const GValue *value);
|
const GValue *value);
|
||||||
|
|
||||||
|
@ -241,9 +241,7 @@ clutter_animation_real_completed (ClutterAnimation *self)
|
|||||||
p_value = clutter_interval_peek_initial_value (interval);
|
p_value = clutter_interval_peek_initial_value (interval);
|
||||||
|
|
||||||
if (animatable != NULL)
|
if (animatable != NULL)
|
||||||
clutter_animatable_set_final_state (animatable, self,
|
clutter_animatable_set_final_state (animatable, p_name, p_value);
|
||||||
p_name,
|
|
||||||
p_value);
|
|
||||||
else
|
else
|
||||||
g_object_set_property (priv->object, p_name, p_value);
|
g_object_set_property (priv->object, p_name, p_value);
|
||||||
}
|
}
|
||||||
@ -662,9 +660,7 @@ clutter_animation_validate_bind (ClutterAnimation *animation,
|
|||||||
{
|
{
|
||||||
ClutterAnimatable *animatable = CLUTTER_ANIMATABLE (priv->object);
|
ClutterAnimatable *animatable = CLUTTER_ANIMATABLE (priv->object);
|
||||||
|
|
||||||
pspec = clutter_animatable_find_property (animatable,
|
pspec = clutter_animatable_find_property (animatable, property_name);
|
||||||
animation,
|
|
||||||
property_name);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -789,7 +785,6 @@ clutter_animation_bind (ClutterAnimation *animation,
|
|||||||
|
|
||||||
if (CLUTTER_IS_ANIMATABLE (priv->object))
|
if (CLUTTER_IS_ANIMATABLE (priv->object))
|
||||||
clutter_animatable_get_initial_state (CLUTTER_ANIMATABLE (priv->object),
|
clutter_animatable_get_initial_state (CLUTTER_ANIMATABLE (priv->object),
|
||||||
animation,
|
|
||||||
property_name,
|
property_name,
|
||||||
&initial);
|
&initial);
|
||||||
else
|
else
|
||||||
@ -901,9 +896,7 @@ clutter_animation_update_interval (ClutterAnimation *animation,
|
|||||||
{
|
{
|
||||||
ClutterAnimatable *animatable = CLUTTER_ANIMATABLE (priv->object);
|
ClutterAnimatable *animatable = CLUTTER_ANIMATABLE (priv->object);
|
||||||
|
|
||||||
pspec = clutter_animatable_find_property (animatable,
|
pspec = clutter_animatable_find_property (animatable, property_name);
|
||||||
animation,
|
|
||||||
property_name);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1101,9 +1094,7 @@ on_alpha_notify (GObject *gobject,
|
|||||||
if (apply)
|
if (apply)
|
||||||
{
|
{
|
||||||
if (is_animatable)
|
if (is_animatable)
|
||||||
clutter_animatable_set_final_state (animatable, animation,
|
clutter_animatable_set_final_state (animatable, p_name, &value);
|
||||||
p_name,
|
|
||||||
&value);
|
|
||||||
else
|
else
|
||||||
g_object_set_property (priv->object, p_name, &value);
|
g_object_set_property (priv->object, p_name, &value);
|
||||||
}
|
}
|
||||||
@ -1747,7 +1738,6 @@ done:
|
|||||||
|
|
||||||
if (CLUTTER_IS_ANIMATABLE (priv->object))
|
if (CLUTTER_IS_ANIMATABLE (priv->object))
|
||||||
clutter_animatable_get_initial_state (CLUTTER_ANIMATABLE (priv->object),
|
clutter_animatable_get_initial_state (CLUTTER_ANIMATABLE (priv->object),
|
||||||
animation,
|
|
||||||
property_name,
|
property_name,
|
||||||
&cur_value);
|
&cur_value);
|
||||||
else
|
else
|
||||||
@ -1773,7 +1763,6 @@ done:
|
|||||||
{
|
{
|
||||||
if (CLUTTER_IS_ANIMATABLE (priv->object))
|
if (CLUTTER_IS_ANIMATABLE (priv->object))
|
||||||
clutter_animatable_set_final_state (CLUTTER_ANIMATABLE (priv->object),
|
clutter_animatable_set_final_state (CLUTTER_ANIMATABLE (priv->object),
|
||||||
animation,
|
|
||||||
property_name,
|
property_name,
|
||||||
&real_value);
|
&real_value);
|
||||||
else
|
else
|
||||||
@ -1812,9 +1801,7 @@ clutter_animation_setupv (ClutterAnimation *animation,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (animatable != NULL)
|
if (animatable != NULL)
|
||||||
pspec = clutter_animatable_find_property (animatable,
|
pspec = clutter_animatable_find_property (animatable, property_name);
|
||||||
animation,
|
|
||||||
property_name);
|
|
||||||
else
|
else
|
||||||
pspec = g_object_class_find_property (klass, property_name);
|
pspec = g_object_class_find_property (klass, property_name);
|
||||||
|
|
||||||
@ -1914,7 +1901,6 @@ clutter_animation_setup_valist (ClutterAnimation *animation,
|
|||||||
|
|
||||||
if (animatable != NULL)
|
if (animatable != NULL)
|
||||||
pspec = clutter_animatable_find_property (animatable,
|
pspec = clutter_animatable_find_property (animatable,
|
||||||
animation,
|
|
||||||
property_name);
|
property_name);
|
||||||
else
|
else
|
||||||
pspec = g_object_class_find_property (klass, property_name);
|
pspec = g_object_class_find_property (klass, property_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user