[clutter/remove-alpha: 3/3] animation: Deprecate Alpha usage
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/remove-alpha: 3/3] animation: Deprecate Alpha usage
- Date: Mon, 10 Oct 2011 11:07:37 +0000 (UTC)
commit fabac882af6d126453234e5d4f541f637c85e8dc
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Mon Oct 10 11:25:40 2011 +0100
animation: Deprecate Alpha usage
We can use ClutterTimeline and its progress mode inside
ClutterAnimation; obviously, we have to maintain the invariants because
of the ClutterAnimation:alpha property, but if all you set is the :mode
property using one of the Clutter animation modes then we can skip the
ClutterAlpha entirely.
clutter/clutter-animation.c | 100 +++++++++++++++++++++++++++++++------------
clutter/clutter-animation.h | 7 +++
2 files changed, 80 insertions(+), 27 deletions(-)
---
diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c
index 8124373..e036718 100644
--- a/clutter/clutter-animation.c
+++ b/clutter/clutter-animation.c
@@ -193,6 +193,7 @@ struct _ClutterAnimationPrivate
GHashTable *properties;
ClutterAlpha *alpha;
+ ClutterTimeline *timeline;
guint timeline_started_id;
guint timeline_completed_id;
@@ -310,7 +311,7 @@ clutter_animation_dispose (GObject *gobject)
if (priv->alpha != NULL)
timeline = clutter_alpha_get_timeline (priv->alpha);
else
- timeline = NULL;
+ timeline = priv->timeline;
if (timeline != NULL && priv->timeline_started_id != 0)
g_signal_handler_disconnect (timeline, priv->timeline_started_id);
@@ -546,13 +547,16 @@ clutter_animation_class_init (ClutterAnimationClass *klass)
* The #ClutterAlpha used by the animation.
*
* Since: 1.0
+ *
+ * Deprecated: 1.10: Use the #ClutterAnimation:timeline property and
+ * the #ClutterTimeline:progress-mode property instead.
*/
obj_props[PROP_ALPHA] =
g_param_spec_object ("alpha",
P_("Alpha"),
P_("The alpha used by the animation"),
CLUTTER_TYPE_ALPHA,
- CLUTTER_PARAM_READWRITE);
+ CLUTTER_PARAM_READWRITE | G_PARAM_DEPRECATED);
g_object_class_install_properties (gobject_class,
PROP_LAST,
@@ -1089,7 +1093,10 @@ on_timeline_frame (ClutterTimeline *timeline,
priv = animation->priv;
- alpha_value = clutter_alpha_get_alpha (priv->alpha);
+ if (priv->alpha != NULL)
+ alpha_value = clutter_alpha_get_alpha (priv->alpha);
+ else
+ alpha_value = clutter_timeline_get_progress (priv->timeline);
if (CLUTTER_IS_ANIMATABLE (priv->object))
{
@@ -1169,12 +1176,16 @@ clutter_animation_get_timeline_internal (ClutterAnimation *animation)
{
ClutterAnimationPrivate *priv = animation->priv;
ClutterTimeline *timeline;
- ClutterAlpha *alpha;
- alpha = clutter_animation_get_alpha_internal (animation);
- timeline = clutter_alpha_get_timeline (alpha);
- if (timeline != NULL)
- return timeline;
+ if (priv->timeline != NULL)
+ return priv->timeline;
+
+ if (priv->alpha != NULL)
+ {
+ timeline = clutter_alpha_get_timeline (priv->alpha);
+ if (timeline != NULL)
+ return timeline;
+ }
timeline = g_object_new (CLUTTER_TYPE_TIMELINE, NULL);
@@ -1193,14 +1204,19 @@ clutter_animation_get_timeline_internal (ClutterAnimation *animation)
G_CALLBACK (on_timeline_frame),
animation);
- clutter_alpha_set_timeline (alpha, timeline);
+ if (priv->alpha != NULL)
+ {
+ clutter_alpha_set_timeline (priv->alpha, timeline);
+
+ /* the alpha owns the timeline now */
+ g_object_unref (timeline);
+ }
- /* the alpha owns the timeline now */
- g_object_unref (timeline);
+ priv->timeline = timeline;
g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_TIMELINE]);
- return timeline;
+ return priv->timeline;
}
/**
@@ -1301,16 +1317,29 @@ void
clutter_animation_set_mode (ClutterAnimation *animation,
gulong mode)
{
- ClutterAlpha *alpha;
-
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
g_object_freeze_notify (G_OBJECT (animation));
- alpha = clutter_animation_get_alpha_internal (animation);
- g_assert (CLUTTER_IS_ALPHA (alpha));
+ if (animation->priv->alpha != NULL || mode > CLUTTER_ANIMATION_LAST)
+ {
+ ClutterAlpha *alpha;
+
+ if (animation->priv->alpha == NULL)
+ alpha = clutter_animation_get_alpha_internal (animation);
+ else
+ alpha = animation->priv->alpha;
+
+ clutter_alpha_set_mode (alpha, mode);
+ }
+ else
+ {
+ ClutterTimeline *timeline;
- clutter_alpha_set_mode (alpha, mode);
+ timeline = clutter_animation_get_timeline_internal (animation);
+
+ clutter_timeline_set_progress_mode (timeline, mode);
+ }
g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_MODE]);
@@ -1331,13 +1360,16 @@ clutter_animation_set_mode (ClutterAnimation *animation,
gulong
clutter_animation_get_mode (ClutterAnimation *animation)
{
- ClutterAlpha *alpha;
+ ClutterTimeline *timeline;
g_return_val_if_fail (CLUTTER_IS_ANIMATION (animation), CLUTTER_LINEAR);
- alpha = clutter_animation_get_alpha_internal (animation);
+ if (animation->priv->alpha != NULL)
+ return clutter_alpha_get_mode (animation->priv->alpha);
+
+ timeline = clutter_animation_get_timeline_internal (animation);
- return clutter_alpha_get_mode (alpha);
+ return clutter_timeline_get_progress_mode (timeline);
}
/**
@@ -1363,8 +1395,6 @@ clutter_animation_set_duration (ClutterAnimation *animation,
g_object_freeze_notify (G_OBJECT (animation));
timeline = clutter_animation_get_timeline_internal (animation);
- g_assert (CLUTTER_IS_TIMELINE (timeline));
-
clutter_timeline_set_duration (timeline, msecs);
clutter_timeline_rewind (timeline);
@@ -1453,11 +1483,13 @@ clutter_animation_get_duration (ClutterAnimation *animation)
/**
* clutter_animation_set_timeline:
* @animation: a #ClutterAnimation
- * @timeline: a #ClutterTimeline, or %NULL to unset the
+ * @timeline: (allow-none): a #ClutterTimeline, or %NULL to unset the
* current #ClutterTimeline
*
* Sets the #ClutterTimeline used by @animation.
*
+ * This function will take a reference on the passed @timeline.
+ *
* Since: 1.0
*/
void
@@ -1466,7 +1498,6 @@ clutter_animation_set_timeline (ClutterAnimation *animation,
{
ClutterAnimationPrivate *priv;
ClutterTimeline *cur_timeline;
- ClutterAlpha *alpha;
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
g_return_if_fail (timeline == NULL || CLUTTER_IS_TIMELINE (timeline));
@@ -1496,14 +1527,19 @@ clutter_animation_set_timeline (ClutterAnimation *animation,
priv->timeline_completed_id = 0;
priv->timeline_frame_id = 0;
- alpha = clutter_animation_get_alpha_internal (animation);
- clutter_alpha_set_timeline (alpha, timeline);
+ if (priv->alpha != NULL)
+ clutter_alpha_set_timeline (priv->alpha, timeline);
+ else
+ priv->timeline = timeline;
+
g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_TIMELINE]);
g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_DURATION]);
g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_LOOP]);
- if (timeline)
+ if (timeline != NULL)
{
+ g_object_ref (timeline);
+
priv->timeline_started_id =
g_signal_connect (timeline, "started",
G_CALLBACK (on_timeline_started),
@@ -1550,6 +1586,9 @@ clutter_animation_get_timeline (ClutterAnimation *animation)
* of the #ClutterAlpha instance.
*
* Since: 1.0
+ *
+ * Deprecated: 1.10: Use clutter_animation_get_timeline() and
+ * clutter_timeline_set_progress_mode() instead.
*/
void
clutter_animation_set_alpha (ClutterAnimation *animation,
@@ -1650,6 +1689,9 @@ out:
* Return value: (transfer none): the alpha object used by the animation
*
* Since: 1.0
+ *
+ * Deprecated: 1.10: Use clutter_animation_get_timeline() and
+ * clutter_timeline_get_progress_mode() instead.
*/
ClutterAlpha *
clutter_animation_get_alpha (ClutterAnimation *animation)
@@ -2035,6 +2077,8 @@ animation_create_for_actor (ClutterActor *actor)
* #ClutterActor and should not be unreferenced with g_object_unref()
*
* Since: 1.0
+ *
+ * Deprecated: 1.10: Use clutter_actor_animate_with_timeline() instead
*/
ClutterAnimation *
clutter_actor_animate_with_alpha (ClutterActor *actor,
@@ -2444,6 +2488,8 @@ clutter_actor_animate_with_timelinev (ClutterActor *actor,
* #ClutterActor and should not be unreferenced with g_object_unref()
*
* Since: 1.0
+ *
+ * Deprecated: 1.10: Use clutter_actor_animate_with_timelinev() instead
*/
ClutterAnimation *
clutter_actor_animate_with_alphav (ClutterActor *actor,
diff --git a/clutter/clutter-animation.h b/clutter/clutter-animation.h
index f572e4d..9e452fc 100644
--- a/clutter/clutter-animation.h
+++ b/clutter/clutter-animation.h
@@ -114,9 +114,12 @@ gboolean clutter_animation_get_loop (ClutterAnimation *an
void clutter_animation_set_timeline (ClutterAnimation *animation,
ClutterTimeline *timeline);
ClutterTimeline * clutter_animation_get_timeline (ClutterAnimation *animation);
+
+#if !defined(CLUTTER_DISABLE_DEPRECATED) || defined(CLUTTER_COMPILATION)
void clutter_animation_set_alpha (ClutterAnimation *animation,
ClutterAlpha *alpha);
ClutterAlpha * clutter_animation_get_alpha (ClutterAnimation *animation);
+#endif
ClutterAnimation * clutter_animation_bind (ClutterAnimation *animation,
const gchar *property_name,
@@ -148,10 +151,12 @@ ClutterAnimation * clutter_actor_animate_with_timeline (ClutterActor *
ClutterTimeline *timeline,
const gchar *first_property_name,
...) G_GNUC_NULL_TERMINATED;
+#if !defined(CLUTTER_DISABLE_DEPRECATED) || defined(CLUTTER_COMPILATION)
ClutterAnimation * clutter_actor_animate_with_alpha (ClutterActor *actor,
ClutterAlpha *alpha,
const gchar *first_property_name,
...) G_GNUC_NULL_TERMINATED;
+#endif
ClutterAnimation * clutter_actor_animatev (ClutterActor *actor,
gulong mode,
@@ -165,11 +170,13 @@ ClutterAnimation * clutter_actor_animate_with_timelinev (ClutterActor
gint n_properties,
const gchar * const properties[],
const GValue *values);
+#if !defined(CLUTTER_DISABLE_DEPRECATED) || defined(CLUTTER_COMPILATION)
ClutterAnimation * clutter_actor_animate_with_alphav (ClutterActor *actor,
ClutterAlpha *alpha,
gint n_properties,
const gchar * const properties[],
const GValue *values);
+#endif
ClutterAnimation * clutter_actor_get_animation (ClutterActor *actor);
void clutter_actor_detach_animation (ClutterActor *actor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]