fix confusion in Canvas::LineSet over window vs. item coordinates that affected redra...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 23 Oct 2013 01:12:47 +0000 (21:12 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 23 Oct 2013 01:12:47 +0000 (21:12 -0400)
libs/canvas/line_set.cc

index 5aefe1bf47f76cff8c2428ab4686a79b7450a576..bc2c2c100a61dc313d89a657bf54a0cc6ee0dd0f 100644 (file)
@@ -67,16 +67,25 @@ LineSet::set_height (Distance height)
 void
 LineSet::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
 {
+       /* area is in window coordinates */
+
        for (list<Line>::const_iterator i = _lines.begin(); i != _lines.end(); ++i) {
-               if (i->y > area.y1) {
+
+               Duple self = item_to_window (Duple (area.x0, i->y));
+
+               if (self.y > area.y1) {
+                       /* line is past the ymax for the render rect, nothing
+                          to draw 
+                       */
                        break;
-               } else if (i->y > area.y0) {
+               } else if (self.y > area.y0) {
+                       /* line is between ymin and ymax for the render rect,
+                          draw something.
+                       */
                        set_source_rgba (context, i->color);
                        context->set_line_width (i->width);
-                       Duple p0 = item_to_window (Duple (area.x0, i->y));
-                       Duple p1 = item_to_window (Duple (area.x1, i->y));
-                       context->move_to (p0.x, p0.y);
-                       context->line_to (p1.x, p1.y);
+                       context->move_to (area.x0, self.y);
+                       context->line_to (area.x1, self.y);
                        context->stroke ();
                }
        }