Fix for SMPTE clock text entry
[ardour.git] / gtk2_ardour / canvas-simplerect.c
index 49f63603cf22c2efbf735a93f6eabc0fa7f10ba5..d59096e68b40279d28139eedd078b2399077f69b 100644 (file)
@@ -94,6 +94,8 @@ gnome_canvas_simplerect_class_init (GnomeCanvasSimpleRectClass *class)
        gobject_class = (GObjectClass *) class;
        object_class = (GtkObjectClass *) class;
        item_class = (GnomeCanvasItemClass *) class;
+       
+       parent_class = g_type_class_peek_parent (class);
 
        gobject_class->set_property = gnome_canvas_simplerect_set_property;
        gobject_class->get_property = gnome_canvas_simplerect_get_property;
@@ -225,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
@@ -264,7 +263,7 @@ 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;
+       double a, b, c, d;
        
        old_x1 = item->x1;
        old_y1 = item->y1;
@@ -288,42 +287,24 @@ gnome_canvas_simplerect_reset_bounds (GnomeCanvasItem *item)
        gnome_canvas_w2c (GNOME_CANVAS(item->canvas), x2, y2, &simplerect->bbox_lrx, &simplerect->bbox_lry);
 
        /* 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);
-       }
+
+               a = MIN(a, item->x2);
+               a = MIN(a, old_x2);
+               b = MAX(b, item->x2);
+               b = MAX(b, old_x2);
+
+               c = MIN(item->y1, old_y1);
+               d = MAX(item->y1, old_y1);
+
+               c = MIN(c,item->y2);
+               c = MIN(c, old_y2);
+               d = MAX(d,item->y2);
+               d = MAX(d, old_y2);
+
+               gnome_canvas_request_redraw (item->canvas, a, c, b + 0.5, d + 0.5);
 }
 
 /* 
@@ -495,8 +476,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;
        }
 
@@ -504,7 +485,12 @@ gnome_canvas_simplerect_update (GnomeCanvasItem *item, double *affine, ArtSVP *c
        UINT_TO_RGBA (simplerect->outline_color, &simplerect->outline_r, &simplerect->outline_g, &simplerect->outline_b, &foo);
 }
 
-#define SIMPLERECT_FAST_RENDERER
+// this can be useful for debugging/understanding how the canvas redraws
+// stuff.
+
+#undef HARLEQUIN_DEBUGGING
+
+#undef SIMPLERECT_FAST_RENDERER
 #ifdef SIMPLERECT_FAST_RENDERER
 
 static void
@@ -526,15 +512,13 @@ gnome_canvas_simplerect_render (GnomeCanvasItem *item,
 
        if (buf->is_bg) {
 
-               // this can be useful for debugging/understanding how the canvas redraws
-               // stuff.
-
-               // gint randr, randg, randb;
-               // randr = random() % 255;
-               // randg = random() % 255;
-               // randb = random() % 255;
-               // PAINT_BOX(buf, randr, randg, randb, 255, buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1);
-
+#ifdef HARLEQUIN_DEBUGGING
+               gint randr, randg, randb;
+               randr = random() % 255;
+               randg = random() % 255;
+               randb = random() % 255;
+               PAINT_BOX(buf, randr, randg, randb, 255, buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1);
+#endif
                gnome_canvas_buf_ensure_buf (buf);
                buf->is_bg = FALSE;
        }
@@ -560,16 +544,18 @@ gnome_canvas_simplerect_render (GnomeCanvasItem *item,
                
                // this can be useful for debugging/understanding how the canvas redraws
                // stuff.
-               
-               // gint randr, randg, randb;
-               // randr = random() % 255;
-               // randg = random() % 255;
-               // randb = random() % 255;
-               // PAINT_BOX(buf, randr, randg, randb, simplerect->fill_a, begin, sy, end, ey);
-               
-               FAST_PAINT_BOX (buf, simplerect->fill_r, simplerect->fill_g, simplerect->fill_b, simplerect->fill_a, 
-                               intersection.x0, intersection.y0,
-                               intersection.x1, intersection.y1);
+
+#ifdef HARLEQUIN_DEBUGGING
+               gint randr, randg, randb;
+               randr = random() % 255;
+               randg = random() % 255;
+               randb = random() % 255;
+               PAINT_BOX(buf, randr, randg, randb, simplerect->fill_a, begin, sy, end, ey);
+#else          
+               PAINT_BOX (buf, simplerect->fill_r, simplerect->fill_g, simplerect->fill_b, simplerect->fill_a, 
+                          intersection.x0, intersection.y0,
+                          intersection.x1, intersection.y1);
+#endif
                
        }
 
@@ -616,15 +602,13 @@ gnome_canvas_simplerect_render (GnomeCanvasItem *item,
 
        if (buf->is_bg) {
 
-               // this can be useful for debugging/understanding how the canvas redraws
-               // stuff.
-
-               // gint randr, randg, randb;
-               // randr = random() % 255;
-               // randg = random() % 255;
-               // randb = random() % 255;
-               // PAINT_BOX(buf, randr, randg, randb, 255, buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1);
-
+#ifdef HARLEQUIN_DEBUGGING
+               gint randr, randg, randb;
+               randr = random() % 255;
+               randg = random() % 255;
+               randb = random() % 255;
+               PAINT_BOX(buf, randr, randg, randb, 255, buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1);
+#endif
                gnome_canvas_buf_ensure_buf (buf);
                buf->is_bg = FALSE;
        }
@@ -641,16 +625,15 @@ gnome_canvas_simplerect_render (GnomeCanvasItem *item,
 
        if (simplerect->fill) {
                
-               // this can be useful for debugging/understanding how the canvas redraws
-               // stuff.
-               
-               // gint randr, randg, randb;
-               // randr = random() % 255;
-               // randg = random() % 255;
-               // randb = random() % 255;
-               // PAINT_BOX(buf, randr, randg, randb, simplerect->fill_a, begin, sy, end, ey);
-               
+#ifdef HARLEQUIN_DEBUGGING
+               gint randr, randg, randb;
+               randr = random() % 255;
+               randg = random() % 255;
+               randb = random() % 255;
+               PAINT_BOX(buf, randr, randg, randb, simplerect->fill_a, begin, sy, end, ey);
+#else          
                PAINT_BOX(buf, simplerect->fill_r, simplerect->fill_g, simplerect->fill_b, simplerect->fill_a, begin, sy, end, ey);
+#endif
        }
 
        for (i = 0; i < simplerect->outline_pixels; ++i) {