[evolution/foocanvas] Reverts two commits and fixes e-canvas-background.c



commit 435442b25d84fc21f9c378d2117879b34f98a836
Author: H.Habighorst <h habighorst googlemail com>
Date:   Thu May 20 16:58:00 2010 +0200

    Reverts two commits and fixes e-canvas-background.c
    
    Simplifies ecb_bounds: Return the bbox of ecb.
    Changes ecb_draw: Use the full expose to draw.

 widgets/misc/e-canvas-background.c |   52 +++++++++++------------------------
 widgets/misc/e-canvas-background.h |    2 +-
 2 files changed, 18 insertions(+), 36 deletions(-)
---
diff --git a/widgets/misc/e-canvas-background.c b/widgets/misc/e-canvas-background.c
index ad908a8..eacf55c 100644
--- a/widgets/misc/e-canvas-background.c
+++ b/widgets/misc/e-canvas-background.c
@@ -49,7 +49,7 @@ struct _ECanvasBackgroundPrivate {
 	guint rgba;		/* Fill color, RGBA */
 	GdkColor color;		/* Fill color */
 	GdkBitmap *stipple;	/* Stipple for fill */
-	GdkGC *gc;			/* GC for filling */
+	GdkGC *gc;		/* GC for filling */
 	gdouble x1;
 	gdouble x2;
 	gdouble y1;
@@ -91,30 +91,12 @@ static void
 ecb_bounds (FooCanvasItem *item, gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2)
 {
 	ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
-	gdouble x, y, width, height;
 
 	/* Wrong BBox's are the source of redraw nightmares */
-	x = ecb->priv->x1;
-	y = ecb->priv->y1;
-	width = ecb->priv->x2;
-	height = ecb->priv->y2;
-
-	if (ecb->priv->x1 < 0)
-		x = -(gdouble)UINT_MAX;
-
-	if (ecb->priv->y1 < 0)
-		y = -(gdouble)UINT_MAX;
-
-	if (ecb->priv->x2 < 0)
-		width = (gdouble)UINT_MAX;
-
-	if (ecb->priv->y2 < 0)
-		height = (gdouble)UINT_MAX;
-
-	*x1 = x;
-	*y1 = y;
-	*x2 = width + 1;
-	*y2 = height + 1;
+	*x1 = ecb->priv->x1;
+	*y1 = ecb->priv->y1;
+	*x2 = ecb->priv->x2 + 1;
+	*y2 = ecb->priv->y2 + 1;
 }
 
 /*
@@ -126,7 +108,7 @@ ecb_update (FooCanvasItem *item, gdouble i2w_dx, gdouble i2w_dy, gint flags)
 	ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
 	gdouble x, y, width, height;
 
-	// foo_canvas_group_update wipes the bbox!
+	/* foo_canvas_group_update wipes the bbox! */
 	x = item->x1;
 	y = item->y1;
 	width  = item->x2;
@@ -326,10 +308,10 @@ ecb_init (ECanvasBackground *ecb)
 	ecb->priv->color.blue   = 0;
 	ecb->priv->stipple      = NULL;
 	ecb->priv->gc           = NULL;
-	ecb->priv->x1           = 0.0;
-	ecb->priv->x2           = 0.0;
-	ecb->priv->y1           = 0.0;
-	ecb->priv->y2           = 0.0;
+	ecb->priv->x1           = -1.0;
+	ecb->priv->x2           = -1.0;
+	ecb->priv->y1           = -1.0;
+	ecb->priv->y2           = -1.0;
 }
 
 static void
@@ -373,8 +355,8 @@ ecb_draw (FooCanvasItem *item,
 	ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
 	gint x, y, width, height;
 
-	x = 0;
-	y = 0;
+	x = expose->area.x;
+	y = expose->area.y;
 	width = expose->area.width;
 	height = expose->area.height;
 
@@ -382,17 +364,17 @@ ecb_draw (FooCanvasItem *item,
 	 * Find out our real position after grouping
 	 */
 
-	if (ecb->priv->x1 > 0 && ecb->priv->x1 > x)
+	if (ecb->priv->x1 >= 0 && ecb->priv->x1 < x)
 		x = ecb->priv->x1;
-	if (ecb->priv->y1 > 0 && ecb->priv->y1 > y)
+	if (ecb->priv->y1 >= 0 && ecb->priv->y1 < y)
 		y = ecb->priv->y1;
-	if (ecb->priv->x2 > 0 && ecb->priv->x2 < width)
+	if (ecb->priv->x2 >= 0 && ecb->priv->x2 < width)
 		width = ecb->priv->x2;
-	if (ecb->priv->y2 > 0 && ecb->priv->y2 < height)
+	if (ecb->priv->y2 >= 0 && ecb->priv->y2 < height)
 		height = ecb->priv->y2;
 
 	gdk_draw_rectangle (drawable, ecb->priv->gc, TRUE,
-			    x, y, width - x, height - y);
+			    x, y, width, height);
 }
 
 static double
diff --git a/widgets/misc/e-canvas-background.h b/widgets/misc/e-canvas-background.h
index d60869d..d44afbc 100644
--- a/widgets/misc/e-canvas-background.h
+++ b/widgets/misc/e-canvas-background.h
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
  * fill_color_gdk	GdkColor*	RW		Allocated GdkColor for fill
  * fill_stipple		GdkBitmap*	RW		Stipple pattern for fill
  * x1                   gdouble		RW              Coordinates for edges of background rectangle
- * x2                   gdouble		RW              Default is all of them = 0.
+ * x2                   gdouble		RW              Default is all of them = -1.
  * y1                   gdouble		RW              Which means that the entire space is shown.
  * y2                   gdouble		RW
  */



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