[evolution/rendering-cleanup: 36/97] gnome-canvas: Change line-width handling of GnomeCanvasShape



commit decd53b16e45d3c38951686e16efa6fd3f1c6b81
Author: Benjamin Otte <otte redhat com>
Date:   Fri Oct 15 00:13:46 2010 +0200

    gnome-canvas: Change line-width handling of GnomeCanvasShape
    
    Remove "width-pixels" property and replace the "width-units" property
    name with "line-width".
    
    Also adapt the code to use "line-width". It didn't really matter which
    property was used, because the views weren't scaled.

 calendar/gui/e-day-view.c                   |    6 +-
 calendar/gui/weekday-picker.c               |    2 +-
 libgnomecanvas/gnome-canvas-shape-private.h |    3 +-
 libgnomecanvas/gnome-canvas-shape.c         |   70 +++++++--------------------
 4 files changed, 22 insertions(+), 59 deletions(-)
---
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 4b0fc0c..8eaffce 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1156,7 +1156,7 @@ e_day_view_init (EDayView *day_view)
 	day_view->drag_long_event_rect_item =
 		gnome_canvas_item_new (canvas_group,
 				       gnome_canvas_rect_get_type (),
-				       "width_pixels", 1,
+				       "line_width", 1.0,
 				       NULL);
 	gnome_canvas_item_hide (day_view->drag_long_event_rect_item);
 
@@ -1229,14 +1229,14 @@ e_day_view_init (EDayView *day_view)
 	day_view->drag_rect_item =
 		gnome_canvas_item_new (canvas_group,
 				       gnome_canvas_rect_get_type (),
-				       "width_pixels", 1,
+				       "line_width", 1.0,
 				       NULL);
 	gnome_canvas_item_hide (day_view->drag_rect_item);
 
 	day_view->drag_bar_item =
 		gnome_canvas_item_new (canvas_group,
 				       gnome_canvas_rect_get_type (),
-				       "width_pixels", 1,
+				       "line_width", 1.0,
 				       NULL);
 	gnome_canvas_item_hide (day_view->drag_bar_item);
 
diff --git a/calendar/gui/weekday-picker.c b/calendar/gui/weekday-picker.c
index 0221027..369c76f 100644
--- a/calendar/gui/weekday-picker.c
+++ b/calendar/gui/weekday-picker.c
@@ -173,7 +173,7 @@ configure_items (WeekdayPicker *wp)
 				       "y1", (double) 0,
 				       "x2", (double) ((i + 1) * box_width),
 				       "y2", (double) (height - 1),
-				       "width_pixels", 0,
+				       "line_width", 0.0,
 				       NULL);
 
 		c = get_day_text (day);
diff --git a/libgnomecanvas/gnome-canvas-shape-private.h b/libgnomecanvas/gnome-canvas-shape-private.h
index b36609a..fb4637c 100644
--- a/libgnomecanvas/gnome-canvas-shape-private.h
+++ b/libgnomecanvas/gnome-canvas-shape-private.h
@@ -75,9 +75,8 @@ struct _GnomeCanvasShapePriv {
 
 	guint fill_set : 1;		/* Is fill color set? */
 	guint outline_set : 1;		/* Is outline color set? */
-	guint width_pixels : 1;		/* Is outline width specified in pixels or units? */
 
-	gdouble width;			/* Width of outline, in user coords */
+	gdouble line_width;		/* Width of outline, in user coords */
 
 	guint32 fill_rgba;		/* Fill color, RGBA */
 	guint32 outline_rgba;		/* Outline color, RGBA */
diff --git a/libgnomecanvas/gnome-canvas-shape.c b/libgnomecanvas/gnome-canvas-shape.c
index a1e2f74..e033add 100644
--- a/libgnomecanvas/gnome-canvas-shape.c
+++ b/libgnomecanvas/gnome-canvas-shape.c
@@ -49,8 +49,7 @@ enum {
 	PROP_OUTLINE_COLOR,
 	PROP_OUTLINE_COLOR_GDK,
 	PROP_OUTLINE_COLOR_RGBA,
-	PROP_WIDTH_PIXELS,
-	PROP_WIDTH_UNITS,
+	PROP_LINE_WIDTH,
 	PROP_CAP_STYLE,
 	PROP_JOIN_STYLE,
 	PROP_WIND,
@@ -135,14 +134,9 @@ gnome_canvas_shape_class_init (GnomeCanvasShapeClass *class)
                                                             0, G_MAXUINT, 0,
                                                             (G_PARAM_READABLE | G_PARAM_WRITABLE)));
         g_object_class_install_property (gobject_class,
-                                         PROP_WIDTH_PIXELS,
-                                         g_param_spec_uint ("width_pixels", NULL, NULL,
-                                                            0, G_MAXUINT, 0,
-                                                            (G_PARAM_READABLE | G_PARAM_WRITABLE)));
-        g_object_class_install_property (gobject_class,
-                                         PROP_WIDTH_UNITS,
-                                         g_param_spec_double ("width_units", NULL, NULL,
-                                                              0.0, G_MAXDOUBLE, 0.0,
+                                         PROP_LINE_WIDTH,
+                                         g_param_spec_double ("line_width", NULL, NULL,
+                                                              0.0, G_MAXDOUBLE, 1.0,
                                                               (G_PARAM_READABLE | G_PARAM_WRITABLE)));
         g_object_class_install_property (gobject_class,
                                          PROP_CAP_STYLE,
@@ -195,9 +189,8 @@ gnome_canvas_shape_init (GnomeCanvasShape *shape)
 
 	shape->priv->fill_set = FALSE;
 	shape->priv->outline_set = FALSE;
-	shape->priv->width_pixels = FALSE;
 
-	shape->priv->width = 1.0;
+	shape->priv->line_width = 1.0;
 
 	shape->priv->fill_rgba = 0x0000003f;
 	shape->priv->outline_rgba = 0x0000007f;
@@ -373,16 +366,8 @@ gnome_canvas_shape_set_property (GObject      *object,
 		gnome_canvas_item_request_update (item);
 		break;
 
-	case PROP_WIDTH_PIXELS:
-		priv->width = g_value_get_uint (value);
-		priv->width_pixels = TRUE;
-
-		gnome_canvas_item_request_update (item);
-		break;
-
-	case PROP_WIDTH_UNITS:
-		priv->width = fabs (g_value_get_double (value));
-		priv->width_pixels = FALSE;
+	case PROP_LINE_WIDTH:
+		priv->line_width = g_value_get_double (value);
 
 		gnome_canvas_item_request_update (item);
 		break;
@@ -524,12 +509,8 @@ gnome_canvas_shape_get_property (GObject     *object,
 		g_value_set_enum (value, priv->join);
 		break;
 
-	case PROP_WIDTH_PIXELS:
-		g_value_set_uint (value, priv->width);
-		break;
-
-	case PROP_WIDTH_UNITS:
-		g_value_set_double (value, priv->width);
+	case PROP_LINE_WIDTH:
+		g_value_set_double (value, priv->line_width);
 		break;
 
 	case PROP_MITERLIMIT:
@@ -729,21 +710,12 @@ gnome_canvas_shape_update_gdk (GnomeCanvasShape * shape, gdouble * affine, ArtSV
 	if (priv->outline_set) {
 		GdkLineStyle style;
 
-		if (priv->width_pixels) {
-			width = (gint) floor (priv->width + 0.5);
-			/* Never select 0 pixels unless the user asked for it,
-			 * since that is the X11 zero width lines are non-specified */
-			if (priv->width_pixels != 0 && width == 0) {
-				width = 1;
-			}
-		} else {
-			width = (gint) floor ((priv->width * priv->scale) + 0.5);
-			/* Never select 0 pixels unless the user asked for it,
-			 * since that is the X11 zero width lines are non-speciifed */
-			if (priv->width != 0 && width == 0) {
-				width = 1;
-			}
-		}
+                width = (gint) floor ((priv->line_width * priv->scale) + 0.5);
+                /* Never select 0 pixels unless the user asked for it,
+                 * since that is the X11 zero width lines are non-speciifed */
+                if (priv->line_width != 0 && width == 0) {
+                        width = 1;
+                }
 
 		/* If dashed, set it in GdkGC */
 
@@ -1006,11 +978,7 @@ gnome_canvas_shape_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_
 
 		/* Set linewidth */
 
-		if (priv->width_pixels) {
-			width = priv->width;
-		} else {
-			width = priv->width * priv->scale;
-		}
+		width = priv->line_width * priv->scale;
 
 		if (width < 0.5) width = 0.5;
 
@@ -1300,11 +1268,7 @@ gnome_canvas_shape_bounds (GnomeCanvasItem *item, gdouble *x1, gdouble *y1, gdou
 
 		/* Set linewidth */
 
-		if (priv->width_pixels) {
-			width = priv->width;
-		} else {
-			width = priv->width * priv->scale;
-		}
+		width = priv->line_width * priv->scale;
 
 		if (width < 0.5) width = 0.5;
 



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