[gimp] Factor out tag hit detection into a utility function



commit 25a8a9ea9f967f063e4028e66e66b09e42de3703
Author: Michael Natterer <mitch gimp org>
Date:   Fri Jul 10 04:31:53 2009 +0200

    Factor out tag hit detection into a utility function

 app/widgets/gimptagpopup.c |   34 ++++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/app/widgets/gimptagpopup.c b/app/widgets/gimptagpopup.c
index 086133d..4c13b65 100644
--- a/app/widgets/gimptagpopup.c
+++ b/app/widgets/gimptagpopup.c
@@ -89,6 +89,9 @@ static gboolean gimp_tag_popup_border_event            (GtkWidget          *widg
 static gboolean gimp_tag_popup_list_event              (GtkWidget          *widget,
                                                         GdkEvent           *event,
                                                         GimpTagPopup       *popup);
+static gboolean gimp_tag_popup_is_in_tag               (PopupTagData       *tag_data,
+                                                        gint                x,
+                                                        gint                y);
 static void     gimp_tag_popup_toggle_tag              (GimpTagPopup       *popup,
                                                         PopupTagData       *tag_data);
 static void     gimp_tag_popup_check_can_toggle        (GimpTagged         *tagged,
@@ -864,10 +867,7 @@ gimp_tag_popup_list_event (GtkWidget    *widget,
         {
           PopupTagData *tag_data = &popup->tag_data[i];
 
-          if (x >= tag_data->bounds.x                          &&
-              y >= tag_data->bounds.y                          &&
-              x <  tag_data->bounds.x + tag_data->bounds.width &&
-              y <  tag_data->bounds.y + tag_data->bounds.height)
+          if (gimp_tag_popup_is_in_tag (tag_data, x, y))
             {
               gimp_tag_popup_toggle_tag (popup, tag_data);
               gtk_widget_queue_draw (widget);
@@ -889,10 +889,7 @@ gimp_tag_popup_list_event (GtkWidget    *widget,
         {
           PopupTagData *tag_data = &popup->tag_data[i];
 
-          if (x >= tag_data->bounds.x                          &&
-              y >= tag_data->bounds.y                          &&
-              x <  tag_data->bounds.x + tag_data->bounds.width &&
-              y <  tag_data->bounds.y + tag_data->bounds.height)
+          if (gimp_tag_popup_is_in_tag (tag_data, x, y))
             {
               if (popup->prelight != tag_data)
                 {
@@ -921,10 +918,7 @@ gimp_tag_popup_list_event (GtkWidget    *widget,
         {
           PopupTagData *tag_data = &popup->tag_data[i];
 
-          if (x >= tag_data->bounds.x                          &&
-              y >= tag_data->bounds.y                          &&
-              x <  tag_data->bounds.x + tag_data->bounds.width &&
-              y <  tag_data->bounds.y + tag_data->bounds.height)
+          if (gimp_tag_popup_is_in_tag (tag_data, x, y))
             {
               gimp_tag_popup_toggle_tag (popup, tag_data);
               gtk_widget_destroy (GTK_WIDGET (popup));
@@ -936,6 +930,22 @@ gimp_tag_popup_list_event (GtkWidget    *widget,
   return FALSE;
 }
 
+static gboolean
+gimp_tag_popup_is_in_tag (PopupTagData *tag_data,
+                          gint          x,
+                          gint          y)
+{
+  if (x >= tag_data->bounds.x                          &&
+      y >= tag_data->bounds.y                          &&
+      x <  tag_data->bounds.x + tag_data->bounds.width &&
+      y <  tag_data->bounds.y + tag_data->bounds.height)
+    {
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 gimp_tag_popup_toggle_tag (GimpTagPopup *popup,
                            PopupTagData *tag_data)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]