diff --git a/clutter/clutter-bind-constraint.c b/clutter/clutter-bind-constraint.c index 1fb45213f..984aed334 100644 --- a/clutter/clutter-bind-constraint.c +++ b/clutter/clutter-bind-constraint.c @@ -175,6 +175,13 @@ clutter_bind_constraint_update_allocation (ClutterConstraint *constraint, allocation->y2 = allocation->y1 + actor_height; break; + case CLUTTER_BIND_POSITION: + allocation->x1 = source_position.x + bind->offset; + allocation->y1 = source_position.y + bind->offset; + allocation->x2 = allocation->x1 + actor_width; + allocation->y2 = allocation->y1 + actor_height; + break; + case CLUTTER_BIND_WIDTH: allocation->x2 = allocation->x1 + source_width + bind->offset; break; @@ -183,6 +190,11 @@ clutter_bind_constraint_update_allocation (ClutterConstraint *constraint, allocation->y2 = allocation->y1 + source_height + bind->offset; break; + case CLUTTER_BIND_SIZE: + allocation->x2 = allocation->x1 + source_width + bind->offset; + allocation->y2 = allocation->y1 + source_height + bind->offset; + break; + default: g_assert_not_reached (); break; diff --git a/clutter/clutter-bind-constraint.h b/clutter/clutter-bind-constraint.h index b160c39cc..d5486c13c 100644 --- a/clutter/clutter-bind-constraint.h +++ b/clutter/clutter-bind-constraint.h @@ -54,6 +54,10 @@ typedef struct _ClutterBindConstraintClass ClutterBindConstraintClass; * @CLUTTER_BIND_Y: Bind the Y coordinate * @CLUTTER_BIND_WIDTH: Bind the width * @CLUTTER_BIND_HEIGHT: Bidng the height + * @CLUTTER_BIND_POSITION: Equivalent to to %CLUTTER_BIND_X and + * %CLUTTER_BIND_Y + * @CLUTTER_BIND_SIZE: Equivalent to %CLUTTER_BIND_WIDTH and + * %CLUTTER_BIND_HEIGHT * * Specifies which property should be used in a binding * @@ -63,7 +67,9 @@ typedef enum { /*< prefix=CLUTTER_BIND >*/ CLUTTER_BIND_X, CLUTTER_BIND_Y, CLUTTER_BIND_WIDTH, - CLUTTER_BIND_HEIGHT + CLUTTER_BIND_HEIGHT, + CLUTTER_BIND_POSITION, + CLUTTER_BIND_SIZE } ClutterBindCoordinate; GType clutter_bind_constraint_get_type (void) G_GNUC_CONST; diff --git a/tests/interactive/test-constraints.c b/tests/interactive/test-constraints.c index 9efb55dab..9ebbea40d 100644 --- a/tests/interactive/test-constraints.c +++ b/tests/interactive/test-constraints.c @@ -152,7 +152,6 @@ test_constraints_main (int argc, char *argv[]) clutter_color_from_string (&rect_color, colors[i]); rect = clutter_rectangle_new (); clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect), &rect_color); - clutter_actor_set_size (rect, 128, 128); clutter_actor_set_opacity (rect, 0); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); @@ -162,6 +161,9 @@ test_constraints_main (int argc, char *argv[]) constraint = clutter_bind_constraint_new (rects[Center], CLUTTER_BIND_Y, 0.0); clutter_actor_add_constraint_with_name (rect, "y-bind", constraint); + constraint = clutter_bind_constraint_new (rects[Center], CLUTTER_BIND_SIZE, 0.0); + clutter_actor_add_constraint_with_name (rect, "size-bind", constraint); + rects[i] = rect; } diff --git a/tests/interactive/test-flow-layout.c b/tests/interactive/test-flow-layout.c index 22b3cba4d..9f323080c 100644 --- a/tests/interactive/test-flow-layout.c +++ b/tests/interactive/test-flow-layout.c @@ -110,10 +110,7 @@ test_flow_layout_main (int argc, char *argv[]) clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); if (!fixed_size) - { - clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_WIDTH, 0.0)); - clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_HEIGHT, 0.0)); - } + clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0)); clutter_actor_set_position (box, 0, 0);