[cairo-commit] goocanvas/src goocanvasgroup.c, 1.10, 1.11 goocanvasgroupview.c, 1.16, 1.17 goocanvasgroupview.h, 1.3, 1.4 goocanvasimageview.c, 1.13, 1.14 goocanvasitemview.c, 1.12, 1.13 goocanvasitemview.h, 1.11, 1.12 goocanvasitemviewsimple.c, 1.8, 1.9 goocanvasitemviewsimple.h, 1.4, 1.5 goocanvaspolylineview.c, 1.14, 1.15 goocanvastextview.c, 1.15, 1.16 goocanvasview.c, 1.25, 1.26

Damon Chaplin commit at pdx.freedesktop.org
Wed Jul 26 08:08:21 PDT 2006


Committed by: damon

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

Modified Files:
	goocanvasgroup.c goocanvasgroupview.c goocanvasgroupview.h 
	goocanvasimageview.c goocanvasitemview.c goocanvasitemview.h 
	goocanvasitemviewsimple.c goocanvasitemviewsimple.h 
	goocanvaspolylineview.c goocanvastextview.c goocanvasview.c 
Log Message:
2006-07-26  Damon Chaplin  <damon at gnome.org>

	* src/goocanvas*view.c: support an optional transformation matrix for
	each view, which is combined with the underlying item's transform.
	(I'm not sure if this will overcomplicate things.)

	* src/goocanvasgroupview.c: support generic GooCanvasItems as the
	underlying group rather than just GooCanvasGroups. This allows us to
	use subclasses of GooCanvasGroupView easily.
	(goo_canvas_group_view_set_group): new function to set the underlying
	group item, creating child views and setting up signal handlers etc.



Index: goocanvasgroup.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroup.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- goocanvasgroup.c	19 Jul 2006 13:38:13 -0000	1.10
+++ goocanvasgroup.c	26 Jul 2006 15:08:19 -0000	1.11
@@ -285,9 +285,7 @@
 			      GooCanvasView     *canvas_view,
 			      GooCanvasItemView *parent_view)
 {
-  GooCanvasGroup *group = GOO_CANVAS_GROUP (group_item);
-
-  return goo_canvas_group_view_new (canvas_view, parent_view, group);
+  return goo_canvas_group_view_new (canvas_view, parent_view, group_item);
 }
 
 

Index: goocanvasgroupview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroupview.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- goocanvasgroupview.c	21 Jul 2006 10:30:30 -0000	1.16
+++ goocanvasgroupview.c	26 Jul 2006 15:08:19 -0000	1.17
@@ -8,9 +8,10 @@
 /**
  * SECTION:goocanvasgroupview
  * @Title: GooCanvasGroupView
- * @Short_Description: a view for a #GooCanvasGroup item.
+ * @Short_Description: a view for a group #GooCanvasItem.
  *
- * #GooCanvasGroupView represents a view of a #GooCanvasGroup item.
+ * #GooCanvasGroupView represents a view of a group #GooCanvasItem (typically
+ * a #GooCanvasGroup).
  *
  * It implements the #GooCanvasItemView interface, so you can use the
  * #GooCanvasItemView functions such as goo_canvas_item_view_get_item()
@@ -53,7 +54,7 @@
 						GParamSpec           *pspec);
 static void add_child_views_recursively     (GooCanvasGroupView   *group_view);
 static void connect_group_signals           (GooCanvasGroupView   *group_view);
-static void on_group_changed                (GooCanvasGroup       *group,
+static void on_group_changed                (GooCanvasItem        *group,
 					     gboolean              recompute_bounds,
 					     GooCanvasGroupView   *view);
 
@@ -93,60 +94,77 @@
 
 
 static void
-goo_canvas_group_view_title_changed (GooCanvasGroup     *group,
+goo_canvas_group_view_title_changed (GooCanvasItem      *group,
 				     GParamSpec         *pspec,
 				     GooCanvasGroupView *group_view)
 {
   AtkObject *accessible;
+  gchar *title;
 
   accessible = atk_gobject_accessible_for_object (G_OBJECT (group_view));
-  atk_object_set_name (accessible, group->title);
+  g_object_get (group, "title", &title, NULL);
+  atk_object_set_name (accessible, title);
+  g_free (title);
 }
 
 
 static void
-goo_canvas_group_view_description_changed (GooCanvasGroup     *group,
+goo_canvas_group_view_description_changed (GooCanvasItem      *group,
 					   GParamSpec         *pspec,
 					   GooCanvasGroupView *group_view)
 {
   AtkObject *accessible;
+  gchar *description;
 
   accessible = atk_gobject_accessible_for_object (G_OBJECT (group_view));
-  atk_object_set_description (accessible, group->description);
+  g_object_get (group, "description", &description, NULL);
+  atk_object_set_description (accessible, description);
+  g_free (description);
 }
 
 
 /**
- * goo_canvas_group_view_new:
- * @canvas_view: the canvas view.
- * @parent_view: the parent view.
- * @group: the group item.
+ * goo_canvas_group_view_set_group:
+ * @group_view: a #GooCanvasGroupView.
+ * @group: a #GooCanvasItem.
  * 
- * Creates a new #GooCanvasGroupView for the given #GooCanvasGroup item.
+ * This function is only intended to be used by subclasses during construction
+ * of the item views.
  *
- * This is not normally used by application code, as the views are created
- * automatically by #GooCanvasView.
- * 
- * Returns: a new #GooCanvasGroupView.
+ * It sets the underlying group item, creates any necessary child views, and
+ * sets up signal handlers to update child views as the underlying items
+ * are changed.
  **/
-GooCanvasItemView*
-goo_canvas_group_view_new      (GooCanvasView     *canvas_view,
-				GooCanvasItemView *parent_view,
-				GooCanvasGroup    *group)
+void
+goo_canvas_group_view_set_group (GooCanvasGroupView *group_view,
+				 GooCanvasItem      *group)
 {
-  GooCanvasGroupView *group_view;
   AtkObject *accessible;
+  gchar *title, *description;
+
+  if (group_view->group)
+    {
+      g_signal_handlers_disconnect_matched (group_view->group,
+					    G_SIGNAL_MATCH_DATA,
+					    0, 0, NULL, NULL, group_view);
+
+      g_object_unref (group_view->group);
+    }
 
-  group_view = GOO_CANVAS_GROUP_VIEW (g_object_new (GOO_TYPE_CANVAS_GROUP_VIEW, NULL));
-  group_view->canvas_view = canvas_view;
-  group_view->parent_view = parent_view;
   group_view->group = g_object_ref (group);
 
+  g_object_get (group,
+		"title", &title,
+		"description", &description,
+		NULL);
+
   accessible = atk_gobject_accessible_for_object (G_OBJECT (group_view));
-  if (group->title)
-    atk_object_set_name (accessible, group->title);
-  if (group->description)
-    atk_object_set_description (accessible, group->description);
+  if (title)
+    atk_object_set_name (accessible, title);
+  if (description)
+    atk_object_set_description (accessible, description);
+  g_free (title);
+  g_free (description);
 
   g_signal_connect (group, "notify::title",
 		    G_CALLBACK (goo_canvas_group_view_title_changed),
@@ -160,6 +178,35 @@
 
   g_signal_connect (group, "changed", G_CALLBACK (on_group_changed),
 		    group_view);
+}
+
+
+/**
+ * goo_canvas_group_view_new:
+ * @canvas_view: the canvas view.
+ * @parent_view: the parent view.
+ * @group: the group item.
+ * 
+ * Creates a new #GooCanvasGroupView for the given #GooCanvasItem.
+ *
+ * This is not normally used by application code, as the views are created
+ * automatically by #GooCanvasView.
+ * 
+ * Returns: a new #GooCanvasGroupView.
+ **/
+GooCanvasItemView*
+goo_canvas_group_view_new      (GooCanvasView     *canvas_view,
+				GooCanvasItemView *parent_view,
+				GooCanvasItem     *group)
+{
+  GooCanvasGroupView *group_view;
+
+  group_view = g_object_new (GOO_TYPE_CANVAS_GROUP_VIEW, NULL);
+
+  group_view->canvas_view = canvas_view;
+  group_view->parent_view = parent_view;
+
+  goo_canvas_group_view_set_group (group_view, group);
 
   return GOO_CANVAS_ITEM_VIEW (group_view);
 }
@@ -234,7 +281,7 @@
 
 
 static void
-on_child_item_added (GooCanvasGroup     *group,
+on_child_item_added (GooCanvasItem      *group,
 		     gint                position,
 		     GooCanvasGroupView *group_view)
 {
@@ -242,7 +289,7 @@
   GooCanvasItemView *view;
 
   /* Get a view for the item. */
-  item = group->items->pdata[position];
+  item = goo_canvas_item_get_child (group, position);
   view = goo_canvas_view_create_item_view (group_view->canvas_view, item,
 					   (GooCanvasItemView*) group_view);
 
@@ -256,7 +303,7 @@
 
 
 static void
-on_child_item_moved (GooCanvasGroup     *group,
+on_child_item_moved (GooCanvasItem      *group,
 		     gint                old_position,
 		     gint                new_position,
 		     GooCanvasGroupView *group_view)
@@ -277,7 +324,7 @@
 
 
 static void
-on_child_item_removed (GooCanvasGroup     *group,
+on_child_item_removed (GooCanvasItem      *group,
 		       gint                item_num,
 		       GooCanvasGroupView *group_view)
 {
@@ -303,9 +350,11 @@
 static void
 add_child_views_recursively (GooCanvasGroupView *group_view)
 {
-  gint i;
+  gint n_children, i;
 
-  for (i = 0; i < group_view->group->items->len; i++)
+  n_children = goo_canvas_item_get_n_children (group_view->group);
+
+  for (i = 0; i < n_children; i++)
     {
       on_child_item_added (group_view->group, i, group_view);
     }
@@ -315,7 +364,7 @@
 static void
 connect_group_signals (GooCanvasGroupView *group_view)
 {
-  GooCanvasGroup *group = group_view->group;
+  GooCanvasItem *group = group_view->group;
 
   g_signal_connect (group, "child-added", G_CALLBACK (on_child_item_added),
 		    group_view);
@@ -376,6 +425,7 @@
 {
   GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
   GooCanvasBounds child_bounds;
+  cairo_matrix_t transform;
   gint i;
 
   if (entire_tree || (group_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE))
@@ -389,7 +439,10 @@
       bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0.0;
 
       cairo_save (cr);
-      cairo_transform (cr, &group_view->group->transform);
+
+      if (goo_canvas_item_view_get_combined_transform (view, &transform))
+	cairo_transform (cr, &transform);
+
       for (i = 0; i < group_view->item_views->len; i++)
 	{
 	  GooCanvasItemView *child_view = group_view->item_views->pdata[i];
@@ -470,33 +523,51 @@
 					gboolean            parent_visible)
 {
   GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
-  GooCanvasGroup *group = group_view->group;
   GooCanvasBounds child_bounds;
   GooCanvasItemView *found_item = NULL;
+  GooCanvasItemVisibility visibility;
   gboolean visible = parent_visible;
+  cairo_matrix_t transform;
   int i;
 
   if (group_view->flags & GOO_CANVAS_ITEM_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
-	  && group_view->canvas_view->scale < group->visibility_threshold))
-    visible = FALSE;
+  g_object_get (group_view->group, "visibility", &visibility, NULL);
+
+  if (visibility == GOO_CANVAS_ITEM_INVISIBLE)
+    {
+      visible = FALSE;
+    }
+  else if (visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD)
+    {
+      gdouble visibility_threshold;
+      g_object_get (group_view->group,
+		    "visibility-threshold", &visibility_threshold,
+		    NULL);
+      if (group_view->canvas_view->scale < 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))
+      GooCanvasPointerEvents pointer_events;
+      g_object_get (group_view->group,
+		    "pointer-events", &pointer_events,
+		    NULL);
+      if (pointer_events == GOO_CANVAS_EVENTS_NONE
+	  || ((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);
-  cairo_transform (cr, &group_view->group->transform);
+
+  if (goo_canvas_item_view_get_combined_transform (view, &transform))
+    cairo_transform (cr, &transform);
+
   for (i = group_view->item_views->len - 1; i >= 0; i--)
     {
       GooCanvasItemView *child_view = group_view->item_views->pdata[i];
@@ -523,13 +594,23 @@
 goo_canvas_group_view_is_visible  (GooCanvasItemView   *view)
 {
   GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
-  GooCanvasGroup *group = group_view->group;
+  GooCanvasItemVisibility visibility;
 
-  if (group->visibility == GOO_CANVAS_ITEM_INVISIBLE
-      || (group->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
-	  && group_view->canvas_view->scale < group->visibility_threshold))
+  g_object_get (group_view->group, "visibility", &visibility, NULL);
+
+  if (visibility == GOO_CANVAS_ITEM_INVISIBLE)
     return FALSE;
 
+  if (visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD)
+    {
+      gdouble visibility_threshold;
+      g_object_get (group_view->group,
+		    "visibility-threshold", &visibility_threshold,
+		    NULL);
+      if (group_view->canvas_view->scale < visibility_threshold)
+	return FALSE;
+    }
+
   if (group_view->parent_view)
     return goo_canvas_item_view_is_visible (group_view->parent_view);
 
@@ -544,19 +625,33 @@
 			     gdouble            scale)
 {
   GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
-  GooCanvasGroup *group = group_view->group;
   GooCanvasBounds child_bounds;
+  GooCanvasItemVisibility visibility;
+  cairo_matrix_t transform;
   gint i;
 
   /* Check if the item should be visible. */
-  if (group->visibility == GOO_CANVAS_ITEM_INVISIBLE
-      || (group->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
-	  && scale < group->visibility_threshold))
+  g_object_get (group_view->group, "visibility", &visibility, NULL);
+
+  if (visibility == GOO_CANVAS_ITEM_INVISIBLE)
     return;
 
+  if (visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD)
+    {
+      gdouble visibility_threshold;
+      g_object_get (group_view->group,
+		    "visibility-threshold", &visibility_threshold,
+		    NULL);
+      if (group_view->canvas_view->scale < visibility_threshold)
+	return;
+    }
+
   /* Paint all the items in the group. */
   cairo_save (cr);
-  cairo_transform (cr, &group->transform);
+
+  if (goo_canvas_item_view_get_combined_transform (view, &transform))
+    cairo_transform (cr, &transform);
+
   for (i = 0; i < group_view->item_views->len; i++)
     {
       GooCanvasItemView *child_view = group_view->item_views->pdata[i];
@@ -594,10 +689,10 @@
 
 
 static void
-on_group_changed                (GooCanvasGroup     *group,
+on_group_changed                (GooCanvasItem      *group,
 				 gboolean            recompute_bounds,
 				 GooCanvasGroupView *view)
 {
   view->flags |= GOO_CANVAS_ITEM_VIEW_NEED_ENTIRE_SUBTREE_UPDATE;
-  goo_canvas_group_view_request_update ((GooCanvasItemView*) view);
+  goo_canvas_item_view_request_update ((GooCanvasItemView*) view);
 }

Index: goocanvasgroupview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroupview.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- goocanvasgroupview.h	18 Apr 2006 15:43:07 -0000	1.3
+++ goocanvasgroupview.h	26 Jul 2006 15:08:19 -0000	1.4
@@ -41,7 +41,7 @@
   GooCanvasItemView *parent_view;
 
   /* The corresponding group item. */
-  GooCanvasGroup *group;
+  GooCanvasItem *group;
 
   /* An array of pointers to GooCanvasItemViews, corresponding exactly to
      the items in the model. */
@@ -63,8 +63,11 @@
 GType              goo_canvas_group_view_get_type (void) G_GNUC_CONST;
 GooCanvasItemView* goo_canvas_group_view_new      (GooCanvasView     *canvas_view,
 						   GooCanvasItemView *parent_view,
-						   GooCanvasGroup    *group);
+						   GooCanvasItem     *group);
 
+/* For subclass construction functions. */
+void   goo_canvas_group_view_set_group (GooCanvasGroupView *group_view,
+					GooCanvasItem      *group);
 
 G_END_DECLS
 

Index: goocanvasimageview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasimageview.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- goocanvasimageview.c	21 Jul 2006 10:30:30 -0000	1.13
+++ goocanvasimageview.c	26 Jul 2006 15:08:19 -0000	1.14
@@ -120,8 +120,11 @@
     }
 
   cairo_save (cr);
+
   if (simple->transform)
     cairo_transform (cr, simple->transform);
+  if (simple_view->transform)
+    cairo_transform (cr, simple_view->transform);
 
   cairo_device_to_user (cr, &user_x, &user_y);
 
@@ -153,6 +156,8 @@
       cairo_save (cr);
       if (simple->transform)
 	cairo_transform (cr, simple->transform);
+      if (simple_view->transform)
+	cairo_transform (cr, simple_view->transform);
 
       canvas_view = goo_canvas_item_view_get_canvas_view (simple_view->parent_view);
 
@@ -200,6 +205,8 @@
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
+  if (simple_view->transform)
+    cairo_transform (cr, simple_view->transform);
 
   goo_canvas_item_simple_set_fill_options (simple, cr);
   cairo_set_source (cr, image->pattern);

Index: goocanvasitemview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemview.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- goocanvasitemview.c	21 Jul 2006 10:30:30 -0000	1.12
+++ goocanvasitemview.c	26 Jul 2006 15:08:19 -0000	1.13
@@ -385,6 +385,89 @@
 
 
 /**
+ * goo_canvas_item_view_get_transform:
+ * @view: a #GooCanvasItemView.
+ * 
+ * Gets the transformation matrix of an item view.
+ * 
+ * Returns: the item view's transformation matrix.
+ **/
+cairo_matrix_t*
+goo_canvas_item_view_get_transform  (GooCanvasItemView *view)
+{
+  GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
+
+  /* If the item view implements get_transform() use that. */
+  return iface->get_transform ? iface->get_transform (view) : NULL;
+}
+
+
+/**
+ * goo_canvas_item_view_set_transform:
+ * @view: a #GooCanvasItemView.
+ * @matrix: the new transformation matrix, or %NULL to reset the
+ *  transformation to the identity matrix.
+ * 
+ * Sets the transformation matrix of an item view.
+ **/
+void
+goo_canvas_item_view_set_transform  (GooCanvasItemView *view,
+				     cairo_matrix_t    *matrix)
+{
+  GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
+
+  if (iface->set_transform)
+    iface->set_transform (view, matrix);
+  else
+    g_warning ("The %s class doesn't support the set_transform method",
+	       G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (view)));
+}
+
+
+/**
+ * goo_canvas_item_view_get_combined_transform:
+ * @view: a #GooCanvasItemView.
+ * @result: the matrix to store the resulting transform in.
+ * 
+ * Gets the total transformation matrix of an item view, which is a combination
+ * of the item's transformation and the item view's transformation.
+ * 
+ * Returns: TRUE if there is a transformation.
+ **/
+gboolean
+goo_canvas_item_view_get_combined_transform  (GooCanvasItemView *view,
+					      cairo_matrix_t    *result)
+{
+  GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
+  cairo_matrix_t *view_transform, *item_transform;
+
+  view_transform = iface->get_transform ? iface->get_transform (view) : NULL;
+  item_transform = goo_canvas_item_get_transform (iface->get_item (view));
+
+  if (view_transform && item_transform)
+    {
+      /* The item transform is applied before the view transform. */
+      cairo_matrix_multiply (result, item_transform, view_transform);
+    }
+  else if (view_transform)
+    {
+      *result = *view_transform;
+    }
+  else if (item_transform)
+    {
+      *result = *item_transform;
+    }
+  else
+    {
+      cairo_matrix_init_identity (result);
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+
+/**
  * goo_canvas_item_view_get_n_children:
  * @view: a #GooCanvasItemView.
  * 

Index: goocanvasitemview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemview.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- goocanvasitemview.h	21 Jul 2006 10:30:30 -0000	1.11
+++ goocanvasitemview.h	26 Jul 2006 15:08:19 -0000	1.12
@@ -56,6 +56,11 @@
   GooCanvasItemView*   (* get_parent_view)  (GooCanvasItemView   *view);
   void                 (* set_parent_view)  (GooCanvasItemView   *view,
 					     GooCanvasItemView   *parent_view);
+
+  cairo_matrix_t*      (* get_transform)    (GooCanvasItemView   *view);
+  void                 (* set_transform)    (GooCanvasItemView   *view,
+					     cairo_matrix_t      *matrix);
+
   GooCanvasItem*       (* get_item)	    (GooCanvasItemView   *view);
   void                 (* get_bounds)	    (GooCanvasItemView   *view,
 					     GooCanvasBounds     *bounds);
@@ -131,6 +136,12 @@
 							 GooCanvasItemView  *parent_view);
 gboolean           goo_canvas_item_view_is_container    (GooCanvasItemView *view);
 
+cairo_matrix_t*    goo_canvas_item_view_get_transform   (GooCanvasItemView *view);
+void               goo_canvas_item_view_set_transform   (GooCanvasItemView *view,
+							 cairo_matrix_t    *matrix);
+gboolean           goo_canvas_item_view_get_combined_transform (GooCanvasItemView *view,
+								cairo_matrix_t    *result);
+
 GooCanvasItem*     goo_canvas_item_view_get_item    (GooCanvasItemView  *view);
 void               goo_canvas_item_view_get_bounds  (GooCanvasItemView  *view,
 						     GooCanvasBounds    *bounds);

Index: goocanvasitemviewsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemviewsimple.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- goocanvasitemviewsimple.c	21 Jul 2006 10:30:30 -0000	1.8
+++ goocanvasitemviewsimple.c	26 Jul 2006 15:08:19 -0000	1.9
@@ -87,6 +87,9 @@
   g_object_unref (simple_view->item);
   simple_view->item = NULL;
 
+  if (simple_view->transform)
+    g_free (simple_view->transform);
+
   G_OBJECT_CLASS (goo_canvas_item_view_simple_parent_class)->finalize (object);
 }
 
@@ -160,6 +163,56 @@
 }
 
 
+static cairo_matrix_t*
+goo_canvas_item_view_simple_get_transform (GooCanvasItemView       *view)
+{
+  return GOO_CANVAS_ITEM_VIEW_SIMPLE (view)->transform;
+}
+
+
+static void
+goo_canvas_item_view_simple_request_update (GooCanvasItemViewSimple *simple_view,
+					    gboolean                 recompute_bounds)
+{
+  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
+    {
+      goo_canvas_view_request_redraw (simple_view->canvas_view,
+				      &simple_view->bounds);
+    }
+}
+
+
+static void
+goo_canvas_item_view_simple_set_transform (GooCanvasItemView *view,
+					   cairo_matrix_t *transform)
+{
+  GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
+
+  if (transform)
+    {
+      if (!simple_view->transform)
+	simple_view->transform = g_new (cairo_matrix_t, 1);
+
+      *simple_view->transform = *transform;
+    }
+  else
+    {
+      g_free (simple_view->transform);
+      simple_view->transform = NULL;
+    }
+
+  goo_canvas_item_view_simple_request_update (simple_view, TRUE);
+}
+
+
 static void
 goo_canvas_item_view_simple_get_bounds  (GooCanvasItemView   *view,
 					 GooCanvasBounds     *bounds)
@@ -208,6 +261,8 @@
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
+  if (simple_view->transform)
+    cairo_transform (cr, simple_view->transform);
 
   cairo_device_to_user (cr, &user_x, &user_y);
 
@@ -258,6 +313,8 @@
       cairo_save (cr);
       if (simple->transform)
 	cairo_transform (cr, simple->transform);
+      if (simple_view->transform)
+	cairo_transform (cr, simple_view->transform);
 
       /* Request a redraw of the existing bounds. */
       goo_canvas_view_request_redraw (simple_view->canvas_view,
@@ -297,6 +354,8 @@
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
+  if (simple_view->transform)
+    cairo_transform (cr, simple_view->transform);
 
   /* Use the virtual method subclasses define to create the path. */
   GOO_CANVAS_ITEM_VIEW_SIMPLE_GET_CLASS (view)->create_path (simple, cr);
@@ -313,6 +372,8 @@
   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_transform    = goo_canvas_item_view_simple_get_transform;
+  iface->set_transform    = goo_canvas_item_view_simple_set_transform;
   iface->get_bounds       = goo_canvas_item_view_simple_get_bounds;
   iface->get_item_view_at = goo_canvas_item_view_simple_get_item_view_at;
   iface->is_visible       = goo_canvas_item_view_simple_is_visible;
@@ -338,21 +399,7 @@
 					  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);
-    }
+  goo_canvas_item_view_simple_request_update (simple_view, recompute_bounds);
 }
 
 

Index: goocanvasitemviewsimple.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemviewsimple.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvasitemviewsimple.h	24 Apr 2006 13:53:42 -0000	1.4
+++ goocanvasitemviewsimple.h	26 Jul 2006 15:08:19 -0000	1.5
@@ -55,6 +55,9 @@
   /* The item in the model. */
   GooCanvasItemSimple *item;
 
+  /* The transformation matrix of this particular view, or NULL. */
+  cairo_matrix_t *transform;
+
   /* The bounds of the item, relative to the entire canvas. */
   GooCanvasBounds bounds;
 

Index: goocanvaspolylineview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvaspolylineview.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- goocanvaspolylineview.c	21 Jul 2006 10:30:30 -0000	1.14
+++ goocanvaspolylineview.c	26 Jul 2006 15:08:19 -0000	1.15
@@ -211,6 +211,8 @@
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
+  if (simple_view->transform)
+    cairo_transform (cr, simple_view->transform);
 
   cairo_device_to_user (cr, &user_x, &user_y);
 
@@ -322,6 +324,8 @@
       cairo_save (cr);
       if (simple->transform)
 	cairo_transform (cr, simple->transform);
+      if (simple_view->transform)
+	cairo_transform (cr, simple_view->transform);
 
       canvas_view = goo_canvas_item_view_get_canvas_view (simple_view->parent_view);
 
@@ -364,6 +368,8 @@
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
+  if (simple_view->transform)
+    cairo_transform (cr, simple_view->transform);
 
   goo_canvas_polyline_view_create_path (polyline, cr);
   goo_canvas_item_simple_paint_path (simple, cr);

Index: goocanvastextview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastextview.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- goocanvastextview.c	21 Jul 2006 10:30:30 -0000	1.15
+++ goocanvastextview.c	26 Jul 2006 15:08:19 -0000	1.16
@@ -200,6 +200,8 @@
       cairo_save (cr);
       if (simple->transform)
 	cairo_transform (cr, simple->transform);
+      if (simple_view->transform)
+	cairo_transform (cr, simple_view->transform);
 
       canvas_view = goo_canvas_item_view_get_canvas_view (simple_view->parent_view);
 
@@ -272,6 +274,8 @@
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
+  if (simple_view->transform)
+    cairo_transform (cr, simple_view->transform);
 
   cairo_device_to_user (cr, &user_x, &user_y);
 
@@ -338,6 +342,8 @@
   cairo_save (cr);
   if (simple->transform)
     cairo_transform (cr, simple->transform);
+  if (simple_view->transform)
+    cairo_transform (cr, simple_view->transform);
 
   goo_canvas_item_simple_set_fill_options (simple, cr);
 

Index: goocanvasview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- goocanvasview.c	21 Jul 2006 10:30:30 -0000	1.25
+++ goocanvasview.c	26 Jul 2006 15:08:19 -0000	1.26
@@ -2322,9 +2322,8 @@
 				       gdouble           *y)
 {
   GooCanvasItemView *tmp_view = item_view;
-  GooCanvasItem *item;
   GList *list = NULL, *l;
-  cairo_matrix_t *item_transform, inverse = { 1, 0, 0, 1, 0, 0 };
+  cairo_matrix_t item_view_transform, inverse = { 1, 0, 0, 1, 0, 0 };
 
   /* Step up from the item view to the top, pushing views onto the list. */
   while (tmp_view)
@@ -2336,13 +2335,10 @@
   /* Now step down applying the inverse of each view's transformation. */
   for (l = list; l; l = l->next)
     {
-      item = goo_canvas_item_view_get_item ((GooCanvasItemView*) l->data);
-      item_transform = goo_canvas_item_get_transform (item);
-      if (item_transform)
+      if (goo_canvas_item_view_get_combined_transform ((GooCanvasItemView*) l->data, &item_view_transform))
 	{
-	  cairo_matrix_t tmp = *item_transform;
-	  cairo_matrix_invert (&tmp);
-	  cairo_matrix_multiply (&inverse, &inverse, &tmp);
+	  cairo_matrix_invert (&item_view_transform);
+	  cairo_matrix_multiply (&inverse, &inverse, &item_view_transform);
 	}
     }
   g_list_free (list);
@@ -2370,9 +2366,8 @@
 					 gdouble           *y)
 {
   GooCanvasItemView *tmp_view = item_view;
-  GooCanvasItem *item;
   GList *list = NULL, *l;
-  cairo_matrix_t *item_transform, transform = { 1, 0, 0, 1, 0, 0 };
+  cairo_matrix_t item_view_transform, transform = { 1, 0, 0, 1, 0, 0 };
 
   /* Step up from the item view to the top, pushing views onto the list. */
   while (tmp_view)
@@ -2384,10 +2379,10 @@
   /* Now step down applying each view's transformation. */
   for (l = list; l; l = l->next)
     {
-      item = goo_canvas_item_view_get_item ((GooCanvasItemView*) l->data);
-      item_transform = goo_canvas_item_get_transform (item);
-      if (item_transform)
-	cairo_matrix_multiply (&transform, &transform, item_transform);
+      if (goo_canvas_item_view_get_combined_transform ((GooCanvasItemView*) l->data, &item_view_transform))
+	{
+	  cairo_matrix_multiply (&transform, &transform, &item_view_transform);
+	}
     }
   g_list_free (list);
 



More information about the cairo-commit mailing list