diff options
author | Benjamin Otte <otte@redhat.com> | 2010-10-10 08:31:45 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-10-30 01:49:59 +0800 |
commit | b3a95d0299386bccbdebb967d15f4df02cf15891 (patch) | |
tree | 52b90e4b913bb1c4cd17df3335216bf518a6e01c /libgnomecanvas/gnome-canvas-pixbuf.c | |
parent | 08e71ba8ae72f333f017c25168b9ec85ea5954fa (diff) | |
download | gsoc2013-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-pixbuf.c')
-rw-r--r-- | libgnomecanvas/gnome-canvas-pixbuf.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/libgnomecanvas/gnome-canvas-pixbuf.c b/libgnomecanvas/gnome-canvas-pixbuf.c index b591724153..bb824cb53a 100644 --- a/libgnomecanvas/gnome-canvas-pixbuf.c +++ b/libgnomecanvas/gnome-canvas-pixbuf.c @@ -93,12 +93,11 @@ static void gnome_canvas_pixbuf_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_path, gint flags); static void gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, GdkDrawable *drawable, gint x, gint y, gint width, gint height); -static gdouble gnome_canvas_pixbuf_point (GnomeCanvasItem *item, - gdouble x, - gdouble y, - gint cx, - gint cy, - GnomeCanvasItem **actual_item); +static GnomeCanvasItem *gnome_canvas_pixbuf_point (GnomeCanvasItem *item, + gdouble x, + gdouble y, + gint cx, + gint cy); static void gnome_canvas_pixbuf_bounds (GnomeCanvasItem *item, gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2); @@ -816,13 +815,12 @@ gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, GdkDrawable *drawable, /* Point handler for the pixbuf canvas item */ -static double +static GnomeCanvasItem * gnome_canvas_pixbuf_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, - gint cy, - GnomeCanvasItem **actual_item) + gint cy) { GnomeCanvasPixbuf *gcp; PixbufPrivate *priv; @@ -837,12 +835,10 @@ gnome_canvas_pixbuf_point (GnomeCanvasItem *item, priv = gcp->priv; pixbuf = priv->pixbuf; - *actual_item = item; - no_hit = item->canvas->pixels_per_unit * 2 + 10; if (!priv->pixbuf) - return no_hit; + return NULL; gnome_canvas_item_i2c_affine (item, i2c); compute_render_affine (gcp, render_affine, i2c); @@ -856,19 +852,19 @@ gnome_canvas_pixbuf_point (GnomeCanvasItem *item, if (px < 0 || px >= gdk_pixbuf_get_width (pixbuf) || py < 0 || py >= gdk_pixbuf_get_height (pixbuf)) - return no_hit; + return NULL; if (!gdk_pixbuf_get_has_alpha (pixbuf)) - return 0.0; + return item; src = gdk_pixbuf_get_pixels (pixbuf) + py * gdk_pixbuf_get_rowstride (pixbuf) + px * gdk_pixbuf_get_n_channels (pixbuf); if (src[3] < 128) - return no_hit; + return NULL; else - return 0.0; + return item; } |