[glide] More work on animation manager
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] More work on animation manager
- Date: Tue, 27 Apr 2010 05:48:13 +0000 (UTC)
commit 6c68c3cdb7d1d0ffad7080e165a0be24233d7d4b
Author: Robert Carr <racarr Valentine localdomain>
Date: Tue Apr 27 01:27:19 2010 -0400
More work on animation manager
src/Makefile.am | 4 ++-
src/glide-animation-manager.c | 74 +++++++++++++++++++++++++++++++---------
src/glide-animation-manager.h | 9 +++--
3 files changed, 65 insertions(+), 22 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 532faf1..a44d2ab 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,7 +55,9 @@ glide_SOURCES = \
glide-pdf-exporter.c \
glide-pdf-exporter.h \
glide-cairo-util.c \
- glide-cairo-util.h
+ glide-cairo-util.h \
+ glide-animation-manager.c \
+ glide-animation-manager.h
glide_LDFLAGS = \
diff --git a/src/glide-animation-manager.c b/src/glide-animation-manager.c
index b1c828f..dd0e819 100644
--- a/src/glide-animation-manager.c
+++ b/src/glide-animation-manager.c
@@ -16,8 +16,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <gobject/gvaluecollector.h>
+#include <glib.h>
+#include <string.h>
+
+#include "glide-animation-manager.h"
-#include "glide-animations-manager.h"
static GList *animations = NULL;
@@ -26,8 +30,8 @@ glide_animation_manager_register_animation (GlideAnimationCallback callback, con
{
GlideAnimation *animation = g_malloc (sizeof (GlideAnimation));
- animation->name = name;
- animation->callback = callback;
+ animation->name = g_strdup (name);
+ animation->animate = callback;
animations = g_list_append (animations, animation);
}
@@ -45,10 +49,10 @@ glide_animation_manager_get_animation (const gchar *animation)
for (t = animations; t; t = t->next)
{
- GlideAnimation *animation = (GlideAnimation *)t->data;
+ GlideAnimation *a = (GlideAnimation *)t->data;
- if (!strcmp (animation->name, animation))
- return animation;
+ if (!strcmp (a->name, animation))
+ return a;
}
return NULL;
}
@@ -58,7 +62,7 @@ glide_animation_manager_do_animation (GlideAnimationInfo *info,
ClutterActor *a,
ClutterActor *b)
{
- info->animation->animate (info, a, b);
+ return info->animation->animate (info, a, b);
}
@@ -74,14 +78,14 @@ glide_animation_info_get_type (void)
(GBoxedCopyFunc) glide_animation_info_copy,
(GBoxedFreeFunc) glide_animation_info_free);
}
- return glide_animation_info_type;
+ return _glide_animation_info_type;
}
GlideAnimationInfo *
-glide_animation_info_copy (GlideAnimationInfo *info)
+glide_animation_info_copy (const GlideAnimationInfo *info)
{
if (G_LIKELY (info != NULL))
- return g_slide_dup (GlideAnimationInfo, info);
+ return g_slice_dup (GlideAnimationInfo, info);
return NULL;
}
@@ -90,13 +94,13 @@ void
glide_animation_info_free (GlideAnimationInfo *info)
{
if (G_LIKELY (info != NULL))
- g_slice_free (ClutterColor, color);
+ g_slice_free (GlideAnimationInfo, info);
}
GlideAnimationInfo *
glide_animation_info_new ()
{
- return g_slide_new (GlideAnimationInfo);
+ return g_slice_new (GlideAnimationInfo);
}
void
@@ -137,7 +141,7 @@ glide_value_copy_animation_info (const GValue *src,
}
static gpointer
-glide_value_peek_color (const GValue *value)
+glide_value_peek_animation_info (const GValue *value)
{
return value->data[0].v_pointer;
}
@@ -173,7 +177,7 @@ glide_value_lcopy_animation_info (const GValue *value,
GTypeCValue *collect_values,
guint collect_flags)
{
- GlideAnimation_Info **animation_info_p = collect_values[0].v_pointer;
+ GlideAnimationInfo **animation_info_p = collect_values[0].v_pointer;
if (!animation_info_p)
return g_strdup_printf ("value location for '%s' passed as NULL",
@@ -197,7 +201,7 @@ param_animation_info_init (GParamSpec *pspec)
{
GlideParamSpecAnimationInfo *aspec = GLIDE_PARAM_SPEC_ANIMATION_INFO (pspec);
- aspect->default_value = NULL;
+ aspec->default_value = NULL;
}
static void
@@ -205,7 +209,7 @@ param_animation_info_finalize (GParamSpec *pspec)
{
GlideParamSpecAnimationInfo *aspec = GLIDE_PARAM_SPEC_ANIMATION_INFO (pspec);
- glide_animation_info_free (aspect->default_value);
+ glide_animation_info_free (aspec->default_value);
}
static void
@@ -247,7 +251,7 @@ glide_param_animation_info_get_type (void)
if (G_UNLIKELY (pspec_type == 0))
{
- const GParamSpecTypeInfo = pspec_info = {
+ const GParamSpecTypeInfo pspec_info = {
sizeof (GlideParamSpecAnimationInfo),
16,
param_animation_info_init,
@@ -280,3 +284,39 @@ glide_param_spec_animation_info (const gchar *name,
return G_PARAM_SPEC (aspec);
}
+
+static void
+glide_animation_fade_completed (ClutterTimeline *t,
+ gpointer user_data)
+{
+ ClutterActor *a = (ClutterActor *)user_data;
+
+ clutter_actor_set_opacity (a, 0xff);
+ clutter_actor_hide (a);
+}
+
+static ClutterTimeline *
+glide_animation_fade (GlideAnimationInfo *info,
+ ClutterActor *a,
+ ClutterActor *b)
+{
+ ClutterTimeline *timeline = clutter_timeline_new (info->duration);
+
+ clutter_actor_set_opacity (b, 0x00);
+ clutter_actor_show_all (b);
+
+ clutter_actor_raise (b, a);
+
+ clutter_actor_animate_with_timeline (b, CLUTTER_LINEAR,
+ timeline, "opacity", 0xff, NULL);
+
+ g_signal_connect (timeline, "completed", G_CALLBACK (glide_animation_fade_completed), a);
+
+ return timeline;
+}
+
+void
+glide_animation_manager_register_animations ()
+{
+ glide_animation_manager_register_animation (glide_animation_fade, "Fade");
+}
diff --git a/src/glide-animation-manager.h b/src/glide-animation-manager.h
index 2f0890c..cfc95f4 100644
--- a/src/glide-animation-manager.h
+++ b/src/glide-animation-manager.h
@@ -20,6 +20,7 @@
#ifndef __GLIDE_ANIMATIONS_H__
#define __GLIDE_ANIMATIONS_H__
+#include <glib-object.h>
#include <clutter/clutter.h>
G_BEGIN_DECLS
@@ -27,7 +28,7 @@ G_BEGIN_DECLS
typedef struct _GlideAnimationInfo GlideAnimationInfo;
typedef struct _GlideAnimation GlideAnimation;
-typedef ClutterTimeline (*GlideAnimationCallback) (GlideAnimationInfo *info,
+typedef ClutterTimeline *(*GlideAnimationCallback) (GlideAnimationInfo *info,
ClutterActor *a,
ClutterActor *b);
@@ -47,7 +48,7 @@ const GlideAnimation *glide_animation_manager_get_animation (const gchar *animat
ClutterTimeline * glide_animation_manager_do_animation (GlideAnimationInfo *info, ClutterActor *a, ClutterActor *b);
-#define GLIDE_TYPE_ANIMATION_INFO (glide_animation_info_get_type());
+#define GLIDE_TYPE_ANIMATION_INFO (glide_animation_info_get_type())
GType glide_animation_info_get_type (void) G_GNUC_CONST;
@@ -61,7 +62,7 @@ void glide_animation_info_free (GlideAnimationInfo *info);
#define GLIDE_PARAM_SPEC_ANIMATION_INFO(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GLIDE_TYPE_PARAM_ANIMATION_INFO, GlideParamSpecAnimationInfo))
#define GLIDE_IS_PARAM_SPEC_ANIMATION_INFO(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GLIDE_TYPE_PARAM_ANIMATION_INFO))
-#define GLIDE_VALUE_HOLDS_ANIMATION_INFO(x) (G_VALUE_HOLDS ((x), GLIDE_TYPE_ANIMATION_INFO));
+#define GLIDE_VALUE_HOLDS_ANIMATION_INFO(x) (G_VALUE_HOLDS ((x), GLIDE_TYPE_ANIMATION_INFO))
typedef struct _GlideParamSpecAnimationInfo GlideParamSpecAnimationInfo;
@@ -75,7 +76,7 @@ struct _GlideParamSpecAnimationInfo
void glide_value_set_animation_info (GValue *value, const GlideAnimationInfo *info);
G_CONST_RETURN GlideAnimationInfo *glide_value_get_animation_info (const GValue *value);
-GType glide_param_spec_animation_info_get_type (void) G_GNUC_CONST;
+GType glide_param_animation_info_get_type (void) G_GNUC_CONST;
GParamSpec *glide_param_spec_animation_info (const gchar *name,
const gchar *nick,
const gchar *blurb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]