[goocanvas/new-api] 2010-06-29 Damon Chaplin <damon gnome org>



commit 7248b9741d4aa6aa825e0f6d295fb5fe314e2b5b
Author: Damon Chaplin <damon gnome org>
Date:   Tue Jun 29 19:01:31 2010 +0100

    2010-06-29  Damon Chaplin  <damon gnome org>
    
    	    * src/goocanvasitemsimple.c (goo_canvas_item_simple_update)
    	    (goo_canvas_item_simple_paint): fixed a few painting bugs.
    
    	    * demo/demo.c: only scale the text items if the shift key is pressed
    	    while mouse-scrolling. Otherwise it is confusing.

 ChangeLog                 |    8 ++++++++
 demo/demo.c               |   25 +++++++++++++++++++------
 src/goocanvasitemsimple.c |   40 +++++++++++++++++++++++++++++++++++-----
 3 files changed, 62 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3f4d3f4..bc1c311 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-06-29  Damon Chaplin  <damon gnome org>
 
+	* src/goocanvasitemsimple.c (goo_canvas_item_simple_update)
+	(goo_canvas_item_simple_paint): fixed a few painting bugs.
+
+	* demo/demo.c: only scale the text items if the shift key is pressed
+	while mouse-scrolling. Otherwise it is confusing.
+
+2010-06-29  Damon Chaplin  <damon gnome org>
+
 	* src/goocanvasitem.h: rearranged a bit.
 
 2010-06-28  Damon Chaplin  <damon gnome org>
diff --git a/demo/demo.c b/demo/demo.c
index e636b78..2b148d2 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -395,13 +395,21 @@ on_scroll (GooCanvasItem *item,
   g_print ("received 'scroll-event' signal\n");
 #endif
 
-  if (event->direction == GDK_SCROLL_UP)
-    goo_canvas_item_scale (item, 1.1, 1.1);
-  else if (event->direction == GDK_SCROLL_DOWN)
-    goo_canvas_item_scale (item, 0.909, 0.909);
-  else return FALSE;
+  if (event->state & GDK_SHIFT_MASK)
+    {
+      if (event->direction == GDK_SCROLL_UP)
+	{
+	  goo_canvas_item_scale (item, 1.1, 1.1);
+	  return TRUE;
+	}
+      else if (event->direction == GDK_SCROLL_DOWN)
+	{
+	  goo_canvas_item_scale (item, 0.909, 0.909);
+	  return TRUE;
+	}
+    }
 
-  return TRUE;
+  return FALSE;
 }
 
 static gboolean
@@ -866,30 +874,35 @@ setup_rectangles (GooCanvasItem *root)
 			      NULL);
   cairo_pattern_destroy (pattern);
   setup_item_signals (item);
+  g_object_set_data (item, "id", "SeaGreen");
 
   child = goo_canvas_rect_new (item, 80, 30, 20, 20,
 			      "fill-color", "orange",
 			      "tooltip", "Child of Medium Sea Green stippled rectangle",
 			      NULL);
   setup_item_signals (child);
+  g_object_set_data (child, "id", "Orange1");
 
   child = goo_canvas_rect_new (item, 170, 30, 20, 20,
 			      "fill-color", "orange",
 			      "tooltip", "Child of Medium Sea Green stippled rectangle",
 			      NULL);
   setup_item_signals (child);
+  g_object_set_data (child, "id", "Orange2");
 
   child = goo_canvas_rect_new (item, 80, 90, 20, 20,
 			      "fill-color", "orange",
 			      "tooltip", "Child of Medium Sea Green stippled rectangle",
 			      NULL);
   setup_item_signals (child);
+  g_object_set_data (child, "id", "Orange3");
 
   child = goo_canvas_rect_new (item, 170, 90, 20, 20,
 			      "fill-color", "orange",
 			      "tooltip", "Child of Medium Sea Green stippled rectangle",
 			      NULL);
   setup_item_signals (child);
+  g_object_set_data (child, "id", "Orange4");
 
 
 
diff --git a/src/goocanvasitemsimple.c b/src/goocanvasitemsimple.c
index 69ce68b..dbb74ce 100644
--- a/src/goocanvasitemsimple.c
+++ b/src/goocanvasitemsimple.c
@@ -900,10 +900,15 @@ goo_canvas_item_simple_update  (GooCanvasItem   *item,
       simple->bounds.x2 += x_offset;
       simple->bounds.y2 += y_offset;
 
-      cairo_restore (cr);
+#if 0
+      g_print ("Simple '%s' bounds: %g, %g  %g x %g\n",
+	       g_object_get_data (G_OBJECT (simple), "id"),
+	       simple->bounds.x1, simple->bounds.y1,
+	       simple->bounds.x2 - simple->bounds.x1,
+	       simple->bounds.y2 - simple->bounds.y1);
+#endif
 
-      /* Request a redraw of the new bounds. */
-      goo_canvas_request_item_redraw (simple->canvas, &simple->bounds, simple->is_static);
+      cairo_restore (cr);
 
       /* Now handle any children. */
       if (simple->children)
@@ -926,10 +931,29 @@ goo_canvas_item_simple_update  (GooCanvasItem   *item,
 		  simple->bounds.y1 = MIN (simple->bounds.y1, child_bounds.y1);
 		  simple->bounds.x2 = MAX (simple->bounds.x2, child_bounds.x2);
 		  simple->bounds.y2 = MAX (simple->bounds.y2, child_bounds.y2);
+
+#if 0
+		  g_print ("Child '%s' bounds: %g, %g  %g x %g\n",
+			   g_object_get_data (G_OBJECT (child), "id"),
+			   child_bounds.x1, child_bounds.y1,
+			   child_bounds.x2 - child_bounds.x1,
+			   child_bounds.y2 - child_bounds.y1);
+#endif
 		}
 	    }
 	  cairo_restore (cr);
+
+#if 0
+	  g_print ("Simple '%s' bounds with children: %g, %g  %g x %g\n",
+		   g_object_get_data (G_OBJECT (simple), "id"),
+		   simple->bounds.x1, simple->bounds.y1,
+		   simple->bounds.x2 - simple->bounds.x1,
+		   simple->bounds.y2 - simple->bounds.y1);
+#endif
 	}
+
+      /* Request a redraw of the new bounds. */
+      goo_canvas_request_item_redraw (simple->canvas, &simple->bounds, simple->is_static);
     }
 
   *bounds = simple->bounds;
@@ -1187,17 +1211,23 @@ goo_canvas_item_simple_paint (GooCanvasItem         *item,
 
   class->simple_paint (simple, cr, bounds);
 
+  cairo_restore (cr);
+
   /* Paint the children. */
   if (simple->children)
     {
+      cairo_save (cr);
+      if (simple->transform)
+	cairo_transform (cr, simple->transform);
+
       for (i = 0; i < simple->children->len; i++)
 	{
 	  GooCanvasItem *child = simple->children->pdata[i];
 	  goo_canvas_item_paint (child, cr, bounds, scale);
 	}
-    }
 
-  cairo_restore (cr);
+      cairo_restore (cr);
+    }
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]