![]() |
![]() |
![]() |
Clutter Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
ClutterBindConstraint; enum ClutterBindCoordinate; ClutterConstraint * clutter_bind_constraint_new (ClutterActor *source
,ClutterBindCoordinate coordinate
,gfloat offset
); void clutter_bind_constraint_set_source (ClutterBindConstraint *constraint
,ClutterActor *source
); ClutterActor * clutter_bind_constraint_get_source (ClutterBindConstraint *constraint
); void clutter_bind_constraint_set_coordinate (ClutterBindConstraint *constraint
,ClutterBindCoordinate coordinate
); ClutterBindCoordinate clutter_bind_constraint_get_coordinate (ClutterBindConstraint *constraint
); void clutter_bind_constraint_set_offset (ClutterBindConstraint *constraint
,gfloat offset
); gfloat clutter_bind_constraint_get_offset (ClutterBindConstraint *constraint
);
GObject +----GInitiallyUnowned +----ClutterActorMeta +----ClutterConstraint +----ClutterBindConstraint
"coordinate" ClutterBindCoordinate : Read / Write / Construct "offset" gfloat : Read / Write / Construct "source" ClutterActor* : Read / Write / Construct
ClutterBindConstraint is a ClutterConstraint that binds the position or the size of the ClutterActor to which it is applied to the the position or the size of another ClutterActor, 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:
/* source */ 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); /* second rectangle */ 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); /* third rectangle */ 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);
The following code animates the second and third rectangles to "expand" them horizontally from underneath the first rectangle:
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);
Example 7. Animating the offset property of ClutterBindConstraint
FIXME: MISSING XINCLUDE CONTENT
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 "offset" property is
animated through the 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.
ClutterBindConstraint is available since Clutter 1.4
typedef struct _ClutterBindConstraint ClutterBindConstraint;
ClutterBindConstraint is an opaque structure whose members cannot be directly accessed
Since 1.4
typedef enum { /*< prefix=CLUTTER_BIND >*/ CLUTTER_BIND_X, CLUTTER_BIND_Y, CLUTTER_BIND_WIDTH, CLUTTER_BIND_HEIGHT, CLUTTER_BIND_POSITION, CLUTTER_BIND_SIZE, CLUTTER_BIND_ALL } ClutterBindCoordinate;
Specifies which property should be used in a binding
Bind the X coordinate | |
Bind the Y coordinate | |
Bind the width | |
Bind the height | |
Equivalent to to CLUTTER_BIND_X and
CLUTTER_BIND_Y (added in Clutter 1.6)
|
|
Equivalent to CLUTTER_BIND_WIDTH and
CLUTTER_BIND_HEIGHT (added in Clutter 1.6)
|
|
Equivalent to CLUTTER_BIND_POSITION and
CLUTTER_BIND_SIZE (added in Clutter 1.10)
|
Since 1.4
ClutterConstraint * clutter_bind_constraint_new (ClutterActor *source
,ClutterBindCoordinate coordinate
,gfloat offset
);
Creates a new constraint, binding a ClutterActor's position to
the given coordinate
of the position of source
|
the ClutterActor to use as the source of
the binding, or NULL . [allow-none]
|
|
the coordinate to bind |
|
the offset to apply to the binding, in pixels |
Returns : |
the newly created ClutterBindConstraint |
Since 1.4
void clutter_bind_constraint_set_source (ClutterBindConstraint *constraint
,ClutterActor *source
);
Sets the source ClutterActor for the constraint
|
a ClutterBindConstraint |
|
a ClutterActor, or NULL to unset the source. [allow-none]
|
Since 1.4
ClutterActor * clutter_bind_constraint_get_source (ClutterBindConstraint *constraint
);
Retrieves the ClutterActor set using clutter_bind_constraint_set_source()
|
a ClutterBindConstraint |
Returns : |
a pointer to the source actor. [transfer none] |
Since 1.4
void clutter_bind_constraint_set_coordinate (ClutterBindConstraint *constraint
,ClutterBindCoordinate coordinate
);
Sets the coordinate to bind in the constraint
|
a ClutterBindConstraint |
|
the coordinate to bind |
Since 1.4
ClutterBindCoordinate clutter_bind_constraint_get_coordinate
(ClutterBindConstraint *constraint
);
Retrieves the bound coordinate of the constraint
|
a ClutterBindConstraint |
Returns : |
the bound coordinate |
Since 1.4
void clutter_bind_constraint_set_offset (ClutterBindConstraint *constraint
,gfloat offset
);
Sets the offset to be applied to the constraint
|
a ClutterBindConstraint |
|
the offset to apply, in pixels |
Since 1.4
gfloat clutter_bind_constraint_get_offset (ClutterBindConstraint *constraint
);
Retrieves the offset set using clutter_bind_constraint_set_offset()
|
a ClutterBindConstraint |
Returns : |
the offset, in pixels |
Since 1.4
"coordinate"
property"coordinate" ClutterBindCoordinate : Read / Write / Construct
The coordinate to be bound
Default value: CLUTTER_BIND_X
Since 1.4
"offset"
property "offset" gfloat : Read / Write / Construct
The offset, in pixels, to be applied to the binding
Default value: 0
Since 1.4
"source"
property"source" ClutterActor* : Read / Write / Construct
The ClutterActor used as the source for the binding.
The ClutterActor must not be contained inside the actor associated to the constraint.
Since 1.4