another redirect dialog fix
[ardour.git] / gtk2_ardour / canvas-simplerect.c
index 62d3a96bcf4da2dafdd8ed55ff84638d7b668be2..d50943f0c3dfc55ba9b3868898eabb0f8d483d3b 100644 (file)
@@ -227,9 +227,6 @@ gnome_canvas_simplerect_init (GnomeCanvasSimpleRect *simplerect)
        simplerect->outline_color = 0;
        simplerect->outline_pixels = 1;
        simplerect->outline_what = 0xf;
-
-       // GTK2FIX
-       // GNOME_CANVAS_ITEM(simplerect)->object.flags |= GNOME_CANVAS_ITEM_NO_AUTO_REDRAW;
 }
 
 static void
@@ -260,19 +257,20 @@ gnome_canvas_simplerect_bounds (GnomeCanvasItem *item, double *x1, double *y1, d
 
 }
 
+
 static void 
 gnome_canvas_simplerect_reset_bounds (GnomeCanvasItem *item)
 {
        GnomeCanvasSimpleRect* simplerect;
        double x1, x2, y1, y2;
        double old_x1, old_x2, old_y1, old_y2;
-       double a, b;
-       
+       ArtDRect unionrect, old, new;
+
        old_x1 = item->x1;
        old_y1 = item->y1;
        old_x2 = item->x2;
        old_y2 = item->y2;
-
+       
        gnome_canvas_simplerect_bounds (item, &x1, &y1, &x2, &y2);
        gnome_canvas_item_i2w (item, &x1, &y1);
        gnome_canvas_item_i2w (item, &x2, &y2);
@@ -291,41 +289,73 @@ gnome_canvas_simplerect_reset_bounds (GnomeCanvasItem *item)
 
        /* now queue redraws for changed areas */
 
-       if (item->x1 != old_x1) {
-               
-               /* left edge changed. redraw the area that altered */
-               
-               a = MIN(item->x1, old_x1); 
-               b = MAX(item->x1, old_x1);
-               gnome_canvas_request_redraw (item->canvas, a - 1, item->y1, b + 1, item->y2);
-       }
-       
-       if (item->x2 != old_x2) {
-               
-               /* right edge changed. redraw the area that altered */
-               
-               a = MIN(item->x2, old_x2);
-               b = MAX(item->x2, old_x2);
-               gnome_canvas_request_redraw (item->canvas, a - 1, item->y1, b + 1, item->y2);
-       }
-       
-       if (item->y1 != old_y1) {
-               
-               /* top edge changed. redraw the area that altered */
-               
-               a = MIN(item->y1, old_y1);
-               b = MAX(item->y1, old_y1);
-               gnome_canvas_request_redraw (item->canvas, item->x1, a - 1, item->x2, b + 1);
-       }
-       
-       if (item->y2 != old_y2) {
-               
-               /* lower edge changed. redraw the area that altered */
-               
-               a = MIN(item->y2, old_y2);
-               b = MAX(item->y2, old_y2);
-               gnome_canvas_request_redraw (item->canvas, item->x1, a - 1, item->x2, b + 1);
-       }
+       if (item->x1 == old_x1 && item->x2 == old_x2) {
+
+               /* no change in x-axis position */
+
+               if (item->y1 == old_y1) {
+                       /* top didn't change, so just draw bottom */
+
+                       double start_y = MIN (item->y2, old_y2);
+                       double end_y = MAX (item->y2, old_y2);
+
+                       gnome_canvas_request_redraw (item->canvas, item->x1, start_y - 0.5, item->x2, end_y + 1.5);
+                       return;
+
+               } else if (item->y2 == old_y2) {
+
+                       /* bottom didn't change, just draw top */
+
+                       double start_y = MIN (item->y1, old_y1);
+                       double end_y = MAX (item->y1, old_y1);
+
+                       gnome_canvas_request_redraw (item->canvas, item->x1, start_y - 0.5, item->x2, end_y + 1.5);
+                       return;
+
+               }
+
+       } else if (item->y1 == old_y1 && item->y2 == old_y2) {
+
+               /* no change in y-axis position */
+
+               if (item->x1 == old_x1) {
+                       /* start didn't change, so just draw at the end */
+
+                       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);
+                       return;
+
+               } else if (item->x2 == old_x2) {
+
+                       /* end didn't change, so just draw at the start */
+                       
+                       double start_x = MIN (item->x1, old_x1);
+                       double end_x = MAX (item->x1, old_x1);
+
+                       gnome_canvas_request_redraw (item->canvas, start_x - 0.5, item->y1, end_x + 1.5, item->y2 + 0.5);
+                       return;
+
+               }
+       } 
+
+       new.x0 = x1;
+       new.y0 = y1;
+       new.x1 = x2;
+       new.y1 = y2;
+
+       old.x0 = old_x1;
+       old.y0 = old_y1;
+       old.x1 = old_x2;
+       old.y1 = old_y2;
+
+       art_drect_union (&unionrect, &old, &new);
+       gnome_canvas_request_redraw (item->canvas, 
+                                    unionrect.x0 - 0.5,
+                                    unionrect.y0 - 0.5,
+                                    unionrect.x1 + 1.5,
+                                    unionrect.y1 + 1.5);
 }
 
 /* 
@@ -497,8 +527,8 @@ gnome_canvas_simplerect_update (GnomeCanvasItem *item, double *affine, ArtSVP *c
                gnome_canvas_request_redraw (item->canvas, 
                                           simplerect->bbox_ulx,
                                           simplerect->bbox_uly,
-                                          simplerect->bbox_lrx+1,
-                                          simplerect->bbox_lry+1);
+                                          simplerect->bbox_lrx+0.5,
+                                          simplerect->bbox_lry+0.5);
                simplerect->full_draw_on_update = FALSE;
        }
 
@@ -530,7 +560,7 @@ gnome_canvas_simplerect_render (GnomeCanvasItem *item,
        if (parent_class->render) {
                (*parent_class->render) (item, buf);
        }
-
+       
        if (buf->is_bg) {
 
 #ifdef HARLEQUIN_DEBUGGING