if CANVAS_DEBUG is defined, then the env variable CANVAS_HARLEQUIN_DEBUGGING will...
[ardour.git] / libs / canvas / canvas.cc
index 27ad1f4964e4046c996ca1af08a6b45bad5804f3..242f8ecbfd20acadf161e7df36b3b121fd6b7ec4 100644 (file)
@@ -110,16 +110,17 @@ Canvas::render (Rect const & area, Cairo::RefPtr<Cairo::Context> const & context
 
                _root.render (*draw, context);
 
-#if 0
-               // This transparently colors the rect being rendered, after it has been drawn.
-               double r = (random() % 65536) /65536.0;
-               double g = (random() % 65536) /65536.0;
-               double b = (random() % 65536) /65536.0;
-               context->rectangle (draw->x0, draw->y0, draw->x1 - draw->x0, draw->y1 - draw->y0);
-               context->set_source_rgba (r, g, b, 0.25);
-               context->fill ();
+#ifdef CANVAS_DEBUG
+               if (getenv ("CANVAS_HARLEQUIN_DEBUGGING")) {
+                       // This transparently colors the rect being rendered, after it has been drawn.
+                       double r = (random() % 65536) /65536.0;
+                       double g = (random() % 65536) /65536.0;
+                       double b = (random() % 65536) /65536.0;
+                       context->rectangle (draw->x0, draw->y0, draw->x1 - draw->x0, draw->y1 - draw->y0);
+                       context->set_source_rgba (r, g, b, 0.25);
+                       context->fill ();
+               }
 #endif
-
        }
 
 }
@@ -231,8 +232,21 @@ Canvas::window_to_canvas (Duple const & d) const
        std::list<Item*> const& root_children (_root.items());
        ScrollGroup* sg = 0;
 
+       /* if the coordinates are negative, clamp to zero and find the item
+        * that covers that "edge" position.
+        */
+
+       Duple in_window (d);
+
+       if (in_window.x < 0) {
+               in_window.x = 0;
+       }
+       if (in_window.y < 0) {
+               in_window.y = 0;
+       }
+
        for (std::list<Item*>::const_iterator i = root_children.begin(); i != root_children.end(); ++i) {
-               if (((sg = dynamic_cast<ScrollGroup*>(*i)) != 0) && sg->covers_window (d)) {
+               if (((sg = dynamic_cast<ScrollGroup*>(*i)) != 0) && sg->covers_window (in_window)) {
                        break;
                }
        }