
@c %start of fragment

@node ClutterBindConstraint
@chapter ClutterBindConstraint
A constraint binding the position or size of an actor

@section Overview
@code{<clutter-bind-constraint>} is a @code{<clutter-constraint>} that
binds the position or the size of the @code{<clutter-actor>} to which it
is applied to the the position or the size of another
@code{<clutter-actor>}, or "source".

An offset can be applied to the constraint, to avoid overlapping. The
offset can also be animated. For instance, the following code will set
up three actors to be bound to the same origin:

@example 

/&#x002A; source &#x002A;/
rect[0] = clutter_rectangle_new_with_color (&red_color);
clutter_actor_set_position (rect[0], x_pos, y_pos);
clutter_actor_set_size (rect[0], 100, 100);

/&#x002A; second rectangle &#x002A;/
rect[1] = clutter_rectangle_new_with_color (&green_color);
clutter_actor_set_size (rect[1], 100, 100);
clutter_actor_set_opacity (rect[1], 0);

constraint = clutter_bind_constraint_new (rect[0], CLUTTER_BIND_X, 0.0);
clutter_actor_add_constraint_with_name (rect[1], "green-x", constraint);
constraint = clutter_bind_constraint_new (rect[0], CLUTTER_BIND_Y, 0.0);
clutter_actor_add_constraint_with_name (rect[1], "green-y", constraint);

/&#x002A; third rectangle &#x002A;/
rect[2] = clutter_rectangle_new_with_color (&blue_color);
clutter_actor_set_size (rect[2], 100, 100);
clutter_actor_set_opacity (rect[2], 0);

constraint = clutter_bind_constraint_new (rect[0], CLUTTER_BIND_X, 0.0);
clutter_actor_add_constraint_with_name (rect[2], "blue-x", constraint);
constraint = clutter_bind_constraint_new (rect[0], CLUTTER_BIND_Y, 0.0);
clutter_actor_add_constraint_with_name (rect[2], "blue-y", constraint);
@end example

The following code animates the second and third rectangles to "expand"
them horizontally from underneath the first rectangle:

@example 

clutter_actor_animate (rect[1], CLUTTER_EASE_OUT_CUBIC, 250,
                       "@@constraints.green-x.offset", 100.0,
                       "opacity", 255,
                       NULL);
clutter_actor_animate (rect[2], CLUTTER_EASE_OUT_CUBIC, 250,
                       "@@constraints.blue-x.offset", 200.0,
                       "opacity", 255,
                       NULL);
@end example

@c (example (@ (id "bind-constraint-example")))
@c (title "Animating the offset property of ClutterBindConstraint")
@example 
@c (http://www.w3.org/2001/XInclude:include (@ (parse "text") (href "../../../../tests/interactive/test-constraints.c")) (c (% (all "(http://www.w3.org/2001/XInclude:fallback \"FIXME: MISSING XINCLUDE CONTENT\")"))))
@end example

The example above creates eight rectangles and binds them to a rectangle
positioned in the center of the stage; when the user presses the center
rectangle, the @code{<"offset">} property is animated through the
@code{clutter-actor-animate} function to lay out the eight rectangles
around the center one. Pressing one of the outer rectangles will animate
the offset back to 0.

@code{<clutter-bind-constraint>} is available since Clutter 1.4

@section Usage
@include defuns-clutter-bind-constraint.xml.texi

@c %end of fragment
