diff --git a/ChangeLog b/ChangeLog index 87b69ff1c..c278f17ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2007-06-12 Matthew Allum + + * clutter/clutter-alpha.c: + Remove stray g_debug. + + * clutter/clutter-behaviour-rotate.c: + Register private class member. + + * clutter/clutter-behaviour.c: + * clutter/clutter-behaviour.h: + Add applied and removed signals. + + * Makefile.am: + * configure.ac: + * examples/Makefile.am: + * examples/README: + * examples/behave.c: + * examples/slider.c: + * examples/super-oh.c: + * examples/test-entry.c: + * examples/test-text.c: + * examples/test.c: + * tests/Makefile.am: + Remove examples, moving applicable code into tests. + 2007-06-11 Tomas Frydrych * clutter/clutter-alpha.c: diff --git a/Makefile.am b/Makefile.am index f0df847a3..8c742b0fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=clutter doc examples tests +SUBDIRS=clutter doc tests pcfiles = clutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.pc diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c index 392d2cdf9..7b8d34cbe 100644 --- a/clutter/clutter-alpha.c +++ b/clutter/clutter-alpha.c @@ -773,11 +773,6 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha, */ r = ((x >> 12) * (x >> 12) * 3 - (x >> 15) * (x >> 16) * (x >> 16)) >> 8; - g_debug ("Frame %d of %d, x %f, ret %f", - frame, n_frames, - CLUTTER_FIXED_TO_DOUBLE (x >> 8), - CLUTTER_FIXED_TO_DOUBLE (r)); - return CFX_INT (r * CLUTTER_ALPHA_MAX_ALPHA); } diff --git a/clutter/clutter-behaviour-rotate.c b/clutter/clutter-behaviour-rotate.c index 801932b5b..7e5606b7d 100644 --- a/clutter/clutter-behaviour-rotate.c +++ b/clutter/clutter-behaviour-rotate.c @@ -259,6 +259,8 @@ clutter_behaviour_rotate_class_init (ClutterBehaviourRotateClass *klass) CLUTTER_TYPE_ROTATE_DIRECTION, CLUTTER_ROTATE_CW, CLUTTER_PARAM_READWRITE)); + + g_type_class_add_private (klass, sizeof (ClutterBehaviourRotatePrivate)); } static void diff --git a/clutter/clutter-behaviour.c b/clutter/clutter-behaviour.c index 767d19ad8..f50373d2f 100644 --- a/clutter/clutter-behaviour.c +++ b/clutter/clutter-behaviour.c @@ -58,6 +58,7 @@ #include "clutter-behaviour.h" #include "clutter-debug.h" #include "clutter-private.h" +#include "clutter-marshal.h" /** * clutter_knot_copy: @@ -157,9 +158,12 @@ enum }; enum { - SIGNAL_LAST + APPLY, + REMOVE, + LAST_SIGNAL }; +static guint behave_signals[LAST_SIGNAL] = { 0 }; #define CLUTTER_BEHAVIOUR_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ @@ -173,6 +177,7 @@ clutter_behaviour_finalize (GObject *object) clutter_behaviour_set_alpha (self, NULL); + /* FIXME: Should we also emit remove signals here ? */ g_slist_foreach (self->priv->actors, (GFunc) g_object_unref, NULL); g_slist_free (self->priv->actors); @@ -251,6 +256,43 @@ clutter_behaviour_class_init (ClutterBehaviourClass *klass) klass->alpha_notify = clutter_behaviour_alpha_notify_unimplemented; + /** + * ClutterBeavhour::apply: + * @behaviour: the #ClutterBehvaiour that received the signal + * @actor: the actor the behaviour was applied to. + * + * The ::apply signal is emitted each time the behaviour is applied + * to an actor. + * + */ + behave_signals[APPLY] = + g_signal_new ("apply", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (ClutterBehaviourClass, apply), + NULL, NULL, + clutter_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + CLUTTER_TYPE_ACTOR); + /** + * ClutterBehaviour::remove: + * @behaviour: the #ClutterBehaviour that received the signal + * @actor: the actor added to the group + * + * The ::remove signal is emitted each time an actor has been removed + * from the group + * + */ + behave_signals[REMOVE] = + g_signal_new ("remove", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (ClutterBehaviourClass, remove), + NULL, NULL, + clutter_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + CLUTTER_TYPE_ACTOR); + g_type_class_add_private (klass, sizeof (ClutterBehaviourPrivate)); } @@ -290,6 +332,9 @@ clutter_behaviour_apply (ClutterBehaviour *behave, } g_object_ref (actor); + + g_signal_emit (behave, behave_signals[APPLY], 0, actor); + behave->priv->actors = g_slist_prepend (behave->priv->actors, actor); } @@ -341,6 +386,9 @@ clutter_behaviour_remove (ClutterBehaviour *behave, } g_object_unref (actor); + + g_signal_emit (behave, behave_signals[REMOVE], 0, actor); + behave->priv->actors = g_slist_remove (behave->priv->actors, actor); } diff --git a/clutter/clutter-behaviour.h b/clutter/clutter-behaviour.h index e4c401c6c..889aaa21a 100644 --- a/clutter/clutter-behaviour.h +++ b/clutter/clutter-behaviour.h @@ -102,6 +102,11 @@ struct _ClutterBehaviourClass void (*alpha_notify) (ClutterBehaviour *behave, guint32 alpha_value); + void (*apply) (ClutterBehaviour *behave, + ClutterActor *actor); + void (*remove) (ClutterBehaviour *behave, + ClutterActor *actor); + /* padding, for future expansion */ void (*_clutter_behaviour1) (void); void (*_clutter_behaviour2) (void); diff --git a/configure.ac b/configure.ac index be344f1c6..43eee196d 100644 --- a/configure.ac +++ b/configure.ac @@ -285,7 +285,6 @@ AC_CONFIG_FILES([ clutter/cogl/Makefile clutter/cogl/gl/Makefile clutter/cogl/gles/Makefile - examples/Makefile tests/Makefile doc/Makefile doc/reference/Makefile diff --git a/examples/Makefile.am b/examples/Makefile.am deleted file mode 100644 index 0f31c7f4c..000000000 --- a/examples/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -noinst_PROGRAMS = test super-oh behave test-text slider test-entry - -INCLUDES = -I$(top_srcdir)/ -LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la - -AM_CFLAGS = $(CLUTTER_CFLAGS) -AM_LDFLAGS = $(CLUTTER_LIBS) - -slider_SOURCES = slider.c - -test_SOURCES = test.c -test_CFLAGS = $(CLUTTER_CFLAGS) $(GCONF_CFLAGS) -test_LDFLAGS = \ - $(CLUTTER_LIBS) \ - $(GCONF_LIBS) - -super_oh_SOURCES = super-oh.c -super_oh_CFLAGS = $(CLUTTER_CFLAGS) $(GCONF_CFLAGS) -super_oh_LDFLAGS = \ - $(CLUTTER_LIBS) \ - $(GCONF_LIBS) - -behave_SOURCES = behave.c -behave_CFLAGS = $(CLUTTER_CFLAGS) $(GCONF_CFLAGS) -behave_LDFLAGS = \ - $(CLUTTER_LIBS) \ - $(GCONF_LIBS) - -test_text_SOURCES = test-text.c -test_text_CFLAGS = $(CLUTTER_CFLAGS) $(GCONF_CFLAGS) -test_text_LDFLAGS = \ - $(CLUTTER_LIBS) \ - $(GCONF_LIBS) - -test_entry_SOURCES = test-entry.c -test_entry_CFLAGS = $(CLUTTER_CFLAGS) $(GCONF_CFLAGS) -test_entry_LDFLAGS = \ - $(CLUTTER_LIBS) \ - $(GCONF_LIBS) - -EXTRA_DIST = redhand.png \ - clutter-logo-800x600.png \ - README diff --git a/examples/README b/examples/README deleted file mode 100644 index f62ead674..000000000 --- a/examples/README +++ /dev/null @@ -1,24 +0,0 @@ -examples/ -=== - -This directory contains a number of simple hacks come tests come -examples come clutter demos. - -There are: - - o test - - Lots of randomness. Scratchpad to test new features. - - o test.py - - Like above but more randomness in python. - - o super-oh - - Spinning OH logos. Click to dissapear. - - - -Also see http://svn.o-hand.com/repos/misc/trunk/opt for a simple -clutter based presentation program. diff --git a/examples/clutter-logo-800x600.png b/examples/clutter-logo-800x600.png deleted file mode 100644 index 7a81de9f4..000000000 Binary files a/examples/clutter-logo-800x600.png and /dev/null differ diff --git a/examples/slider.c b/examples/slider.c deleted file mode 100644 index 383f09a31..000000000 --- a/examples/slider.c +++ /dev/null @@ -1,196 +0,0 @@ -#include -#include - -#include - -typedef struct Tile -{ - ClutterActor *actor; - gint orig_pos; -} -Tile; - -static Tile *Tiles[4][4]; -static int TileW, TileH, BlankTileX, BlankTileY; -static ClutterEffectTemplate *Template; -static ClutterTimeline *EffectTimeline; - -ClutterActor* -make_tiles (GdkPixbuf *pixbuf) -{ - int x, y , w, h; - int i = 0, j = 0; - int pos = 0; - ClutterActor *group; - - group = clutter_group_new(); - - w = gdk_pixbuf_get_width (pixbuf); - h = gdk_pixbuf_get_height (pixbuf); - - TileW = w / 4; - TileH = h / 4; - - for (y = 0; y < h; y += TileH) - { - for (x = 0; x < w; x += TileW) - { - GdkPixbuf *subpixbuf; - Tile *tile; - - subpixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, - 8, TileW, TileH); - - gdk_pixbuf_copy_area (pixbuf, x, y, TileW, TileH, - subpixbuf, 0, 0); - - tile = g_slice_new0 (Tile); - - if (pos != 15) - { - tile->actor = clutter_texture_new_from_pixbuf (subpixbuf); - clutter_container_add_actor (CLUTTER_CONTAINER (group), - tile->actor); - clutter_actor_set_position (tile->actor, x, y); - } - else - { - /* blank tile */ - tile->actor = NULL; - BlankTileX = i; - BlankTileY = j; - } - - g_object_unref (subpixbuf); - - tile->orig_pos = pos; - Tiles[j][i] = tile; - - pos++; i++; - } - i=0; j++; - } - - return group; -} - -static void -switch_blank_tile (int i, int j) -{ - Tile *tmp; - ClutterKnot knots[2]; - - knots[0].x = i * TileW; - knots[0].y = j * TileH; - - knots[1].x = BlankTileX * TileW; - knots[1].y = BlankTileY * TileH; - - EffectTimeline = clutter_effect_move (Template, - Tiles[j][i]->actor, - knots, - 2, - NULL, - NULL); - - /* Add a week pointer to returned timeline so we know whilst its - * playing and thus valid. - */ - g_object_add_weak_pointer (G_OBJECT(EffectTimeline), - (gpointer*)&EffectTimeline); - - tmp = Tiles[BlankTileY][BlankTileX]; - Tiles[BlankTileY][BlankTileX] = Tiles[j][i]; - Tiles[j][i] = tmp; - - BlankTileY = j; - BlankTileX = i; -} - -static void -key_press_event_cb (ClutterStage *stage, - ClutterKeyEvent *event, - gpointer user_data) -{ - Tile *tmp, *tmp2; - - if (clutter_key_event_symbol(event) == CLUTTER_q) - clutter_main_quit(); - - /* Do move if there is a move already happening */ - if (EffectTimeline != NULL) - return; - - switch (clutter_key_event_symbol(event)) - { - case CLUTTER_Up: - if (BlankTileY < 3) - switch_blank_tile (BlankTileX, BlankTileY+1); - break; - case CLUTTER_Down: - if (BlankTileY > 0) - switch_blank_tile (BlankTileX, BlankTileY-1); - break; - case CLUTTER_Left: - if (BlankTileX < 3) - switch_blank_tile (BlankTileX+1, BlankTileY); - break; - case CLUTTER_Right: - if (BlankTileX > 0) - switch_blank_tile (BlankTileX-1, BlankTileY); - break; - default: - break; - } -} - -int -main (int argc, char **argv) -{ - GError *error; - GdkPixbuf *pixbuf; - ClutterActor *stage, *group; - ClutterColor bgcolour; - - /* Initiate clutter */ - clutter_init (&argc, &argv); - - /* Setup the stage */ - stage = clutter_stage_get_default (); - g_object_set (stage, "fullscreen", TRUE, NULL); - - clutter_color_parse ("#000000", &bgcolour); - clutter_stage_set_color (CLUTTER_STAGE (stage), &bgcolour); - - /* Create Tiles */ - error = NULL; - pixbuf = gdk_pixbuf_new_from_file ("image.jpg", &error); - if (error) - { - g_warning ("Unable to load `image.jpg': %s", error->message); - g_error_free (error); - return EXIT_FAILURE; - } - - group = make_tiles (pixbuf); - - /* Add to stage and center */ - clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); - clutter_actor_set_position (group, - (clutter_actor_get_width (stage) - clutter_actor_get_width (group)) / 2, - (clutter_actor_get_height (stage) - clutter_actor_get_height (group)) / 2); - - /* Link up event collection */ - g_signal_connect (stage, - "key-press-event", - G_CALLBACK(key_press_event_cb), - NULL); - - /* Template to use for slider animation */ - Template = clutter_effect_template_new (clutter_timeline_new (15, 60), - CLUTTER_ALPHA_RAMP_INC); - - clutter_actor_show_all (stage); - - clutter_main(); -} diff --git a/examples/test.c b/examples/test.c deleted file mode 100644 index 8e311c7a0..000000000 --- a/examples/test.c +++ /dev/null @@ -1,151 +0,0 @@ -#include - -#define PARA_TEXT "This is a paragraph of text to check both " \ - "word wrapping and basic clipping." - -void -rect_cb (ClutterTimeline *timeline, - gint frame_num, - gpointer data) -{ - ClutterActor *rect = CLUTTER_ACTOR(data); - gint x, y; - static gint direction = 1; - - x = clutter_actor_get_x (rect); - y = clutter_actor_get_y (rect); - - if (x > (CLUTTER_STAGE_WIDTH() - 200)) - direction = -1; - - if (x < 100) - direction = 1; - - x += direction; - - clutter_actor_set_position (rect, x, y); -} - - -void -text_cb (ClutterTimeline *timeline, - gint frame_num, - gpointer data) -{ - ClutterLabel *label; - gchar buf[32]; - gint opacity; - - label = CLUTTER_LABEL(data); - - opacity = frame_num/2; - - g_snprintf(buf, 32, "--> %i <--", frame_num); - - clutter_label_set_text (label, buf); - clutter_actor_set_size(CLUTTER_ACTOR(label), 150, 0); - clutter_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); - - clutter_actor_set_opacity (CLUTTER_ACTOR(label), opacity); - - clutter_actor_rotate_z (CLUTTER_ACTOR(label), - frame_num, - clutter_actor_get_width (CLUTTER_ACTOR(label))/2, - clutter_actor_get_height (CLUTTER_ACTOR(label))/2); -} - -void -para_cb (ClutterTimeline *timeline, - gint frame_num, - gpointer data) -{ - - -} - -static void -key_press_cb (ClutterStage *stage, - ClutterKeyEvent *event, - gpointer data) -{ - g_print ("key-press-event\n"); -} - -static void -key_release_cb (ClutterStage *stage, - ClutterKeyEvent *event, - gpointer data) -{ - g_print ("key-release-event\n"); -} - -int -main (int argc, char *argv[]) -{ - ClutterActor *texture, *label, *rect, *para; - ClutterActor *stage; - ClutterTimeline *timeline; - ClutterColor rect_col = { 0xff, 0x0, 0x0, 0x99 }; - GdkPixbuf *pixbuf; - - clutter_init (&argc, &argv); - - stage = clutter_stage_get_default (); - g_signal_connect (stage, "key-press-event", - G_CALLBACK (key_press_cb), NULL); - g_signal_connect (stage, "key-release-event", - G_CALLBACK (key_release_cb), NULL); - g_signal_connect (stage, "button-press-event", - G_CALLBACK (clutter_main_quit), - NULL); - - pixbuf = gdk_pixbuf_new_from_file ("clutter-logo-800x600.png", NULL); - - if (!pixbuf) - g_error("pixbuf load failed"); - - texture = clutter_texture_new_from_pixbuf (pixbuf); - - label = clutter_label_new_with_text("Sans Bold 32", "hello"); - - clutter_actor_set_opacity (CLUTTER_ACTOR(label), 0x99); - clutter_actor_set_position (CLUTTER_ACTOR(label), 550, 100); - clutter_actor_set_size(label, 400, 0); - - - rect = clutter_rectangle_new_with_color(&rect_col); - clutter_actor_set_size(rect, 100, 100); - clutter_actor_set_position(rect, 100, 100); - - para = clutter_label_new_with_text ("Sans 24", PARA_TEXT); - clutter_actor_set_position(para, 10, 10); - clutter_actor_set_size(para, 200, 0); - - clutter_container_add (CLUTTER_CONTAINER (stage), - texture, label, - rect, para, - NULL); - - clutter_actor_set_size (CLUTTER_ACTOR (stage), 800, 600); - - clutter_actor_show_all (CLUTTER_ACTOR (stage)); - - timeline = clutter_timeline_new (360, 200); - g_object_set (timeline, "loop", TRUE, 0); - g_signal_connect (timeline, "new-frame", G_CALLBACK (text_cb), label); - clutter_timeline_start (timeline); - - timeline = clutter_timeline_new (1, 30); - g_object_set (timeline, "loop", TRUE, 0); - g_signal_connect (timeline, "new-frame", G_CALLBACK (rect_cb), rect); - clutter_timeline_start (timeline); - - timeline = clutter_timeline_new (1, 10); - g_object_set (timeline, "loop", TRUE, 0); - g_signal_connect (timeline, "new-frame", G_CALLBACK (para_cb), rect); - clutter_timeline_start (timeline); - - clutter_main(); - - return 0; -} diff --git a/tests/Makefile.am b/tests/Makefile.am index db15cee36..9cf9cce5f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,5 @@ -noinst_PROGRAMS = test-textures test-events test-offscreen test-scale +noinst_PROGRAMS = test-textures test-events test-offscreen test-scale \ + test-actors test-behave test-text test-entry INCLUDES = -I$(top_srcdir)/ LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la @@ -9,3 +10,7 @@ test_textures_SOURCES = test-textures.c test_events_SOURCES = test-events.c test_offscreen_SOURCES = test-offscreen.c test_scale_SOURCES = test-scale.c +test_actor_SOURCES = test-actors.c +test_behave_SOURCES = test-behave.c +test_text_SOURCES = test-text.c +test_entry_SOURCES = test-entry.c \ No newline at end of file diff --git a/examples/redhand.png b/tests/redhand.png similarity index 100% rename from examples/redhand.png rename to tests/redhand.png diff --git a/examples/super-oh.c b/tests/test-actors.c similarity index 100% rename from examples/super-oh.c rename to tests/test-actors.c diff --git a/examples/behave.c b/tests/test-behave.c similarity index 100% rename from examples/behave.c rename to tests/test-behave.c diff --git a/examples/test-entry.c b/tests/test-entry.c similarity index 100% rename from examples/test-entry.c rename to tests/test-entry.c diff --git a/examples/test-text.c b/tests/test-text.c similarity index 100% rename from examples/test-text.c rename to tests/test-text.c