X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fline_set.cc;h=1625e0478dd80cee7fe0e9f15b41664330242648;hb=98dec658ee4067bdb22262640a821334ddc2ed83;hp=c3ee5d44b9a49ef808b9e59190977a3609fd7519;hpb=11619a37bff79c050e39e434bc9899b516cbe4a1;p=ardour.git diff --git a/libs/canvas/line_set.cc b/libs/canvas/line_set.cc index c3ee5d44b9..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,16 +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); - context->move_to (area.x0, i->y); - context->line_to (area.x1, i->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 (); } } @@ -100,3 +104,9 @@ LineSet::clear () _bounding_box_dirty = true; end_change (); } + +bool +LineSet::covers (Duple const & /*point*/) const +{ + return false; +}