[clutter] Add some utility initializers to ClutterActorBox
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] Add some utility initializers to ClutterActorBox
- Date: Sat, 17 Mar 2012 15:27:48 +0000 (UTC)
commit 5e9d6f72577c788c24049d8057f856a0f669fa59
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Sat Mar 17 15:27:26 2012 +0000
Add some utility initializers to ClutterActorBox
clutter/clutter-actor-box.c | 58 +++++++++++++++++++++++++--
clutter/clutter-types.h | 28 +++++++++++++
clutter/clutter.symbols | 2 +
doc/reference/clutter/clutter-sections.txt | 3 +
4 files changed, 86 insertions(+), 5 deletions(-)
---
diff --git a/clutter/clutter-actor-box.c b/clutter/clutter-actor-box.c
index 9c8c797..0a7f156 100644
--- a/clutter/clutter-actor-box.c
+++ b/clutter/clutter-actor-box.c
@@ -32,12 +32,63 @@ clutter_actor_box_new (gfloat x_1,
ClutterActorBox *box;
box = g_slice_new (ClutterActorBox);
+ clutter_actor_box_init (box, x_1, y_1, x_2, y_2);
+
+ return box;
+}
+
+/**
+ * clutter_actor_box_init:
+ * @box: a #ClutterActorBox
+ * @x_1: X coordinate of the top left point
+ * @y_1: Y coordinate of the top left point
+ * @x_2: X coordinate of the bottom right point
+ * @y_2: Y coordinate of the bottom right point
+ *
+ * Initializes @box with the given coordinates.
+ *
+ * Since: 1.10
+ */
+void
+clutter_actor_box_init (ClutterActorBox *box,
+ gfloat x_1,
+ gfloat y_1,
+ gfloat x_2,
+ gfloat y_2)
+{
+ g_return_if_fail (box != NULL);
+
box->x1 = x_1;
box->y1 = y_1;
box->x2 = x_2;
box->y2 = y_2;
+}
- return box;
+/**
+ * clutter_actor_box_init_rect:
+ * @box: a #ClutterActorBox
+ * @x: X coordinate of the origin
+ * @y: Y coordinate of the origin
+ * @width: width of the box
+ * @height: height of the box
+ *
+ * Initializes @box with the given origin and size.
+ *
+ * Since: 1.10
+ */
+void
+clutter_actor_box_init_rect (ClutterActorBox *box,
+ gfloat x,
+ gfloat y,
+ gfloat width,
+ gfloat height)
+{
+ g_return_if_fail (box != NULL);
+
+ box->x1 = x;
+ box->y1 = y;
+ box->x2 = box->x1 + width;
+ box->y2 = box->y1 + height;
}
/**
@@ -444,10 +495,7 @@ clutter_actor_box_set_origin (ClutterActorBox *box,
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_init_rect (box, x, y, width, height);
}
/**
diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h
index 8b41f63..f9cda74 100644
--- a/clutter/clutter-types.h
+++ b/clutter/clutter-types.h
@@ -151,11 +151,39 @@ struct _ClutterActorBox
gfloat y2;
};
+/**
+ * CLUTTER_ACTOR_BOX_INIT:
+ * @x_1: the X coordinate of the top left corner
+ * @y_1: the Y coordinate of the top left corner
+ * @x_2: the X coordinate of the bottom right corner
+ * @y_2: the Y coordinate of the bottom right corner
+ *
+ * A simple macro for initializing a #ClutterActorBox when declaring
+ * it, e.g.:
+ *
+ * |[
+ * ClutterActorBox box = CLUTTER_ACTOR_BOX_INIT (0, 0, 400, 600);
+ * ]|
+ *
+ * Since: 1.10
+ */
+#define CLUTTER_ACTOR_BOX_INIT(x_1,y_1,x_2,y_2) { (x_1), (y_1), (x_2), (y_2) }
+
GType clutter_actor_box_get_type (void) G_GNUC_CONST;
ClutterActorBox *clutter_actor_box_new (gfloat x_1,
gfloat y_1,
gfloat x_2,
gfloat y_2);
+void clutter_actor_box_init (ClutterActorBox *box,
+ gfloat x_1,
+ gfloat y_1,
+ gfloat x_2,
+ gfloat y_2);
+void clutter_actor_box_init_rect (ClutterActorBox *box,
+ gfloat x,
+ gfloat y,
+ gfloat width,
+ gfloat height);
ClutterActorBox *clutter_actor_box_copy (const ClutterActorBox *box);
void clutter_actor_box_free (ClutterActorBox *box);
gboolean clutter_actor_box_equal (const ClutterActorBox *box_a,
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index 558a2f6..3b4f8b1 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -58,6 +58,8 @@ clutter_actor_box_get_type
clutter_actor_box_get_width
clutter_actor_box_get_x
clutter_actor_box_get_y
+clutter_actor_box_init_rect
+clutter_actor_box_init
clutter_actor_box_interpolate
clutter_actor_box_new
clutter_actor_box_set_origin
diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt
index 6b5dc66..09ca289 100644
--- a/doc/reference/clutter/clutter-sections.txt
+++ b/doc/reference/clutter/clutter-sections.txt
@@ -522,7 +522,10 @@ clutter_actor_set_shader_param_int
<SUBSECTION>
ClutterActorBox
+CLUTTER_ACTOR_BOX_INIT
clutter_actor_box_new
+clutter_actor_box_init
+clutter_actor_box_init_rect
clutter_actor_box_copy
clutter_actor_box_free
clutter_actor_box_equal
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]