From 4a21425f4837798d01f4435b68582faf9029c61c Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 13 Dec 2009 01:23:54 +0000 Subject: [PATCH] layout: Let begin_animation() return the Alpha When beginning a new animation for a LayoutManager, the implementation should return the ClutterAlpha used. This allows controlling the timeline and/or modifying the animation parameters on the fly. --- clutter/clutter-box-layout.c | 5 +++-- clutter/clutter-layout-manager.c | 30 ++++++++++++++++++++++-------- clutter/clutter-layout-manager.h | 5 +++-- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/clutter/clutter-box-layout.c b/clutter/clutter-box-layout.c index 00b16256a..f9a7dbb0d 100644 --- a/clutter/clutter-box-layout.c +++ b/clutter/clutter-box-layout.c @@ -967,7 +967,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout, g_list_free (children); } -static void +static ClutterAlpha * clutter_box_layout_begin_animation (ClutterLayoutManager *manager, guint duration, gulong easing) @@ -982,7 +982,8 @@ clutter_box_layout_begin_animation (ClutterLayoutManager *manager, /* we want the default implementation */ parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_box_layout_parent_class); - parent_class->begin_animation (manager, duration, easing); + + return parent_class->begin_animation (manager, duration, easing); } static void diff --git a/clutter/clutter-layout-manager.c b/clutter/clutter-layout-manager.c index 251f3e647..35b624f1d 100644 --- a/clutter/clutter-layout-manager.c +++ b/clutter/clutter-layout-manager.c @@ -226,7 +226,7 @@ layout_manager_real_get_child_meta_type (ClutterLayoutManager *manager) return G_TYPE_INVALID; } -static void +static ClutterAlpha * layout_manager_real_begin_animation (ClutterLayoutManager *manager, guint duration, gulong mode) @@ -236,7 +236,14 @@ layout_manager_real_begin_animation (ClutterLayoutManager *manager, alpha = g_object_get_qdata (G_OBJECT (manager), quark_layout_alpha); if (alpha != NULL) - return; + { + timeline = clutter_alpha_get_timeline (alpha); + clutter_timeline_set_duration (timeline, duration); + + clutter_alpha_set_mode (alpha, mode); + + return alpha; + }; timeline = clutter_timeline_new (duration); alpha = clutter_alpha_new_full (timeline, mode); @@ -254,6 +261,8 @@ layout_manager_real_begin_animation (ClutterLayoutManager *manager, (GDestroyNotify) g_object_unref); clutter_timeline_start (timeline); + + return alpha; } static gdouble @@ -1004,19 +1013,24 @@ clutter_layout_manager_list_child_properties (ClutterLayoutManager *manager, * * The result of this function depends on the @manager implementation * + * Return value: (transfer none): The #ClutterAlpha created by the + * layout manager; the returned instance is owned by the layout + * manager and should not be unreferenced + * * Since: 1.2 */ -void +ClutterAlpha * clutter_layout_manager_begin_animation (ClutterLayoutManager *manager, guint duration, gulong mode) { - g_return_if_fail (CLUTTER_IS_LAYOUT_MANAGER (manager)); - g_return_if_fail (duration > 0 && duration < 1000); + ClutterLayoutManagerClass *klass; - CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager)->begin_animation (manager, - duration, - mode); + g_return_val_if_fail (CLUTTER_IS_LAYOUT_MANAGER (manager), NULL); + + klass = CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager); + + return klass->begin_animation (manager, duration, mode); } /** diff --git a/clutter/clutter-layout-manager.h b/clutter/clutter-layout-manager.h index 1271a3db4..e249b6b1a 100644 --- a/clutter/clutter-layout-manager.h +++ b/clutter/clutter-layout-manager.h @@ -30,6 +30,7 @@ #define __CLUTTER_LAYOUT_MANAGER_H__ #include +#include #include #include @@ -126,7 +127,7 @@ struct _ClutterLayoutManagerClass ClutterContainer *container, ClutterActor *actor); - void (* begin_animation) (ClutterLayoutManager *manager, + ClutterAlpha * (* begin_animation) (ClutterLayoutManager *manager, guint duration, gulong mode); gdouble (* get_animation_progress) (ClutterLayoutManager *manager); @@ -198,7 +199,7 @@ void clutter_layout_manager_child_get_property (ClutterLayoutMa const gchar *property_name, GValue *value); -void clutter_layout_manager_begin_animation (ClutterLayoutManager *manager, +ClutterAlpha * clutter_layout_manager_begin_animation (ClutterLayoutManager *manager, guint duration, gulong mode); void clutter_layout_manager_end_animation (ClutterLayoutManager *manager);