[glide] Some more work on animation options
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] Some more work on animation options
- Date: Tue, 27 Apr 2010 08:49:43 +0000 (UTC)
commit 1c09e97aad9558f8ea1ed2feb9703603b4a80341
Author: Robert Carr <racarr Valentine localdomain>
Date: Tue Apr 27 04:33:58 2010 -0400
Some more work on animation options
data/ui/glide-window.ui | 23 ++++++++--
src/Makefile.am | 3 +-
src/glide-animation-manager.c | 14 +++++-
src/glide-animation-manager.h | 2 +
src/glide-json-util.c | 6 ++-
src/glide-slide.c | 2 +-
src/glide-slide.h | 2 +-
src/glide-vala-animations.vala | 42 +++++++++++++++++
src/glide-window.c | 100 +++++++++++++++++++++++++++++++++++++++-
9 files changed, 183 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/glide-window.ui b/data/ui/glide-window.ui
index d02017a..126e320 100644
--- a/data/ui/glide-window.ui
+++ b/data/ui/glide-window.ui
@@ -606,13 +606,28 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="animation-combobox">
+ <object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
- <property name="sensitive">False</property>
- <signal name="changed" handler="glide_window_animations_box_changed_cb"/>
+ <child>
+ <object class="GtkComboBox" id="animation-combobox">
+ <property name="visible">True</property>
+ <signal name="changed" handler="glide_window_animations_box_changed_cb"/>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="animation-option-combobox">
+ <property name="visible">True</property>
+ <signal name="changed" handler="glide_window_animations_option_box_changed_cb"/>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="padding">38</property>
<property name="position">5</property>
</packing>
</child>
diff --git a/src/Makefile.am b/src/Makefile.am
index 4fbb6e9..b835f12 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,8 +17,7 @@ AM_CPPFLAGS = \
AM_CFLAGS =\
-g \
- -Wall \
- -Werror
+ -Wall
glide_VALASOURCES = \
glide-vala-animations.vala
diff --git a/src/glide-animation-manager.c b/src/glide-animation-manager.c
index c36ff97..20267e9 100644
--- a/src/glide-animation-manager.c
+++ b/src/glide-animation-manager.c
@@ -302,6 +302,18 @@ glide_animation_manager_register_animations ()
glide_animation_manager_register_animation (glide_animations_animate_zoom, NULL, "Zoom");
glide_animation_manager_register_animation (glide_animations_animate_zoom_contents, NULL, "Zoom Contents");
glide_animation_manager_register_animation (glide_animations_animate_pivot, NULL, "Pivot");
- glide_animation_manager_register_animation (glide_animations_animate_slide, NULL, "Slide");
+ glide_animation_manager_register_animation ((GlideAnimationCallback)glide_animate_slide, (GlideAnimationListOptionsCallback)glide_animate_slide_list_options, "Slide");
glide_animation_manager_register_animation (glide_animations_animate_doorway, NULL, "Doorway");
}
+
+void
+glide_animation_manager_free_options (GList *l)
+{
+ GList *t = l;
+ for (t; t; t = t->next)
+ {
+ g_free (t->data);
+ }
+ g_list_free (l);
+
+}
diff --git a/src/glide-animation-manager.h b/src/glide-animation-manager.h
index 5b6b378..486ac11 100644
--- a/src/glide-animation-manager.h
+++ b/src/glide-animation-manager.h
@@ -90,6 +90,8 @@ GParamSpec *glide_param_spec_animation_info (const gchar *name,
const GlideAnimationInfo *default_value,
GParamFlags flags);
+void glide_animation_manager_free_options (GList *l);
+
G_END_DECLS
#endif
diff --git a/src/glide-json-util.c b/src/glide-json-util.c
index 2cbe397..9c5b591 100644
--- a/src/glide-json-util.c
+++ b/src/glide-json-util.c
@@ -49,16 +49,18 @@ glide_json_object_get_animation (JsonObject *obj,
{
JsonNode *n = json_object_get_member (obj, prop);
JsonObject *anim_obj = json_node_get_object (n);
- const gchar *name;
+ const gchar *name, *option;
guint duration;
const GlideAnimation *animation;
name = glide_json_object_get_string (anim_obj, "name");
duration = glide_json_object_get_double (anim_obj, "duration");
+ option = glide_json_object_get_string (anim_obj, "option");
animation = glide_animation_manager_get_animation (name);
info->animation = animation;
info->duration = duration;
+ info->option = g_strdup (option);
}
void
@@ -75,11 +77,13 @@ glide_json_object_set_animation (JsonObject *obj,
{
glide_json_object_set_string (animation_obj, "name", info->animation->name);
glide_json_object_set_double (animation_obj, "duration", info->duration);
+ glide_json_object_set_string (animation_obj, "option", info->option);
}
else
{
glide_json_object_set_string (animation_obj, "name", "None");
glide_json_object_set_double (animation_obj, "duration", 0);
+ glide_json_object_set_string (animation_obj, "option", "None");
}
json_object_set_member (obj, "animation", n);
diff --git a/src/glide-slide.c b/src/glide-slide.c
index 3d9ec13..bedcfc2 100644
--- a/src/glide-slide.c
+++ b/src/glide-slide.c
@@ -736,7 +736,7 @@ glide_slide_set_animation (GlideSlide *slide, const GlideAnimationInfo *info)
g_object_notify (G_OBJECT (slide), "animation");
}
-const GlideAnimationInfo *
+GlideAnimationInfo *
glide_slide_get_animation (GlideSlide *slide)
{
return slide->priv->animation;
diff --git a/src/glide-slide.h b/src/glide-slide.h
index 6b11879..db66d39 100644
--- a/src/glide-slide.h
+++ b/src/glide-slide.h
@@ -60,7 +60,7 @@ 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 GlideAnimationInfo *info);
-const GlideAnimationInfo *glide_slide_get_animation (GlideSlide *slide);
+GlideAnimationInfo *glide_slide_get_animation (GlideSlide *slide);
void glide_slide_add_actor_content (GlideSlide *s, ClutterActor *a);
diff --git a/src/glide-vala-animations.vala b/src/glide-vala-animations.vala
index 318332f..69c2990 100644
--- a/src/glide-vala-animations.vala
+++ b/src/glide-vala-animations.vala
@@ -19,4 +19,46 @@ namespace Glide {
return timeline;
}
+
+ public static
+ GLib.List animate_slide_list_options ()
+ {
+ var list = new GLib.List<string> ();
+ list.append("Up");
+ list.append("Down");
+ list.append("Left");
+ list.append("Right");
+
+ return list;
+ }
+
+ public static
+ Clutter.Timeline animate_slide (AnimationInfo info,
+ Clutter.Actor a,
+ Clutter.Actor b)
+ {
+ var timeline = new Clutter.Timeline (info.duration);
+ b.show_all ();
+
+ switch (info.option)
+ {
+ case "Up":
+ b.y = a.height;
+ b.animate_with_timeline (Clutter.AnimationMode.EASE_IN_OUT_SINE, timeline, "y", 0.0);
+ a.animate_with_timeline(Clutter.AnimationMode.EASE_IN_OUT_SINE, timeline, "y", -a.height);
+ break;
+ default:
+ break;
+ }
+
+ timeline.completed.connect ((t) => {
+ a.hide();
+ a.y = 0;
+ });
+
+ return timeline;
+
+ }
+
+
}
\ No newline at end of file
diff --git a/src/glide-window.c b/src/glide-window.c
index 7086e47..bf16eb8 100644
--- a/src/glide-window.c
+++ b/src/glide-window.c
@@ -162,6 +162,39 @@ glide_window_update_slide_label (GlideWindow *w)
}
static void
+glide_window_animation_box_set_animation_option (GlideWindow *w,
+ const GlideAnimationInfo *info)
+{
+ GtkComboBox *c = GTK_COMBO_BOX (GLIDE_WINDOW_UI_OBJECT (w, "animation-option-combobox"));
+ GtkTreeModel *m = gtk_combo_box_get_model (c);
+ GtkTreeIter iter;
+ const gchar *option;
+
+ if (!info || !info->option)
+ option = "None";
+ else
+ option = info->option;
+
+ if (!gtk_tree_model_get_iter_first (m, &iter))
+ return;
+ do {
+ gchar *e;
+
+ gtk_tree_model_get (m, &iter, 0, &e, -1);
+ if (!strcmp (e, option))
+ {
+ gtk_combo_box_set_active_iter (c, &iter);
+ g_free (e);
+ return;
+ }
+ g_free (e);
+ } while (gtk_tree_model_iter_next (m, &iter));
+
+ gtk_tree_model_get_iter_first (m, &iter);
+ gtk_combo_box_set_active_iter (c, &iter);
+}
+
+static void
glide_window_animation_box_set_animation (GlideWindow *w,
const GlideAnimationInfo *info)
{
@@ -183,12 +216,16 @@ glide_window_animation_box_set_animation (GlideWindow *w,
if (!strcmp (e, animation))
{
gtk_combo_box_set_active_iter (c, &iter);
+ glide_window_animation_box_set_animation_option (w, info);
+
g_free (e);
return;
}
g_free (e);
} while (gtk_tree_model_iter_next (m, &iter));
+
+
}
static void
@@ -699,6 +736,58 @@ glide_window_slide_background_cb (GtkDialog *dialog,
gtk_widget_destroy (GTK_WIDGET (dialog));
}
+static void
+glide_window_update_animation_options_box (GlideWindow *w,
+ const GlideAnimation *anim)
+{
+ GtkComboBox *c = GTK_COMBO_BOX (GLIDE_WINDOW_UI_OBJECT(w, "animation-option-combobox"));
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GList *options, *o;
+
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+ gtk_combo_box_set_model (c, GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ if (anim && anim->list_options)
+ options = anim->list_options ();
+ else
+ return;
+
+ for (o = options; o; o = o->next)
+ {
+ gchar *option = (gchar *)o->data;
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, option,
+ -1);
+ }
+
+ glide_animation_manager_free_options (options);
+
+}
+
+void
+glide_window_animations_option_box_changed_cb (GtkWidget *cbox,
+ gpointer user_data)
+{
+ GlideWindow *w = (GlideWindow *)user_data;
+ GlideAnimationInfo *info;
+ gchar *option = NULL;
+ GtkTreeIter iter;
+ GlideSlide *s = glide_document_get_nth_slide (w->priv->document,
+ glide_stage_manager_get_current_slide (w->priv->manager));
+
+ info = glide_slide_get_animation (s);
+ if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX (cbox), &iter))
+ {
+ GtkTreeModel *model;
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX (cbox));
+
+ gtk_tree_model_get(model, &iter, 0, &option, -1);
+ }
+ info->option = option;
+}
+
void
glide_window_animations_box_changed_cb (GtkWidget *cbox,
gpointer user_data)
@@ -709,6 +798,7 @@ glide_window_animations_box_changed_cb (GtkWidget *cbox,
GlideSlide *s = glide_document_get_nth_slide (w->priv->document,
glide_stage_manager_get_current_slide (w->priv->manager));
GlideAnimationInfo info;
+ const GlideAnimation *ga;
if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX (cbox), &iter))
{
@@ -718,10 +808,13 @@ glide_window_animations_box_changed_cb (GtkWidget *cbox,
gtk_tree_model_get(model, &iter, 0, &animation, -1);
}
+ ga = glide_animation_manager_get_animation (animation);
info.duration = 1000;
- info.animation = glide_animation_manager_get_animation (animation);
+ info.animation = ga;
info.option = NULL;
+ glide_window_update_animation_options_box (w, ga);
+
glide_slide_set_animation (s, &info);
g_free (animation);
}
@@ -1279,6 +1372,7 @@ static void
glide_window_setup_combobox (GlideWindow *w)
{
GtkComboBox *c = GTK_COMBO_BOX (GLIDE_WINDOW_UI_OBJECT(w, "animation-combobox"));
+ GtkComboBox *c2 = GTK_COMBO_BOX (GLIDE_WINDOW_UI_OBJECT(w, "animation-option-combobox"));
GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
GtkCellRenderer *renderer;
GtkTreeIter iter;
@@ -1305,6 +1399,10 @@ glide_window_setup_combobox (GlideWindow *w)
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (c), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(c), renderer, "text", 0, NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (c2), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(c2), renderer, "text", 0, NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]