X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fcanvas-simplerect.c;h=fe6e1855be03848cd092b7699c31b3032a8a3f52;hb=8de005efd58ac0733ce127d3a3bbaf969a62f2a6;hp=a3894b079071e90dbd4e2aea956b0db3d6fc2e0a;hpb=bb9cc45cd22af67ac275a5e73accbe14fee664d8;p=ardour.git diff --git a/gtk2_ardour/canvas-simplerect.c b/gtk2_ardour/canvas-simplerect.c index a3894b0790..fe6e1855be 100644 --- a/gtk2_ardour/canvas-simplerect.c +++ b/gtk2_ardour/canvas-simplerect.c @@ -20,7 +20,6 @@ enum { PROP_FILL_COLOR_RGBA, PROP_OUTLINE_COLOR_RGBA, PROP_DRAW - }; static void gnome_canvas_simplerect_class_init (GnomeCanvasSimpleRectClass *class); @@ -233,13 +232,9 @@ gnome_canvas_simplerect_init (GnomeCanvasSimpleRect *simplerect) static void gnome_canvas_simplerect_destroy (GtkObject *object) { - GnomeCanvasSimpleRect *rect; - g_return_if_fail (object != NULL); g_return_if_fail (GNOME_IS_CANVAS_SIMPLERECT (object)); - rect = GNOME_CANVAS_SIMPLERECT (object); - /* remember, destroy can be run multiple times! */ if (GTK_OBJECT_CLASS (parent_class)->destroy) @@ -255,7 +250,6 @@ gnome_canvas_simplerect_bounds (GnomeCanvasItem *item, double *x1, double *y1, d *y1 = simplerect->y1; *x2 = simplerect->x2 + 1; *y2 = simplerect->y2 + 1; - } @@ -325,7 +319,7 @@ gnome_canvas_simplerect_reset_bounds (GnomeCanvasItem *item) double start_x = MIN (item->x2, old_x2); double end_x = MAX (item->x2, old_x2); - gnome_canvas_request_redraw (item->canvas, start_x - 0.5, item->y1, end_x + 1.5, item->y2); + gnome_canvas_request_redraw (item->canvas, start_x - 0.5, item->y1, end_x + 1.5, item->y2 + 0.5); return; } else if (item->x2 == old_x2) { @@ -456,7 +450,23 @@ gnome_canvas_simplerect_set_property (GObject *object, break; } - simplerect->full_draw_on_update = update; + if (!simplerect->full_draw_on_update) { + /* XXX: not sure about this; + * + * I changed the next line to be conditional, rather than always + * being executed. Without the condition, the following bug occurs: + * + * caller sets a property (e.g. outline colour); this sets update = TRUE and hence full_draw_on_update = TRUE + * update is requested (and it is intended, I suppose, that during this update, full_draw_on_update is noted) + * ... update does not occur before ... + * caller sets the same property again to the same value; this sets update = FALSE and hence full_draw_on_update = FALSE + * update now occurs, but full_draw_on_update is FALSE, so the full redraw does not happen, + * which results in graphical glitches. + * + * (Carl, 2/1/2010) + */ + simplerect->full_draw_on_update = update; + } if (update || bounds_changed) { gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(object)); @@ -517,7 +527,6 @@ static void gnome_canvas_simplerect_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) { GnomeCanvasSimpleRect *simplerect; - unsigned char foo; simplerect = GNOME_CANVAS_SIMPLERECT (item); @@ -528,15 +537,15 @@ gnome_canvas_simplerect_update (GnomeCanvasItem *item, double *affine, ArtSVP *c if (simplerect->full_draw_on_update) { gnome_canvas_request_redraw (item->canvas, - simplerect->bbox_ulx, - simplerect->bbox_uly, - simplerect->bbox_lrx+0.5, - simplerect->bbox_lry+0.5); + simplerect->bbox_ulx, + simplerect->bbox_uly, + simplerect->bbox_lrx+0.5, + simplerect->bbox_lry+0.5); simplerect->full_draw_on_update = FALSE; } UINT_TO_RGBA (simplerect->fill_color, &simplerect->fill_r, &simplerect->fill_g, &simplerect->fill_b, &simplerect->fill_a); - UINT_TO_RGBA (simplerect->outline_color, &simplerect->outline_r, &simplerect->outline_g, &simplerect->outline_b, &foo); + UINT_TO_RGBA (simplerect->outline_color, &simplerect->outline_r, &simplerect->outline_g, &simplerect->outline_b, &simplerect->outline_a); } // this can be useful for debugging/understanding how the canvas redraws @@ -613,28 +622,30 @@ gnome_canvas_simplerect_render (GnomeCanvasItem *item, } - for (i = 0; i < simplerect->outline_pixels; ++i) { - - if (simplerect->outline_what & 0x1) { - if (begin == simplerect->bbox_ulx) { - PAINT_VERT(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, begin + i, sy, ey); - } - } - - if (simplerect->outline_what & 0x2) { - if (end == (simplerect->bbox_lrx - 1)) { - PAINT_VERT(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, end - i, sy, ey + 1); - } - } - - if (simplerect->outline_what & 0x4) { - PAINT_HORIZ(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, begin, end, sy+i); - } - - if (simplerect->outline_what & 0x8) { - PAINT_HORIZ(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, begin, end + 1, ey-i); - } - } + if (simplerect->outline_a > 0) { + for (i = 0; i < simplerect->outline_pixels; ++i) { + + if (simplerect->outline_what & 0x1) { + if (begin == simplerect->bbox_ulx) { + PAINT_VERTA(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, simplerect->outline_a, begin + i, sy, ey); + } + } + + if (simplerect->outline_what & 0x2) { + if (end == (simplerect->bbox_lrx - 1)) { + PAINT_VERTA(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, simplerect->outline_a, end - i, sy, ey + 1); + } + } + + if (simplerect->outline_what & 0x4) { + PAINT_HORIZA(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, simplerect->outline_a, begin, end, sy+i); + } + + if (simplerect->outline_what & 0x8) { + PAINT_HORIZA(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, simplerect->outline_a, begin, end + 1, ey-i); + } + } + } } #else /* SIMPLERECT_FAST_RENDERER */ @@ -646,7 +657,7 @@ gnome_canvas_simplerect_render (GnomeCanvasItem *item, GnomeCanvasSimpleRect *simplerect; int end, begin; int ey, sy; - unsigned int i; + int i; simplerect = GNOME_CANVAS_SIMPLERECT (item); @@ -690,28 +701,30 @@ gnome_canvas_simplerect_render (GnomeCanvasItem *item, #endif } - for (i = 0; i < simplerect->outline_pixels; ++i) { - - if (simplerect->outline_what & 0x1) { - if (begin == simplerect->bbox_ulx) { - PAINT_VERT(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, begin + i, sy, ey); - } - } - - if (simplerect->outline_what & 0x2) { - if (end == (simplerect->bbox_lrx - 1)) { - PAINT_VERT(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, end - i, sy, ey + 1); - } - } - - if (simplerect->outline_what & 0x4) { - PAINT_HORIZ(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, begin, end, sy+i); - } - - if (simplerect->outline_what & 0x8) { - PAINT_HORIZ(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, begin, end + 1, ey-i); - } - } + if (simplerect->outline_a) { + for (i = 0; i < (int) simplerect->outline_pixels; ++i) { + + if (simplerect->outline_what & 0x1) { + if (begin == simplerect->bbox_ulx) { + PAINT_VERTA(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, simplerect->outline_a, begin + i, sy, ey); + } + } + + if (simplerect->outline_what & 0x2) { + if (end == (simplerect->bbox_lrx - 1)) { + PAINT_VERTA(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, simplerect->outline_a, end - i, sy, ey + 1); + } + } + + if (simplerect->outline_what & 0x4) { + PAINT_HORIZA(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, simplerect->outline_a, begin, end, sy+i); + } + + if (simplerect->outline_what & 0x8) { + PAINT_HORIZA(buf, simplerect->outline_r, simplerect->outline_g, simplerect->outline_b, simplerect->outline_a, begin, end + 1, ey-i); + } + } + } } #endif /* SIMPLERECT_FAST_RENDERER */ @@ -830,12 +843,9 @@ gnome_canvas_simplerect_point (GnomeCanvasItem *item, double x, double y, int cx (void) cx; (void) cy; - GnomeCanvasSimpleRect *simplerect; double x1, y1, x2, y2; double dx, dy; - simplerect = GNOME_CANVAS_SIMPLERECT (item); - *actual_item = item; /* Find the bounds for the rectangle plus its outline width */