[cairo-commit]
goocanvas/demo Makefile.am, 1.8, 1.9 demo-animation.c,
NONE, 1.1 demo.c, 1.13, 1.14 mv-demo-animation.c, NONE,
1.1 mv-demo.c, 1.1, 1.2
Damon Chaplin
commit at pdx.freedesktop.org
Tue Feb 13 04:32:50 PST 2007
- Previous message: [cairo-commit] goocanvas ChangeLog,1.74,1.75 TODO,1.21,1.22
- Next message: [cairo-commit] goocanvas/src goocanvasitem.c, 1.17,
1.18 goocanvasitem.h, 1.12, 1.13 goocanvasitemmodel.c, 1.7,
1.8 goocanvasitemmodel.h, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: damon
Update of /cvs/cairo/goocanvas/demo
In directory kemper:/tmp/cvs-serv18111/demo
Modified Files:
Makefile.am demo.c mv-demo.c
Added Files:
demo-animation.c mv-demo-animation.c
Log Message:
2007-02-13 Damon Chaplin <damon at gnome.org>
* src/goocanvasitemmodel.c (goo_canvas_item_model_animate):
* src/goocanvasitem.c (goo_canvas_item_animate): added "absolute"
parameter, and rewrote the animation code, using the same code for
GooCanvasItem and GooCanvasItemModel.
* demo/demo-animation.c:
* demo/mv-demo-animation.c: new files for animation demo pages.
* demo/mv-demo.c:
* demo/demo.c: added new animation pages and updated animation calls.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Makefile.am 9 Dec 2006 12:08:38 -0000 1.8
+++ Makefile.am 13 Feb 2007 12:32:44 -0000 1.9
@@ -12,14 +12,14 @@
demo_SOURCES = \
demo.c demo-fifteen.c demo-scalability.c demo-grabs.c \
demo-arrowhead.c demo-features.c demo-events.c \
- demo-paths.c demo-focus.c demo-item.c
+ demo-paths.c demo-focus.c demo-item.c demo-animation.c
demo_LDADD = $(top_builddir)/src/libgoocanvas.la @PACKAGE_LIBS@ $(INTLLIBS)
mv_demo_SOURCES = \
mv-demo.c mv-demo-fifteen.c mv-demo-scalability.c mv-demo-grabs.c \
mv-demo-arrowhead.c mv-demo-features.c mv-demo-events.c \
- mv-demo-paths.c mv-demo-focus.c
+ mv-demo-paths.c mv-demo-focus.c mv-demo-animation.c
mv_demo_LDADD = $(top_builddir)/src/libgoocanvas.la @PACKAGE_LIBS@ $(INTLLIBS)
--- NEW FILE: demo-animation.c ---
#include <config.h>
#include <string.h>
#include <gtk/gtk.h>
#include <goocanvas.h>
GooCanvasItem *ellipse1, *ellipse2, *rect1, *rect2, *rect3, *rect4;
static void
start_animation_clicked (GtkWidget *button, gpointer data)
{
/* Absolute. */
goo_canvas_item_set_simple_transform (ellipse1, 100, 100, 1, 0);
goo_canvas_item_animate (ellipse1, 500, 100, 2, 720, TRUE, 2000, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
goo_canvas_item_set_simple_transform (rect1, 100, 200, 1, 0);
goo_canvas_item_animate (rect1, 100, 200, 1, 350, TRUE, 40 * 36, 40,
GOO_CANVAS_ANIMATE_RESTART);
goo_canvas_item_set_simple_transform (rect3, 200, 200, 1, 0);
goo_canvas_item_animate (rect3, 200, 200, 3, 0, TRUE, 400, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
/* Relative. */
goo_canvas_item_set_simple_transform (ellipse2, 100, 400, 1, 0);
goo_canvas_item_animate (ellipse2, 400, 0, 2, 720, FALSE, 2000, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
goo_canvas_item_set_simple_transform (rect2, 100, 500, 1, 0);
goo_canvas_item_animate (rect2, 0, 0, 1, 350, FALSE, 40 * 36, 40,
GOO_CANVAS_ANIMATE_RESTART);
goo_canvas_item_set_simple_transform (rect4, 200, 500, 1, 0);
goo_canvas_item_animate (rect4, 0, 0, 3, 0, FALSE, 400, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
}
static void
stop_animation_clicked (GtkWidget *button, gpointer data)
{
goo_canvas_item_stop_animation (ellipse1);
goo_canvas_item_stop_animation (ellipse2);
goo_canvas_item_stop_animation (rect1);
goo_canvas_item_stop_animation (rect2);
goo_canvas_item_stop_animation (rect3);
goo_canvas_item_stop_animation (rect4);
}
static void
setup_canvas (GtkWidget *canvas)
{
GooCanvasItem *root;
root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
/* Absolute. */
ellipse1 = goo_canvas_ellipse_new (root, 0, 0, 25, 15,
"fill-color", "blue",
NULL);
goo_canvas_item_translate (ellipse1, 100, 100);
rect1 = goo_canvas_rect_new (root, -10, -10, 20, 20,
"fill-color", "blue",
NULL);
goo_canvas_item_translate (rect1, 100, 200);
rect3 = goo_canvas_rect_new (root, -10, -10, 20, 20,
"fill-color", "blue",
NULL);
goo_canvas_item_translate (rect3, 200, 200);
/* Relative. */
ellipse2 = goo_canvas_ellipse_new (root, 0, 0, 25, 15,
"fill-color", "red",
NULL);
goo_canvas_item_translate (ellipse2, 100, 400);
rect2 = goo_canvas_rect_new (root, -10, -10, 20, 20,
"fill-color", "red",
NULL);
goo_canvas_item_translate (rect2, 100, 500);
rect4 = goo_canvas_rect_new (root, -10, -10, 20, 20,
"fill-color", "red",
NULL);
goo_canvas_item_translate (rect4, 200, 500);
}
GtkWidget *
create_animation_page (void)
{
GtkWidget *vbox, *hbox, *w, *scrolled_win, *canvas;
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_widget_show (vbox);
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
w = gtk_button_new_with_label("Start Animation");
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
g_signal_connect (w, "clicked", (GtkSignalFunc) start_animation_clicked,
NULL);
w = gtk_button_new_with_label("Stop Animation");
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
g_signal_connect (w, "clicked", (GtkSignalFunc) stop_animation_clicked,
NULL);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_SHADOW_IN);
gtk_widget_show (scrolled_win);
gtk_container_add (GTK_CONTAINER (vbox), scrolled_win);
canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
setup_canvas (canvas);
return vbox;
}
Index: demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- demo.c 12 Feb 2007 14:23:50 -0000 1.13
+++ demo.c 13 Feb 2007 12:32:44 -0000 1.14
@@ -31,6 +31,7 @@
GtkWidget *create_events_page (void);
GtkWidget *create_paths_page (void);
GtkWidget *create_focus_page (void);
+GtkWidget *create_animation_page (void);
#if CAIRO_HAS_PDF_SURFACE
static void
@@ -108,11 +109,11 @@
animate_ellipse_clicked (GtkWidget *button, GooCanvas *canvas)
{
#if 1
- goo_canvas_item_animate (ellipse2, 100, 100, 1, 90, 1000, 40,
+ goo_canvas_item_animate (ellipse2, 100, 100, 1, 90, TRUE, 1000, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
#endif
#if 0
- goo_canvas_item_animate (textitem, -300, -200, 1, 90, 1000, 40,
+ goo_canvas_item_animate (textitem, -300, -200, 1, 90, TRUE, 1000, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
#endif
}
@@ -1242,6 +1243,11 @@
create_focus_page (),
gtk_label_new ("Focus"));
#endif
+#if 1
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
+ create_animation_page (),
+ gtk_label_new ("Animation"));
+#endif
return window;
}
--- NEW FILE: mv-demo-animation.c ---
#include <config.h>
#include <string.h>
#include <gtk/gtk.h>
#include <goocanvas.h>
GooCanvasItemModel *root = NULL;
GooCanvasItemModel *ellipse1, *ellipse2, *rect1, *rect2, *rect3, *rect4;
static void
start_animation_clicked (GtkWidget *button, gpointer data)
{
/* Absolute. */
goo_canvas_item_model_set_simple_transform (ellipse1, 100, 100, 1, 0);
goo_canvas_item_model_animate (ellipse1, 500, 100, 2, 720, TRUE, 2000, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
goo_canvas_item_model_set_simple_transform (rect1, 100, 200, 1, 0);
goo_canvas_item_model_animate (rect1, 100, 200, 1, 350, TRUE, 40 * 36, 40,
GOO_CANVAS_ANIMATE_RESTART);
goo_canvas_item_model_set_simple_transform (rect3, 200, 200, 1, 0);
goo_canvas_item_model_animate (rect3, 200, 200, 3, 0, TRUE, 400, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
/* Relative. */
goo_canvas_item_model_set_simple_transform (ellipse2, 100, 400, 1, 0);
goo_canvas_item_model_animate (ellipse2, 400, 0, 2, 720, FALSE, 2000, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
goo_canvas_item_model_set_simple_transform (rect2, 100, 500, 1, 0);
goo_canvas_item_model_animate (rect2, 0, 0, 1, 350, FALSE, 40 * 36, 40,
GOO_CANVAS_ANIMATE_RESTART);
goo_canvas_item_model_set_simple_transform (rect4, 200, 500, 1, 0);
goo_canvas_item_model_animate (rect4, 0, 0, 3, 0, FALSE, 400, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
}
static void
stop_animation_clicked (GtkWidget *button, gpointer data)
{
goo_canvas_item_model_stop_animation (ellipse1);
goo_canvas_item_model_stop_animation (ellipse2);
goo_canvas_item_model_stop_animation (rect1);
goo_canvas_item_model_stop_animation (rect2);
goo_canvas_item_model_stop_animation (rect3);
goo_canvas_item_model_stop_animation (rect4);
}
static GooCanvasItemModel*
create_canvas_model (void)
{
if (root)
return root;
root = goo_canvas_group_model_new (NULL, NULL);
/* Absolute. */
ellipse1 = goo_canvas_ellipse_model_new (root, 0, 0, 25, 15,
"fill-color", "blue",
NULL);
goo_canvas_item_model_translate (ellipse1, 100, 100);
rect1 = goo_canvas_rect_model_new (root, -10, -10, 20, 20,
"fill-color", "blue",
NULL);
goo_canvas_item_model_translate (rect1, 100, 200);
rect3 = goo_canvas_rect_model_new (root, -10, -10, 20, 20,
"fill-color", "blue",
NULL);
goo_canvas_item_model_translate (rect3, 200, 200);
/* Relative. */
ellipse2 = goo_canvas_ellipse_model_new (root, 0, 0, 25, 15,
"fill-color", "red",
NULL);
goo_canvas_item_model_translate (ellipse2, 100, 400);
rect2 = goo_canvas_rect_model_new (root, -10, -10, 20, 20,
"fill-color", "red",
NULL);
goo_canvas_item_model_translate (rect2, 100, 500);
rect4 = goo_canvas_rect_model_new (root, -10, -10, 20, 20,
"fill-color", "red",
NULL);
goo_canvas_item_model_translate (rect4, 200, 500);
return root;
}
GtkWidget *
create_animation_page (void)
{
GtkWidget *vbox, *hbox, *w, *scrolled_win, *canvas;
GooCanvasItemModel *root;
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_widget_show (vbox);
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
w = gtk_button_new_with_label("Start Animation");
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
g_signal_connect (w, "clicked", (GtkSignalFunc) start_animation_clicked,
NULL);
w = gtk_button_new_with_label("Stop Animation");
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
g_signal_connect (w, "clicked", (GtkSignalFunc) stop_animation_clicked,
NULL);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_SHADOW_IN);
gtk_widget_show (scrolled_win);
gtk_container_add (GTK_CONTAINER (vbox), scrolled_win);
canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
root = create_canvas_model ();
goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);
return vbox;
}
Index: mv-demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/mv-demo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mv-demo.c 29 Nov 2006 18:27:06 -0000 1.1
+++ mv-demo.c 13 Feb 2007 12:32:44 -0000 1.2
@@ -29,6 +29,7 @@
GtkWidget *create_events_page (void);
GtkWidget *create_paths_page (void);
GtkWidget *create_focus_page (void);
+GtkWidget *create_animation_page (void);
#if CAIRO_HAS_PDF_SURFACE
static void
@@ -106,11 +107,11 @@
animate_ellipse_clicked (GtkWidget *button, GooCanvas *canvas)
{
#if 1
- goo_canvas_item_model_animate (ellipse2, 100, 100, 1, 90, 1000, 40,
+ goo_canvas_item_model_animate (ellipse2, 100, 100, 1, 90, TRUE, 1000, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
#endif
#if 0
- goo_canvas_item_model_animate (textitem, -300, -200, 1, 90, 1000, 40,
+ goo_canvas_item_model_animate (textitem, -300, -200, 1, 90, TRUE, 1000, 40,
GOO_CANVAS_ANIMATE_BOUNCE);
#endif
}
@@ -1222,6 +1223,11 @@
create_focus_page (),
gtk_label_new ("Focus"));
#endif
+#if 1
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
+ create_animation_page (),
+ gtk_label_new ("Animation"));
+#endif
return window;
}
- Previous message: [cairo-commit] goocanvas ChangeLog,1.74,1.75 TODO,1.21,1.22
- Next message: [cairo-commit] goocanvas/src goocanvasitem.c, 1.17,
1.18 goocanvasitem.h, 1.12, 1.13 goocanvasitemmodel.c, 1.7,
1.8 goocanvasitemmodel.h, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list