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.
This commit is contained in:
Emmanuele Bassi 2009-12-13 01:23:54 +00:00
parent 2e6397c391
commit 4a21425f48
3 changed files with 28 additions and 12 deletions

View File

@ -967,7 +967,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
g_list_free (children); g_list_free (children);
} }
static void static ClutterAlpha *
clutter_box_layout_begin_animation (ClutterLayoutManager *manager, clutter_box_layout_begin_animation (ClutterLayoutManager *manager,
guint duration, guint duration,
gulong easing) gulong easing)
@ -982,7 +982,8 @@ clutter_box_layout_begin_animation (ClutterLayoutManager *manager,
/* we want the default implementation */ /* we want the default implementation */
parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_box_layout_parent_class); 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 static void

View File

@ -226,7 +226,7 @@ layout_manager_real_get_child_meta_type (ClutterLayoutManager *manager)
return G_TYPE_INVALID; return G_TYPE_INVALID;
} }
static void static ClutterAlpha *
layout_manager_real_begin_animation (ClutterLayoutManager *manager, layout_manager_real_begin_animation (ClutterLayoutManager *manager,
guint duration, guint duration,
gulong mode) gulong mode)
@ -236,7 +236,14 @@ layout_manager_real_begin_animation (ClutterLayoutManager *manager,
alpha = g_object_get_qdata (G_OBJECT (manager), quark_layout_alpha); alpha = g_object_get_qdata (G_OBJECT (manager), quark_layout_alpha);
if (alpha != NULL) 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); timeline = clutter_timeline_new (duration);
alpha = clutter_alpha_new_full (timeline, mode); alpha = clutter_alpha_new_full (timeline, mode);
@ -254,6 +261,8 @@ layout_manager_real_begin_animation (ClutterLayoutManager *manager,
(GDestroyNotify) g_object_unref); (GDestroyNotify) g_object_unref);
clutter_timeline_start (timeline); clutter_timeline_start (timeline);
return alpha;
} }
static gdouble static gdouble
@ -1004,19 +1013,24 @@ clutter_layout_manager_list_child_properties (ClutterLayoutManager *manager,
* *
* The result of this function depends on the @manager implementation * 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 * Since: 1.2
*/ */
void ClutterAlpha *
clutter_layout_manager_begin_animation (ClutterLayoutManager *manager, clutter_layout_manager_begin_animation (ClutterLayoutManager *manager,
guint duration, guint duration,
gulong mode) gulong mode)
{ {
g_return_if_fail (CLUTTER_IS_LAYOUT_MANAGER (manager)); ClutterLayoutManagerClass *klass;
g_return_if_fail (duration > 0 && duration < 1000);
CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager)->begin_animation (manager, g_return_val_if_fail (CLUTTER_IS_LAYOUT_MANAGER (manager), NULL);
duration,
mode); klass = CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager);
return klass->begin_animation (manager, duration, mode);
} }
/** /**

View File

@ -30,6 +30,7 @@
#define __CLUTTER_LAYOUT_MANAGER_H__ #define __CLUTTER_LAYOUT_MANAGER_H__
#include <clutter/clutter-actor.h> #include <clutter/clutter-actor.h>
#include <clutter/clutter-alpha.h>
#include <clutter/clutter-container.h> #include <clutter/clutter-container.h>
#include <clutter/clutter-types.h> #include <clutter/clutter-types.h>
@ -126,7 +127,7 @@ struct _ClutterLayoutManagerClass
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor); ClutterActor *actor);
void (* begin_animation) (ClutterLayoutManager *manager, ClutterAlpha * (* begin_animation) (ClutterLayoutManager *manager,
guint duration, guint duration,
gulong mode); gulong mode);
gdouble (* get_animation_progress) (ClutterLayoutManager *manager); gdouble (* get_animation_progress) (ClutterLayoutManager *manager);
@ -198,7 +199,7 @@ void clutter_layout_manager_child_get_property (ClutterLayoutMa
const gchar *property_name, const gchar *property_name,
GValue *value); GValue *value);
void clutter_layout_manager_begin_animation (ClutterLayoutManager *manager, ClutterAlpha * clutter_layout_manager_begin_animation (ClutterLayoutManager *manager,
guint duration, guint duration,
gulong mode); gulong mode);
void clutter_layout_manager_end_animation (ClutterLayoutManager *manager); void clutter_layout_manager_end_animation (ClutterLayoutManager *manager);