ClutterBindConstraint

## ClutterBindConstraint ClutterBindConstraint — A constraint binding the position or size of an actor |

## Functions

ClutterConstraint * | clutter_bind_constraint_new ()
void | clutter_bind_constraint_set_source ()
ClutterActor * | clutter_bind_constraint_get_source ()
void | clutter_bind_constraint_set_coordinate ()
ClutterBindCoordinate | clutter_bind_constraint_get_coordinate ()
void | clutter_bind_constraint_set_offset ()
gfloat | clutter_bind_constraint_get_offset ()

## Properties

ClutterBindCoordinate | coordinate | Read / Write / Construct
gfloat | offset | Read / Write / Construct
ClutterActor * | source | Read / Write / Construct

## Types and Values

| ClutterBindConstraint
enum | ClutterBindCoordinate

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── ClutterActorMeta
                ╰── ClutterConstraint
                    ╰── ClutterBindConstraint

## Description

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

## Functions

### clutter_bind_constraint_new ()

    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`

#### Parameters

source | the ClutterActor to use as the source of the binding, or `NULL`. | [allow-none]
coordinate | the coordinate to bind |
offset | the offset to apply to the binding, in pixels |

#### Returns

the newly created ClutterBindConstraint

Since 1.4

### clutter_bind_constraint_set_source ()

    void
    clutter_bind_constraint_set_source (ClutterBindConstraint *constraint,
                                        ClutterActor *source);

Sets the source ClutterActor for the constraint

#### Parameters

constraint | a ClutterBindConstraint |
source | a ClutterActor, or `NULL` to unset the source. | [allow-none]

Since 1.4

### clutter_bind_constraint_get_source ()

    ClutterActor *
    clutter_bind_constraint_get_source (ClutterBindConstraint *constraint);

Retrieves the ClutterActor set using `clutter_bind_constraint_set_source()`

#### Parameters

constraint | a ClutterBindConstraint |

#### Returns

a pointer to the source actor.

[transfer none]

Since 1.4

### clutter_bind_constraint_set_coordinate ()

    void
    clutter_bind_constraint_set_coordinate
                                   (ClutterBindConstraint *constraint,
                                    ClutterBindCoordinate coordinate);

Sets the coordinate to bind in the constraint

#### Parameters

constraint | a ClutterBindConstraint |
coordinate | the coordinate to bind |

Since 1.4

### clutter_bind_constraint_get_coordinate ()

    ClutterBindCoordinate
    clutter_bind_constraint_get_coordinate
                                   (ClutterBindConstraint *constraint);

Retrieves the bound coordinate of the constraint

#### Parameters

constraint | a ClutterBindConstraint |

#### Returns

the bound coordinate

Since 1.4

### clutter_bind_constraint_set_offset ()

    void
    clutter_bind_constraint_set_offset (ClutterBindConstraint *constraint,
                                        gfloat offset);

Sets the offset to be applied to the constraint

#### Parameters

constraint | a ClutterBindConstraint |
offset | the offset to apply, in pixels |

Since 1.4

### clutter_bind_constraint_get_offset ()

    gfloat
    clutter_bind_constraint_get_offset (ClutterBindConstraint *constraint);

Retrieves the offset set using `clutter_bind_constraint_set_offset()`

#### Parameters

constraint | a ClutterBindConstraint |

#### Returns

the offset, in pixels

Since 1.4

## Types and Values

### ClutterBindConstraint

    typedef struct _ClutterBindConstraint ClutterBindConstraint;

ClutterBindConstraint is an opaque structure whose members cannot be directly accessed

Since 1.4

### enum ClutterBindCoordinate

Specifies which property should be used in a binding

#### Members

CLUTTER_BIND_X | Bind the X coordinate |
CLUTTER_BIND_Y | Bind the Y coordinate |
CLUTTER_BIND_WIDTH | Bind the width |
CLUTTER_BIND_HEIGHT | Bind the height |
CLUTTER_BIND_POSITION | Equivalent to to `CLUTTER_BIND_X` and `CLUTTER_BIND_Y` (added in Clutter 1.6) |
CLUTTER_BIND_SIZE | Equivalent to `CLUTTER_BIND_WIDTH` and `CLUTTER_BIND_HEIGHT` (added in Clutter 1.6) |
CLUTTER_BIND_ALL | Equivalent to `CLUTTER_BIND_POSITION` and `CLUTTER_BIND_SIZE` (added in Clutter 1.10) |

Since 1.4

## Property Details

### The `“coordinate”` property

      “coordinate”               ClutterBindCoordinate

The coordinate to be bound

Flags: Read / Write / Construct

Default value: CLUTTER_BIND_X

Since 1.4

### The `“offset”` property

      “offset”                   gfloat

The offset, in pixels, to be applied to the binding

Flags: Read / Write / Construct

Default value: 0

Since 1.4

### The `“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