bind-constraint: Add BIND_POSITION and BIND_SIZE
CLUTTER_BIND_POSITION and CLUTTER_BIND_SIZE are two convenience enumeration values for binding x and y, and width and height respectively, using a single ClutterBindConstraint.
This commit is contained in:
parent
4f53653bf9
commit
5329c98694
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user