aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
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 /widgets
parent08e71ba8ae72f333f017c25168b9ec85ea5954fa (diff)
downloadgsoc2013-evolution-b3a95d0299386bccbdebb967d15f4df02cf15891.tar
gsoc2013-evolution-b3a95d0299386bccbdebb967d15f4df02cf15891.tar.gz
gsoc2013-evolution-b3a95d0299386bccbdebb967d15f4df02cf15891.tar.bz2
gsoc2013-evolution-b3a95d0299386bccbdebb967d15f4df02cf15891.tar.lz
gsoc2013-evolution-b3a95d0299386bccbdebb967d15f4df02cf15891.tar.xz
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 'widgets')
-rw-r--r--widgets/misc/e-calendar-item.c13
-rw-r--r--widgets/misc/e-canvas-background.c16
-rw-r--r--widgets/misc/e-canvas.c10
-rw-r--r--widgets/table/e-table-field-chooser-item.c8
-rw-r--r--widgets/table/e-table-header-item.c8
-rw-r--r--widgets/table/e-table-item.c9
-rw-r--r--widgets/text/e-reflow.c18
-rw-r--r--widgets/text/e-text.c14
8 files changed, 37 insertions, 59 deletions
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index f5d2f870af..5ca1143c96 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -90,12 +90,11 @@ static void e_calendar_item_draw_day_numbers (ECalendarItem *calitem,
gint start_weekday,
gint cells_x,
gint cells_y);
-static gdouble e_calendar_item_point (GnomeCanvasItem *item,
+static GnomeCanvasItem *e_calendar_item_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item);
+ gint cy);
static void e_calendar_item_stop_selecting (ECalendarItem *calitem,
guint32 time);
static void e_calendar_item_selection_add_days (ECalendarItem *calitem,
@@ -1760,13 +1759,11 @@ e_calendar_item_get_week_number (ECalendarItem *calitem,
/* This is supposed to return the nearest item the the point and the distance.
Since we are the only item we just return ourself and 0 for the distance.
This is needed so that we get button/motion events. */
-static double
+static GnomeCanvasItem *
e_calendar_item_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
- *actual_item = item;
- return 0.0;
+ return item;
}
static void
diff --git a/widgets/misc/e-canvas-background.c b/widgets/misc/e-canvas-background.c
index f6179379e4..b2be246f21 100644
--- a/widgets/misc/e-canvas-background.c
+++ b/widgets/misc/e-canvas-background.c
@@ -371,23 +371,21 @@ ecb_draw (GnomeCanvasItem *item,
x1, y1, x2 - x1, y2 - y1);
}
-static double
-ecb_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+static GnomeCanvasItem *
+ecb_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
if (ecb->priv->x1 >= 0 && ecb->priv->x1 > x)
- return 1.0;
+ return NULL;
if (ecb->priv->x2 >= 0 && ecb->priv->x2 < x)
- return 1.0;
+ return NULL;
if (ecb->priv->y1 >= 0 && ecb->priv->y1 > y)
- return 1.0;
+ return NULL;
if (ecb->priv->y2 >= 0 && ecb->priv->y2 < y)
- return 1.0;
- *actual_item = item;
+ return NULL;
- return 0.0;
+ return item;
}
static void
diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c
index dfa529ec6b..0b24b84cb9 100644
--- a/widgets/misc/e-canvas.c
+++ b/widgets/misc/e-canvas.c
@@ -167,13 +167,12 @@ canvas_emit_event (GnomeCanvas *canvas,
* invariant. */
#define HACKISH_AFFINE
-static double
+static GnomeCanvasItem *
gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
gdouble x,
gdouble y,
gint cx,
- gint cy,
- GnomeCanvasItem **actual_item)
+ gint cy)
{
#ifdef HACKISH_AFFINE
gdouble i2w[6], w2c[6], i2c[6], c2i[6];
@@ -193,7 +192,7 @@ gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
#endif
return (* GNOME_CANVAS_ITEM_CLASS (G_OBJECT_GET_CLASS (item))->point) (
- item, x, y, cx, cy, actual_item);
+ item, x, y, cx, cy);
}
/* Re-picks the current item in the canvas, based on the event's coordinates.
@@ -287,8 +286,7 @@ pick_current_item (GnomeCanvas *canvas, GdkEvent *event)
/* find the closest item */
if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE)
- gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy,
- &canvas->new_current_item);
+ canvas->new_current_item = gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy);
else
canvas->new_current_item = NULL;
} else
diff --git a/widgets/table/e-table-field-chooser-item.c b/widgets/table/e-table-field-chooser-item.c
index 67beee9d52..20048007d7 100644
--- a/widgets/table/e-table-field-chooser-item.c
+++ b/widgets/table/e-table-field-chooser-item.c
@@ -522,12 +522,10 @@ etfci_draw (GnomeCanvasItem *item,
}
}
-static double
-etfci_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+static GnomeCanvasItem *
+etfci_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
- *actual_item = item;
- return 0.0;
+ return item;
}
static gboolean
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index f3ed548463..0f7444285a 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -1070,12 +1070,10 @@ ethi_draw (GnomeCanvasItem *item,
g_hash_table_destroy (arrows);
}
-static double
-ethi_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+static GnomeCanvasItem *
+ethi_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
- *actual_item = item;
- return 0.0;
+ return item;
}
/*
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 7bd0ed4427..d68c69a220 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -2042,13 +2042,10 @@ exit:
cairo_destroy (cr);
}
-static double
-eti_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+static GnomeCanvasItem *
+eti_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
- *actual_item = item;
-
- return 0.0;
+ return item;
}
static gboolean
diff --git a/widgets/text/e-reflow.c b/widgets/text/e-reflow.c
index 3e062f0f93..4974fd8f04 100644
--- a/widgets/text/e-reflow.c
+++ b/widgets/text/e-reflow.c
@@ -43,7 +43,7 @@ static void e_reflow_unrealize (GnomeCanvasItem *item);
static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
static void e_reflow_update (GnomeCanvasItem *item, gdouble affine[6], ArtSVP *clip_path, gint flags);
-static gdouble e_reflow_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy, GnomeCanvasItem **actual_item);
+static GnomeCanvasItem *e_reflow_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy);
static void e_reflow_reflow (GnomeCanvasItem *item, gint flags);
static void set_empty (EReflow *reflow);
@@ -1347,22 +1347,16 @@ e_reflow_update (GnomeCanvasItem *item, gdouble affine[6], ArtSVP *clip_path, gi
}
}
-static double
+static GnomeCanvasItem *
e_reflow_point (GnomeCanvasItem *item,
- gdouble x, gdouble y, gint cx, gint cy,
- GnomeCanvasItem **actual_item)
+ gdouble x, gdouble y, gint cx, gint cy)
{
- gdouble distance = 1;
-
- *actual_item = NULL;
+ GnomeCanvasItem *child;
if (GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->point)
- distance = GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->point (item, x, y, cx, cy, actual_item);
- if ((gint) (distance * item->canvas->pixels_per_unit + 0.5) <= 0 && *actual_item)
- return distance;
+ child = GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->point (item, x, y, cx, cy);
- *actual_item = item;
- return 0;
+ return child ? child : item;
#if 0
if (y >= E_REFLOW_BORDER_WIDTH && y <= reflow->height - E_REFLOW_BORDER_WIDTH) {
gfloat n_x;
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 378a8dfc0e..e58d5bf8a2 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -1620,9 +1620,9 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
/* Point handler for the text item */
-static double
+static GnomeCanvasItem *
e_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
- gint cx, gint cy, GnomeCanvasItem **actual_item)
+ gint cx, gint cy)
{
EText *text;
gdouble clip_width;
@@ -1630,8 +1630,6 @@ e_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
text = E_TEXT (item);
- *actual_item = item;
-
/* The idea is to build bounding rectangles for each of the lines of
* text (clipped by the clipping rectangle, if it is activated) and see
* whether the point is inside any of these. If it is, we are done.
@@ -1656,17 +1654,17 @@ e_text_point (GnomeCanvasItem *item, gdouble x, gdouble y,
cx > text->clip_cx + clip_width ||
cy < text->clip_cy ||
cy > text->clip_cy + clip_height)
- return 1;
+ return NULL;
if (text->fill_clip_rectangle || !text->text || !*text->text)
- return 0;
+ return item;
cx -= text->cx;
if (pango_layout_xy_to_index (text->layout, cx, cy, NULL, NULL))
- return 0;
+ return item;
- return 1;
+ return NULL;
}
/* Bounds handler for the text item */