mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 20:32:16 +00:00
cookbook/examples: Use real implicit animations
Instead of clutter_actor_animate().
This commit is contained in:
parent
65cf2039d8
commit
073ec80c05
@ -7,26 +7,26 @@ typedef struct
|
|||||||
gfloat target;
|
gfloat target;
|
||||||
} AnimationSpec;
|
} 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
|
static gboolean
|
||||||
button_pressed_cb (ClutterActor *actor,
|
button_pressed_cb (ClutterActor *actor,
|
||||||
ClutterEvent *event,
|
ClutterEvent *event,
|
||||||
gpointer user_data)
|
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;
|
return TRUE;
|
||||||
|
|
||||||
animation_spec = (AnimationSpec *) user_data;
|
clutter_actor_save_easing_state (actor);
|
||||||
|
clutter_actor_set_easing_duration (actor, 500);
|
||||||
|
|
||||||
clutter_actor_animate (actor, CLUTTER_LINEAR, 500,
|
g_object_set (actor, animation_spec->axis, animation_spec->target, NULL);
|
||||||
animation_spec->axis, animation_spec->target,
|
transition = clutter_actor_get_transition (actor, animation_spec->axis);
|
||||||
NULL);
|
clutter_timeline_set_auto_reverse (CLUTTER_TIMELINE (transition), TRUE);
|
||||||
|
clutter_timeline_set_repeat_count (CLUTTER_TIMELINE (transition), 1);
|
||||||
|
|
||||||
|
clutter_actor_restore_easing_state (actor);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -49,23 +49,29 @@ main (int argc,
|
|||||||
|
|
||||||
stage = clutter_stage_new ();
|
stage = clutter_stage_new ();
|
||||||
clutter_actor_set_size (stage, 500, 500);
|
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);
|
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_reactive (rectangle1, TRUE);
|
||||||
clutter_actor_set_size (rectangle1, 50, 50);
|
clutter_actor_set_size (rectangle1, 50, 50);
|
||||||
clutter_actor_set_position (rectangle1, 400, 400);
|
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_reactive (rectangle2, TRUE);
|
||||||
clutter_actor_set_size (rectangle2, 50, 50);
|
clutter_actor_set_size (rectangle2, 50, 50);
|
||||||
clutter_actor_set_position (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_reactive (rectangle3, TRUE);
|
||||||
clutter_actor_set_size (rectangle3, 50, 50);
|
clutter_actor_set_size (rectangle3, 50, 50);
|
||||||
clutter_actor_set_position (rectangle3, 225, 225);
|
clutter_actor_set_position (rectangle3, 225, 225);
|
||||||
|
clutter_actor_add_child (stage, rectangle3);
|
||||||
|
|
||||||
g_signal_connect (rectangle1,
|
g_signal_connect (rectangle1,
|
||||||
"button-press-event",
|
"button-press-event",
|
||||||
@ -82,12 +88,6 @@ main (int argc,
|
|||||||
G_CALLBACK (button_pressed_cb),
|
G_CALLBACK (button_pressed_cb),
|
||||||
&z_move);
|
&z_move);
|
||||||
|
|
||||||
clutter_container_add (CLUTTER_CONTAINER (stage),
|
|
||||||
rectangle1,
|
|
||||||
rectangle2,
|
|
||||||
rectangle3,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
clutter_actor_show (stage);
|
clutter_actor_show (stage);
|
||||||
|
|
||||||
clutter_main ();
|
clutter_main ();
|
||||||
|
Loading…
Reference in New Issue
Block a user