[glide] New animation system works



commit a1bb9b82d9114dc4428c920eadb8833107a05677
Author: Robert Carr <racarr Valentine localdomain>
Date:   Tue Apr 27 01:48:30 2010 -0400

    New animation system works

 src/glide-animation-manager.c |    4 ++--
 src/glide-animation-manager.h |   10 +++++-----
 src/glide-slide-priv.h        |    2 +-
 src/glide-slide.c             |   32 +++++++++++++++++---------------
 src/glide-slide.h             |    5 +++--
 src/glide-stage-manager.c     |   22 ++++------------------
 src/glide-window.c            |   13 ++++++++++---
 7 files changed, 42 insertions(+), 46 deletions(-)
---
diff --git a/src/glide-animation-manager.c b/src/glide-animation-manager.c
index 852ffa5..d249bd7 100644
--- a/src/glide-animation-manager.c
+++ b/src/glide-animation-manager.c
@@ -58,7 +58,7 @@ glide_animation_manager_get_animation (const gchar *animation)
 }
 
 ClutterTimeline *
-glide_animation_manager_do_animation (GlideAnimationInfo *info,
+glide_animation_manager_do_animation (const GlideAnimationInfo *info,
 				      ClutterActor *a,
 				      ClutterActor *b)
 {
@@ -296,7 +296,7 @@ glide_animation_fade_completed (ClutterTimeline *t,
 }
 
 static ClutterTimeline *
-glide_animation_fade (GlideAnimationInfo *info,
+glide_animation_fade (const GlideAnimationInfo *info,
 		      ClutterActor *a,
 		      ClutterActor *b)
 {
diff --git a/src/glide-animation-manager.h b/src/glide-animation-manager.h
index 14551bb..32be110 100644
--- a/src/glide-animation-manager.h
+++ b/src/glide-animation-manager.h
@@ -17,8 +17,8 @@
  */
 
 
-#ifndef __GLIDE_ANIMATIONS_H__
-#define __GLIDE_ANIMATIONS_H__
+#ifndef __GLIDE_ANIMATION_MANAGER_H__
+#define __GLIDE_ANIMATION_MANAGER_H__
 
 #include <glib-object.h>
 #include <clutter/clutter.h>
@@ -28,7 +28,7 @@ G_BEGIN_DECLS
 typedef struct _GlideAnimationInfo GlideAnimationInfo;
 typedef struct _GlideAnimation GlideAnimation;
 
-typedef ClutterTimeline *(*GlideAnimationCallback) (GlideAnimationInfo *info,
+typedef ClutterTimeline *(*GlideAnimationCallback) (const GlideAnimationInfo *info,
 						   ClutterActor *a,
 						   ClutterActor *b);
 
@@ -38,7 +38,7 @@ struct _GlideAnimation {
 };
 
 struct _GlideAnimationInfo {
-  GlideAnimation *animation;
+  const GlideAnimation *animation;
   guint duration;
 };
 
@@ -46,7 +46,7 @@ void glide_animation_manager_register_animation (GlideAnimationCallback callback
 const GList *glide_animation_manager_get_animations ();
 const GlideAnimation *glide_animation_manager_get_animation (const gchar *animation);
 
-ClutterTimeline * glide_animation_manager_do_animation (GlideAnimationInfo *info, ClutterActor *a, ClutterActor *b);
+ClutterTimeline * glide_animation_manager_do_animation (const GlideAnimationInfo *info, ClutterActor *a, ClutterActor *b);
 
 void glide_animation_manager_register_animations();
 
diff --git a/src/glide-slide-priv.h b/src/glide-slide-priv.h
index 1d39fb4..a1d4666 100644
--- a/src/glide-slide-priv.h
+++ b/src/glide-slide-priv.h
@@ -32,7 +32,7 @@ struct _GlideSlidePrivate
   ClutterLayoutManager *layout;
   
   gchar *background;
-  gchar *animation;
+  GlideAnimationInfo *animation;
   
   CoglHandle background_material;
   
diff --git a/src/glide-slide.c b/src/glide-slide.c
index 9c8a51d..f8c1543 100644
--- a/src/glide-slide.c
+++ b/src/glide-slide.c
@@ -64,7 +64,7 @@ glide_slide_get_property (GObject *object,
       g_value_set_string (value, slide->priv->background);
       break;
     case PROP_ANIMATION:
-      g_value_set_string (value, slide->priv->animation);
+      glide_value_set_animation_info (value, slide->priv->animation);
       break;
     case PROP_COLOR:
       clutter_value_set_color (value, &slide->priv->color);
@@ -93,7 +93,7 @@ glide_slide_set_property (GObject *object,
       glide_slide_set_background (slide, g_value_get_string (value));
       break;
     case PROP_ANIMATION:
-      glide_slide_set_animation (slide, g_value_get_string (value));
+      glide_slide_set_animation (slide, glide_value_get_animation_info (value));
       break;
     case PROP_COLOR:
       glide_slide_set_color (slide, clutter_value_get_color (value));
@@ -420,6 +420,8 @@ glide_slide_dispose (GObject *object)
 {
   GlideSlide *self = GLIDE_SLIDE (object);
   GlideSlidePrivate *priv = self->priv;
+  
+  // TODO: Probably need to free animation?
 
   if (priv->children)
     {
@@ -478,9 +480,9 @@ glide_slide_serialize (GlideActor *self)
   
   if (slide->priv->background)
     glide_json_object_set_string (obj, "background", slide->priv->background); 
-  if (slide->priv->animation)
+  /*  if (slide->priv->animation)
     glide_json_object_set_string (obj, "animation", slide->priv->animation); 
-  else
+    else*/
     glide_json_object_set_string (obj, "animation", "None"); 
   
   return node;
@@ -584,11 +586,11 @@ glide_slide_class_init (GlideSlideClass *klass)
 
   g_object_class_install_property (object_class,
 				   PROP_ANIMATION,
-				   g_param_spec_string ("animation",
-							"Transition Animation",
-							"The transition animation to be used in moving to the next slide.",
-							NULL,
-							G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    
+				   glide_param_spec_animation_info ("animation",
+								    "Animation", "The animation to use during slide transitions",
+								    NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+								    
+								    
   
   g_object_class_install_property (object_class,
 				   PROP_COLOR,
@@ -648,8 +650,8 @@ glide_slide_construct_from_json (GlideSlide *slide, JsonObject *slide_obj, Glide
     glide_slide_set_background (slide, background);
 
   animation = glide_json_object_get_string (slide_obj, "animation");
-  if (animation)
-    glide_slide_set_animation (slide, animation);
+  //  if (animation)
+  //    glide_slide_set_animation (slide, animation);
   
   actors_l = json_array_get_elements (actors);
   for (a = actors_l; a; a = a->next)
@@ -723,16 +725,16 @@ glide_slide_get_background (GlideSlide *slide)
 }
 
 void 
-glide_slide_set_animation (GlideSlide *slide, const gchar *animation)
+glide_slide_set_animation (GlideSlide *slide, const GlideAnimationInfo *info)
 {
   if (slide->priv->animation)
-    g_free (slide->priv->animation);
+    glide_animation_info_free (slide->priv->animation);
   
-  slide->priv->animation = g_strdup (animation);
+  slide->priv->animation = glide_animation_info_copy (info);
   g_object_notify (G_OBJECT (slide), "animation");
 }
 
-const gchar *
+const GlideAnimationInfo *
 glide_slide_get_animation (GlideSlide *slide)
 {
   return slide->priv->animation;
diff --git a/src/glide-slide.h b/src/glide-slide.h
index 3337f88..6b11879 100644
--- a/src/glide-slide.h
+++ b/src/glide-slide.h
@@ -24,6 +24,7 @@
 #include <clutter/clutter.h>
 
 #include "glide-actor.h"
+#include "glide-animation-manager.h"
 
 G_BEGIN_DECLS
 
@@ -58,8 +59,8 @@ void glide_slide_construct_from_json (GlideSlide *slide, JsonObject *slide_obj,
 void glide_slide_set_background (GlideSlide *slide, const gchar *background);
 const gchar *glide_slide_get_background (GlideSlide *slide);
 
-void glide_slide_set_animation (GlideSlide *slide, const gchar *animation);
-const gchar *glide_slide_get_animation (GlideSlide *slide);
+void glide_slide_set_animation (GlideSlide *slide, const GlideAnimationInfo *info);
+const GlideAnimationInfo *glide_slide_get_animation (GlideSlide *slide);
 
 void glide_slide_add_actor_content (GlideSlide *s, ClutterActor *a);
 
diff --git a/src/glide-stage-manager.c b/src/glide-stage-manager.c
index 88f6d4e..f277b5c 100644
--- a/src/glide-stage-manager.c
+++ b/src/glide-stage-manager.c
@@ -222,15 +222,15 @@ glide_stage_manager_advance_slide (GlideStageManager *manager)
   if (manager->priv->current_slide + 1 < glide_document_get_n_slides(manager->priv->document))
     {
       GlideSlide *a, *b;
-      const gchar *animation;
+      const GlideAnimationInfo *a_info;
 
       
       a = glide_document_get_nth_slide (manager->priv->document, manager->priv->current_slide);
       b = glide_document_get_nth_slide (manager->priv->document, manager->priv->current_slide+1);
 
-      animation = glide_slide_get_animation (a);
+      a_info = glide_slide_get_animation (a);
       
-      if (!animation || !strcmp(animation, "None"))
+      if (!a_info || !strcmp(a_info->animation->name, "None"))
 	{
 	  glide_stage_manager_set_slide_next (manager);
 	  return;
@@ -238,21 +238,7 @@ glide_stage_manager_advance_slide (GlideStageManager *manager)
 
       manager->priv->current_slide++;
       
-      if (!strcmp(animation, "Drop"))
-	glide_animations_animate_drop (CLUTTER_ACTOR (a), CLUTTER_ACTOR (b), 1500);
-      if (!strcmp(animation, "Fade"))
-	glide_animations_animate_fade (CLUTTER_ACTOR (a), CLUTTER_ACTOR (b), 1000);
-      if (!strcmp(animation, "Zoom"))
-	glide_animations_animate_zoom (CLUTTER_ACTOR (a), CLUTTER_ACTOR (b), 1200);
-      if (!strcmp(animation, "Pivot"))
-	glide_animations_animate_pivot (CLUTTER_ACTOR (a), CLUTTER_ACTOR (b), 2000);
-      if (!strcmp(animation, "Slide"))
-	glide_animations_animate_slide (CLUTTER_ACTOR (a), CLUTTER_ACTOR (b), 1200);
-      if (!strcmp(animation, "Zoom Contents"))
-	glide_animations_animate_zoom_contents (CLUTTER_ACTOR (a), CLUTTER_ACTOR (b), 1200);
-      if (!strcmp(animation, "Doorway"))
-	glide_animations_animate_doorway (CLUTTER_ACTOR (a), CLUTTER_ACTOR (b), 1200);
-      
+      glide_animation_manager_do_animation (a_info, CLUTTER_ACTOR (a), CLUTTER_ACTOR (b));
       // XXX: Maybe not?
       g_object_notify (G_OBJECT (manager), "current-slide");
     }
diff --git a/src/glide-window.c b/src/glide-window.c
index f08e672..e19e8f2 100644
--- a/src/glide-window.c
+++ b/src/glide-window.c
@@ -163,14 +163,17 @@ glide_window_update_slide_label (GlideWindow *w)
 
 static void
 glide_window_animation_box_set_animation (GlideWindow *w,
-					  const gchar *animation)
+					  const GlideAnimationInfo *info)
 {
   GtkComboBox *c = GTK_COMBO_BOX (GLIDE_WINDOW_UI_OBJECT (w, "animation-combobox"));
   GtkTreeModel *m = gtk_combo_box_get_model (c);
   GtkTreeIter iter;
+  const gchar *animation;
   
-  if (!animation)
+  if (!info || !info->animation)
     animation = "None";
+  else
+    animation = info->animation->name;
   
   gtk_tree_model_get_iter_first (m, &iter);
   do {
@@ -705,6 +708,7 @@ glide_window_animations_box_changed_cb (GtkWidget *cbox,
   gchar *animation;
   GlideSlide *s = glide_document_get_nth_slide (w->priv->document,
 						glide_stage_manager_get_current_slide (w->priv->manager));
+  GlideAnimationInfo info;
 
   if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX (cbox), &iter))
     {
@@ -714,7 +718,10 @@ glide_window_animations_box_changed_cb (GtkWidget *cbox,
       gtk_tree_model_get(model, &iter, 0, &animation, -1);
     }
   
-  glide_slide_set_animation (s, animation);
+  info.duration = 1000;
+  info.animation = glide_animation_manager_get_animation (animation);
+  
+  glide_slide_set_animation (s, &info);
   g_free (animation);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]