[clutter] base-types: Add zero point and rect
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] base-types: Add zero point and rect
- Date: Mon, 11 Jun 2012 09:03:24 +0000 (UTC)
commit 17539bca95e14be051311995dbec3a2b75f00150
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Sat Jun 9 10:35:56 2012 +0100
base-types: Add zero point and rect
A constant ClutterPoint for (0, 0) and a constant degenerate ClutterRect
can be useful as guards for pointers, freeing the NULL value to mean
"unset".
clutter/clutter-base-types.c | 42 ++++++++++++
clutter/clutter-types.h | 96 ++++++++++++++-------------
clutter/clutter.symbols | 2 +
doc/reference/clutter/clutter-sections.txt | 2 +
4 files changed, 96 insertions(+), 46 deletions(-)
---
diff --git a/clutter/clutter-base-types.c b/clutter/clutter-base-types.c
index d485d5f..ac5bc73 100644
--- a/clutter/clutter-base-types.c
+++ b/clutter/clutter-base-types.c
@@ -377,6 +377,26 @@ G_DEFINE_BOXED_TYPE (ClutterMargin, clutter_margin,
* ClutterPoint
*/
+static const ClutterPoint _clutter_point_zero = CLUTTER_POINT_INIT_ZERO;
+
+/**
+ * clutter_point_zero:
+ *
+ * A point centered at (0, 0).
+ *
+ * The returned value can be used as a guard.
+ *
+ * Return value: a point centered in (0, 0); the returned #ClutterPoint
+ * is owned by Clutter and it should not be modified or freed.
+ *
+ * Since: 1.12
+ */
+const ClutterPoint *
+clutter_point_zero (void)
+{
+ return &_clutter_point_zero;
+}
+
/**
* clutter_point_alloc:
*
@@ -672,6 +692,8 @@ G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterSize, clutter_size,
* ClutterRect
*/
+static const ClutterRect _clutter_rect_zero = CLUTTER_RECT_INIT_ZERO;
+
static gboolean clutter_rect_progress (const GValue *a,
const GValue *b,
gdouble progress,
@@ -706,6 +728,26 @@ clutter_rect_normalize_internal (ClutterRect *rect)
}
/**
+ * clutter_rect_zero:
+ *
+ * A #ClutterRect with #ClutterRect.origin set at (0, 0) and a size
+ * of 0.
+ *
+ * The returned value can be used as a guard.
+ *
+ * Return value: a rectangle with origin in (0, 0) and a size of 0.
+ * The returned #ClutterRect is owned by Clutter and it should not
+ * be modified or freed.
+ *
+ * Since: 1.12
+ */
+const ClutterRect *
+clutter_rect_zero (void)
+{
+ return &_clutter_rect_zero;
+}
+
+/**
* clutter_rect_alloc:
*
* Creates a new, empty #ClutterRect.
diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h
index d57d7b0..cd31e9b 100644
--- a/clutter/clutter-types.h
+++ b/clutter/clutter-types.h
@@ -162,23 +162,25 @@ CLUTTER_AVAILABLE_IN_1_12
GType clutter_point_get_type (void) G_GNUC_CONST;
CLUTTER_AVAILABLE_IN_1_12
-ClutterPoint * clutter_point_alloc (void);
+const ClutterPoint * clutter_point_zero (void);
CLUTTER_AVAILABLE_IN_1_12
-ClutterPoint * clutter_point_init (ClutterPoint *point,
- float x,
- float y);
+ClutterPoint * clutter_point_alloc (void);
CLUTTER_AVAILABLE_IN_1_12
-ClutterPoint * clutter_point_copy (const ClutterPoint *point);
+ClutterPoint * clutter_point_init (ClutterPoint *point,
+ float x,
+ float y);
CLUTTER_AVAILABLE_IN_1_12
-void clutter_point_free (ClutterPoint *point);
+ClutterPoint * clutter_point_copy (const ClutterPoint *point);
CLUTTER_AVAILABLE_IN_1_12
-gboolean clutter_point_equals (const ClutterPoint *a,
- const ClutterPoint *b);
+void clutter_point_free (ClutterPoint *point);
CLUTTER_AVAILABLE_IN_1_12
-float clutter_point_distance (const ClutterPoint *a,
- const ClutterPoint *b,
- float *x_distance,
- float *y_distance);
+gboolean clutter_point_equals (const ClutterPoint *a,
+ const ClutterPoint *b);
+CLUTTER_AVAILABLE_IN_1_12
+float clutter_point_distance (const ClutterPoint *a,
+ const ClutterPoint *b,
+ float *x_distance,
+ float *y_distance);
/**
* ClutterSize:
@@ -295,58 +297,60 @@ CLUTTER_AVAILABLE_IN_1_12
GType clutter_rect_get_type (void) G_GNUC_CONST;
CLUTTER_AVAILABLE_IN_1_12
-ClutterRect * clutter_rect_alloc (void);
+const ClutterRect * clutter_rect_zero (void);
+CLUTTER_AVAILABLE_IN_1_12
+ClutterRect * clutter_rect_alloc (void);
CLUTTER_AVAILABLE_IN_1_12
-ClutterRect * clutter_rect_init (ClutterRect *rect,
- float x,
- float y,
- float width,
- float height);
+ClutterRect * clutter_rect_init (ClutterRect *rect,
+ float x,
+ float y,
+ float width,
+ float height);
CLUTTER_AVAILABLE_IN_1_12
-ClutterRect * clutter_rect_copy (const ClutterRect *rect);
+ClutterRect * clutter_rect_copy (const ClutterRect *rect);
CLUTTER_AVAILABLE_IN_1_12
-void clutter_rect_free (ClutterRect *rect);
+void clutter_rect_free (ClutterRect *rect);
CLUTTER_AVAILABLE_IN_1_12
-gboolean clutter_rect_equals (ClutterRect *a,
- ClutterRect *b);
+gboolean clutter_rect_equals (ClutterRect *a,
+ ClutterRect *b);
CLUTTER_AVAILABLE_IN_1_12
-ClutterRect * clutter_rect_normalize (ClutterRect *rect);
+ClutterRect * clutter_rect_normalize (ClutterRect *rect);
CLUTTER_AVAILABLE_IN_1_12
-void clutter_rect_get_center (ClutterRect *rect,
- ClutterPoint *center);
+void clutter_rect_get_center (ClutterRect *rect,
+ ClutterPoint *center);
CLUTTER_AVAILABLE_IN_1_12
-gboolean clutter_rect_contains_point (ClutterRect *rect,
- ClutterPoint *point);
+gboolean clutter_rect_contains_point (ClutterRect *rect,
+ ClutterPoint *point);
CLUTTER_AVAILABLE_IN_1_12
-gboolean clutter_rect_contains_rect (ClutterRect *a,
- ClutterRect *b);
+gboolean clutter_rect_contains_rect (ClutterRect *a,
+ ClutterRect *b);
CLUTTER_AVAILABLE_IN_1_12
-void clutter_rect_union (ClutterRect *a,
- ClutterRect *b,
- ClutterRect *res);
+void clutter_rect_union (ClutterRect *a,
+ ClutterRect *b,
+ ClutterRect *res);
CLUTTER_AVAILABLE_IN_1_12
-gboolean clutter_rect_intersection (ClutterRect *a,
- ClutterRect *b,
- ClutterRect *res);
+gboolean clutter_rect_intersection (ClutterRect *a,
+ ClutterRect *b,
+ ClutterRect *res);
CLUTTER_AVAILABLE_IN_1_12
-void clutter_rect_offset (ClutterRect *rect,
- float d_x,
- float d_y);
+void clutter_rect_offset (ClutterRect *rect,
+ float d_x,
+ float d_y);
CLUTTER_AVAILABLE_IN_1_12
-void clutter_rect_inset (ClutterRect *rect,
- float d_x,
- float d_y);
+void clutter_rect_inset (ClutterRect *rect,
+ float d_x,
+ float d_y);
CLUTTER_AVAILABLE_IN_1_12
-void clutter_rect_clamp_to_pixel (ClutterRect *rect);
+void clutter_rect_clamp_to_pixel (ClutterRect *rect);
CLUTTER_AVAILABLE_IN_1_12
-float clutter_rect_get_x (ClutterRect *rect);
+float clutter_rect_get_x (ClutterRect *rect);
CLUTTER_AVAILABLE_IN_1_12
-float clutter_rect_get_y (ClutterRect *rect);
+float clutter_rect_get_y (ClutterRect *rect);
CLUTTER_AVAILABLE_IN_1_12
-float clutter_rect_get_width (ClutterRect *rect);
+float clutter_rect_get_width (ClutterRect *rect);
CLUTTER_AVAILABLE_IN_1_12
-float clutter_rect_get_height (ClutterRect *rect);
+float clutter_rect_get_height (ClutterRect *rect);
/**
* ClutterVertex:
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index 65c7e2a..cb53456 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -1044,6 +1044,7 @@ clutter_point_equals
clutter_point_free
clutter_point_get_type
clutter_point_init
+clutter_point_zero
clutter_profile_flags DATA
clutter_property_transition_get_property_name
clutter_property_transition_get_type
@@ -1068,6 +1069,7 @@ clutter_rect_intersection
clutter_rect_normalize
clutter_rect_offset
clutter_rect_union
+clutter_rect_zero
clutter_rectangle_get_border_color
clutter_rectangle_get_border_width
clutter_rectangle_get_color
diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt
index d33a084..c7617c9 100644
--- a/doc/reference/clutter/clutter-sections.txt
+++ b/doc/reference/clutter/clutter-sections.txt
@@ -3187,6 +3187,7 @@ ClutterPaintVolume
<SUBSECTION>
CLUTTER_POINT_INIT
CLUTTER_POINT_INIT_ZERO
+clutter_point_zero
clutter_point_alloc
clutter_point_init
clutter_point_copy
@@ -3206,6 +3207,7 @@ clutter_size_equals
<SUBSECTION>
CLUTTER_RECT_INIT
CLUTTER_RECT_INIT_ZERO
+clutter_rect_zero
clutter_rect_alloc
clutter_rect_init
clutter_rect_copy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]