X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fline_set.cc;h=1625e0478dd80cee7fe0e9f15b41664330242648;hb=c29d392b0ca534b29f3436dc10004cc807bd0eee;hp=5aefe1bf47f76cff8c2428ab4686a79b7450a576;hpb=75b933eadbe8f90a73a29bb207ff26eebcd4121a;p=ardour.git diff --git a/libs/canvas/line_set.cc b/libs/canvas/line_set.cc index 5aefe1bf47..1625e0478d 100644 --- a/libs/canvas/line_set.cc +++ b/libs/canvas/line_set.cc @@ -45,11 +45,9 @@ LineSet::compute_bounding_box () const { if (_lines.empty ()) { _bounding_box = boost::optional (); - _bounding_box_dirty = false; - return; + } else { + _bounding_box = Rect (0, _lines.front().y - (_lines.front().width/2.0), COORD_MAX, min (_height, _lines.back().y - (_lines.back().width/2.0))); } - - _bounding_box = Rect (0, _lines.front().y, COORD_MAX, min (_height, _lines.back().y)); _bounding_box_dirty = false; } @@ -67,18 +65,22 @@ 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) { - break; - } else if (i->y > area.y0) { - 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->stroke (); + + Rect self = item_to_window (Rect (0, i->y - (i->width/2.0), COORD_MAX, i->y + (i->width/2.0))); + boost::optional intersect = self.intersection (area); + + if (!intersect) { + continue; } + + set_source_rgba (context, i->color); + context->set_line_width (i->width); + context->move_to (intersect->x0, self.y0 + ((self.y1 - self.y0)/2.0)); + context->line_to (intersect->x1, self.y0 + ((self.y1 - self.y0)/2.0)); + context->stroke (); } } @@ -102,3 +104,9 @@ LineSet::clear () _bounding_box_dirty = true; end_change (); } + +bool +LineSet::covers (Duple const & /*point*/) const +{ + return false; +}