[clutter] cookbook/examples: Use real implicit animations
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] cookbook/examples: Use real implicit animations
- Date: Mon, 19 Mar 2012 18:10:50 +0000 (UTC)
commit 073ec80c05c27a36d2412f9d6784c12c01417bc5
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Mon Mar 19 18:10:26 2012 +0000
cookbook/examples: Use real implicit animations
Instead of clutter_actor_animate().
doc/cookbook/examples/animations-moving-implicit.c | 42 ++++++++++----------
1 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/doc/cookbook/examples/animations-moving-implicit.c b/doc/cookbook/examples/animations-moving-implicit.c
index 79083e6..460320f 100644
--- a/doc/cookbook/examples/animations-moving-implicit.c
+++ b/doc/cookbook/examples/animations-moving-implicit.c
@@ -7,26 +7,26 @@ typedef struct
gfloat target;
} AnimationSpec;
-static const ClutterColor stage_color = { 0x33, 0x33, 0x55, 0xff };
-static const ClutterColor red = { 0xff, 0x00, 0x00, 0xff };
-static const ClutterColor green = { 0x00, 0xff, 0x00, 0xff };
-static const ClutterColor blue = { 0x00, 0x00, 0xff, 0xff };
-
static gboolean
button_pressed_cb (ClutterActor *actor,
ClutterEvent *event,
gpointer user_data)
{
- AnimationSpec *animation_spec;
+ AnimationSpec *animation_spec = user_data;
+ ClutterTransition *transition;
- if (clutter_actor_get_animation (actor) != NULL)
+ if (clutter_actor_get_transition (actor, animation_spec->axis) != NULL)
return TRUE;
- animation_spec = (AnimationSpec *) user_data;
+ clutter_actor_save_easing_state (actor);
+ clutter_actor_set_easing_duration (actor, 500);
+
+ g_object_set (actor, animation_spec->axis, animation_spec->target, NULL);
+ transition = clutter_actor_get_transition (actor, animation_spec->axis);
+ clutter_timeline_set_auto_reverse (CLUTTER_TIMELINE (transition), TRUE);
+ clutter_timeline_set_repeat_count (CLUTTER_TIMELINE (transition), 1);
- clutter_actor_animate (actor, CLUTTER_LINEAR, 500,
- animation_spec->axis, animation_spec->target,
- NULL);
+ clutter_actor_restore_easing_state (actor);
return TRUE;
}
@@ -49,23 +49,29 @@ main (int argc,
stage = clutter_stage_new ();
clutter_actor_set_size (stage, 500, 500);
- clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
+ clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Aluminium2);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
- rectangle1 = clutter_rectangle_new_with_color (&red);
+ rectangle1 = clutter_actor_new ();
+ clutter_actor_set_background_color (rectangle1, CLUTTER_COLOR_ScarletRed);
clutter_actor_set_reactive (rectangle1, TRUE);
clutter_actor_set_size (rectangle1, 50, 50);
clutter_actor_set_position (rectangle1, 400, 400);
+ clutter_actor_add_child (stage, rectangle1);
- rectangle2 = clutter_rectangle_new_with_color (&green);
+ rectangle2 = clutter_actor_new ();
+ clutter_actor_set_background_color (rectangle2, CLUTTER_COLOR_Chameleon);
clutter_actor_set_reactive (rectangle2, TRUE);
clutter_actor_set_size (rectangle2, 50, 50);
clutter_actor_set_position (rectangle2, 50, 50);
+ clutter_actor_add_child (stage, rectangle2);
- rectangle3 = clutter_rectangle_new_with_color (&blue);
+ rectangle3 = clutter_actor_new ();
+ clutter_actor_set_background_color (rectangle3, CLUTTER_COLOR_SkyBlue);
clutter_actor_set_reactive (rectangle3, TRUE);
clutter_actor_set_size (rectangle3, 50, 50);
clutter_actor_set_position (rectangle3, 225, 225);
+ clutter_actor_add_child (stage, rectangle3);
g_signal_connect (rectangle1,
"button-press-event",
@@ -82,12 +88,6 @@ main (int argc,
G_CALLBACK (button_pressed_cb),
&z_move);
- clutter_container_add (CLUTTER_CONTAINER (stage),
- rectangle1,
- rectangle2,
- rectangle3,
- NULL);
-
clutter_actor_show (stage);
clutter_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]