From 192f22d89e53abe321e1301c5d15b25db533f02d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 22 Oct 2013 21:12:47 -0400 Subject: [PATCH] fix confusion in Canvas::LineSet over window vs. item coordinates that affected redraw (or not) of MIDI track note lines when the canvas origin != 0 --- libs/canvas/line_set.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libs/canvas/line_set.cc b/libs/canvas/line_set.cc index 5aefe1bf47..bc2c2c100a 100644 --- a/libs/canvas/line_set.cc +++ b/libs/canvas/line_set.cc @@ -67,16 +67,25 @@ LineSet::set_height (Distance height) void LineSet::render (Rect const & area, Cairo::RefPtr context) const { + /* area is in window coordinates */ + for (list::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 (); } }