[cairo-commit] goocanvas/src goocanvasitemsimple.c, 1.33, 1.34 goocanvasitemsimple.h, 1.23, 1.24 goocanvaspolyline.c, 1.15, 1.16 goocanvasrect.c, 1.13, 1.14

Damon Chaplin commit at pdx.freedesktop.org
Fri May 11 09:31:00 PDT 2007


Committed by: damon

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

Modified Files:
	goocanvasitemsimple.c goocanvasitemsimple.h 
	goocanvaspolyline.c goocanvasrect.c 
Log Message:
2007-05-11  Damon Chaplin  <damon at gnome.org>

	* demo/demo-large-rect.c: 
	* demo/demo-large-line.c: 
	* demo/demo-large-items.c: new demo and items to show how to create a
	very large canvas and very large items.

	* src/goocanvasitemsimple.c (goo_canvas_item_simple_get_line_width): 
	added utility function to get an item's line width.
	Also changed default line width property value to 2.0, and returned
	canvas line width setting if item's line width isn't set.

	* src/goocanvasrect.c (goo_canvas_rect_update): 
	* src/goocanvaspolyline.c (goo_canvas_polyline_reconfigure_arrows): use
	the above function to get the line width.



Index: goocanvasitemsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- goocanvasitemsimple.c	25 Apr 2007 13:24:38 -0000	1.33
+++ goocanvasitemsimple.c	11 May 2007 16:30:49 -0000	1.34
@@ -149,7 +149,7 @@
 				   g_param_spec_double ("line-width",
 							_("Line Width"),
 							_("The line width to use for the item's perimeter"),
-							0.0, G_MAXDOUBLE, 0.0,
+							0.0, G_MAXDOUBLE, 2.0,
 							G_PARAM_READWRITE));
 
   g_object_class_install_property (gobject_class, PROP_LINE_CAP,
@@ -416,12 +416,14 @@
 static void
 goo_canvas_item_simple_get_common_property (GObject                 *object,
 					    GooCanvasItemSimpleData *simple_data,
+					    GooCanvas               *canvas,
 					    guint                    prop_id,
 					    GValue                  *value,
 					    GParamSpec              *pspec)
 {
   GooCanvasStyle *style = simple_data->style;
   GValue *svalue;
+  gdouble line_width = 2.0;
   gchar *font = NULL;
 
   switch (prop_id)
@@ -451,7 +453,11 @@
       /* Line style & width properties. */
     case PROP_LINE_WIDTH:
       svalue = goo_canvas_style_get_property (style, goo_canvas_style_line_width_id);
-      g_value_set_double (value, svalue ? svalue->data[0].v_double : 2.0);
+      if (svalue)
+	line_width = svalue->data[0].v_double;
+      else if (canvas)
+	line_width = goo_canvas_get_default_line_width (canvas);
+      g_value_set_double (value, line_width);
       break;
     case PROP_LINE_CAP:
       svalue = goo_canvas_style_get_property (style, goo_canvas_style_line_cap_id);
@@ -537,7 +543,8 @@
       g_value_set_string (value, atk_object_get_description (accessible));
       break;
     default:
-      goo_canvas_item_simple_get_common_property (object, simple_data, prop_id,
+      goo_canvas_item_simple_get_common_property (object, simple_data,
+						  simple->canvas, prop_id,
 						  value, pspec);
       break;
     }
@@ -1739,6 +1746,29 @@
 }
 
 
+/**
+ * goo_canvas_item_simple_get_line_width:
+ * @item: a #GooCanvasItemSimple.
+ * 
+ * Gets the item's line width.
+ * 
+ * Returns: the item's line width.
+ **/
+gdouble
+goo_canvas_item_simple_get_line_width (GooCanvasItemSimple   *item)
+{
+  GValue *value;
+
+  value = goo_canvas_style_get_property (item->simple_data->style,
+					 goo_canvas_style_line_width_id);
+  if (value)
+    return value->data[0].v_double;
+  else if (item->canvas)
+    return goo_canvas_get_default_line_width (item->canvas);
+  else
+    return 2.0;
+}
+
 
 /**
  * SECTION:goocanvasitemmodelsimple
@@ -1843,8 +1873,8 @@
       g_value_set_string (value, smodel->description);
       break;
     default:
-      goo_canvas_item_simple_get_common_property (object, simple_data, prop_id,
-						  value, pspec);
+      goo_canvas_item_simple_get_common_property (object, simple_data, NULL,
+						  prop_id, value, pspec);
       break;
     }
 }

Index: goocanvasitemsimple.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- goocanvasitemsimple.h	30 Mar 2007 11:40:28 -0000	1.23
+++ goocanvasitemsimple.h	11 May 2007 16:30:49 -0000	1.24
@@ -181,6 +181,7 @@
 void     goo_canvas_item_simple_changed			(GooCanvasItemSimple	*item,
 							 gboolean		 recompute_bounds);
 void     goo_canvas_item_simple_check_style		(GooCanvasItemSimple	*item);
+gdouble  goo_canvas_item_simple_get_line_width		(GooCanvasItemSimple   *item);
 void	 goo_canvas_item_simple_set_model		(GooCanvasItemSimple	*item,
 							 GooCanvasItemModel	*model);
 

Index: goocanvaspolyline.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvaspolyline.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- goocanvaspolyline.c	6 Mar 2007 13:21:26 -0000	1.15
+++ goocanvaspolyline.c	11 May 2007 16:30:49 -0000	1.16
@@ -387,9 +387,8 @@
 goo_canvas_polyline_reconfigure_arrows (GooCanvasPolyline *polyline)
 {
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) polyline;
-  GooCanvasItemSimpleData *simple_data = simple->simple_data;
   GooCanvasPolylineData *polyline_data = polyline->polyline_data;
-  double line_width = 2.0;
+  double line_width;
 
   if (!polyline_data->reconfigure_arrows)
     return;
@@ -400,20 +399,7 @@
       || (!polyline_data->start_arrow && !polyline_data->end_arrow))
     return;
 
-  /* Determine the item's line width setting, either the default canvas line
-     width or the item style's line width setting. */
-  if (simple->canvas)
-    line_width = goo_canvas_get_default_line_width (simple->canvas);
-  if (simple_data->style)
-    {
-      GValue *value;
-
-      value = goo_canvas_style_get_property (simple_data->style,
-					     goo_canvas_style_line_width_id);
-      if (value)
-	line_width = value->data[0].v_double;
-    }
-
+  line_width = goo_canvas_item_simple_get_line_width (simple);
   ensure_arrow_data (polyline_data);
 
   if (polyline_data->start_arrow)

Index: goocanvasrect.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasrect.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- goocanvasrect.c	25 Apr 2007 10:23:40 -0000	1.13
+++ goocanvasrect.c	11 May 2007 16:30:49 -0000	1.14
@@ -371,19 +371,11 @@
 {
   GooCanvasRect *rect = (GooCanvasRect*) simple;
   GooCanvasRectData *rect_data = rect->rect_data;
-  gdouble line_width, half_line_width;
-  GValue *value;
+  gdouble half_line_width;
 
   /* We can quickly compute the bounds as being just the rectangle's size
      plus half the line width around each edge. */
-  value = goo_canvas_style_get_property (simple->simple_data->style,
-					 goo_canvas_style_line_width_id);
-  if (value)
-    line_width = value->data[0].v_double;
-  else
-    line_width = goo_canvas_get_default_line_width (simple->canvas);
-
-  half_line_width = line_width / 2;
+  half_line_width = goo_canvas_item_simple_get_line_width (simple) / 2;
 
   simple->bounds.x1 = rect_data->x - half_line_width;
   simple->bounds.y1 = rect_data->y - half_line_width;



More information about the cairo-commit mailing list