[cairo-commit] goocanvas/demo demo.c,1.19,1.20
Damon Chaplin
commit at pdx.freedesktop.org
Tue Feb 27 06:45:14 PST 2007
Committed by: damon
Update of /cvs/cairo/goocanvas/demo
In directory kemper:/tmp/cvs-serv26732/demo
Modified Files:
demo.c
Log Message:
2007-02-27 Damon Chaplin <damon at gnome.org>
* Released GooCanvas 0.7
2007-02-27 Damon Chaplin <damon at gnome.org>
* src/goocanvas.c (goo_canvas_get_items_in_area): new function to
get items inside or outside a given area.
* demo/demo.c: added little test for goo_canvas_get_items_at() and
goo_canvas_get_items_in_area().
Index: demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- demo.c 24 Feb 2007 11:16:36 -0000 1.19
+++ demo.c 27 Feb 2007 14:45:07 -0000 1.20
@@ -242,6 +242,32 @@
}
+static void
+output_items_in_area (GooCanvas *canvas,
+ gdouble x,
+ gdouble y)
+{
+ static gdouble last_x = 0.0, last_y = 0.0;
+ GooCanvasBounds area;
+ GList *items, *elem;
+
+ /* Print out the items from the last point to this one. */
+ area.x1 = MIN (x, last_x);
+ area.x2 = MAX (x, last_x);
+ area.y1 = MIN (y, last_y);
+ area.y2 = MAX (y, last_y);
+ items = goo_canvas_get_items_in_area (canvas, &area, TRUE, FALSE, FALSE);
+ for (elem = items; elem; elem = elem->next)
+ {
+ g_print (" found items in area (%g, %g - %g, %g): %p\n",
+ area.x1, area.y1, area.x2, area.y2, elem->data);
+ }
+ g_list_free (items);
+ last_x = x;
+ last_y = y;
+}
+
+
static gboolean
on_button_press (GooCanvasItem *item,
GooCanvasItem *target,
@@ -250,11 +276,19 @@
{
GooCanvas *canvas;
GdkCursor *fleur;
+ GList *items, *elem;
-#if 0
g_print ("%p received 'button-press' signal at %g, %g (root: %g, %g)\n",
item, event->x, event->y, event->x_root, event->y_root);
-#endif
+
+ canvas = goo_canvas_item_get_canvas (item);
+ items = goo_canvas_get_items_at (canvas, event->x_root, event->y_root,
+ TRUE);
+ for (elem = items; elem; elem = elem->next)
+ g_print (" found items: %p\n", elem->data);
+ g_list_free (items);
+
+ output_items_in_area (canvas, event->x_root, event->y_root);
switch (event->button)
{
@@ -274,7 +308,6 @@
drag_y = event->y;
fleur = gdk_cursor_new (GDK_FLEUR);
- canvas = goo_canvas_item_get_canvas (item);
goo_canvas_pointer_grab (canvas, item,
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
fleur,
@@ -326,10 +359,15 @@
GdkEventButton *event,
gpointer data)
{
+ GooCanvas *canvas;
+
#if 1
g_print ("background received 'button-press' signal\n");
#endif
+ canvas = goo_canvas_item_get_canvas (item);
+ output_items_in_area (canvas, event->x_root, event->y_root);
+
return TRUE;
}
More information about the cairo-commit
mailing list