[gtk+/wip/carlosg/event-delivery: 21/105] gdk: Add gdk_rectangle_contains_point() call
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/carlosg/event-delivery: 21/105] gdk: Add gdk_rectangle_contains_point() call
- Date: Sun, 14 May 2017 23:39:13 +0000 (UTC)
commit 5b20d5ab5254a54cde87c55e257d2d29e119b7da
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri May 12 11:46:33 2017 +0200
gdk: Add gdk_rectangle_contains_point() call
A little helper function for a somewhat common operation.
docs/reference/gdk/gdk4-sections.txt | 1 +
gdk/gdkrectangle.c | 25 +++++++++++++++++++++++++
gdk/gdkrectangle.h | 5 +++++
3 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index 25891c8..2f60092 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -534,6 +534,7 @@ GdkRectangle
gdk_rectangle_intersect
gdk_rectangle_union
gdk_rectangle_equal
+gdk_rectangle_contains_point
<SUBSECTION Private>
gdk_rectangle_get_type
diff --git a/gdk/gdkrectangle.c b/gdk/gdkrectangle.c
index 491de6c..6e6fa61 100644
--- a/gdk/gdkrectangle.c
+++ b/gdk/gdkrectangle.c
@@ -137,6 +137,31 @@ gdk_rectangle_intersect (const GdkRectangle *src1,
}
/**
+ * 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
* @rect2: a #GdkRectangle
diff --git a/gdk/gdkrectangle.h b/gdk/gdkrectangle.h
index 7c0252f..225f048 100644
--- a/gdk/gdkrectangle.h
+++ b/gdk/gdkrectangle.h
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]