gdk: Add gdk_rectangle_contains_point() call

A little helper function for a somewhat common operation.
This commit is contained in:
Carlos Garnacho
2017-05-12 11:46:33 +02:00
parent 28f8a27d65
commit fee289cd06
3 changed files with 31 additions and 0 deletions

View File

@@ -534,6 +534,7 @@ GdkRectangle
gdk_rectangle_intersect
gdk_rectangle_union
gdk_rectangle_equal
gdk_rectangle_contains_point
<SUBSECTION Private>
gdk_rectangle_get_type

View File

@@ -136,6 +136,31 @@ gdk_rectangle_intersect (const GdkRectangle *src1,
return return_val;
}
/**
* gdk_rectangle_contains_point:
* @rect: a #GdkRectangle
* @x: X coordinate
* @y: Y coordinate
*
* Returns #TRUE if @rect contains the point described by @x and @y.
*
* Returns: #TRUE if @rect contains the point
*
* Since: 3.90
**/
gboolean
gdk_rectangle_contains_point (const GdkRectangle *rect,
int x,
int y)
{
g_return_val_if_fail (rect != NULL, FALSE);
return x >= rect->x &&
x < rect->x + rect->width &&
y >= rect->y &&
y < rect->y + rect->height;
}
/**
* gdk_rectangle_equal:
* @rect1: a #GdkRectangle

View File

@@ -49,6 +49,11 @@ GDK_AVAILABLE_IN_3_20
gboolean gdk_rectangle_equal (const GdkRectangle *rect1,
const GdkRectangle *rect2);
GDK_AVAILABLE_IN_3_90
gboolean gdk_rectangle_contains_point (const GdkRectangle *rect,
int x,
int y);
GDK_AVAILABLE_IN_ALL
GType gdk_rectangle_get_type (void) G_GNUC_CONST;