diff --git a/doc/cookbook/Makefile.am b/doc/cookbook/Makefile.am index 2104d2bd2..a0c4bd7b7 100644 --- a/doc/cookbook/Makefile.am +++ b/doc/cookbook/Makefile.am @@ -53,6 +53,7 @@ VIDEO_FILES = \ videos/animations-rotating-container-reverses-direction.ogv \ videos/textures-split-go.ogv \ videos/events-mouse-scroll.ogv \ + videos/textures-crossfade-two-textures.ogv \ $(NULL) EXTRA_DIST = \ diff --git a/doc/cookbook/examples/textures-crossfade.c b/doc/cookbook/examples/textures-crossfade.c index e6b94cff5..0ba9ccbec 100644 --- a/doc/cookbook/examples/textures-crossfade.c +++ b/doc/cookbook/examples/textures-crossfade.c @@ -28,6 +28,16 @@ static GOptionEntry entries[] = { { NULL } }; +static gboolean +start_animation (ClutterActor *actor, + ClutterEvent *event, + gpointer user_data) +{ + ClutterState *transitions = CLUTTER_STATE (user_data); + clutter_state_set_state (transitions, "show-top"); + return TRUE; +} + static gboolean load_image (ClutterTexture *texture, gchar *image_path) @@ -75,7 +85,7 @@ main (int argc, char *argv[]) stage = clutter_stage_get_default (); clutter_stage_set_title (CLUTTER_STAGE (stage), "cross-fade"); - clutter_actor_set_size (stage, 600, 600); + clutter_actor_set_size (stage, 400, 300); clutter_actor_show (stage); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); @@ -83,7 +93,7 @@ main (int argc, char *argv[]) CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_box_new (layout); - clutter_actor_set_size (box, 600, 600); + clutter_actor_set_size (box, 400, 300); bottom = clutter_texture_new (); top = clutter_texture_new (); @@ -113,8 +123,11 @@ main (int argc, char *argv[]) /* make the bottom opaque and top transparent */ clutter_state_warp_to_state (transitions, "show-bottom"); - /* fade in the top texture and fade out the bottom texture */ - clutter_state_set_state (transitions, "show-top"); + /* on key press, fade in the top texture and fade out the bottom texture */ + g_signal_connect (stage, + "key-press-event", + G_CALLBACK (start_animation), + transitions); clutter_actor_show (stage); diff --git a/doc/cookbook/videos/textures-crossfade-two-textures.ogv b/doc/cookbook/videos/textures-crossfade-two-textures.ogv new file mode 100644 index 000000000..b9c3c1b84 Binary files /dev/null and b/doc/cookbook/videos/textures-crossfade-two-textures.ogv differ