actor-box: Add setters for origin and size
authorEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 25 Oct 2010 14:45:35 +0000 (15:45 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 25 Oct 2010 14:45:35 +0000 (15:45 +0100)
clutter/clutter-actor-box.c
clutter/clutter-types.h
doc/reference/clutter/clutter-sections.txt

index 89bedd9..4f9b071 100644 (file)
@@ -420,6 +420,55 @@ clutter_actor_box_progress (const GValue *a,
   return TRUE;
 }
 
+/**
+ * clutter_actor_box_set_origin:
+ * @box: a #ClutterActorBox
+ * @x: the X coordinate of the new origin
+ * @y: the Y coordinate of the new origin
+ *
+ * Changes the origin of @box, maintaining the size of the #ClutterActorBox.
+ *
+ * Since: 1.6
+ */
+void
+clutter_actor_box_set_origin (ClutterActorBox *box,
+                              gfloat           x,
+                              gfloat           y)
+{
+  gfloat width, height;
+
+  g_return_if_fail (box != NULL);
+
+  width = box->x2 - box->x1;
+  height = box->y2 - box->y1;
+
+  box->x1 = x;
+  box->y1 = y;
+  box->x2 = box->x1 + width;
+  box->y2 = box->y1 + height;
+}
+
+/**
+ * clutter_actor_box_set_size:
+ * @box: a #ClutterActorBox
+ * @width: the new width
+ * @height: the new height
+ *
+ * Sets the size of @box, maintaining the origin of the #ClutterActorBox.
+ *
+ * Since: 1.6
+ */
+void
+clutter_actor_box_set_size (ClutterActorBox *box,
+                            gfloat           width,
+                            gfloat           height)
+{
+  g_return_if_fail (box != NULL);
+
+  box->x2 = box->x1 + width;
+  box->y2 = box->y1 + height;
+}
+
 G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterActorBox, clutter_actor_box,
                                clutter_actor_box_copy,
                                clutter_actor_box_free,
index 6854f29..e8fd673 100644 (file)
@@ -189,6 +189,13 @@ void             clutter_actor_box_union          (const ClutterActorBox *a,
                                                    const ClutterActorBox *b,
                                                    ClutterActorBox       *result);
 
+void             clutter_actor_box_set_origin     (ClutterActorBox       *box,
+                                                   gfloat                 x,
+                                                   gfloat                 y);
+void             clutter_actor_box_set_size       (ClutterActorBox       *box,
+                                                   gfloat                 width,
+                                                   gfloat                 height);
+
 /**
  * ClutterGeometry:
  * @x: X coordinate of the top left corner of an actor
index 2025dfa..2f70ad8 100644 (file)
@@ -451,7 +451,9 @@ clutter_actor_box_get_x
 clutter_actor_box_get_y
 clutter_actor_box_get_width
 clutter_actor_box_get_height
+clutter_actor_box_set_origin
 clutter_actor_box_get_origin
+clutter_actor_box_set_size
 clutter_actor_box_get_size
 clutter_actor_box_get_area
 clutter_actor_box_contains