+2007-06-12 Matthew Allum <mallum@openedhand.com>
+
+ * 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 <tf@openedhand.com>
* clutter/clutter-alpha.c:
-SUBDIRS=clutter doc examples tests
+SUBDIRS=clutter doc tests
pcfiles = clutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.pc
*/
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);
}
CLUTTER_TYPE_ROTATE_DIRECTION,
CLUTTER_ROTATE_CW,
CLUTTER_PARAM_READWRITE));
+
+ g_type_class_add_private (klass, sizeof (ClutterBehaviourRotatePrivate));
}
static void
#include "clutter-behaviour.h"
#include "clutter-debug.h"
#include "clutter-private.h"
+#include "clutter-marshal.h"
/**
* clutter_knot_copy:
};
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), \
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);
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));
}
}
g_object_ref (actor);
+
+ g_signal_emit (behave, behave_signals[APPLY], 0, actor);
+
behave->priv->actors = g_slist_prepend (behave->priv->actors, actor);
}
}
g_object_unref (actor);
+
+ g_signal_emit (behave, behave_signals[REMOVE], 0, actor);
+
behave->priv->actors = g_slist_remove (behave->priv->actors, actor);
}
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);
clutter/cogl/Makefile
clutter/cogl/gl/Makefile
clutter/cogl/gles/Makefile
- examples/Makefile
tests/Makefile
doc/Makefile
doc/reference/Makefile
+++ /dev/null
-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
+++ /dev/null
-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.
+++ /dev/null
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <clutter/clutter.h>
-
-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();
-}
+++ /dev/null
-#include <clutter/clutter.h>
-
-#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;
-}
-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
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