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".
This commit is contained in:
parent
24495918bb
commit
17539bca95
@ -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,
|
||||
@ -705,6 +727,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:
|
||||
*
|
||||
|
@ -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_init (ClutterRect *rect,
|
||||
float x,
|
||||
float y,
|
||||
float width,
|
||||
float height);
|
||||
ClutterRect * clutter_rect_alloc (void);
|
||||
CLUTTER_AVAILABLE_IN_1_12
|
||||
ClutterRect * clutter_rect_copy (const ClutterRect *rect);
|
||||
ClutterRect * clutter_rect_init (ClutterRect *rect,
|
||||
float x,
|
||||
float y,
|
||||
float width,
|
||||
float height);
|
||||
CLUTTER_AVAILABLE_IN_1_12
|
||||
void clutter_rect_free (ClutterRect *rect);
|
||||
ClutterRect * clutter_rect_copy (const ClutterRect *rect);
|
||||
CLUTTER_AVAILABLE_IN_1_12
|
||||
gboolean clutter_rect_equals (ClutterRect *a,
|
||||
ClutterRect *b);
|
||||
void clutter_rect_free (ClutterRect *rect);
|
||||
CLUTTER_AVAILABLE_IN_1_12
|
||||
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:
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user