animatable: Add custom properties to Animatable

Like ClutterScriptable, it would be good to have the Animatable
interface allow defining custom properties that can be animated.
This commit is contained in:
Emmanuele Bassi 2010-05-19 12:21:54 +01:00
parent b842f0ad8e
commit 3a1162cbcf
2 changed files with 100 additions and 14 deletions

View File

@ -124,3 +124,66 @@ clutter_animatable_animate_property (ClutterAnimatable *animatable,
return res;
}
GParamSpec *
clutter_animatable_find_property (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name)
{
ClutterAnimatableIface *iface;
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);
CLUTTER_NOTE (ANIMATION, "Looking for property '%s'", property_name);
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
if (iface->find_property != NULL)
return iface->find_property (animatable, animation, property_name);
return g_object_class_find_property (G_OBJECT_GET_CLASS (animatable),
property_name);
}
void
clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
GValue *value)
{
ClutterAnimatableIface *iface;
g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
g_return_if_fail (property_name != NULL);
CLUTTER_NOTE (ANIMATION, "Getting initial state of '%s'", property_name);
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
if (iface->get_initial_state != NULL)
iface->get_initial_state (animatable, animation, property_name, value);
else
g_object_get_property (G_OBJECT (animatable), property_name, value);
}
void
clutter_animatable_set_final_state (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
const GValue *value)
{
ClutterAnimatableIface *iface;
g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
g_return_if_fail (property_name != NULL);
CLUTTER_NOTE (ANIMATION, "Setting state of property '%s'", property_name);
iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
if (iface->set_final_state != NULL)
iface->set_final_state (animatable, animation, property_name, value);
else
g_object_set_property (G_OBJECT (animatable), property_name, value);
}

View File

@ -65,24 +65,47 @@ struct _ClutterAnimatableIface
GTypeInterface parent_iface;
/*< public >*/
gboolean (* animate_property) (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
const GValue *initial_value,
const GValue *final_value,
gdouble progress,
GValue *value);
gboolean (* animate_property) (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
const GValue *initial_value,
const GValue *final_value,
gdouble progress,
GValue *value);
GParamSpec *(* find_property) (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name);
void (* get_initial_state) (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
GValue *value);
void (* set_final_state) (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
const GValue *value);
};
GType clutter_animatable_get_type (void) G_GNUC_CONST;
gboolean clutter_animatable_animate_property (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
const GValue *initial_value,
const GValue *final_value,
gdouble progress,
GValue *value);
gboolean clutter_animatable_animate_property (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
const GValue *initial_value,
const GValue *final_value,
gdouble progress,
GValue *value);
GParamSpec *clutter_animatable_find_property (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name);
void clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
GValue *initial);
void clutter_animatable_set_final_state (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
const GValue *final);
G_END_DECLS