[gimp] app: implement GimpCanvasItem::hit() in GimpCanvasProgress



commit 2d2bdbd48f05e0b5ca6b7abdcfcfce559882e386
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 30 03:40:34 2014 +0200

    app: implement GimpCanvasItem::hit() in GimpCanvasProgress
    
    Allow hits only on the progress text. Hackish proof-of-concept hack.

 app/display/gimpcanvasprogress.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/app/display/gimpcanvasprogress.c b/app/display/gimpcanvasprogress.c
index 4fbdbb8..3a1c62c 100644
--- a/app/display/gimpcanvasprogress.c
+++ b/app/display/gimpcanvasprogress.c
@@ -83,7 +83,9 @@ static void             gimp_canvas_progress_get_property (GObject          *obj
                                                            GParamSpec       *pspec);
 static void             gimp_canvas_progress_draw         (GimpCanvasItem   *item,
                                                            cairo_t          *cr);
-static cairo_region_t * gimp_canvas_progress_get_extents  (GimpCanvasItem   *item);
+static cairo_region_t * gimp_canvas_progress_get_extents  (GimpCanvasItem   *item);static gboolean        
gimp_canvas_progress_hit          (GimpCanvasItem   *item,
+                                                                                                             
                                gdouble           x,
+                                                                                                             
                                gdouble           y);
 
 static GimpProgress   * gimp_canvas_progress_start        (GimpProgress      *progress,
                                                            const gchar       *message,
@@ -123,6 +125,7 @@ gimp_canvas_progress_class_init (GimpCanvasProgressClass *klass)
 
   item_class->draw           = gimp_canvas_progress_draw;
   item_class->get_extents    = gimp_canvas_progress_get_extents;
+  item_class->hit            = gimp_canvas_progress_hit;
 
   g_object_class_install_property (object_class, PROP_ANCHOR,
                                    g_param_spec_enum ("anchor", NULL, NULL,
@@ -323,6 +326,24 @@ gimp_canvas_progress_get_extents (GimpCanvasItem *item)
   return cairo_region_create_rectangle (&rectangle);
 }
 
+static gboolean
+gimp_canvas_progress_hit (GimpCanvasItem *item,
+                          gdouble         x,
+                          gdouble         y)
+{
+  gdouble px, py;
+  gint    pwidth, pheight;
+  gdouble tx, ty;
+
+  gimp_canvas_progress_transform (item, &px, &py, &pwidth, &pheight);
+  gimp_canvas_item_transform_xy_f (item, x, y, &tx, &ty);
+
+  pheight -= BORDER + 2 * RADIUS;
+
+  return (tx >= px && tx < (px + pwidth) &&
+          ty >= py && ty < (py + pheight));
+}
+
 static GimpProgress *
 gimp_canvas_progress_start (GimpProgress *progress,
                             const gchar  *message,


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