aboutsummaryrefslogtreecommitdiffstats
path: root/libgnomecanvas/gnome-canvas-widget.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-10-10 08:31:45 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-30 01:49:59 +0800
commitb3a95d0299386bccbdebb967d15f4df02cf15891 (patch)
tree52b90e4b913bb1c4cd17df3335216bf518a6e01c /libgnomecanvas/gnome-canvas-widget.c
parent08e71ba8ae72f333f017c25168b9ec85ea5954fa (diff)
downloadgsoc2013-evolution-b3a95d0299386bccbdebb967d15f4df02cf15891.tar.gz
gsoc2013-evolution-b3a95d0299386bccbdebb967d15f4df02cf15891.tar.zst
gsoc2013-evolution-b3a95d0299386bccbdebb967d15f4df02cf15891.zip
gnome-canvas: Change GnomeCanvasItem->point vfunc
Previously the function returned the distance to the nearest item. Now it only returns an item that is hit. This slightly changes semantics (button events are no longer dispatched to the nearest item, but only to the item actually clicked on), but makes the code way simpler and actually does what one would expect.
Diffstat (limited to 'libgnomecanvas/gnome-canvas-widget.c')
-rw-r--r--libgnomecanvas/gnome-canvas-widget.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/libgnomecanvas/gnome-canvas-widget.c b/libgnomecanvas/gnome-canvas-widget.c
index 2229803872..84450bc080 100644
--- a/libgnomecanvas/gnome-canvas-widget.c
+++ b/libgnomecanvas/gnome-canvas-widget.c
@@ -62,12 +62,11 @@ static void gnome_canvas_widget_update (GnomeCanvasItem *item,
gdouble *affine,
ArtSVP *clip_path,
gint flags);
-static gdouble gnome_canvas_widget_point (GnomeCanvasItem *item,
+static GnomeCanvasItem *gnome_canvas_widget_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item);
+ gint cy);
static void gnome_canvas_widget_bounds (GnomeCanvasItem *item,
gdouble *x1,
gdouble *y1,
@@ -424,18 +423,15 @@ gnome_canvas_widget_draw (GnomeCanvasItem *item,
#endif
}
-static double
+static GnomeCanvasItem *
gnome_canvas_widget_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
GnomeCanvasWidget *witem;
gdouble x1, y1, x2, y2;
- gdouble dx, dy;
witem = GNOME_CANVAS_WIDGET (item);
- *actual_item = item;
-
gnome_canvas_c2w (item->canvas, witem->cx, witem->cy, &x1, &y1);
x2 = x1 + (witem->cwidth - 1) / item->canvas->pixels_per_unit;
@@ -444,25 +440,10 @@ gnome_canvas_widget_point (GnomeCanvasItem *item, gdouble x, gdouble y,
/* Is point inside widget bounds? */
if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2))
- return 0.0;
+ return item;
/* Point is outside widget bounds */
-
- if (x < x1)
- dx = x1 - x;
- else if (x > x2)
- dx = x - x2;
- else
- dx = 0.0;
-
- if (y < y1)
- dy = y1 - y;
- else if (y > y2)
- dy = y - y2;
- else
- dy = 0.0;
-
- return sqrt (dx * dx + dy * dy);
+ return NULL;
}
static void