[cairo-commit] goocanvas/src goocanvasitemsimple.c,1.35,1.36
Damon Chaplin
commit at pdx.freedesktop.org
Mon Feb 25 07:34:03 PST 2008
Committed by: damon
Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv28914/src
Modified Files:
goocanvasitemsimple.c
Log Message:
2008-02-25 Damon Chaplin <damon at gnome.org>
* src/goocanvasitemsimple.c: added default implementations for the
simple_update/paint/get_item_at() virtual functions that call
simple_create_path(). These make it easier for language bindings.
Based on patch from Jonathon Jongsma.
Index: goocanvasitemsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- goocanvasitemsimple.c 13 Aug 2007 11:18:23 -0000 1.35
+++ goocanvasitemsimple.c 25 Feb 2008 15:34:59 -0000 1.36
@@ -96,6 +96,20 @@
const GValue *value,
GParamSpec *pspec);
+static void goo_canvas_item_simple_default_create_path (GooCanvasItemSimple *simple,
+ cairo_t *cr);
+static void goo_canvas_item_simple_default_update (GooCanvasItemSimple *simple,
+ cairo_t *cr);
+static void goo_canvas_item_simple_default_paint (GooCanvasItemSimple *simple,
+ cairo_t *cr,
+ const GooCanvasBounds *bounds);
+static gboolean goo_canvas_item_simple_default_is_item_at (GooCanvasItemSimple *simple,
+ double x,
+ double y,
+ cairo_t *cr,
+ gboolean is_pointer_event);
+
+
G_DEFINE_TYPE_WITH_CODE (GooCanvasItemSimple, goo_canvas_item_simple,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM,
@@ -328,6 +342,11 @@
}
goo_canvas_item_simple_install_common_properties (gobject_class);
+
+ klass->simple_create_path = goo_canvas_item_simple_default_create_path;
+ klass->simple_update = goo_canvas_item_simple_default_update;
+ klass->simple_paint = goo_canvas_item_simple_default_paint;
+ klass->simple_is_item_at = goo_canvas_item_simple_default_is_item_at;
}
@@ -983,7 +1002,6 @@
GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
GooCanvasItemSimpleData *simple_data = simple->simple_data;
double user_x = x, user_y = y;
- GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
cairo_matrix_t matrix;
gboolean add_item = FALSE;
@@ -1006,8 +1024,6 @@
|| (simple_data->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
&& simple->canvas->scale < simple_data->visibility_threshold)))
return found_items;
-
- pointer_events = simple_data->pointer_events;
}
cairo_save (cr);
@@ -1033,20 +1049,8 @@
}
}
- if (class->simple_is_item_at)
- {
- add_item = class->simple_is_item_at (simple, user_x, user_y, cr,
- is_pointer_event);
- }
- else
- {
- /* Use the virtual method subclasses define to create the path. */
- class->simple_create_path (simple, cr);
-
- if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr,
- pointer_events))
- add_item = TRUE;
- }
+ add_item = class->simple_is_item_at (simple, user_x, user_y, cr,
+ is_pointer_event);
cairo_restore (cr);
@@ -1058,6 +1062,31 @@
static gboolean
+goo_canvas_item_simple_default_is_item_at (GooCanvasItemSimple *simple,
+ double x,
+ double y,
+ cairo_t *cr,
+ gboolean is_pointer_event)
+{
+ GooCanvasItemSimpleClass *class = GOO_CANVAS_ITEM_SIMPLE_GET_CLASS (simple);
+
+ GooCanvasItemSimpleData *simple_data = simple->simple_data;
+ GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
+
+ if (is_pointer_event)
+ pointer_events = simple_data->pointer_events;
+
+ /* Use the virtual method subclasses define to create the path. */
+ class->simple_create_path (simple, cr);
+
+ if (goo_canvas_item_simple_check_in_path (simple, x, y, cr, pointer_events))
+ return TRUE;
+
+ return FALSE;
+}
+
+
+static gboolean
goo_canvas_item_simple_is_visible (GooCanvasItem *item)
{
GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
@@ -1129,17 +1158,7 @@
cairo_get_matrix (cr, &transform);
- if (class->simple_update)
- {
- class->simple_update (simple, cr);
- }
- else
- {
- /* Use the identity matrix to get the bounds completely in user space. */
- cairo_identity_matrix (cr);
- class->simple_create_path (simple, cr);
- goo_canvas_item_simple_get_path_bounds (simple, cr, &simple->bounds);
- }
+ class->simple_update (simple, cr);
/* Modify the extents by the item's clip path. */
if (simple_data->clip_path_commands)
@@ -1165,6 +1184,20 @@
static void
+goo_canvas_item_simple_default_update (GooCanvasItemSimple *simple,
+ cairo_t *cr)
+{
+ GooCanvasItemSimpleClass *class = GOO_CANVAS_ITEM_SIMPLE_GET_CLASS (simple);
+
+ /* Use the identity matrix to get the bounds completely in user space. */
+ cairo_identity_matrix (cr);
+
+ class->simple_create_path (simple, cr);
+ goo_canvas_item_simple_get_path_bounds (simple, cr, &simple->bounds);
+}
+
+
+static void
goo_canvas_item_simple_update (GooCanvasItem *item,
gboolean entire_tree,
cairo_t *cr,
@@ -1333,21 +1366,31 @@
cairo_clip (cr);
}
- if (class->simple_paint)
- {
- class->simple_paint (simple, cr, bounds);
- }
- else
- {
- class->simple_create_path (simple, cr);
-
- goo_canvas_item_simple_paint_path (simple, cr);
- }
+ class->simple_paint (simple, cr, bounds);
cairo_restore (cr);
}
+static void
+goo_canvas_item_simple_default_paint (GooCanvasItemSimple *simple,
+ cairo_t *cr,
+ const GooCanvasBounds *bounds)
+{
+ GooCanvasItemSimpleClass *class = GOO_CANVAS_ITEM_SIMPLE_GET_CLASS (simple);
+
+ class->simple_create_path (simple, cr);
+ goo_canvas_item_simple_paint_path (simple, cr);
+}
+
+
+static void
+goo_canvas_item_simple_default_create_path (GooCanvasItemSimple *simple,
+ cairo_t *cr)
+{
+ /* Do nothing. */
+}
+
static void
goo_canvas_item_simple_title_changed (GooCanvasItemModelSimple *smodel,
More information about the cairo-commit
mailing list