## ClutterBindConstraint

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

## Synopsis

                        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);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----ClutterActorMeta
                   +----ClutterConstraint
                         +----ClutterBindConstraint

## Properties

      "coordinate"               ClutterBindCoordinate  : Read / Write / Construct
      "offset"                   gfloat                : Read / Write / Construct
      "source"                   ClutterActor*         : Read / Write / Construct

## 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

## Details

### ClutterBindConstraint

    typedef struct _ClutterBindConstraint ClutterBindConstraint;

ClutterBindConstraint is an opaque structure whose members cannot be directly accessed

Since 1.4

### enum ClutterBindCoordinate

    typedef enum { /*< prefix=CLUTTER_BIND >*/
      CLUTTER_BIND_X,
      CLUTTER_BIND_Y,
      CLUTTER_BIND_WIDTH,
      CLUTTER_BIND_HEIGHT
    } ClutterBindCoordinate;

Specifies which property should be used in a binding

`CLUTTER_BIND_X` | Bind the X coordinate
`CLUTTER_BIND_Y` | Bind the Y coordinate
`CLUTTER_BIND_WIDTH` | Bind the width
`CLUTTER_BIND_HEIGHT` | Bidng the height

Since 1.4

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

`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

`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()`

`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

`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

`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

`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()`

`constraint` : | a ClutterBindConstraint
Returns : | the offset, in pixels

Since 1.4

## Property Details

### The `"coordinate"` property

      "coordinate"               ClutterBindCoordinate  : Read / Write / Construct

The coordinate to be bound

Default value: CLUTTER_BIND_X

Since 1.4

### The `"offset"` property

      "offset"                   gfloat                : Read / Write / Construct

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

Default value: 0

Since 1.4

### The `"source"` property

      "source"                   ClutterActor*         : Read / Write / Construct

The ClutterActor used as the source for the binding

Since 1.4