[clutter] animatable: Deprecate and replace animate_property()
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] animatable: Deprecate and replace animate_property()
- Date: Fri, 29 Jul 2011 10:53:27 +0000 (UTC)
commit 8b861cea8fdc10231b9ed466e688d1b7abf48f2c
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Jul 15 14:27:26 2011 +0100
animatable: Deprecate and replace animate_property()
The animate_property() method of the Animatable interface is far less
than optimal:
â it has a direct reference to ClutterAnimation;
â it has an interval decomposed as two values.
These issues tie the Animatable interface with the Animation object,
even though it's neither necessary nor future-proof.
Let's introduce a new method, interpolate_value(), which does not
reference ClutterAnimation and uses a ClutterInterval to express the
initial and final states.
clutter/clutter-animatable.c | 62 ++++++++++++++++++++++++++++++++++++-----
clutter/clutter-animatable.h | 16 ++++++++++-
2 files changed, 69 insertions(+), 9 deletions(-)
---
diff --git a/clutter/clutter-animatable.c b/clutter/clutter-animatable.c
index cbf4597..f5400e3 100644
--- a/clutter/clutter-animatable.c
+++ b/clutter/clutter-animatable.c
@@ -84,6 +84,9 @@ clutter_animatable_default_init (ClutterAnimatableInterface *iface)
* be applied to the #ClutterAnimatable, and %FALSE otherwise
*
* Since: 1.0
+ *
+ * Deprecated: 1.8: Use clutter_animatable_interpolate_value()
+ * instead
*/
gboolean
clutter_animatable_animate_property (ClutterAnimatable *animatable,
@@ -94,6 +97,7 @@ clutter_animatable_animate_property (ClutterAnimatable *animatable,
gdouble progress,
GValue *value)
{
+ ClutterAnimatableIface *iface;
gboolean res;
g_return_val_if_fail (CLUTTER_IS_ANIMATABLE (animatable), FALSE);
@@ -107,14 +111,26 @@ clutter_animatable_animate_property (ClutterAnimatable *animatable,
G_VALUE_TYPE (value) == G_VALUE_TYPE (final_value),
FALSE);
- res =
- CLUTTER_ANIMATABLE_GET_IFACE (animatable)->animate_property (animatable,
- animation,
- property_name,
- initial_value,
- final_value,
- progress,
- value);
+ iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
+ if (iface->animate_property == NULL)
+ {
+ ClutterInterval *interval;
+
+ interval = clutter_animation_get_interval (animation, property_name);
+ if (interval == NULL)
+ return FALSE;
+
+ res = clutter_animatable_interpolate_value (animatable, property_name,
+ interval,
+ progress,
+ value);
+ }
+ else
+ res = iface->animate_property (animatable, animation,
+ property_name,
+ initial_value, final_value,
+ progress,
+ value);
return res;
}
@@ -207,3 +223,33 @@ clutter_animatable_set_final_state (ClutterAnimatable *animatable,
else
g_object_set_property (G_OBJECT (animatable), property_name, value);
}
+
+gboolean
+clutter_animatable_interpolate_value (ClutterAnimatable *animatable,
+ const gchar *property_name,
+ ClutterInterval *interval,
+ gdouble progress,
+ GValue *value)
+{
+ ClutterAnimatableIface *iface;
+
+ g_return_val_if_fail (CLUTTER_IS_ANIMATABLE (animatable), FALSE);
+ g_return_val_if_fail (property_name != NULL, FALSE);
+ g_return_val_if_fail (CLUTTER_IS_INTERVAL (interval), FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
+
+ CLUTTER_NOTE (ANIMATION, "Interpolating '%s' (progress: %.3f)",
+ property_name,
+ progress);
+
+ iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
+ if (iface->interpolate_value != NULL)
+ {
+ return iface->interpolate_value (animatable, property_name,
+ interval,
+ progress,
+ value);
+ }
+ else
+ return clutter_interval_compute_value (interval, progress, value);
+}
diff --git a/clutter/clutter-animatable.h b/clutter/clutter-animatable.h
index 2edd6b0..13690f9 100644
--- a/clutter/clutter-animatable.h
+++ b/clutter/clutter-animatable.h
@@ -53,13 +53,15 @@ typedef struct _ClutterAnimatableIface ClutterAnimatableIface;
/**
* ClutterAnimatableIface:
* @animate_property: virtual function for custom interpolation of a
- * property
+ * property. This virtual function is deprecated
* @find_property: virtual function for retrieving the #GParamSpec of
* an animatable property
* @get_initial_state: virtual function for retrieving the initial
* state of an animatable property
* @set_final_state: virtual function for setting the state of an
* animatable property
+ * @interpolate_value: virtual function for interpolating the progress
+ * of a property
*
* Base interface for #GObject<!-- -->s that can be animated by a
* a #ClutterAnimation.
@@ -87,10 +89,16 @@ struct _ClutterAnimatableIface
void (* set_final_state) (ClutterAnimatable *animatable,
const gchar *property_name,
const GValue *value);
+ gboolean (* interpolate_value) (ClutterAnimatable *animatable,
+ const gchar *property_name,
+ ClutterInterval *interval,
+ gdouble progress,
+ GValue *value);
};
GType clutter_animatable_get_type (void) G_GNUC_CONST;
+#ifndef CLUTTER_DISABLE_DEPRECATED
gboolean clutter_animatable_animate_property (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
@@ -98,6 +106,7 @@ gboolean clutter_animatable_animate_property (ClutterAnimatable *animatable,
const GValue *final_value,
gdouble progress,
GValue *value);
+#endif /* CLUTTER_DISABLE_DEPRECATED */
GParamSpec *clutter_animatable_find_property (ClutterAnimatable *animatable,
const gchar *property_name);
@@ -107,6 +116,11 @@ void clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
void clutter_animatable_set_final_state (ClutterAnimatable *animatable,
const gchar *property_name,
const GValue *value);
+gboolean clutter_animatable_interpolate_value (ClutterAnimatable *animatable,
+ const gchar *property_name,
+ ClutterInterval *interval,
+ gdouble progress,
+ GValue *value);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]