Top | ![]() |
![]() |
![]() |
![]() |
ClutterBindCoordinate | coordinate | Read / Write / Construct |
gfloat | offset | Read / Write / Construct |
ClutterActor * | source | Read / Write / Construct |
GObject ╰── GInitiallyUnowned ╰── ClutterActorMeta ╰── ClutterConstraint ╰── ClutterBindConstraint
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// 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:
1 2 3 4 5 6 7 8 |
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); |
ClutterBindConstraint is available since Clutter 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
source |
the ClutterActor to use as the source of
the binding, or |
[allow-none] |
coordinate |
the coordinate to bind |
|
offset |
the offset to apply to the binding, in pixels |
Since 1.4
void clutter_bind_constraint_set_source (ClutterBindConstraint *constraint
,ClutterActor *source
);
Sets the source ClutterActor for the constraint
Since 1.4
ClutterActor *
clutter_bind_constraint_get_source (ClutterBindConstraint *constraint
);
Retrieves the ClutterActor set using clutter_bind_constraint_set_source()
Since 1.4
void clutter_bind_constraint_set_coordinate (ClutterBindConstraint *constraint
,ClutterBindCoordinate coordinate
);
Sets the coordinate to bind in the constraint
Since 1.4
ClutterBindCoordinate
clutter_bind_constraint_get_coordinate
(ClutterBindConstraint *constraint
);
Retrieves the bound coordinate of the constraint
Since 1.4
void clutter_bind_constraint_set_offset (ClutterBindConstraint *constraint
,gfloat offset
);
Sets the offset to be applied to the constraint
Since 1.4
gfloat
clutter_bind_constraint_get_offset (ClutterBindConstraint *constraint
);
Retrieves the offset set using clutter_bind_constraint_set_offset()
Since 1.4
typedef struct _ClutterBindConstraint ClutterBindConstraint;
ClutterBindConstraint is an opaque structure whose members cannot be directly accessed
Since 1.4
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 |
||
Equivalent to |
||
Equivalent to |
Since 1.4
“coordinate”
property“coordinate” ClutterBindCoordinate
The coordinate to be bound
Flags: Read / Write / Construct
Default value: CLUTTER_BIND_X
Since 1.4
“offset”
property “offset” gfloat
The offset, in pixels, to be applied to the binding
Flags: Read / Write / Construct
Default value: 0
Since 1.4
“source”
property“source” ClutterActor *
The ClutterActor used as the source for the binding.
The ClutterActor must not be contained inside the actor associated to the constraint.
Flags: Read / Write / Construct
Since 1.4