[cairo-commit] goocanvas/src Makefile.am, 1.6,
1.7 goocanvasellipseview.c, 1.6, 1.7 goocanvasellipseview.h,
1.2, 1.3 goocanvasgroupview.c, 1.8, 1.9 goocanvasimageview.c,
1.6, 1.7 goocanvasimageview.h, 1.2, 1.3 goocanvasitem.c, 1.5,
1.6 goocanvasitemsimple.c, 1.6, 1.7 goocanvasitemviewsimple.c,
NONE, 1.1 goocanvasitemviewsimple.h, NONE,
1.1 goocanvasmodel.c, 1.2, 1.3 goocanvaspathview.c, 1.4,
1.5 goocanvaspathview.h, 1.2, 1.3 goocanvaspolylineview.c, 1.7,
1.8 goocanvaspolylineview.h, 1.3, 1.4 goocanvasrectview.c, 1.6,
1.7 goocanvasrectview.h, 1.2, 1.3 goocanvastextview.c, 1.7,
1.8 goocanvastextview.h, 1.3, 1.4 goocanvasview.c, 1.10, 1.11
Damon Chaplin
commit at pdx.freedesktop.org
Sun Apr 16 06:20:07 PDT 2006
Committed by: damon
Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv12414/src
Modified Files:
Makefile.am goocanvasellipseview.c goocanvasellipseview.h
goocanvasgroupview.c goocanvasimageview.c goocanvasimageview.h
goocanvasitem.c goocanvasitemsimple.c goocanvasmodel.c
goocanvaspathview.c goocanvaspathview.h
goocanvaspolylineview.c goocanvaspolylineview.h
goocanvasrectview.c goocanvasrectview.h goocanvastextview.c
goocanvastextview.h goocanvasview.c
Added Files:
goocanvasitemviewsimple.c goocanvasitemviewsimple.h
Log Message:
2006-04-16 Damon Chaplin <damon at gnome.org>
* src/goocanvasitemviewsimple.[hc]: new base class for item views,
so we can share a lot of the common code.
* src/*view.[hc]: updated item views to be a subclass of above.
* src/*.c: removed lots of unused debugging code.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/goocanvas/src/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Makefile.am 14 Apr 2006 12:49:10 -0000 1.6
+++ Makefile.am 16 Apr 2006 13:20:05 -0000 1.7
@@ -25,6 +25,7 @@
goocanvasitem.h \
goocanvasitemsimple.h \
goocanvasitemview.h \
+ goocanvasitemviewsimple.h \
goocanvasmodel.h \
goocanvasmodelsimple.h \
goocanvaspolyline.h \
@@ -50,6 +51,7 @@
goocanvasitem.c \
goocanvasitemsimple.c \
goocanvasitemview.c \
+ goocanvasitemviewsimple.c \
goocanvasmodel.c \
goocanvasmodelsimple.c \
goocanvaspolyline.c \
Index: goocanvasellipseview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasellipseview.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- goocanvasellipseview.c 13 Apr 2006 17:07:44 -0000 1.6
+++ goocanvasellipseview.c 16 Apr 2006 13:20:05 -0000 1.7
@@ -27,38 +27,32 @@
#include <config.h>
#include <math.h>
#include <gtk/gtk.h>
-#include "goocanvasview.h"
#include "goocanvasellipseview.h"
#include "goocanvasellipse.h"
-static void canvas_item_view_interface_init (GooCanvasItemViewIface *iface);
-static void goo_canvas_ellipse_view_finalize (GObject *object);
-static void on_ellipse_changed (GooCanvasEllipse *ellipse,
- gboolean recompute_bounds,
- GooCanvasEllipseView *view);
+static void goo_canvas_ellipse_view_create_path (GooCanvasItemSimple *simple,
+ cairo_t *cr);
G_DEFINE_TYPE_WITH_CODE (GooCanvasEllipseView, goo_canvas_ellipse_view,
- G_TYPE_OBJECT,
+ GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE,
G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM_VIEW,
- canvas_item_view_interface_init));
+ NULL));
static void
goo_canvas_ellipse_view_class_init (GooCanvasEllipseViewClass *klass)
{
- GObjectClass *gobject_class = (GObjectClass*) klass;
+ GooCanvasItemViewSimpleClass *simple_view_class = (GooCanvasItemViewSimpleClass*) klass;
- gobject_class->finalize = goo_canvas_ellipse_view_finalize;
+ simple_view_class->create_path = goo_canvas_ellipse_view_create_path;
}
static void
goo_canvas_ellipse_view_init (GooCanvasEllipseView *ellipse_view)
{
- GooCanvasBounds *bounds = &ellipse_view->bounds;
- bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0;
}
@@ -78,32 +72,26 @@
goo_canvas_ellipse_view_new (GooCanvasItemView *parent_view,
GooCanvasEllipse *ellipse)
{
- GooCanvasEllipseView *view;
+ GooCanvasItemViewSimple *view;
view = g_object_new (GOO_TYPE_CANVAS_ELLIPSE_VIEW, NULL);
- view->need_update = TRUE;
view->parent_view = parent_view;
- view->ellipse = ellipse;
+ view->item = (GooCanvasItemSimple*) ellipse;
- g_signal_connect (ellipse, "changed", G_CALLBACK (on_ellipse_changed), view);
+ g_signal_connect (ellipse, "changed",
+ G_CALLBACK (goo_canvas_item_view_simple_item_changed),
+ view);
return (GooCanvasItemView*) view;
}
static void
-goo_canvas_ellipse_view_finalize (GObject *object)
+goo_canvas_ellipse_view_create_path (GooCanvasItemSimple *simple,
+ cairo_t *cr)
{
- /*GooCanvasEllipseView *o = (GooCanvasEllipseView*) object;*/
-
- G_OBJECT_CLASS (goo_canvas_ellipse_view_parent_class)->finalize (object);
-}
-
+ GooCanvasEllipse *ellipse = (GooCanvasEllipse*) simple;
-static void
-goo_canvas_ellipse_create_path (GooCanvasEllipse *ellipse,
- cairo_t *cr)
-{
cairo_new_path (cr);
cairo_save (cr);
cairo_translate (cr, ellipse->center_x, ellipse->center_y);
@@ -111,206 +99,3 @@
cairo_arc (cr, 0.0, 0.0, 1.0, 0.0, 2.0 * M_PI);
cairo_restore (cr);
}
-
-
-static GooCanvasItemView*
-goo_canvas_ellipse_view_get_parent_view (GooCanvasItemView *view)
-{
- GooCanvasEllipseView *ellipse_view = (GooCanvasEllipseView*) view;
- return ellipse_view->parent_view;
-}
-
-
-static void
-goo_canvas_ellipse_view_set_parent_view (GooCanvasItemView *view,
- GooCanvasItemView *parent_view)
-{
- GooCanvasEllipseView *ellipse_view = (GooCanvasEllipseView*) view;
- ellipse_view->parent_view = parent_view;
-}
-
-
-static GooCanvasItem*
-goo_canvas_ellipse_view_get_item (GooCanvasItemView *view)
-{
- GooCanvasEllipseView *ellipse_view = (GooCanvasEllipseView*) view;
- return (GooCanvasItem*) ellipse_view->ellipse;
-}
-
-
-static GooCanvasBounds*
-goo_canvas_ellipse_view_get_bounds (GooCanvasItemView *view)
-{
- GooCanvasEllipseView *ellipse_view = (GooCanvasEllipseView*) view;
-
- if (ellipse_view->need_update)
- goo_canvas_item_view_ensure_updated (view);
-
- return &ellipse_view->bounds;
-}
-
-
-static GooCanvasItemView*
-goo_canvas_ellipse_view_get_item_at (GooCanvasItemView *view,
- gdouble x,
- gdouble y,
- 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);
-
- 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,
- pointer_events))
- found_view = view;
-
- cairo_restore (cr);
-
- return found_view;
-}
-
-
-static GooCanvasBounds*
-goo_canvas_ellipse_view_update (GooCanvasItemView *view,
- gboolean entire_tree,
- cairo_t *cr)
-{
- GooCanvasEllipseView *ellipse_view = (GooCanvasEllipseView*) view;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) ellipse_view->ellipse;
- GooCanvasView *canvas_view;
- GooCanvasBounds *bounds = &ellipse_view->bounds;
-
- if (entire_tree || ellipse_view->need_update)
- {
- ellipse_view->need_update = FALSE;
-
-#if 0
- g_print ("Updating ellipse\n");
-#endif
-
- cairo_save (cr);
- if (simple->transform)
- cairo_transform (cr, simple->transform);
-
- canvas_view = goo_canvas_item_view_get_canvas_view (ellipse_view->parent_view);
-
- /* Request a redraw of the existing bounds. */
- goo_canvas_view_request_redraw (canvas_view, bounds);
-
- /* Compute the new bounds. */
- goo_canvas_ellipse_create_path (ellipse_view->ellipse, cr);
- goo_canvas_item_simple_get_path_bounds (simple, cr, bounds);
-
-#if 0
- g_print ("Ellipse bounds: %g,%g - %g, %g\n",
- bounds->x1, bounds->y1, bounds->x2, bounds->y2);
-#endif
-
- /* Request a redraw of the new bounds. */
- goo_canvas_view_request_redraw (canvas_view, bounds);
-
- cairo_restore (cr);
- }
-
- return bounds;
-}
-
-
-static void
-goo_canvas_ellipse_view_paint (GooCanvasItemView *view,
- cairo_t *cr,
- GooCanvasBounds *bounds,
- gdouble scale)
-{
- GooCanvasEllipseView *ellipse_view = (GooCanvasEllipseView*) view;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) ellipse_view->ellipse;
-
-#if 0
- g_print ("Painting ellipse item %p\n", view);
-#endif
-
- /* Check if the item should be visible. */
- if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
- || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
- && scale < simple->visibility_threshold))
- return;
-
- cairo_save (cr);
- if (simple->transform)
- cairo_transform (cr, simple->transform);
-
- goo_canvas_ellipse_create_path (ellipse_view->ellipse, cr);
- goo_canvas_item_simple_paint_path (simple, cr);
-
- cairo_restore (cr);
-}
-
-
-static void
-canvas_item_view_interface_init (GooCanvasItemViewIface *iface)
-{
- iface->get_parent_view = goo_canvas_ellipse_view_get_parent_view;
- iface->set_parent_view = goo_canvas_ellipse_view_set_parent_view;
- iface->get_item = goo_canvas_ellipse_view_get_item;
- iface->get_bounds = goo_canvas_ellipse_view_get_bounds;
- iface->get_item_at = goo_canvas_ellipse_view_get_item_at;
- iface->update = goo_canvas_ellipse_view_update;
- iface->paint = goo_canvas_ellipse_view_paint;
-}
-
-
-static void
-on_ellipse_changed (GooCanvasEllipse *ellipse,
- gboolean recompute_bounds,
- GooCanvasEllipseView *view)
-{
- GooCanvasView *canvas_view;
-
-#if 0
- g_print ("Ellipse changed\n");
-#endif
-
- if (recompute_bounds)
- {
- if (!view->need_update)
- {
- view->need_update = TRUE;
- goo_canvas_item_view_request_update (view->parent_view);
- }
- }
- else
- {
- canvas_view = goo_canvas_item_view_get_canvas_view (view->parent_view);
- goo_canvas_view_request_redraw (canvas_view, &view->bounds);
- }
-}
Index: goocanvasellipseview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasellipseview.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasellipseview.h 13 Apr 2006 17:07:44 -0000 1.2
+++ goocanvasellipseview.h 16 Apr 2006 13:20:05 -0000 1.3
@@ -8,7 +8,7 @@
#define __GOO_CANVAS_ELLIPSE_VIEW_H__
#include <gtk/gtk.h>
-#include "goocanvasitemview.h"
+#include "goocanvasitemviewsimple.h"
#include "goocanvasellipse.h"
G_BEGIN_DECLS
@@ -32,24 +32,12 @@
*/
struct _GooCanvasEllipseView
{
- GObject parent_object;
-
- /* The parent view. */
- GooCanvasItemView *parent_view;
-
- /* The item in the model. */
- GooCanvasEllipse *ellipse;
-
- /* The bounds of the item, relative to the entire canvas. */
- GooCanvasBounds bounds;
-
- /* This is TRUE if we need to recompute our bounds & repaint. */
- guint need_update : 1;
+ GooCanvasItemViewSimple parent_object;
};
struct _GooCanvasEllipseViewClass
{
- GObjectClass parent_class;
+ GooCanvasItemViewSimpleClass parent_class;
};
Index: goocanvasgroupview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroupview.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- goocanvasgroupview.c 16 Apr 2006 10:39:51 -0000 1.8
+++ goocanvasgroupview.c 16 Apr 2006 13:20:05 -0000 1.9
@@ -134,10 +134,6 @@
view = goo_canvas_view_create_item_view (group_view->canvas_view, item,
(GooCanvasItemView*) group_view);
-#if 0
- g_print ("Group view %p adding child view: %p\n", group_view, view);
-#endif
-
if (position >= 0)
goo_canvas_util_ptr_array_insert (group_view->item_views, view, position);
else
@@ -420,11 +416,6 @@
GooCanvasBounds *child_bounds;
gint i;
-#if 0
- g_print (" Painting group: %p views: %i items: %i\n", view,
- group_view->item_views->len, group->items->len);
-#endif
-
/* Check if the item should be visible. */
if (group->visibility == GOO_CANVAS_ITEM_INVISIBLE
|| (group->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
Index: goocanvasimageview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasimageview.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- goocanvasimageview.c 13 Apr 2006 17:07:44 -0000 1.6
+++ goocanvasimageview.c 16 Apr 2006 13:20:05 -0000 1.7
@@ -26,19 +26,15 @@
*/
#include <config.h>
#include <gtk/gtk.h>
-#include "goocanvasview.h"
#include "goocanvasimageview.h"
#include "goocanvasimage.h"
+#include "goocanvasview.h"
static void canvas_item_view_interface_init (GooCanvasItemViewIface *iface);
-static void goo_canvas_image_view_finalize (GObject *object);
-static void on_image_changed (GooCanvasImage *image,
- gboolean recompute_bounds,
- GooCanvasImageView *view);
G_DEFINE_TYPE_WITH_CODE (GooCanvasImageView, goo_canvas_image_view,
- G_TYPE_OBJECT,
+ GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE,
G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM_VIEW,
canvas_item_view_interface_init));
@@ -46,18 +42,14 @@
static void
goo_canvas_image_view_class_init (GooCanvasImageViewClass *klass)
{
- GObjectClass *gobject_class = (GObjectClass*) klass;
- gobject_class->finalize = goo_canvas_image_view_finalize;
}
static void
goo_canvas_image_view_init (GooCanvasImageView *image_view)
{
- GooCanvasBounds *bounds = &image_view->bounds;
- bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0;
}
@@ -77,65 +69,20 @@
goo_canvas_image_view_new (GooCanvasItemView *parent_view,
GooCanvasImage *image)
{
- GooCanvasImageView *view;
+ GooCanvasItemViewSimple *view;
view = g_object_new (GOO_TYPE_CANVAS_IMAGE_VIEW, NULL);
- view->need_update = TRUE;
view->parent_view = parent_view;
- view->image = image;
+ view->item = (GooCanvasItemSimple*) image;
- g_signal_connect (image, "changed", G_CALLBACK (on_image_changed), view);
+ g_signal_connect (image, "changed",
+ G_CALLBACK (goo_canvas_item_view_simple_item_changed),
+ view);
return (GooCanvasItemView*) view;
}
-static void
-goo_canvas_image_view_finalize (GObject *object)
-{
- /*GooCanvasImageView *o = (GooCanvasImageView*) object;*/
-
- G_OBJECT_CLASS (goo_canvas_image_view_parent_class)->finalize (object);
-}
-
-
-static GooCanvasItemView*
-goo_canvas_image_view_get_parent_view (GooCanvasItemView *view)
-{
- GooCanvasImageView *image_view = (GooCanvasImageView*) view;
- return image_view->parent_view;
-}
-
-
-static void
-goo_canvas_image_view_set_parent_view (GooCanvasItemView *view,
- GooCanvasItemView *parent_view)
-{
- GooCanvasImageView *image_view = (GooCanvasImageView*) view;
- image_view->parent_view = parent_view;
-}
-
-
-static GooCanvasItem*
-goo_canvas_image_view_get_item (GooCanvasItemView *view)
-{
- GooCanvasImageView *image_view = (GooCanvasImageView*) view;
- return (GooCanvasItem*) image_view->image;
-}
-
-
-static GooCanvasBounds*
-goo_canvas_image_view_get_bounds (GooCanvasItemView *view)
-{
- GooCanvasImageView *image_view = (GooCanvasImageView*) view;
-
- if (image_view->need_update)
- goo_canvas_item_view_ensure_updated (view);
-
- return &image_view->bounds;
-}
-
-
static GooCanvasItemView*
goo_canvas_image_view_get_item_at (GooCanvasItemView *view,
gdouble x,
@@ -145,13 +92,13 @@
gboolean parent_visible,
gdouble scale)
{
- GooCanvasImageView *image_view = (GooCanvasImageView*) view;
- GooCanvasImage *image = image_view->image;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) image;
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasImage *image = (GooCanvasImage*) simple;
GooCanvasItemView *found_view = view;
double user_x = x, user_y = y;
- if (image_view->need_update)
+ if (simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE)
goo_canvas_item_view_ensure_updated (view);
/* Check if the item should receive events. Note that we don't take
@@ -189,30 +136,30 @@
gboolean entire_tree,
cairo_t *cr)
{
- GooCanvasImageView *image_view = (GooCanvasImageView*) view;
- GooCanvasImage *image = image_view->image;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) image;
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasImage *image = (GooCanvasImage*) simple;
GooCanvasView *canvas_view;
- GooCanvasBounds *bounds = &image_view->bounds;
+ GooCanvasBounds *bounds = &simple_view->bounds;
- if (entire_tree || image_view->need_update)
+ if (entire_tree || (simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE))
{
- image_view->need_update = FALSE;
+ simple_view->flags &= ~GOO_CANVAS_ITEM_VIEW_NEED_UPDATE;
cairo_save (cr);
if (simple->transform)
cairo_transform (cr, simple->transform);
- canvas_view = goo_canvas_item_view_get_canvas_view (image_view->parent_view);
+ canvas_view = goo_canvas_item_view_get_canvas_view (simple_view->parent_view);
/* Request a redraw of the existing bounds. */
goo_canvas_view_request_redraw (canvas_view, bounds);
/* Compute the new bounds. */
- image_view->bounds.x1 = image->x;
- image_view->bounds.y1 = image->y;
- image_view->bounds.x2 = image->x + image->width;
- image_view->bounds.y2 = image->y + image->height;
+ simple_view->bounds.x1 = image->x;
+ simple_view->bounds.y1 = image->y;
+ simple_view->bounds.x2 = image->x + image->width;
+ simple_view->bounds.y2 = image->y + image->height;
goo_canvas_item_simple_user_bounds_to_device (simple, cr, bounds);
@@ -232,18 +179,14 @@
GooCanvasBounds *bounds,
gdouble scale)
{
- GooCanvasImageView *image_view = (GooCanvasImageView*) view;
- GooCanvasImage *image = image_view->image;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) image;
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasImage *image = (GooCanvasImage*) simple;
cairo_matrix_t matrix;
if (!image->pattern)
return;
-#if 0
- g_print ("Painting image item %p\n", view);
-#endif
-
/* Check if the item should be visible. */
if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
|| (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
@@ -271,38 +214,7 @@
static void
canvas_item_view_interface_init (GooCanvasItemViewIface *iface)
{
- iface->get_parent_view = goo_canvas_image_view_get_parent_view;
- iface->set_parent_view = goo_canvas_image_view_set_parent_view;
- iface->get_item = goo_canvas_image_view_get_item;
- iface->get_bounds = goo_canvas_image_view_get_bounds;
iface->get_item_at = goo_canvas_image_view_get_item_at;
iface->update = goo_canvas_image_view_update;
iface->paint = goo_canvas_image_view_paint;
}
-
-
-static void
-on_image_changed (GooCanvasImage *image,
- gboolean recompute_bounds,
- GooCanvasImageView *view)
-{
- GooCanvasView *canvas_view;
-
-#if 0
- g_print ("Image changed\n");
-#endif
-
- if (recompute_bounds)
- {
- if (!view->need_update)
- {
- view->need_update = TRUE;
- goo_canvas_item_view_request_update (view->parent_view);
- }
- }
- else
- {
- canvas_view = goo_canvas_item_view_get_canvas_view (view->parent_view);
- goo_canvas_view_request_redraw (canvas_view, &view->bounds);
- }
-}
Index: goocanvasimageview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasimageview.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasimageview.h 13 Apr 2006 17:07:44 -0000 1.2
+++ goocanvasimageview.h 16 Apr 2006 13:20:05 -0000 1.3
@@ -8,7 +8,7 @@
#define __GOO_CANVAS_IMAGE_VIEW_H__
#include <gtk/gtk.h>
-#include "goocanvasitemview.h"
+#include "goocanvasitemviewsimple.h"
#include "goocanvasimage.h"
G_BEGIN_DECLS
@@ -32,24 +32,12 @@
*/
struct _GooCanvasImageView
{
- GObject parent;
-
- /* The parent view. */
- GooCanvasItemView *parent_view;
-
- /* The item in the model. */
- GooCanvasImage *image;
-
- /* The bounds of the item, relative to the entire canvas. */
- GooCanvasBounds bounds;
-
- /* This is TRUE if we need to recompute our bounds & repaint. */
- guint need_update : 1;
+ GooCanvasItemViewSimple parent_object;
};
struct _GooCanvasImageViewClass
{
- GObjectClass parent_class;
+ GooCanvasItemViewSimpleClass parent_class;
};
Index: goocanvasitem.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- goocanvasitem.c 16 Apr 2006 10:39:51 -0000 1.5
+++ goocanvasitem.c 16 Apr 2006 13:20:05 -0000 1.6
@@ -667,10 +667,6 @@
GDK_THREADS_ENTER ();
-#if 0
- g_print ("In goo_canvas_item_animcate_cb: %i\n", anim->num_steps_left);
-#endif
-
iface = GOO_CANVAS_ITEM_GET_IFACE (anim->item);
matrix = iface->get_transform (anim->item);
if (matrix)
@@ -784,14 +780,6 @@
anim->step.y0 = (new_matrix.y0 - matrix->y0) / anim->total_steps;
anim->forward = TRUE;
-#if 0
- g_print ("Old: %g, %g, %g, %g, %g, %g\nNew: %g, %g, %g, %g, %g, %g\n",
- matrix->xx, matrix->yx, matrix->xy, matrix->yy,
- matrix->x0, matrix->y0,
- new_matrix.xx, new_matrix.yx, new_matrix.xy, new_matrix.yy,
- new_matrix.x0, new_matrix.y0);
-#endif
-
/* Store a pointer to the new animation in the item. This will automatically
stop any current animation and free it. */
g_object_set_data_full (G_OBJECT (item), animation_key, anim,
Index: goocanvasitemsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- goocanvasitemsimple.c 16 Apr 2006 10:39:51 -0000 1.6
+++ goocanvasitemsimple.c 16 Apr 2006 13:20:05 -0000 1.7
@@ -925,13 +925,6 @@
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 (pointer_events & GOO_CANVAS_EVENTS_FILL_MASK
&& (!(pointer_events & GOO_CANVAS_EVENTS_PAINTED_MASK) || do_fill))
--- NEW FILE: goocanvasitemviewsimple.c ---
/*
* GooCanvas. Copyright (C) 2005-6 Damon Chaplin.
* Released under the GNU LGPL license. See COPYING for details.
*
* goocanvasitemviewsimple.c - abstract base class for simple item views.
*/
/**
* SECTION:goocanvasitemviewsimple
* @Title: GooCanvasItemViewSimple
* @Short_Description: the base class for the standard canvas item views.
* @Stability_Level:
* @See_Also:
*
* #GooCanvasItemViewSimple is used as a base class for the standard canvas
* item views.
*
* It provides default implementations for many of the #GooCanvasItemView
* methods.
*/
#include <config.h>
#include <gtk/gtk.h>
#include "goocanvasitemviewsimple.h"
#include "goocanvasview.h"
static void canvas_item_view_interface_init (GooCanvasItemViewIface *iface);
G_DEFINE_TYPE_WITH_CODE (GooCanvasItemViewSimple, goo_canvas_item_view_simple,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM_VIEW,
canvas_item_view_interface_init));
static void
goo_canvas_item_view_simple_class_init (GooCanvasItemViewSimpleClass *klass)
{
}
static void
goo_canvas_item_view_simple_init (GooCanvasItemViewSimple *view)
{
GooCanvasBounds *bounds = &view->bounds;
bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0;
view->flags = GOO_CANVAS_ITEM_VIEW_NEED_UPDATE;
}
static GooCanvasItemView*
goo_canvas_item_view_simple_get_parent_view (GooCanvasItemView *view)
{
GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
return simple_view->parent_view;
}
static void
goo_canvas_item_view_simple_set_parent_view (GooCanvasItemView *view,
GooCanvasItemView *parent_view)
{
GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
simple_view->parent_view = parent_view;
}
static GooCanvasItem*
goo_canvas_item_view_simple_get_item (GooCanvasItemView *view)
{
GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
return (GooCanvasItem*) simple_view->item;
}
static GooCanvasBounds*
goo_canvas_item_view_simple_get_bounds (GooCanvasItemView *view)
{
GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
if (simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE)
goo_canvas_item_view_ensure_updated (view);
return &simple_view->bounds;
}
static GooCanvasItemView*
goo_canvas_item_view_simple_get_item_at (GooCanvasItemView *view,
gdouble x,
gdouble y,
cairo_t *cr,
gboolean is_pointer_event,
gboolean parent_visible,
gdouble scale)
{
GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
GooCanvasItemSimple *simple = simple_view->item;
GooCanvasItemView *found_view = NULL;
double user_x = x, user_y = y;
GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
if (simple_view->flags & GOO_CANVAS_ITEM_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);
cairo_device_to_user (cr, &user_x, &user_y);
/* Use the virtual method subclasses define to create the path. */
GOO_CANVAS_ITEM_VIEW_SIMPLE_GET_CLASS (view)->create_path (simple, cr);
if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr,
pointer_events))
found_view = view;
cairo_restore (cr);
return found_view;
}
static GooCanvasBounds*
goo_canvas_item_view_simple_update (GooCanvasItemView *view,
gboolean entire_tree,
cairo_t *cr)
{
GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
GooCanvasItemSimple *simple = simple_view->item;
GooCanvasView *canvas_view;
GooCanvasBounds *bounds = &simple_view->bounds;
if (entire_tree || (simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE))
{
simple_view->flags &= ~GOO_CANVAS_ITEM_VIEW_NEED_UPDATE;
cairo_save (cr);
if (simple->transform)
cairo_transform (cr, simple->transform);
canvas_view = goo_canvas_item_view_get_canvas_view (simple_view->parent_view);
/* Request a redraw of the existing bounds. */
goo_canvas_view_request_redraw (canvas_view, bounds);
/* Use the virtual method subclasses define to create the path. */
GOO_CANVAS_ITEM_VIEW_SIMPLE_GET_CLASS (view)->create_path (simple, cr);
/* Compute the new bounds. */
goo_canvas_item_simple_get_path_bounds (simple, cr, bounds);
/* Request a redraw of the new bounds. */
goo_canvas_view_request_redraw (canvas_view, bounds);
cairo_restore (cr);
}
return bounds;
}
static void
goo_canvas_item_view_simple_paint (GooCanvasItemView *view,
cairo_t *cr,
GooCanvasBounds *bounds,
gdouble scale)
{
GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
GooCanvasItemSimple *simple = simple_view->item;
/* Check if the item should be visible. */
if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
|| (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
&& scale < simple->visibility_threshold))
return;
cairo_save (cr);
if (simple->transform)
cairo_transform (cr, simple->transform);
/* Use the virtual method subclasses define to create the path. */
GOO_CANVAS_ITEM_VIEW_SIMPLE_GET_CLASS (view)->create_path (simple, cr);
goo_canvas_item_simple_paint_path (simple, cr);
cairo_restore (cr);
}
static void
canvas_item_view_interface_init (GooCanvasItemViewIface *iface)
{
iface->get_parent_view = goo_canvas_item_view_simple_get_parent_view;
iface->set_parent_view = goo_canvas_item_view_simple_set_parent_view;
iface->get_item = goo_canvas_item_view_simple_get_item;
iface->get_bounds = goo_canvas_item_view_simple_get_bounds;
iface->get_item_at = goo_canvas_item_view_simple_get_item_at;
iface->update = goo_canvas_item_view_simple_update;
iface->paint = goo_canvas_item_view_simple_paint;
}
/**
* goo_canvas_item_view_simple_item_changed:
* @item: the #GooCanvasItem that has changed.
* @recompute_bounds: %TRUE if the bounds need to be recomputed.
* @simple_view: the item view.
*
* This function is intended to be used by subclasses of
* #GooCanvasItemViewSimple only.
*
* It is used as a callback for the "changed" signal of the canvas items.
* It requests an update or redraw of the item view as appropriate.
**/
void
goo_canvas_item_view_simple_item_changed (GooCanvasItem *item,
gboolean recompute_bounds,
GooCanvasItemViewSimple *simple_view)
{
GooCanvasView *canvas_view;
if (recompute_bounds)
{
if (!(simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE))
{
simple_view->flags |= GOO_CANVAS_ITEM_VIEW_NEED_UPDATE;
goo_canvas_item_view_request_update (simple_view->parent_view);
}
}
else
{
canvas_view = goo_canvas_item_view_get_canvas_view (simple_view->parent_view);
goo_canvas_view_request_redraw (canvas_view, &simple_view->bounds);
}
}
--- NEW FILE: goocanvasitemviewsimple.h ---
/*
* GooCanvas. Copyright (C) 2005-6 Damon Chaplin.
* Released under the GNU LGPL license. See COPYING for details.
*
* goocanvasitemviewsimple.h - abstract base class for simple item views.
*/
#ifndef __GOO_CANVAS_ITEM_VIEW_SIMPLE_H__
#define __GOO_CANVAS_ITEM_VIEW_SIMPLE_H__
#include <gtk/gtk.h>
#include "goocanvasitemsimple.h"
#include "goocanvasitemview.h"
G_BEGIN_DECLS
typedef enum
{
/* If the view needs to recompute its bounds and redraw. */
GOO_CANVAS_ITEM_VIEW_NEED_UPDATE = 1 << 0
} GooCanvasItemViewFlags;
#define GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE (goo_canvas_item_view_simple_get_type ())
#define GOO_CANVAS_ITEM_VIEW_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE, GooCanvasItemViewSimple))
#define GOO_CANVAS_ITEM_VIEW_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE, GooCanvasItemViewSimpleClass))
#define GOO_IS_CANVAS_ITEM_VIEW_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE))
#define GOO_IS_CANVAS_ITEM_VIEW_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE))
#define GOO_CANVAS_ITEM_VIEW_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE, GooCanvasItemViewSimpleClass))
typedef struct _GooCanvasItemViewSimple GooCanvasItemViewSimple;
typedef struct _GooCanvasItemViewSimpleClass GooCanvasItemViewSimpleClass;
/**
* GooCanvasItemViewSimple
*
* The #GooCanvasItemViewSimple-struct struct contains private data only.
*/
struct _GooCanvasItemViewSimple
{
GObject parent_object;
/* The parent view. */
GooCanvasItemView *parent_view;
/* The item in the model. */
GooCanvasItemSimple *item;
/* The bounds of the item, relative to the entire canvas. */
GooCanvasBounds bounds;
/* This is TRUE if we need to recompute our bounds & repaint. */
GooCanvasItemViewFlags flags;
};
struct _GooCanvasItemViewSimpleClass
{
GObjectClass parent_class;
/* Virtual methods. */
void (* create_path) (GooCanvasItemSimple *item,
cairo_t *cr);
};
GType goo_canvas_item_view_simple_get_type (void) G_GNUC_CONST;
void goo_canvas_item_view_simple_item_changed (GooCanvasItem *item,
gboolean recompute_bounds,
GooCanvasItemViewSimple *simple_view);
G_END_DECLS
#endif /* __GOO_CANVAS_ITEM_VIEW_SIMPLE_H__ */
Index: goocanvasmodel.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasmodel.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasmodel.c 14 Apr 2006 16:59:04 -0000 1.2
+++ goocanvasmodel.c 16 Apr 2006 13:20:05 -0000 1.3
@@ -51,17 +51,7 @@
static void
goo_canvas_model_base_init (gpointer g_class)
{
-#if 0
- static gboolean initialized = FALSE;
-
- if (!initialized)
- {
- GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
-
- initialized = TRUE;
- }
-#endif
}
Index: goocanvaspathview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvaspathview.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvaspathview.c 13 Apr 2006 17:07:44 -0000 1.4
+++ goocanvaspathview.c 16 Apr 2006 13:20:05 -0000 1.5
@@ -27,37 +27,31 @@
#include <config.h>
#include <math.h>
#include <gtk/gtk.h>
-#include "goocanvasview.h"
#include "goocanvaspathview.h"
-static void canvas_item_view_interface_init (GooCanvasItemViewIface *iface);
-static void goo_canvas_path_view_finalize (GObject *object);
-static void on_path_changed (GooCanvasPath *path,
- gboolean recompute_bounds,
- GooCanvasPathView *view);
+static void goo_canvas_path_view_create_path (GooCanvasItemSimple *simple,
+ cairo_t *cr);
G_DEFINE_TYPE_WITH_CODE (GooCanvasPathView, goo_canvas_path_view,
- G_TYPE_OBJECT,
+ GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE,
G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM_VIEW,
- canvas_item_view_interface_init));
+ NULL));
static void
goo_canvas_path_view_class_init (GooCanvasPathViewClass *klass)
{
- GObjectClass *gobject_class = (GObjectClass*) klass;
+ GooCanvasItemViewSimpleClass *simple_view_class = (GooCanvasItemViewSimpleClass*) klass;
- gobject_class->finalize = goo_canvas_path_view_finalize;
+ simple_view_class->create_path = goo_canvas_path_view_create_path;
}
static void
goo_canvas_path_view_init (GooCanvasPathView *path_view)
{
- GooCanvasBounds *bounds = &path_view->bounds;
- bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0;
}
@@ -77,29 +71,21 @@
goo_canvas_path_view_new (GooCanvasItemView *parent_view,
GooCanvasPath *path)
{
- GooCanvasPathView *view;
+ GooCanvasItemViewSimple *view;
view = g_object_new (GOO_TYPE_CANVAS_PATH_VIEW, NULL);
- view->need_update = TRUE;
view->parent_view = parent_view;
- view->path = path;
+ view->item = (GooCanvasItemSimple*) path;
- g_signal_connect (path, "changed", G_CALLBACK (on_path_changed), view);
+ g_signal_connect (path, "changed",
+ G_CALLBACK (goo_canvas_item_view_simple_item_changed),
+ view);
return (GooCanvasItemView*) view;
}
static void
-goo_canvas_path_view_finalize (GObject *object)
-{
- /*GooCanvasPathView *o = (GooCanvasPathView*) object;*/
-
- G_OBJECT_CLASS (goo_canvas_path_view_parent_class)->finalize (object);
-}
-
-
-static void
do_curve_to (GooCanvasPathCommand *cmd,
cairo_t *cr,
gdouble *x,
@@ -417,9 +403,10 @@
static void
-goo_canvas_path_view_create_path (GooCanvasPath *path,
- cairo_t *cr)
+goo_canvas_path_view_create_path (GooCanvasItemSimple *simple,
+ cairo_t *cr)
{
+ GooCanvasPath *path = (GooCanvasPath*) simple;
GooCanvasPathCommand *cmd;
GooCanvasPathCommandType prev_cmd_type = GOO_CANVAS_PATH_CLOSE_PATH;
gdouble x = 0, y = 0, path_start_x = 0, path_start_y = 0;
@@ -520,226 +507,3 @@
prev_cmd_type = cmd->simple.type;
}
}
-
-
-static GooCanvasItemView*
-goo_canvas_path_view_get_parent_view (GooCanvasItemView *view)
-{
- GooCanvasPathView *path_view = (GooCanvasPathView*) view;
- return path_view->parent_view;
-}
-
-
-static void
-goo_canvas_path_view_set_parent_view (GooCanvasItemView *view,
- GooCanvasItemView *parent_view)
-{
- GooCanvasPathView *path_view = (GooCanvasPathView*) view;
- path_view->parent_view = parent_view;
-}
-
-
-static GooCanvasItem*
-goo_canvas_path_view_get_item (GooCanvasItemView *view)
-{
- GooCanvasPathView *path_view = (GooCanvasPathView*) view;
- return (GooCanvasItem*) path_view->path;
-}
-
-
-static GooCanvasBounds*
-goo_canvas_path_view_get_bounds (GooCanvasItemView *view)
-{
- GooCanvasPathView *path_view = (GooCanvasPathView*) view;
-
- if (path_view->need_update)
- goo_canvas_item_view_ensure_updated (view);
-
- return &path_view->bounds;
-}
-
-
-static GooCanvasItemView*
-goo_canvas_path_view_get_item_at (GooCanvasItemView *view,
- gdouble x,
- gdouble y,
- cairo_t *cr,
- gboolean is_pointer_event,
- gboolean parent_visible,
- gdouble scale)
-{
- GooCanvasPathView *path_view = (GooCanvasPathView*) view;
- GooCanvasPath *path = path_view->path;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) path;
- GooCanvasItemView *found_view = NULL;
- double user_x = x, user_y = y;
- GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
-
- if (path_view->need_update)
- goo_canvas_item_view_ensure_updated (view);
-
- if (!path->commands || path->commands->len == 0)
- return NULL;
-
-#if 0
- g_print ("In path_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);
-
- cairo_device_to_user (cr, &user_x, &user_y);
-
- goo_canvas_path_view_create_path (path, cr);
- if (goo_canvas_item_simple_check_in_path (simple, user_x, user_y, cr,
- pointer_events))
- found_view = view;
-
- cairo_restore (cr);
-
- return found_view;
-}
-
-
-static void
-goo_canvas_path_view_compute_bounds (GooCanvasPathView *view,
- cairo_t *cr,
- GooCanvasBounds *bounds)
-{
- GooCanvasPath *path = view->path;
- GooCanvasItemSimple *simple = GOO_CANVAS_ITEM_SIMPLE (path);
-
- goo_canvas_path_view_create_path (path, cr);
- goo_canvas_item_simple_get_path_bounds (simple, cr, bounds);
-
-#if 0
- g_print ("Path view bounds: %g, %g - %g, %g\n",
- bounds->x1, bounds->y1, bounds->x2, bounds->y2);
-#endif
-}
-
-
-static GooCanvasBounds*
-goo_canvas_path_view_update (GooCanvasItemView *view,
- gboolean entire_tree,
- cairo_t *cr)
-{
- GooCanvasPathView *path_view = (GooCanvasPathView*) view;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) path_view->path;
- GooCanvasView *canvas_view;
- GooCanvasBounds *bounds = &path_view->bounds;
-
- if (entire_tree || path_view->need_update)
- {
- path_view->need_update = FALSE;
-
- cairo_save (cr);
- if (simple->transform)
- cairo_transform (cr, simple->transform);
-
- canvas_view = goo_canvas_item_view_get_canvas_view (path_view->parent_view);
-
- /* Request a redraw of the existing bounds. */
- goo_canvas_view_request_redraw (canvas_view, bounds);
-
- /* Compute the new bounds. */
- goo_canvas_path_view_compute_bounds (path_view, cr, bounds);
-
- /* Request a redraw of the new bounds. */
- goo_canvas_view_request_redraw (canvas_view, bounds);
-
- cairo_restore (cr);
- }
-
- return bounds;
-}
-
-
-static void
-goo_canvas_path_view_paint (GooCanvasItemView *view,
- cairo_t *cr,
- GooCanvasBounds *bounds,
- gdouble scale)
-{
- GooCanvasPathView *path_view = (GooCanvasPathView*) view;
- GooCanvasPath *path = path_view->path;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) path;
-
-#if 0
- g_print ("Painting path item %p\n", view);
-#endif
-
- if (!path->commands || path->commands->len == 0)
- return;
-
- /* Check if the item should be visible. */
- if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
- || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
- && scale < simple->visibility_threshold))
- return;
-
- cairo_save (cr);
- if (simple->transform)
- cairo_transform (cr, simple->transform);
-
- goo_canvas_path_view_create_path (path, cr);
- goo_canvas_item_simple_paint_path (simple, cr);
-
- cairo_restore (cr);
-}
-
-
-static void
-canvas_item_view_interface_init (GooCanvasItemViewIface *iface)
-{
- iface->get_parent_view = goo_canvas_path_view_get_parent_view;
- iface->set_parent_view = goo_canvas_path_view_set_parent_view;
- iface->get_item = goo_canvas_path_view_get_item;
- iface->get_bounds = goo_canvas_path_view_get_bounds;
- iface->get_item_at = goo_canvas_path_view_get_item_at;
- iface->update = goo_canvas_path_view_update;
- iface->paint = goo_canvas_path_view_paint;
-}
-
-
-static void
-on_path_changed (GooCanvasPath *path,
- gboolean recompute_bounds,
- GooCanvasPathView *view)
-{
- GooCanvasView *canvas_view;
-
-#if 0
- g_print ("Path changed\n");
-#endif
-
- if (recompute_bounds)
- {
- if (!view->need_update)
- {
- view->need_update = TRUE;
- goo_canvas_item_view_request_update (view->parent_view);
- }
- }
- else
- {
- canvas_view = goo_canvas_item_view_get_canvas_view (view->parent_view);
- goo_canvas_view_request_redraw (canvas_view, &view->bounds);
- }
-}
Index: goocanvaspathview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvaspathview.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvaspathview.h 13 Apr 2006 17:07:44 -0000 1.2
+++ goocanvaspathview.h 16 Apr 2006 13:20:05 -0000 1.3
@@ -8,7 +8,7 @@
#define __GOO_CANVAS_PATH_VIEW_H__
#include <gtk/gtk.h>
-#include "goocanvasitemview.h"
+#include "goocanvasitemviewsimple.h"
#include "goocanvaspath.h"
G_BEGIN_DECLS
@@ -32,24 +32,12 @@
*/
struct _GooCanvasPathView
{
- GObject parent;
-
- /* The parent view. */
- GooCanvasItemView *parent_view;
-
- /* The item in the model. */
- GooCanvasPath *path;
-
- /* The bounds of the item, relative to the entire canvas. */
- GooCanvasBounds bounds;
-
- /* This is TRUE if we need to recompute our bounds & repaint. */
- guint need_update : 1;
+ GooCanvasItemViewSimple parent_object;
};
struct _GooCanvasPathViewClass
{
- GObjectClass parent_class;
+ GooCanvasItemViewSimpleClass parent_class;
};
Index: goocanvaspolylineview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvaspolylineview.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- goocanvaspolylineview.c 13 Apr 2006 17:07:44 -0000 1.7
+++ goocanvaspolylineview.c 16 Apr 2006 13:20:05 -0000 1.8
@@ -33,13 +33,9 @@
void _goo_canvas_polyline_reconfigure_arrows (GooCanvasPolyline *polyline);
static void canvas_item_view_interface_init (GooCanvasItemViewIface *iface);
-static void goo_canvas_polyline_view_finalize (GObject *object);
-static void on_polyline_changed (GooCanvasPolyline *polyline,
- gboolean recompute_bounds,
- GooCanvasPolylineView *view);
G_DEFINE_TYPE_WITH_CODE (GooCanvasPolylineView, goo_canvas_polyline_view,
- G_TYPE_OBJECT,
+ GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE,
G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM_VIEW,
canvas_item_view_interface_init));
@@ -47,18 +43,14 @@
static void
goo_canvas_polyline_view_class_init (GooCanvasPolylineViewClass *klass)
{
- GObjectClass *gobject_class = (GObjectClass*) klass;
- gobject_class->finalize = goo_canvas_polyline_view_finalize;
}
static void
goo_canvas_polyline_view_init (GooCanvasPolylineView *polyline_view)
{
- GooCanvasBounds *bounds = &polyline_view->bounds;
- bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0;
}
@@ -78,14 +70,14 @@
goo_canvas_polyline_view_new (GooCanvasItemView *parent_view,
GooCanvasPolyline *polyline)
{
- GooCanvasPolylineView *view;
+ GooCanvasItemViewSimple *view;
view = g_object_new (GOO_TYPE_CANVAS_POLYLINE_VIEW, NULL);
- view->need_update = TRUE;
view->parent_view = parent_view;
- view->polyline = polyline;
+ view->item = (GooCanvasItemSimple*) polyline;
- g_signal_connect (polyline, "changed", G_CALLBACK (on_polyline_changed),
+ g_signal_connect (polyline, "changed",
+ G_CALLBACK (goo_canvas_item_view_simple_item_changed),
view);
return (GooCanvasItemView*) view;
@@ -93,15 +85,6 @@
static void
-goo_canvas_polyline_view_finalize (GObject *object)
-{
- /*GooCanvasPolylineView *o = (GooCanvasPolylineView*) object;*/
-
- G_OBJECT_CLASS (goo_canvas_polyline_view_parent_class)->finalize (object);
-}
-
-
-static void
goo_canvas_polyline_view_create_path (GooCanvasPolyline *polyline,
cairo_t *cr)
{
@@ -183,43 +166,6 @@
static GooCanvasItemView*
-goo_canvas_polyline_view_get_parent_view (GooCanvasItemView *view)
-{
- GooCanvasPolylineView *polyline_view = (GooCanvasPolylineView*) view;
- return polyline_view->parent_view;
-}
-
-
-static void
-goo_canvas_polyline_view_set_parent_view (GooCanvasItemView *view,
- GooCanvasItemView *parent_view)
-{
- GooCanvasPolylineView *polyline_view = (GooCanvasPolylineView*) view;
- polyline_view->parent_view = parent_view;
-}
-
-
-static GooCanvasItem*
-goo_canvas_polyline_view_get_item (GooCanvasItemView *view)
-{
- GooCanvasPolylineView *polyline_view = (GooCanvasPolylineView*) view;
- return (GooCanvasItem*) polyline_view->polyline;
-}
-
-
-static GooCanvasBounds*
-goo_canvas_polyline_view_get_bounds (GooCanvasItemView *view)
-{
- GooCanvasPolylineView *polyline_view = (GooCanvasPolylineView*) view;
-
- if (polyline_view->need_update)
- goo_canvas_item_view_ensure_updated (view);
-
- return &polyline_view->bounds;
-}
-
-
-static GooCanvasItemView*
goo_canvas_polyline_view_get_item_at (GooCanvasItemView *view,
gdouble x,
gdouble y,
@@ -228,25 +174,21 @@
gboolean parent_visible,
gdouble scale)
{
- GooCanvasPolylineView *polyline_view = (GooCanvasPolylineView*) view;
- GooCanvasPolyline *polyline = polyline_view->polyline;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) polyline;
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasPolyline *polyline = (GooCanvasPolyline*) simple;
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)
+ if (simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE)
goo_canvas_item_view_ensure_updated (view);
if (polyline->num_points == 0)
return NULL;
-#if 0
- 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)
{
@@ -309,10 +251,10 @@
static void
goo_canvas_polyline_view_compute_bounds (GooCanvasPolylineView *view,
+ GooCanvasPolyline *polyline,
cairo_t *cr,
GooCanvasBounds *bounds)
{
- GooCanvasPolyline *polyline = view->polyline;
GooCanvasItemSimple *simple = GOO_CANVAS_ITEM_SIMPLE (polyline);
GooCanvasBounds tmp_bounds;
@@ -351,11 +293,6 @@
bounds->y2 = MAX (bounds->y2, tmp_bounds.y2);
}
}
-
-#if 0
- g_print ("Polyline view bounds: %g, %g - %g, %g\n",
- bounds->x1, bounds->y1, bounds->x2, bounds->y2);
-#endif
}
@@ -364,29 +301,32 @@
gboolean entire_tree,
cairo_t *cr)
{
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
GooCanvasPolylineView *polyline_view = (GooCanvasPolylineView*) view;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) polyline_view->polyline;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasPolyline *polyline = (GooCanvasPolyline*) simple;
GooCanvasView *canvas_view;
- GooCanvasBounds *bounds = &polyline_view->bounds;
+ GooCanvasBounds *bounds = &simple_view->bounds;
- if (entire_tree || polyline_view->need_update)
+ if (entire_tree || (simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE))
{
- polyline_view->need_update = FALSE;
+ simple_view->flags &= ~GOO_CANVAS_ITEM_VIEW_NEED_UPDATE;
- if (polyline_view->polyline->reconfigure_arrows)
- _goo_canvas_polyline_reconfigure_arrows (polyline_view->polyline);
+ if (polyline->reconfigure_arrows)
+ _goo_canvas_polyline_reconfigure_arrows (polyline);
cairo_save (cr);
if (simple->transform)
cairo_transform (cr, simple->transform);
- canvas_view = goo_canvas_item_view_get_canvas_view (polyline_view->parent_view);
+ canvas_view = goo_canvas_item_view_get_canvas_view (simple_view->parent_view);
/* Request a redraw of the existing bounds. */
goo_canvas_view_request_redraw (canvas_view, bounds);
/* Compute the new bounds. */
- goo_canvas_polyline_view_compute_bounds (polyline_view, cr, bounds);
+ goo_canvas_polyline_view_compute_bounds (polyline_view, polyline, cr,
+ bounds);
/* Request a redraw of the new bounds. */
goo_canvas_view_request_redraw (canvas_view, bounds);
@@ -404,13 +344,9 @@
GooCanvasBounds *bounds,
gdouble scale)
{
- GooCanvasPolylineView *polyline_view = (GooCanvasPolylineView*) view;
- GooCanvasPolyline *polyline = polyline_view->polyline;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) polyline;
-
-#if 0
- g_print ("Painting polyline item %p\n", view);
-#endif
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasPolyline *polyline = (GooCanvasPolyline*) simple;
if (polyline->num_points == 0)
return;
@@ -454,38 +390,7 @@
static void
canvas_item_view_interface_init (GooCanvasItemViewIface *iface)
{
- iface->get_parent_view = goo_canvas_polyline_view_get_parent_view;
- iface->set_parent_view = goo_canvas_polyline_view_set_parent_view;
- iface->get_item = goo_canvas_polyline_view_get_item;
- iface->get_bounds = goo_canvas_polyline_view_get_bounds;
iface->get_item_at = goo_canvas_polyline_view_get_item_at;
iface->update = goo_canvas_polyline_view_update;
iface->paint = goo_canvas_polyline_view_paint;
}
-
-
-static void
-on_polyline_changed (GooCanvasPolyline *polyline,
- gboolean recompute_bounds,
- GooCanvasPolylineView *view)
-{
- GooCanvasView *canvas_view;
-
-#if 0
- g_print ("Polyline changed\n");
-#endif
-
- if (recompute_bounds)
- {
- if (!view->need_update)
- {
- view->need_update = TRUE;
- goo_canvas_item_view_request_update (view->parent_view);
- }
- }
- else
- {
- canvas_view = goo_canvas_item_view_get_canvas_view (view->parent_view);
- goo_canvas_view_request_redraw (canvas_view, &view->bounds);
- }
-}
Index: goocanvaspolylineview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvaspolylineview.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- goocanvaspolylineview.h 13 Apr 2006 17:07:44 -0000 1.3
+++ goocanvaspolylineview.h 16 Apr 2006 13:20:05 -0000 1.4
@@ -8,7 +8,7 @@
#define __GOO_CANVAS_POLYLINE_VIEW_H__
#include <gtk/gtk.h>
-#include "goocanvasitemview.h"
+#include "goocanvasitemviewsimple.h"
#include "goocanvaspolyline.h"
G_BEGIN_DECLS
@@ -32,24 +32,12 @@
*/
struct _GooCanvasPolylineView
{
- GObject parent;
-
- /* The parent view. */
- GooCanvasItemView *parent_view;
-
- /* The item in the model. */
- GooCanvasPolyline *polyline;
-
- /* The bounds of the item, relative to the entire canvas. */
- GooCanvasBounds bounds;
-
- /* This is TRUE if we need to recompute our bounds & repaint. */
- guint need_update : 1;
+ GooCanvasItemViewSimple parent_object;
};
struct _GooCanvasPolylineViewClass
{
- GObjectClass parent_class;
+ GooCanvasItemViewSimpleClass parent_class;
};
Index: goocanvasrectview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasrectview.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- goocanvasrectview.c 13 Apr 2006 17:07:44 -0000 1.6
+++ goocanvasrectview.c 16 Apr 2006 13:20:05 -0000 1.7
@@ -28,38 +28,32 @@
#include <math.h>
#include <string.h>
#include <gtk/gtk.h>
-#include "goocanvasview.h"
#include "goocanvasrectview.h"
#include "goocanvasrect.h"
-static void canvas_item_view_interface_init (GooCanvasItemViewIface *iface);
-static void goo_canvas_rect_view_finalize (GObject *object);
-static void on_rect_changed (GooCanvasRect *rect,
- gboolean recompute_bounds,
- GooCanvasRectView *view);
+static void goo_canvas_rect_view_create_path (GooCanvasItemSimple *simple,
+ cairo_t *cr);
G_DEFINE_TYPE_WITH_CODE (GooCanvasRectView, goo_canvas_rect_view,
- G_TYPE_OBJECT,
+ GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE,
G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM_VIEW,
- canvas_item_view_interface_init));
+ NULL));
static void
goo_canvas_rect_view_class_init (GooCanvasRectViewClass *klass)
{
- GObjectClass *gobject_class = (GObjectClass*) klass;
+ GooCanvasItemViewSimpleClass *simple_view_class = (GooCanvasItemViewSimpleClass*) klass;
- gobject_class->finalize = goo_canvas_rect_view_finalize;
+ simple_view_class->create_path = goo_canvas_rect_view_create_path;
}
static void
goo_canvas_rect_view_init (GooCanvasRectView *rect_view)
{
- GooCanvasBounds *bounds = &rect_view->bounds;
- bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0;
}
@@ -79,32 +73,26 @@
goo_canvas_rect_view_new (GooCanvasItemView *parent_view,
GooCanvasRect *rect)
{
- GooCanvasRectView *view;
+ GooCanvasItemViewSimple *view;
view = g_object_new (GOO_TYPE_CANVAS_RECT_VIEW, NULL);
- view->need_update = TRUE;
view->parent_view = parent_view;
- view->rect = rect;
+ view->item = (GooCanvasItemSimple*) rect;
- g_signal_connect (rect, "changed", G_CALLBACK (on_rect_changed), view);
+ g_signal_connect (rect, "changed",
+ G_CALLBACK (goo_canvas_item_view_simple_item_changed),
+ view);
return (GooCanvasItemView*) view;
}
static void
-goo_canvas_rect_view_finalize (GObject *object)
+goo_canvas_rect_view_create_path (GooCanvasItemSimple *simple,
+ cairo_t *cr)
{
- /*GooCanvasRectView *o = (GooCanvasRectView*) object;*/
-
- G_OBJECT_CLASS (goo_canvas_rect_view_parent_class)->finalize (object);
-}
-
+ GooCanvasRect *rect = (GooCanvasRect*) simple;
-static void
-goo_canvas_rect_create_path (GooCanvasRect *rect,
- cairo_t *cr)
-{
cairo_new_path (cr);
/* Check if we need to draw rounded corners. */
@@ -165,203 +153,3 @@
cairo_close_path (cr);
}
}
-
-
-static GooCanvasBounds*
-goo_canvas_rect_view_update (GooCanvasItemView *view,
- gboolean entire_tree,
- cairo_t *cr)
-{
- GooCanvasRectView *rect_view = (GooCanvasRectView*) view;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) rect_view->rect;
- GooCanvasBounds *bounds = &rect_view->bounds;
- GooCanvasView *canvas_view;
-
- if (entire_tree || rect_view->need_update)
- {
- rect_view->need_update = FALSE;
-
- cairo_save (cr);
- if (simple->transform)
- cairo_transform (cr, simple->transform);
-
- canvas_view = goo_canvas_item_view_get_canvas_view (rect_view->parent_view);
-
- /* Request a redraw of the existing bounds. */
- goo_canvas_view_request_redraw (canvas_view, bounds);
-
- /* Compute the new bounds. */
- goo_canvas_rect_create_path (rect_view->rect, cr);
- goo_canvas_item_simple_get_path_bounds (simple, cr, bounds);
-
-#if 0
- g_print ("Rect view bounds: %g, %g - %g, %g\n",
- bounds->x1, bounds->y1, bounds->x2, bounds->y2);
-#endif
-
- /* Request a redraw of the new bounds. */
- goo_canvas_view_request_redraw (canvas_view, bounds);
-
- cairo_restore (cr);
- }
-
- return bounds;
-}
-
-
-static GooCanvasItemView*
-goo_canvas_rect_view_get_parent_view (GooCanvasItemView *view)
-{
- GooCanvasRectView *rect_view = (GooCanvasRectView*) view;
- return rect_view->parent_view;
-}
-
-
-static void
-goo_canvas_rect_view_set_parent_view (GooCanvasItemView *view,
- GooCanvasItemView *parent_view)
-{
- GooCanvasRectView *rect_view = (GooCanvasRectView*) view;
- rect_view->parent_view = parent_view;
-}
-
-
-static GooCanvasItem*
-goo_canvas_rect_view_get_item (GooCanvasItemView *view)
-{
- GooCanvasRectView *rect_view = (GooCanvasRectView*) view;
- return (GooCanvasItem*) rect_view->rect;
-}
-
-
-static GooCanvasBounds*
-goo_canvas_rect_view_get_bounds (GooCanvasItemView *view)
-{
- GooCanvasRectView *rect_view = (GooCanvasRectView*) view;
-
- if (rect_view->need_update)
- goo_canvas_item_view_ensure_updated (view);
-
- return &rect_view->bounds;
-}
-
-
-static GooCanvasItemView*
-goo_canvas_rect_view_get_item_at (GooCanvasItemView *view,
- gdouble x,
- gdouble y,
- 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);
-
- 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,
- pointer_events))
- found_view = view;
-
- cairo_restore (cr);
-
- return found_view;
-}
-
-
-static void
-goo_canvas_rect_view_paint (GooCanvasItemView *view,
- cairo_t *cr,
- GooCanvasBounds *bounds,
- gdouble scale)
-{
- GooCanvasRectView *rect_view = (GooCanvasRectView*) view;
- GooCanvasRect *rect = rect_view->rect;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) rect;
-
-#if 0
- g_print ("Painting rect item %p\n", view);
-#endif
-
- /* Check if the item should be visible. */
- if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
- || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
- && scale < simple->visibility_threshold))
- return;
-
- cairo_save (cr);
- if (simple->transform)
- cairo_transform (cr, simple->transform);
-
- goo_canvas_rect_create_path (rect_view->rect, cr);
- goo_canvas_item_simple_paint_path (simple, cr);
-
- cairo_restore (cr);
-}
-
-
-static void
-canvas_item_view_interface_init (GooCanvasItemViewIface *iface)
-{
- iface->get_parent_view = goo_canvas_rect_view_get_parent_view;
- iface->set_parent_view = goo_canvas_rect_view_set_parent_view;
- iface->get_item = goo_canvas_rect_view_get_item;
- iface->get_bounds = goo_canvas_rect_view_get_bounds;
- iface->get_item_at = goo_canvas_rect_view_get_item_at;
- iface->update = goo_canvas_rect_view_update;
- iface->paint = goo_canvas_rect_view_paint;
-}
-
-
-static void
-on_rect_changed (GooCanvasRect *rect,
- gboolean recompute_bounds,
- GooCanvasRectView *view)
-{
- GooCanvasView *canvas_view;
-
-#if 0
- g_print ("Rect changed\n");
-#endif
-
- if (recompute_bounds)
- {
- if (!view->need_update)
- {
- view->need_update = TRUE;
- goo_canvas_item_view_request_update (view->parent_view);
- }
- }
- else
- {
- canvas_view = goo_canvas_item_view_get_canvas_view (view->parent_view);
- goo_canvas_view_request_redraw (canvas_view, &view->bounds);
- }
-}
Index: goocanvasrectview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasrectview.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasrectview.h 13 Apr 2006 17:07:44 -0000 1.2
+++ goocanvasrectview.h 16 Apr 2006 13:20:05 -0000 1.3
@@ -8,7 +8,7 @@
#define __GOO_CANVAS_RECT_VIEW_H__
#include <gtk/gtk.h>
-#include "goocanvasitemview.h"
+#include "goocanvasitemviewsimple.h"
#include "goocanvasrect.h"
G_BEGIN_DECLS
@@ -32,24 +32,12 @@
*/
struct _GooCanvasRectView
{
- GObject parent;
-
- /* The parent view. */
- GooCanvasItemView *parent_view;
-
- /* The item in the model. */
- GooCanvasRect *rect;
-
- /* The bounds of the item, relative to the entire canvas. */
- GooCanvasBounds bounds;
-
- /* This is TRUE if we need to recompute our bounds & repaint. */
- guint need_update : 1;
+ GooCanvasItemViewSimple parent_object;
};
struct _GooCanvasRectViewClass
{
- GObjectClass parent_class;
+ GooCanvasItemViewSimpleClass parent_class;
};
Index: goocanvastextview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastextview.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- goocanvastextview.c 13 Apr 2006 17:07:44 -0000 1.7
+++ goocanvastextview.c 16 Apr 2006 13:20:05 -0000 1.8
@@ -33,13 +33,9 @@
static void canvas_item_view_interface_init (GooCanvasItemViewIface *iface);
-static void goo_canvas_text_view_finalize (GObject *object);
-static void on_text_changed (GooCanvasText *text,
- gboolean recompute_bounds,
- GooCanvasTextView *view);
G_DEFINE_TYPE_WITH_CODE (GooCanvasTextView, goo_canvas_text_view,
- G_TYPE_OBJECT,
+ GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE,
G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM_VIEW,
canvas_item_view_interface_init));
@@ -47,10 +43,6 @@
static void
goo_canvas_text_view_class_init (GooCanvasTextViewClass *klass)
{
- GObjectClass *gobject_class = (GObjectClass*) klass;
-
- gobject_class->finalize = goo_canvas_text_view_finalize;
-
/* Create the font options once and reuse it. */
klass->font_options = cairo_font_options_create ();
cairo_font_options_set_hint_metrics (klass->font_options,
@@ -63,9 +55,7 @@
static void
goo_canvas_text_view_init (GooCanvasTextView *text_view)
{
- GooCanvasBounds *bounds = &text_view->bounds;
- bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0;
}
@@ -85,34 +75,26 @@
goo_canvas_text_view_new (GooCanvasItemView *parent_view,
GooCanvasText *text)
{
- GooCanvasTextView *view;
+ GooCanvasItemViewSimple *view;
view = g_object_new (GOO_TYPE_CANVAS_TEXT_VIEW, NULL);
- view->need_update = TRUE;
view->parent_view = parent_view;
- view->text = text;
+ view->item = (GooCanvasItemSimple*) text;
- g_signal_connect (text, "changed", G_CALLBACK (on_text_changed), view);
+ g_signal_connect (text, "changed",
+ G_CALLBACK (goo_canvas_item_view_simple_item_changed),
+ view);
return (GooCanvasItemView*) view;
}
-static void
-goo_canvas_text_view_finalize (GObject *object)
-{
- /*GooCanvasTextView *o = (GooCanvasTextView*) object;*/
-
- G_OBJECT_CLASS (goo_canvas_text_view_parent_class)->finalize (object);
-}
-
-
static PangoLayout*
goo_canvas_text_view_create_layout (GooCanvasTextView *text_view,
+ GooCanvasText *text,
cairo_t *cr,
GooCanvasBounds *bounds)
{
- GooCanvasText *text = text_view->text;
PangoLayout *layout;
PangoContext *context;
PangoRectangle logical_rect;
@@ -152,12 +134,6 @@
/* Get size of the text, so we can position it according to anchor. */
pango_layout_get_extents (layout, NULL, &logical_rect);
-#if 0
- g_print ("logical_rect: %i, %i %i x %i\n",
- logical_rect.x, logical_rect.y,
- logical_rect.width, logical_rect.height);
-#endif
-
width = (double) logical_rect.width / PANGO_SCALE;
height = (double) logical_rect.height / PANGO_SCALE;
@@ -207,42 +183,33 @@
gboolean entire_tree,
cairo_t *cr)
{
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
GooCanvasTextView *text_view = (GooCanvasTextView*) view;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) text_view->text;
- GooCanvasBounds *bounds = &text_view->bounds;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasText *text = (GooCanvasText*) simple;
+ GooCanvasBounds *bounds = &simple_view->bounds;
GooCanvasView *canvas_view;
PangoLayout *layout;
- if (entire_tree || text_view->need_update)
+ if (entire_tree || (simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE))
{
- text_view->need_update = FALSE;
+ simple_view->flags &= ~GOO_CANVAS_ITEM_VIEW_NEED_UPDATE;
cairo_save (cr);
if (simple->transform)
cairo_transform (cr, simple->transform);
- canvas_view = goo_canvas_item_view_get_canvas_view (text_view->parent_view);
+ canvas_view = goo_canvas_item_view_get_canvas_view (simple_view->parent_view);
/* Request a redraw of the existing bounds. */
-#if 0
- g_print ("Text view old bounds: %g, %g %g x %g\n",
- bounds->x1, bounds->y1,
- bounds->x2 - bounds->x1, bounds->y2 - bounds->y1);
-#endif
goo_canvas_view_request_redraw (canvas_view, bounds);
/* Compute the new bounds. */
- layout = goo_canvas_text_view_create_layout (text_view, cr, bounds);
+ layout = goo_canvas_text_view_create_layout (text_view, text, cr, bounds);
g_object_unref (layout);
goo_canvas_item_simple_user_bounds_to_device (simple, cr, bounds);
-#if 0
- g_print ("Text view new bounds: %g, %g %g x %g\n",
- bounds->x1, bounds->y1,
- bounds->x2 - bounds->x1, bounds->y2 - bounds->y1);
-#endif
-
/* Request a redraw of the new bounds. */
goo_canvas_view_request_redraw (canvas_view, bounds);
@@ -254,43 +221,6 @@
static GooCanvasItemView*
-goo_canvas_text_view_get_parent_view (GooCanvasItemView *view)
-{
- GooCanvasTextView *text_view = (GooCanvasTextView*) view;
- return text_view->parent_view;
-}
-
-
-static void
-goo_canvas_text_view_set_parent_view (GooCanvasItemView *view,
- GooCanvasItemView *parent_view)
-{
- GooCanvasTextView *text_view = (GooCanvasTextView*) view;
- text_view->parent_view = parent_view;
-}
-
-
-static GooCanvasItem*
-goo_canvas_text_view_get_item (GooCanvasItemView *view)
-{
- GooCanvasTextView *text_view = (GooCanvasTextView*) view;
- return (GooCanvasItem*) text_view->text;
-}
-
-
-static GooCanvasBounds*
-goo_canvas_text_view_get_bounds (GooCanvasItemView *view)
-{
- GooCanvasTextView *text_view = (GooCanvasTextView*) view;
-
- if (text_view->need_update)
- goo_canvas_item_view_ensure_updated (view);
-
- return &text_view->bounds;
-}
-
-
-static GooCanvasItemView*
goo_canvas_text_view_get_item_at (GooCanvasItemView *view,
gdouble x,
gdouble y,
@@ -299,8 +229,10 @@
gboolean parent_visible,
gdouble scale)
{
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
GooCanvasTextView *text_view = (GooCanvasTextView*) view;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) text_view->text;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasText *text = (GooCanvasText*) simple;
GooCanvasItemView *found_view = NULL;
PangoLayout *layout;
GooCanvasBounds bounds;
@@ -309,7 +241,7 @@
int px, py;
double user_x = x, user_y = y;
- if (text_view->need_update)
+ if (simple_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE)
goo_canvas_item_view_ensure_updated (view);
/* Check if the item should receive events. */
@@ -338,17 +270,12 @@
cairo_device_to_user (cr, &user_x, &user_y);
- layout = goo_canvas_text_view_create_layout (text_view, cr, &bounds);
+ layout = goo_canvas_text_view_create_layout (text_view, text, cr, &bounds);
/* Convert the coordinates into Pango units. */
px = (user_x - bounds.x1) * PANGO_SCALE;
py = (user_y - bounds.y1) * PANGO_SCALE;
-#if 0
- g_print ("\nIn get_item_at %g, %g -> %i, %i (bounds %g, %g)\n",
- 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);
@@ -356,16 +283,9 @@
{
pango_layout_iter_get_line_extents (iter, NULL, &log_rect);
-#if 0
- g_print (" line rect %i, %i - %i x %i\n", log_rect.x, log_rect.y,
- log_rect.x + log_rect.width, log_rect.y + log_rect.height);
-#endif
if (px >= log_rect.x && px < log_rect.x + log_rect.width
&& py >= log_rect.y && py < log_rect.y + log_rect.height)
{
-#if 0
- g_print (" ** found **\n");
-#endif
found_view = view;
break;
}
@@ -388,9 +308,10 @@
GooCanvasBounds *bounds,
gdouble scale)
{
+ GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
GooCanvasTextView *text_view = (GooCanvasTextView*) view;
- GooCanvasText *text = text_view->text;
- GooCanvasItemSimple *simple = (GooCanvasItemSimple*) text;
+ GooCanvasItemSimple *simple = simple_view->item;
+ GooCanvasText *text = (GooCanvasText*) simple;
PangoLayout *layout;
GooCanvasBounds layout_bounds;
@@ -398,10 +319,6 @@
if (!text->text || !text->text[0])
return;
-#if 0
- g_print ("Painting text item %p\n", view);
-#endif
-
/* Check if the item should be visible. */
if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
|| (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
@@ -420,19 +337,12 @@
goo_canvas_item_simple_set_fill_options (simple, cr);
cairo_new_path (cr);
- layout = goo_canvas_text_view_create_layout (text_view, cr, &layout_bounds);
+ layout = goo_canvas_text_view_create_layout (text_view, text, cr,
+ &layout_bounds);
cairo_move_to (cr, layout_bounds.x1, layout_bounds.y1);
pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
-#if 0
- cairo_rectangle (cr, layout_bounds.x1, layout_bounds.y1,
- layout_bounds.x2 - layout_bounds.x1,
- layout_bounds.y2 - layout_bounds.y1);
- cairo_set_line_width (cr, 1.0);
- cairo_stroke (cr);
-#endif
-
cairo_restore (cr);
}
@@ -440,38 +350,7 @@
static void
canvas_item_view_interface_init (GooCanvasItemViewIface *iface)
{
- iface->get_parent_view = goo_canvas_text_view_get_parent_view;
- iface->set_parent_view = goo_canvas_text_view_set_parent_view;
- iface->get_item = goo_canvas_text_view_get_item;
- iface->get_bounds = goo_canvas_text_view_get_bounds;
iface->get_item_at = goo_canvas_text_view_get_item_at;
iface->update = goo_canvas_text_view_update;
iface->paint = goo_canvas_text_view_paint;
}
-
-
-static void
-on_text_changed (GooCanvasText *text,
- gboolean recompute_bounds,
- GooCanvasTextView *view)
-{
- GooCanvasView *canvas_view;
-
-#if 0
- g_print ("Text changed\n");
-#endif
-
- if (recompute_bounds)
- {
- if (!view->need_update)
- {
- view->need_update = TRUE;
- goo_canvas_item_view_request_update (view->parent_view);
- }
- }
- else
- {
- canvas_view = goo_canvas_item_view_get_canvas_view (view->parent_view);
- goo_canvas_view_request_redraw (canvas_view, &view->bounds);
- }
-}
Index: goocanvastextview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastextview.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- goocanvastextview.h 13 Apr 2006 17:07:44 -0000 1.3
+++ goocanvastextview.h 16 Apr 2006 13:20:05 -0000 1.4
@@ -8,7 +8,7 @@
#define __GOO_CANVAS_TEXT_VIEW_H__
#include <gtk/gtk.h>
-#include "goocanvasitemview.h"
+#include "goocanvasitemviewsimple.h"
#include "goocanvastext.h"
G_BEGIN_DECLS
@@ -32,24 +32,12 @@
*/
struct _GooCanvasTextView
{
- GObject parent;
-
- /* The parent view. */
- GooCanvasItemView *parent_view;
-
- /* The item in the model. */
- GooCanvasText *text;
-
- /* The bounds of the item, relative to the entire canvas. */
- GooCanvasBounds bounds;
-
- /* This is TRUE if we need to recompute our bounds & repaint. */
- guint need_update : 1;
+ GooCanvasItemViewSimple parent_object;
};
struct _GooCanvasTextViewClass
{
- GObjectClass parent_class;
+ GooCanvasItemViewSimpleClass parent_class;
/* The font options we always use. */
cairo_font_options_t *font_options;
Index: goocanvasview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- goocanvasview.c 16 Apr 2006 10:39:51 -0000 1.10
+++ goocanvasview.c 16 Apr 2006 13:20:05 -0000 1.11
@@ -545,11 +545,6 @@
if (redraw_if_needed)
gtk_widget_queue_draw (GTK_WIDGET (view));
}
-
-#if 0
- g_print ("window x,y: %i, %i offsets x,y: %i, %i\n",
- window_x, window_y, view->canvas_x_offset, view->canvas_y_offset);
-#endif
}
@@ -796,12 +791,6 @@
reconfigure_canvas (view, FALSE);
/* Convert from the center point to the new desired top-left posision. */
-#if 0
- g_print ("Old center %g, %g new: %g, %g\n", x, y,
- x - view->hadjustment->page_size / view->scale / 2,
- y - view->vadjustment->page_size / view->scale / 2);
-#endif
-
x -= view->hadjustment->page_size / view->scale / 2;
y -= view->vadjustment->page_size / view->scale / 2;
@@ -994,13 +983,6 @@
rect.x += view->canvas_x_offset;
rect.y += view->canvas_y_offset;
-#if 0
- g_print ("Redraw request pixels: %i, %i %i x %i <- bounds: %g, %g %g x %g\n",
- rect.x, rect.y, rect.width, rect.height,
- bounds->x1, bounds->y1,
- bounds->x2 - bounds->x1, bounds->y2 - bounds->y1);
-#endif
-
gdk_window_invalidate_rect (view->canvas_window, &rect, FALSE);
}
@@ -1033,19 +1015,6 @@
bounds.x2 = (event->area.width / view->scale) + bounds.x1;
bounds.y2 = (event->area.height / view->scale) + bounds.y1;
-#if 0
- g_print ("In expose_event pixels: %i, %i %i x %i -> bounds: %g, %g %g x %g\n",
- event->area.x, event->area.y,
- event->area.width, event->area.height,
- bounds.x1, bounds.y1, bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
-#endif
-
-#if 0
- cairo_rectangle (cr, event->area.x + 0.5, event->area.y + 0.5,
- event->area.width, event->area.height);
- cairo_stroke (cr);
-#endif
-
/* Translate it to use the canvas pixel offsets. */
cairo_translate (cr, view->canvas_x_offset, view->canvas_y_offset);
@@ -1173,9 +1142,6 @@
while (ancestor)
{
-#if 0
- g_print ("Emitting '%s' event for item: %p\n", signal_name, ancestor);
-#endif
parent = goo_canvas_item_view_get_parent_view (ancestor);
g_signal_emit_by_name (ancestor, signal_name, item_view, event,
@@ -1191,26 +1157,6 @@
}
-#if 0
-/* Returns TRUE if item_view is parent_view or a descendant of it. */
-static gboolean
-is_descendant (GooCanvasItemView *item_view, GooCanvasItemView *parent_view)
-{
- GooCanvasItemView *view = item_view;
-
- while (view)
- {
- if (view == parent_view)
- return TRUE;
-
- view = goo_canvas_item_view_get_parent_view (view);
- }
-
- return FALSE;
-}
-#endif
-
-
/* This is called to emit pointer events - enter/leave notify, motion notify,
and button press/release. */
static gboolean
@@ -1260,8 +1206,6 @@
break;
}
- /*g_print ("Pointer event %g, %g", *x, *y);*/
-
/* Add 0.5 to the pixel coordinates so we use the center of the pixel. */
*x += 0.5;
*y += 0.5;
@@ -1276,8 +1220,6 @@
/* Convert to the item's coordinate space. */
goo_canvas_view_convert_to_item_space (view, target_item_view, x, y);
- /*g_print (" -> %g, %g\n", *x, *y);*/
-
return propagate_event (view, target_item_view, signal_name, &event);
}
More information about the cairo-commit
mailing list