[cairo-commit] goocanvas/src Makefile.am, 1.1.1.1, 1.2 demo-events.c, NONE, 1.1 demo.c, 1.5, 1.6 goocanvasellipseview.c, 1.4, 1.5 goocanvasgroup.c, 1.2, 1.3 goocanvasgroup.h, 1.2, 1.3 goocanvasgroupview.c, 1.4, 1.5 goocanvasimageview.c, 1.4, 1.5 goocanvasitemsimple.c, 1.2, 1.3 goocanvasitemsimple.h, 1.2, 1.3 goocanvasitemview.c, 1.4, 1.5 goocanvasitemview.h, 1.4, 1.5 goocanvaspolylineview.c, 1.4, 1.5 goocanvasrectview.c, 1.4, 1.5 goocanvastextview.c, 1.5, 1.6 goocanvasutils.c, 1.2, 1.3 goocanvasutils.h, 1.2, 1.3 goocanvasview.c, 1.7, 1.8 goocanvasview.h, 1.4, 1.5

Damon Chaplin commit at pdx.freedesktop.org
Sat Apr 8 06:14:20 PDT 2006


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv21941/src

Modified Files:
	Makefile.am demo.c goocanvasellipseview.c goocanvasgroup.c 
	goocanvasgroup.h goocanvasgroupview.c goocanvasimageview.c 
	goocanvasitemsimple.c goocanvasitemsimple.h 
	goocanvasitemview.c goocanvasitemview.h 
	goocanvaspolylineview.c goocanvasrectview.c 
	goocanvastextview.c goocanvasutils.c goocanvasutils.h 
	goocanvasview.c goocanvasview.h 
Added Files:
	demo-events.c 
Log Message:
2006-04-08  Damon Chaplin  <damon at gnome.org>

	* src/goocanvasitemsimple.[hc]: 
	* src/goocanvasgroup.[hc]: added "pointer-events" property, like SVG.

	* src/goocanvasitemsimple.c (goo_canvas_item_simple_get_path_bounds): 
	changed to include both the stroke and fill extents, even if they will
	not be painted. This is needed to handle the "pointer-events" property.

	* src/goocanvasitemsimple.c (goo_canvas_item_simple_check_in_path): 
	added "pointer_events" argument, to specify which parts of the path
	to check.

	* src/goocanvasitemview.[hc]: change get_item_at() to take
	"is_pointer_event", "parent_visible", and "scale" properties, so we
	can handle the "pointer-events" property.

	* src/goocanvasgroupview.c (goo_canvas_group_view_get_item_at): 
	* src/goocanvasellipseview.c (goo_canvas_ellipse_view_get_item_at): 
	* src/goocanvasimageview.c (goo_canvas_image_view_get_item_at): 
	* src/goocanvaspolylineview.c (goo_canvas_polyline_view_get_item_at): 
	* src/goocanvasrectview.c (goo_canvas_rect_view_get_item_at): 
	* src/goocanvastextview.c (goo_canvas_text_view_get_item_at): updated
	to support "pointer-events".

	* src/goocanvasutils.[hc]: added GooCanvasPointerEvents enum, and
	goo_cairo_line_dash_new().

	* src/demo-events.c: new demo page to test "pointer-events" property.

	* src/goocanvastextview.c (goo_canvas_text_view_paint): if the fill
	pattern	has been explicitly set to NULL, don't paint the text.



Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/goocanvas/src/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Makefile.am	15 Dec 2005 15:32:01 -0000	1.1.1.1
+++ Makefile.am	8 Apr 2006 13:14:17 -0000	1.2
@@ -13,7 +13,7 @@
 
 demo_SOURCES = \
 	demo.c demo-fifteen.c demo-scalability.c demo-grabs.c \
-	demo-arrowhead.c demo-features.c \
+	demo-arrowhead.c demo-features.c demo-events.c \
 	goocanvasmarshal.list \
 	goocanvasellipse.h goocanvasellipse.c \
 	goocanvasellipseview.h goocanvasellipseview.c \

--- NEW FILE: demo-events.c ---
#include <config.h>
#include <string.h>
#include <gtk/gtk.h>
#include "goocanvasmodelsimple.h"
#include "goocanvasview.h"
#include "goocanvasitemview.h"
#include "goocanvasgroup.h"
#include "goocanvasgroupview.h"
#include "goocanvaspolyline.h"
#include "goocanvasrect.h"
#include "goocanvastext.h"



static gboolean
on_motion_notify (GooCanvasItemView *view,
		  GooCanvasItemView *target,
		  GdkEventMotion *event,
		  gpointer data)
{
  GooCanvasItem *item = NULL;
  char *item_id = NULL;

  if (target)
    item = goo_canvas_item_view_get_item (target);

  if (item)
    item_id = g_object_get_data (G_OBJECT (item), "id");

  if (item_id)
    g_print ("%s item received 'motion-notify' signal\n", item_id);

  return FALSE;
}


static void
on_item_view_created (GooCanvasView     *view,
		      GooCanvasItemView *item_view,
		      GooCanvasItem     *item,
		      gpointer           data)
{
  g_signal_connect (item_view, "motion_notify_event",
		    (GtkSignalFunc) on_motion_notify, NULL);
}


static void
create_events_area (GooCanvasModelSimple   *canvas_model,
		    gint                    area_num,
		    GooCanvasPointerEvents  pointer_events,
		    gchar                  *label)
{
  gint row = area_num / 3, col = area_num % 3;
  gdouble x = col * 200, y = row * 150;
  GooCanvasItem *root, *rect;
  char *view_id;
  GooCairoLineDash *dash;

  root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));

  dash = goo_cairo_line_dash_new (2, 5.0, 5.0);

  /* Create invisible item. */
  rect = goo_canvas_rect_new (root, x + 45, y + 35, 30, 30,
			      "fill-color", "red",
			      "visibility", GOO_CANVAS_ITEM_INVISIBLE,
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s invisible", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);

  /* Display a thin rect around it to indicate it is there. */
#if 1
  rect = goo_canvas_rect_new (root, x + 42.5, y + 32.5, 36, 36,
			      "line-dash", dash,
			      "line-width", 1.0,
			      "stroke-color", "gray",
			      NULL);
#endif

  /* Create unpainted item. */
  rect = goo_canvas_rect_new (root, x + 85, y + 35, 30, 30,
			      "stroke-pattern", NULL,
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s unpainted", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);

  /* Display a thin rect around it to indicate it is there. */
#if 1
  rect = goo_canvas_rect_new (root, x + 82.5, y + 32.5, 36, 36,
			      "line-dash", dash,
			      "line-width", 1.0,
			      "stroke-color", "gray",
			      NULL);
#endif

  /* Create stroked item. */
  rect = goo_canvas_rect_new (root, x + 125, y + 35, 30, 30,
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s stroked", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);

  /* Create filled item. */
  rect = goo_canvas_rect_new (root, x + 60, y + 75, 30, 30,
			      "fill-color", "red",
			      "stroke-pattern", NULL,
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s filled", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);

  /* Create stroked & filled item. */
  rect = goo_canvas_rect_new (root, x + 100, y + 75, 30, 30,
			      "fill-color", "red",
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s stroked & filled", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);

  goo_canvas_text_new (root, label, x + 100, y + 130, -1, GTK_ANCHOR_CENTER,
		       "font", "Sans 12",
		       "fill-color", "blue",
		       NULL);

  goo_cairo_line_dash_unref (dash);
}


GtkWidget *
create_events_page (void)
{
  GtkWidget *vbox, *alignment, *frame, *label, *canvas;
  GooCanvasModelSimple *canvas_model;

  vbox = gtk_vbox_new (FALSE, 4);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
  gtk_widget_show (vbox);

  /* Instructions */

  label = gtk_label_new ("Move the mouse over the items to check they receive the right motion events.\nThe first 2 items in each group are 1) invisible and 2) visible but unpainted.");
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  /* Frame and canvas */

  alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
  gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
  gtk_widget_show (alignment);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER (alignment), frame);
  gtk_widget_show (frame);

  canvas = goo_canvas_view_new ();

  g_signal_connect (canvas, "item_view_created",
		    (GtkSignalFunc) on_item_view_created,
		    NULL);

  canvas_model = goo_canvas_model_simple_new ();

  gtk_widget_set_size_request (canvas, 600, 450);
  goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0, 600, 450);
  gtk_container_add (GTK_CONTAINER (frame), canvas);
  gtk_widget_show (canvas);

  create_events_area (canvas_model, 0, GOO_CANVAS_EVENTS_NONE, "none");
  create_events_area (canvas_model, 1, GOO_CANVAS_EVENTS_VISIBLE_PAINTED, "visible-painted");
  create_events_area (canvas_model, 2, GOO_CANVAS_EVENTS_VISIBLE_FILL, "visible-fill");
  create_events_area (canvas_model, 3, GOO_CANVAS_EVENTS_VISIBLE_STROKE, "visible-stroke");
  create_events_area (canvas_model, 4, GOO_CANVAS_EVENTS_VISIBLE, "visible");
  create_events_area (canvas_model, 5, GOO_CANVAS_EVENTS_PAINTED, "painted");
  create_events_area (canvas_model, 6, GOO_CANVAS_EVENTS_FILL, "fill");
  create_events_area (canvas_model, 7, GOO_CANVAS_EVENTS_STROKE, "stroke");
  create_events_area (canvas_model, 8, GOO_CANVAS_EVENTS_ALL, "all");

  goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
			     GOO_CANVAS_MODEL (canvas_model));
  g_object_unref (canvas_model);

  return vbox;
}

Index: demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/demo.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- demo.c	3 Apr 2006 11:24:02 -0000	1.5
+++ demo.c	8 Apr 2006 13:14:17 -0000	1.6
@@ -31,6 +31,7 @@
 GtkWidget *create_canvas_arrowhead (void);
 GtkWidget *create_canvas_scalability (void);
 GtkWidget *create_grabs_page (void);
+GtkWidget *create_events_page (void);
 
 
 static void
@@ -1262,6 +1263,11 @@
 			    create_grabs_page (),
 			    gtk_label_new ("Grabs"));
 #endif
+#if 1
+  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
+			    create_events_page (),
+			    gtk_label_new ("Events"));
+#endif
 
   return window;
 }

Index: goocanvasellipseview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasellipseview.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvasellipseview.c	24 Mar 2006 17:32:22 -0000	1.4
+++ goocanvasellipseview.c	8 Apr 2006 13:14:17 -0000	1.5
@@ -122,16 +122,35 @@
 goo_canvas_ellipse_view_get_item_at (GooCanvasItemView  *view,
 				     gdouble             x,
 				     gdouble             y,
-				     cairo_t            *cr)
+				     cairo_t            *cr,
+				     gboolean            is_pointer_event,
+				     gboolean            parent_visible,
+				     gdouble             scale)
 {
   GooCanvasEllipseView *ellipse_view = (GooCanvasEllipseView*) view;
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) ellipse_view->ellipse;
   GooCanvasItemView *found_view = NULL;
   double user_x = x, user_y = y;
+  GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
 
   if (ellipse_view->need_update)
     goo_canvas_item_view_ensure_updated (view);
 
+  /* Check if the item should receive events. */
+  if (is_pointer_event)
+    {
+      if (simple->pointer_events == GOO_CANVAS_EVENTS_NONE)
+	return NULL;
+      if (simple->pointer_events & GOO_CANVAS_EVENTS_VISIBLE_MASK
+	  && (!parent_visible
+	      || simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
+	      || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
+		  && scale < simple->visibility_threshold)))
+	return NULL;
+
+      pointer_events = simple->pointer_events;
+    }
+
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
@@ -139,7 +158,8 @@
   cairo_device_to_user (cr, &user_x, &user_y);
 
   goo_canvas_ellipse_create_path (ellipse_view->ellipse, cr);
-  if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr))
+  if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr,
+					    pointer_events))
     found_view = view;
 
   cairo_restore (cr);
@@ -198,7 +218,7 @@
 goo_canvas_ellipse_view_paint (GooCanvasItemView *view,
 			       cairo_t           *cr,
 			       GooCanvasBounds   *bounds,
-			       gdouble            effective_scale)
+			       gdouble            scale)
 {
   GooCanvasEllipseView *ellipse_view = (GooCanvasEllipseView*) view;
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) ellipse_view->ellipse;
@@ -210,7 +230,7 @@
   /* Check if the item should be visible. */
   if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
       || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
-	  && effective_scale < simple->visibility_threshold))
+	  && scale < simple->visibility_threshold))
     return;
 
   cairo_save (cr);

Index: goocanvasgroup.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroup.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasgroup.c	23 Mar 2006 16:58:48 -0000	1.2
+++ goocanvasgroup.c	8 Apr 2006 13:14:17 -0000	1.3
@@ -17,6 +17,7 @@
   PROP_TRANSFORM,
   PROP_VISIBILITY,
   PROP_VISIBILITY_THRESHOLD,
+  PROP_POINTER_EVENTS
 };
 
 enum {
@@ -67,6 +68,13 @@
   g_object_class_override_property (gobject_class, PROP_VISIBILITY_THRESHOLD,
 				    "visibility-threshold");
 
+  g_object_class_install_property (gobject_class, PROP_POINTER_EVENTS,
+				   g_param_spec_enum ("pointer-events",
+						      NULL, NULL,
+						      GOO_TYPE_CANVAS_POINTER_EVENTS,
+						      GOO_CANVAS_EVENTS_VISIBLE_PAINTED,
+						      G_PARAM_READWRITE));
+
   /* Signals. */
   group_signals[CHANGED] =
     g_signal_new ("changed",
@@ -84,6 +92,7 @@
 {
   group->items = g_ptr_array_sized_new (8);
   cairo_matrix_init_identity (&group->transform);
+  group->pointer_events = GOO_CANVAS_EVENTS_VISIBLE_PAINTED;
 }
 
 
@@ -310,6 +319,9 @@
     case PROP_VISIBILITY_THRESHOLD:
       g_value_set_double (value, group->visibility_threshold);
       break;
+    case PROP_POINTER_EVENTS:
+      g_value_set_enum (value, group->pointer_events);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -339,6 +351,9 @@
     case PROP_VISIBILITY_THRESHOLD:
       group->visibility_threshold = g_value_get_double (value);
       break;
+    case PROP_POINTER_EVENTS:
+      group->pointer_events = g_value_get_enum (value);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

Index: goocanvasgroup.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroup.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasgroup.h	23 Mar 2006 16:58:48 -0000	1.2
+++ goocanvasgroup.h	8 Apr 2006 13:14:17 -0000	1.3
@@ -48,6 +48,9 @@
   /* If visibility is VISIBLE_ABOVE_THRESHOLD the item is visible if the canvas
      scale setting is above this threshold (or equal to it). */
   gdouble visibility_threshold;
+
+  /* What events the group should receive. */
+  GooCanvasPointerEvents pointer_events;
 };
 
 struct _GooCanvasGroupClass

Index: goocanvasgroupview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroupview.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvasgroupview.c	24 Mar 2006 17:32:22 -0000	1.4
+++ goocanvasgroupview.c	8 Apr 2006 13:14:17 -0000	1.5
@@ -319,16 +319,35 @@
 goo_canvas_group_view_get_item_at (GooCanvasItemView  *view,
 				   gdouble             x,
 				   gdouble             y,
-				   cairo_t            *cr)
+				   cairo_t            *cr,
+				   gboolean            is_pointer_event,
+				   gboolean            parent_visible,
+				   gdouble             scale)
 {
   GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
+  GooCanvasGroup *group = group_view->group;
   GooCanvasBounds *child_bounds;
   GooCanvasItemView *found_item = NULL;
+  gboolean visible = parent_visible;
   int i;
 
   if (group_view->need_update)
     goo_canvas_item_view_ensure_updated (view);
 
+  if (group->visibility == GOO_CANVAS_ITEM_INVISIBLE
+      || (group->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
+	  && scale < group->visibility_threshold))
+    visible = FALSE;
+
+  /* Check if the group should receive events. */
+  if (is_pointer_event)
+    {
+      if (group->pointer_events == GOO_CANVAS_EVENTS_NONE
+	  || ((group->pointer_events & GOO_CANVAS_EVENTS_VISIBLE_MASK)
+	      && !visible))
+	return NULL;
+    }
+
   /* Step down from the top item to the bottom in the stack/layer, and return
      the first item found that contains the given point. */
   cairo_save (cr);
@@ -343,7 +362,9 @@
 	  || child_bounds->y1 > y || child_bounds->y2 < y)
 	continue;
 
-      found_item = goo_canvas_item_view_get_item_at (child_view, x, y, cr);
+      found_item = goo_canvas_item_view_get_item_at (child_view, x, y, cr,
+						     is_pointer_event,
+						     visible, scale);
       if (found_item)
 	break;
     }
@@ -357,7 +378,7 @@
 goo_canvas_group_view_paint (GooCanvasItemView *view,
 			     cairo_t           *cr,
 			     GooCanvasBounds   *bounds,
-			     gdouble            effective_scale)
+			     gdouble            scale)
 {
   GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
   GooCanvasGroup *group = group_view->group;
@@ -372,7 +393,7 @@
   /* Check if the item should be visible. */
   if (group->visibility == GOO_CANVAS_ITEM_INVISIBLE
       || (group->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
-	  && effective_scale < group->visibility_threshold))
+	  && scale < group->visibility_threshold))
     return;
 
   /* Paint all the items in the group. */
@@ -389,7 +410,7 @@
 	  || child_bounds->y1 > bounds->y2 || child_bounds->y2 < bounds->y1)
 	continue;
 
-      goo_canvas_item_view_paint (child_view, cr, bounds, effective_scale);
+      goo_canvas_item_view_paint (child_view, cr, bounds, scale);
     }
   cairo_restore (cr);
 }

Index: goocanvasimageview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasimageview.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvasimageview.c	24 Mar 2006 17:32:22 -0000	1.4
+++ goocanvasimageview.c	8 Apr 2006 13:14:17 -0000	1.5
@@ -108,7 +108,10 @@
 goo_canvas_image_view_get_item_at (GooCanvasItemView  *view,
 				   gdouble             x,
 				   gdouble             y,
-				   cairo_t            *cr)
+				   cairo_t            *cr,
+				   gboolean            is_pointer_event,
+				   gboolean            parent_visible,
+				   gdouble             scale)
 {
   GooCanvasImageView *image_view = (GooCanvasImageView*) view;
   GooCanvasImage *image = image_view->image;
@@ -119,6 +122,20 @@
   if (image_view->need_update)
     goo_canvas_item_view_ensure_updated (view);
 
+  /* Check if the item should receive events. Note that we don't take
+     image transparency into account here at present. */
+  if (is_pointer_event)
+    {
+      if (simple->pointer_events == GOO_CANVAS_EVENTS_NONE)
+	return NULL;
+      if (simple->pointer_events & GOO_CANVAS_EVENTS_VISIBLE_MASK
+	  && (!parent_visible
+	      || simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
+	      || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
+		  && scale < simple->visibility_threshold)))
+	return NULL;
+    }
+
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
@@ -181,7 +198,7 @@
 goo_canvas_image_view_paint (GooCanvasItemView *view,
 			     cairo_t           *cr,
 			     GooCanvasBounds   *bounds,
-			     gdouble            effective_scale)
+			     gdouble            scale)
 {
   GooCanvasImageView *image_view = (GooCanvasImageView*) view;
   GooCanvasImage *image = image_view->image;
@@ -198,7 +215,7 @@
   /* Check if the item should be visible. */
   if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
       || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
-	  && effective_scale < simple->visibility_threshold))
+	  && scale < simple->visibility_threshold))
     return;
 
   cairo_save (cr);

Index: goocanvasitemsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasitemsimple.c	23 Mar 2006 16:58:48 -0000	1.2
+++ goocanvasitemsimple.c	8 Apr 2006 13:14:17 -0000	1.3
@@ -40,6 +40,7 @@
   PROP_TRANSFORM,
   PROP_VISIBILITY,
   PROP_VISIBILITY_THRESHOLD,
+  PROP_POINTER_EVENTS
 };
 
 enum {
@@ -271,6 +272,13 @@
   g_object_class_override_property (gobject_class, PROP_VISIBILITY_THRESHOLD,
 				    "visibility-threshold");
 
+  g_object_class_install_property (gobject_class, PROP_POINTER_EVENTS,
+				   g_param_spec_enum ("pointer-events",
+						      NULL, NULL,
+						      GOO_TYPE_CANVAS_POINTER_EVENTS,
+						      GOO_CANVAS_EVENTS_VISIBLE_PAINTED,
+						      G_PARAM_READWRITE));
+
   /* Signals. */
   item_simple_signals[CHANGED] =
     g_signal_new ("changed",
@@ -285,9 +293,9 @@
 
 
 static void
-goo_canvas_item_simple_init (GooCanvasItemSimple *canvas_item_simple)
+goo_canvas_item_simple_init (GooCanvasItemSimple *item)
 {
-
+  item->pointer_events = GOO_CANVAS_EVENTS_VISIBLE_PAINTED;
 }
 
 
@@ -379,6 +387,9 @@
     case PROP_VISIBILITY_THRESHOLD:
       g_value_set_double (value, item->visibility_threshold);
       break;
+    case PROP_POINTER_EVENTS:
+      g_value_set_enum (value, item->pointer_events);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -547,6 +558,9 @@
     case PROP_VISIBILITY_THRESHOLD:
       item->visibility_threshold = g_value_get_double (value);
       break;
+    case PROP_POINTER_EVENTS:
+      item->pointer_events = g_value_get_enum (value);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -739,64 +753,31 @@
 
 
 /* Returns the bounds of the path, using the item's stroke and fill options,
-   in device coords. */
+   in device coords. Note that the bounds include both the stroke and the
+   fill extents, even if they will not be painted. (We need this to handle
+   the "pointer-events" property.) */
 void
 goo_canvas_item_simple_get_path_bounds (GooCanvasItemSimple *item,
 					cairo_t             *cr,
 					GooCanvasBounds     *bounds)
 {
-  GooCanvasStyle *style = item->style;
-  GooCanvasStyleValuesMask mask = 0;
-  gboolean do_stroke = TRUE, do_fill = FALSE;
   GooCanvasBounds tmp_bounds;
 
-  if (style)
-    mask = style->mask;
-
-  /* Determine whether we are going to stroke and/or fill the path. */
-  if (style && (mask & GOO_CANVAS_STYLE_STROKE_PATTERN)
-      && style->stroke_pattern == NULL)
-    do_stroke = FALSE;
-
-  if ((mask & GOO_CANVAS_STYLE_FILL_PATTERN) && style->fill_pattern)
-    do_fill = TRUE;
-
-  /* Calculate the filled extents, if required. */
-  if (do_fill)
-    {
-      goo_canvas_item_simple_set_fill_options (item, cr);
-      cairo_fill_extents (cr, &bounds->x1, &bounds->y1,
-			  &bounds->x2, &bounds->y2);
-      goo_canvas_item_simple_user_bounds_to_device (item, cr, bounds);
-    }
-
-  /* Check the stroke, if required. */
-  if (do_stroke)
-    {
-      goo_canvas_item_simple_set_stroke_options (item, cr);
-
-      if (do_fill)
-	{
-	  cairo_stroke_extents (cr, &tmp_bounds.x1, &tmp_bounds.y1,
-				&tmp_bounds.x2, &tmp_bounds.y2);
-	  goo_canvas_item_simple_user_bounds_to_device (item, cr, &tmp_bounds);
+  /* Calculate the filled extents. */
+  goo_canvas_item_simple_set_fill_options (item, cr);
+  cairo_fill_extents (cr, &bounds->x1, &bounds->y1, &bounds->x2, &bounds->y2);
+  goo_canvas_item_simple_user_bounds_to_device (item, cr, bounds);
 
-	  bounds->x1 = MIN (bounds->x1, tmp_bounds.x1);
-	  bounds->y1 = MIN (bounds->y1, tmp_bounds.y1);
-	  bounds->x2 = MAX (bounds->x2, tmp_bounds.x2);
-	  bounds->y2 = MAX (bounds->y2, tmp_bounds.y2);
-	}
-      else
-	{
-	  cairo_stroke_extents (cr, &bounds->x1, &bounds->y1,
-				&bounds->x2, &bounds->y2);
-	  goo_canvas_item_simple_user_bounds_to_device (item, cr, bounds);
-	}
-    }
+  /* Check the stroke. */
+  goo_canvas_item_simple_set_stroke_options (item, cr);
+  cairo_stroke_extents (cr, &tmp_bounds.x1, &tmp_bounds.y1,
+			&tmp_bounds.x2, &tmp_bounds.y2);
+  goo_canvas_item_simple_user_bounds_to_device (item, cr, &tmp_bounds);
 
-  /* If there is no stroke or fill set the bounds to 0. */
-  if (!do_fill && !do_stroke)
-    bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0.0;
+  bounds->x1 = MIN (bounds->x1, tmp_bounds.x1);
+  bounds->y1 = MIN (bounds->y1, tmp_bounds.y1);
+  bounds->x2 = MAX (bounds->x2, tmp_bounds.x2);
+  bounds->y2 = MAX (bounds->y2, tmp_bounds.y2);
 }
 
 
@@ -838,10 +819,11 @@
 
 
 gboolean
-goo_canvas_item_simple_check_in_path (GooCanvasItemSimple *item,
-				      gdouble              x,
-				      gdouble              y,
-				      cairo_t             *cr)
+goo_canvas_item_simple_check_in_path (GooCanvasItemSimple   *item,
+				      gdouble                x,
+				      gdouble                y,
+				      cairo_t               *cr,
+				      GooCanvasPointerEvents pointer_events)
 {
   GooCanvasStyle *style = item->style;
   GooCanvasStyleValuesMask mask = 0;
@@ -858,8 +840,16 @@
   if ((mask & GOO_CANVAS_STYLE_FILL_PATTERN) && style->fill_pattern)
     do_fill = TRUE;
 
+#if 0
+  g_print ("do_stroke:%i do_fill:%i events&fill:%i events&painted:%i events:%i painted:%i\n",
+	   do_stroke, do_fill, pointer_events & GOO_CANVAS_EVENTS_FILL_MASK,
+	   pointer_events & GOO_CANVAS_EVENTS_PAINTED_MASK,
+	   pointer_events, GOO_CANVAS_EVENTS_PAINTED_MASK);
+#endif
+
   /* Check the filled path, if required. */
-  if (do_fill)
+  if (pointer_events & GOO_CANVAS_EVENTS_FILL_MASK
+      && (!(pointer_events & GOO_CANVAS_EVENTS_PAINTED_MASK) || do_fill))
     {
       goo_canvas_item_simple_set_fill_options (item, cr);
       if (cairo_in_fill (cr, x, y))
@@ -867,7 +857,8 @@
     }
 
   /* Check the stroke, if required. */
-  if (do_stroke)
+  if (pointer_events & GOO_CANVAS_EVENTS_STROKE_MASK
+      && (!(pointer_events & GOO_CANVAS_EVENTS_PAINTED_MASK) || do_stroke))
     {
       goo_canvas_item_simple_set_stroke_options (item, cr);
       if (cairo_in_stroke (cr, x, y))

Index: goocanvasitemsimple.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasitemsimple.h	23 Mar 2006 16:58:48 -0000	1.2
+++ goocanvasitemsimple.h	8 Apr 2006 13:14:17 -0000	1.3
@@ -93,6 +93,9 @@
   /* If visibility is VISIBLE_ABOVE_THRESHOLD the item is visible if the canvas
      scale setting is above this threshold (or equal to it). */
   gdouble visibility_threshold;
+
+  /* What events the item should receive. */
+  GooCanvasPointerEvents pointer_events;
 };
 
 struct _GooCanvasItemSimpleClass
@@ -124,7 +127,8 @@
 gboolean       goo_canvas_item_simple_check_in_path (GooCanvasItemSimple *item,
 						     gdouble              x,
 						     gdouble              y,
-						     cairo_t             *cr);
+						     cairo_t             *cr,
+						     GooCanvasPointerEvents pointer_events);
 void           goo_canvas_item_simple_paint_path    (GooCanvasItemSimple *item,
 						     cairo_t             *cr);
 

Index: goocanvasitemview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemview.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvasitemview.c	24 Mar 2006 17:32:22 -0000	1.4
+++ goocanvasitemview.c	8 Apr 2006 13:14:17 -0000	1.5
@@ -7,6 +7,7 @@
 #include <config.h>
 #include <gtk/gtk.h>
 #include "goocanvasitemview.h"
+#include "goocanvasview.h"
 #include "goocanvasmarshal.h"
 
 
@@ -273,11 +274,15 @@
 goo_canvas_item_view_get_item_at    (GooCanvasItemView  *view,
 				     gdouble             x,
 				     gdouble             y,
-				     cairo_t            *cr)
+				     cairo_t            *cr,
+				     gboolean            is_pointer_event,
+				     gboolean            parent_visible,
+				     gdouble             scale)
 {
   GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
 
-  return iface->get_item_at (view, x, y, cr);
+  return iface->get_item_at (view, x, y, cr, is_pointer_event, parent_visible,
+			     scale);
 }
 
 
@@ -307,9 +312,9 @@
 goo_canvas_item_view_paint (GooCanvasItemView *view,
 			    cairo_t           *cr,
 			    GooCanvasBounds   *bounds,
-			    gdouble            effective_scale)
+			    gdouble            scale)
 {
   GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
 
-  iface->paint (view, cr, bounds, effective_scale);
+  iface->paint (view, cr, bounds, scale);
 }

Index: goocanvasitemview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemview.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvasitemview.h	24 Mar 2006 17:32:22 -0000	1.4
+++ goocanvasitemview.h	8 Apr 2006 13:14:17 -0000	1.5
@@ -42,14 +42,17 @@
   GooCanvasItemView*   (* get_item_at)	    (GooCanvasItemView   *view,
 					     gdouble              x,
 					     gdouble              y,
-					     cairo_t             *cr);
+					     cairo_t             *cr,
+					     gboolean             is_pointer_event,
+					     gboolean             parent_visible,
+					     gdouble              scale);
   GooCanvasBounds*     (* update)           (GooCanvasItemView   *view,
 					     gboolean             entire_tree,
 					     cairo_t             *cr);
   void		       (* paint)	    (GooCanvasItemView   *view,
 					     cairo_t             *cr,
 					     GooCanvasBounds     *bounds,
-					     gdouble              effective_scale);
+					     gdouble              scale);
 
   /* Signals. */
   gboolean	       (* enter_notify_event)	(GooCanvasItemView   *view,
@@ -105,7 +108,10 @@
 GooCanvasItemView* goo_canvas_item_view_get_item_at (GooCanvasItemView  *view,
 						     gdouble             x,
 						     gdouble             y,
-						     cairo_t            *cr);
+						     cairo_t            *cr,
+						     gboolean            is_pointer_event,
+						     gboolean            parent_visible,
+						     gdouble             scale);
 void		   goo_canvas_item_view_ensure_updated (GooCanvasItemView *view);
 GooCanvasBounds*   goo_canvas_item_view_update      (GooCanvasItemView  *view,
 						     gboolean            entire_tree,
@@ -113,7 +119,7 @@
 void               goo_canvas_item_view_paint       (GooCanvasItemView  *view,
 						     cairo_t            *cr,
 						     GooCanvasBounds    *bounds,
-						     gdouble             effective_scale);
+						     gdouble             scale);
 
 
 G_END_DECLS

Index: goocanvaspolylineview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvaspolylineview.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvaspolylineview.c	24 Mar 2006 17:32:22 -0000	1.4
+++ goocanvaspolylineview.c	8 Apr 2006 13:14:17 -0000	1.5
@@ -191,13 +191,19 @@
 goo_canvas_polyline_view_get_item_at (GooCanvasItemView  *view,
 				      gdouble             x,
 				      gdouble             y,
-				      cairo_t            *cr)
+				      cairo_t            *cr,
+				      gboolean            is_pointer_event,
+				      gboolean            parent_visible,
+				      gdouble             scale)
 {
   GooCanvasPolylineView *polyline_view = (GooCanvasPolylineView*) view;
   GooCanvasPolyline *polyline = polyline_view->polyline;
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) polyline;
   GooCanvasItemView *found_view = NULL;
   double user_x = x, user_y = y;
+  GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
+  GooCanvasStyle *style = simple->style;
+  gboolean do_stroke = TRUE;
 
   if (polyline_view->need_update)
     goo_canvas_item_view_ensure_updated (view);
@@ -209,6 +215,21 @@
   g_print ("In polyline_view_get_item_at: %g, %g\n", x, y);
 #endif
 
+  /* Check if the item should receive events. */
+  if (is_pointer_event)
+    {
+      if (simple->pointer_events == GOO_CANVAS_EVENTS_NONE)
+	return NULL;
+      if (simple->pointer_events & GOO_CANVAS_EVENTS_VISIBLE_MASK
+	  && (!parent_visible
+	      || simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
+	      || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
+		  && scale < simple->visibility_threshold)))
+	return NULL;
+
+      pointer_events = simple->pointer_events;
+    }
+
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
@@ -216,11 +237,18 @@
   cairo_device_to_user (cr, &user_x, &user_y);
 
   goo_canvas_polyline_view_create_path (polyline, cr);
-  if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr))
+  if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr,
+					    pointer_events))
     found_view = view;
 
+  if (style && (style->mask & GOO_CANVAS_STYLE_STROKE_PATTERN)
+      && style->stroke_pattern == NULL)
+    do_stroke = FALSE;
+
   /* Check the arrows, if the polyline has them. */
-  if (!found_view && (polyline->start_arrow || polyline->end_arrow))
+  if (!found_view && (polyline->start_arrow || polyline->end_arrow)
+      && (pointer_events & GOO_CANVAS_EVENTS_STROKE_MASK)
+      && (!(pointer_events & GOO_CANVAS_EVENTS_PAINTED_MASK) || do_stroke))
     {
       /* We use the stroke pattern to match the style of the line. */
       goo_canvas_item_simple_set_stroke_options (simple, cr);

Index: goocanvasrectview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasrectview.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvasrectview.c	24 Mar 2006 17:32:22 -0000	1.4
+++ goocanvasrectview.c	8 Apr 2006 13:14:17 -0000	1.5
@@ -218,16 +218,35 @@
 goo_canvas_rect_view_get_item_at (GooCanvasItemView  *view,
 				  gdouble             x,
 				  gdouble             y,
-				  cairo_t            *cr)
+				  cairo_t            *cr,
+				  gboolean            is_pointer_event,
+				  gboolean            parent_visible,
+				  gdouble             scale)
 {
   GooCanvasRectView *rect_view = (GooCanvasRectView*) view;
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) rect_view->rect;
   GooCanvasItemView *found_view = NULL;
   double user_x = x, user_y = y;
+  GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
 
   if (rect_view->need_update)
     goo_canvas_item_view_ensure_updated (view);
 
+  /* Check if the item should receive events. */
+  if (is_pointer_event)
+    {
+      if (simple->pointer_events == GOO_CANVAS_EVENTS_NONE)
+	return NULL;
+      if (simple->pointer_events & GOO_CANVAS_EVENTS_VISIBLE_MASK
+	  && (!parent_visible
+	      || simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
+	      || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
+		  && scale < simple->visibility_threshold)))
+	return NULL;
+
+      pointer_events = simple->pointer_events;
+    }
+
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
@@ -235,7 +254,8 @@
   cairo_device_to_user (cr, &user_x, &user_y);
 
   goo_canvas_rect_create_path (rect_view->rect, cr);
-  if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr))
+  if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr,
+					    pointer_events))
     found_view = view;
 
   cairo_restore (cr);
@@ -248,7 +268,7 @@
 goo_canvas_rect_view_paint (GooCanvasItemView *view,
 			    cairo_t           *cr,
 			    GooCanvasBounds   *bounds,
-			    gdouble            effective_scale)
+			    gdouble            scale)
 {
   GooCanvasRectView *rect_view = (GooCanvasRectView*) view;
   GooCanvasRect *rect = rect_view->rect;
@@ -261,7 +281,7 @@
   /* Check if the item should be visible. */
   if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
       || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
-	  && effective_scale < simple->visibility_threshold))
+	  && scale < simple->visibility_threshold))
     return;
 
   cairo_save (cr);

Index: goocanvastextview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastextview.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- goocanvastextview.c	24 Mar 2006 17:32:22 -0000	1.5
+++ goocanvastextview.c	8 Apr 2006 13:14:17 -0000	1.6
@@ -262,7 +262,10 @@
 goo_canvas_text_view_get_item_at (GooCanvasItemView  *view,
 				  gdouble             x,
 				  gdouble             y,
-				  cairo_t            *cr)
+				  cairo_t            *cr,
+				  gboolean            is_pointer_event,
+				  gboolean            parent_visible,
+				  gdouble             scale)
 {
   GooCanvasTextView *text_view = (GooCanvasTextView*) view;
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) text_view->text;
@@ -277,6 +280,26 @@
   if (text_view->need_update)
     goo_canvas_item_view_ensure_updated (view);
 
+  /* Check if the item should receive events. */
+  if (is_pointer_event)
+    {
+      if (simple->pointer_events == GOO_CANVAS_EVENTS_NONE)
+	return NULL;
+      if (simple->pointer_events & GOO_CANVAS_EVENTS_VISIBLE_MASK
+	  && (!parent_visible
+	      || simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
+	      || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
+		  && scale < simple->visibility_threshold)))
+	return NULL;
+      if (simple->pointer_events & GOO_CANVAS_EVENTS_PAINTED_MASK)
+	{
+	  if (simple->style
+	      && (simple->style->mask & GOO_CANVAS_STYLE_FILL_PATTERN)
+	      && simple->style->fill_pattern == NULL)
+	    return NULL;
+	}
+    }
+
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
@@ -294,6 +317,8 @@
 	   x, y, px, py, bounds.x1, bounds.y1);
 #endif
 
+  /* We use line extents here. Note that SVG uses character cells to determine
+     hits so we have slightly different behavior. */
   iter = pango_layout_get_iter (layout);
   do
     {
@@ -329,7 +354,7 @@
 goo_canvas_text_view_paint (GooCanvasItemView *view,
 			    cairo_t           *cr,
 			    GooCanvasBounds   *bounds,
-			    gdouble            effective_scale)
+			    gdouble            scale)
 {
   GooCanvasTextView *text_view = (GooCanvasTextView*) view;
   GooCanvasText *text = text_view->text;
@@ -348,7 +373,12 @@
   /* Check if the item should be visible. */
   if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
       || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
-	  && effective_scale < simple->visibility_threshold))
+	  && scale < simple->visibility_threshold))
+    return;
+
+  /* If the fill pattern has been explicitly set to NULL, don't paint. */
+  if (simple->style && (simple->style->mask & GOO_CANVAS_STYLE_FILL_PATTERN)
+      && simple->style->fill_pattern == NULL)
     return;
 
   cairo_save (cr);

Index: goocanvasutils.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasutils.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasutils.c	23 Mar 2006 16:58:48 -0000	1.2
+++ goocanvasutils.c	8 Apr 2006 13:14:17 -0000	1.3
@@ -81,6 +81,33 @@
  * Enum types.
  */
 GType
+goo_canvas_pointer_events_get_type (void)
+{
+  static GType etype = 0;
+  if (etype == 0) {
+    static const GEnumValue values[] = {
+      { GOO_CANVAS_EVENTS_VISIBLE_MASK, "GOO_CANVAS_EVENTS_VISIBLE_MASK", "visible-mask" },
+      { GOO_CANVAS_EVENTS_PAINTED_MASK, "GOO_CANVAS_EVENTS_PAINTED_MASK", "painted-mask" },
+      { GOO_CANVAS_EVENTS_FILL_MASK, "GOO_CANVAS_EVENTS_FILL_MASK", "fill-mask" },
+      { GOO_CANVAS_EVENTS_STROKE_MASK, "GOO_CANVAS_EVENTS_STROKE_MASK", "stroke-mask" },
+      { GOO_CANVAS_EVENTS_NONE, "GOO_CANVAS_EVENTS_NONE", "none" },
+      { GOO_CANVAS_EVENTS_VISIBLE_PAINTED, "GOO_CANVAS_EVENTS_VISIBLE_PAINTED", "visible-painted" },
+      { GOO_CANVAS_EVENTS_VISIBLE_FILL, "GOO_CANVAS_EVENTS_VISIBLE_FILL", "visible-fill" },
+      { GOO_CANVAS_EVENTS_VISIBLE_STROKE, "GOO_CANVAS_EVENTS_VISIBLE_STROKE", "visible-stroke" },
+      { GOO_CANVAS_EVENTS_VISIBLE, "GOO_CANVAS_EVENTS_VISIBLE", "visible" },
+      { GOO_CANVAS_EVENTS_PAINTED, "GOO_CANVAS_EVENTS_PAINTED", "painted" },
+      { GOO_CANVAS_EVENTS_FILL, "GOO_CANVAS_EVENTS_FILL", "fill" },
+      { GOO_CANVAS_EVENTS_STROKE, "GOO_CANVAS_EVENTS_STROKE", "stroke" },
+      { GOO_CANVAS_EVENTS_ALL, "GOO_CANVAS_EVENTS_ALL", "all" },
+      { 0, NULL, NULL }
+    };
+    etype = g_enum_register_static ("GooCanvasPointerEvents", values);
+  }
+  return etype;
+}
+
+
+GType
 goo_canvas_item_visibility_get_type (void)
 {
   static GType etype = 0;
@@ -354,6 +381,33 @@
 }
 
 
+GooCairoLineDash*
+goo_cairo_line_dash_new (gint num_dashes,
+			 ...)
+{
+  GooCairoLineDash *dash;
+  va_list var_args;
+  gint i;
+
+  dash = g_new (GooCairoLineDash, 1);
+  dash->ref_count = 1;
+  dash->num_dashes = num_dashes;
+  dash->dashes = g_new (double, num_dashes);
+  dash->dash_offset = 0.0;
+
+  va_start (var_args, num_dashes);
+
+  for (i = 0; i < num_dashes; i++)
+    {
+      dash->dashes[i] = va_arg (var_args, double);
+    }
+
+  va_end (var_args);
+
+  return dash;
+}
+
+
 cairo_matrix_t*
 goo_cairo_matrix_copy   (cairo_matrix_t *matrix)
 {

Index: goocanvasutils.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasutils.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasutils.h	23 Mar 2006 16:58:48 -0000	1.2
+++ goocanvasutils.h	8 Apr 2006 13:14:17 -0000	1.3
@@ -30,6 +30,47 @@
 /*
  * Enum types.
  */
+#define GOO_TYPE_CANVAS_POINTER_EVENTS   (goo_canvas_pointer_events_get_type ())
+GType goo_canvas_pointer_events_get_type   (void) G_GNUC_CONST;
+typedef enum
+{
+  /* If the item must be visible to receive events. */
+  GOO_CANVAS_EVENTS_VISIBLE_MASK	= 1 << 0,
+
+  /* If the fill or stroke must be painted to receive events. */
+  GOO_CANVAS_EVENTS_PAINTED_MASK	= 1 << 1,
+
+  /* If the fill should receive events. */
+  GOO_CANVAS_EVENTS_FILL_MASK		= 1 << 2,
+
+  /* If the stroke should receive events. */
+  GOO_CANVAS_EVENTS_STROKE_MASK		= 1 << 3,
+
+
+  GOO_CANVAS_EVENTS_NONE		= 0,
+
+  GOO_CANVAS_EVENTS_VISIBLE_PAINTED	= GOO_CANVAS_EVENTS_VISIBLE_MASK
+					  | GOO_CANVAS_EVENTS_PAINTED_MASK
+					  | GOO_CANVAS_EVENTS_FILL_MASK
+					  | GOO_CANVAS_EVENTS_STROKE_MASK,
+  GOO_CANVAS_EVENTS_VISIBLE_FILL	= GOO_CANVAS_EVENTS_VISIBLE_MASK
+					  | GOO_CANVAS_EVENTS_FILL_MASK,
+  GOO_CANVAS_EVENTS_VISIBLE_STROKE	= GOO_CANVAS_EVENTS_VISIBLE_MASK
+					  | GOO_CANVAS_EVENTS_STROKE_MASK,
+  GOO_CANVAS_EVENTS_VISIBLE		= GOO_CANVAS_EVENTS_VISIBLE_MASK
+					  | GOO_CANVAS_EVENTS_FILL_MASK
+					  | GOO_CANVAS_EVENTS_STROKE_MASK,
+
+  GOO_CANVAS_EVENTS_PAINTED		= GOO_CANVAS_EVENTS_PAINTED_MASK
+					  | GOO_CANVAS_EVENTS_FILL_MASK
+					  | GOO_CANVAS_EVENTS_STROKE_MASK,
+  GOO_CANVAS_EVENTS_FILL		= GOO_CANVAS_EVENTS_FILL_MASK,
+  GOO_CANVAS_EVENTS_STROKE		= GOO_CANVAS_EVENTS_STROKE_MASK,
+  GOO_CANVAS_EVENTS_ALL			= GOO_CANVAS_EVENTS_FILL_MASK
+					  | GOO_CANVAS_EVENTS_STROKE_MASK
+} GooCanvasPointerEvents;
+
+
 #define GOO_TYPE_CANVAS_ITEM_VISIBILITY   (goo_canvas_item_visibility_get_type ())
 GType goo_canvas_item_visibility_get_type   (void) G_GNUC_CONST;
 typedef enum
@@ -71,6 +112,8 @@
 GType goo_cairo_line_dash_get_type (void) G_GNUC_CONST;
 GType goo_cairo_matrix_get_type    (void) G_GNUC_CONST;
 
+GooCairoLineDash* goo_cairo_line_dash_new   (gint              num_dashes,
+					     ...);
 GooCairoLineDash* goo_cairo_line_dash_ref   (GooCairoLineDash *dash);
 void              goo_cairo_line_dash_unref (GooCairoLineDash *dash);
 cairo_matrix_t*   goo_cairo_matrix_copy     (cairo_matrix_t   *matrix);

Index: goocanvasview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- goocanvasview.c	3 Apr 2006 11:24:02 -0000	1.7
+++ goocanvasview.c	8 Apr 2006 13:14:17 -0000	1.8
@@ -945,7 +945,7 @@
  * @view: a #GooCanvasView.
  * @cr: a cairo context.
  * @bounds: the area to render, or NULL to render the entire canvas.
- * @effective_scale: the scale to compare with each item's visibility
+ * @scale: the scale to compare with each item's visibility
  * threshold to see if they should be rendered. This only affects items that
  * have their visibility set to %GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD.
  * 
@@ -955,14 +955,12 @@
 goo_canvas_view_render (GooCanvasView   *view,
 			cairo_t         *cr,
 			GooCanvasBounds *bounds,
-			gdouble          effective_scale)
+			gdouble          scale)
 {
   if (bounds)
-    goo_canvas_item_view_paint (view->root_view, cr, bounds,
-				effective_scale);
+    goo_canvas_item_view_paint (view->root_view, cr, bounds, scale);
   else
-    goo_canvas_item_view_paint (view->root_view, cr, &view->bounds,
-				effective_scale);
+    goo_canvas_item_view_paint (view->root_view, cr, &view->bounds, scale);
 }
 
 
@@ -1187,7 +1185,8 @@
 
       cr = goo_canvas_view_create_cairo (view);
       new_item_view = goo_canvas_item_view_get_item_at (view->root_view,
-							x, y, cr);
+							x, y, cr, TRUE, TRUE,
+							view->scale);
       cairo_destroy (cr);
     }
 

Index: goocanvasview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvasview.h	24 Mar 2006 17:32:22 -0000	1.4
+++ goocanvasview.h	8 Apr 2006 13:14:17 -0000	1.5
@@ -143,7 +143,7 @@
 void          goo_canvas_view_render	     (GooCanvasView     *view,
 					      cairo_t           *cr,
 					      GooCanvasBounds   *bounds,
-					      gdouble            effective_scale);
+					      gdouble            scale);
 
 /*
  * Coordinate conversion.



More information about the cairo-commit mailing list