summaryrefslogtreecommitdiff
path: root/libs/canvas/line_set.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-10-24 17:13:22 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-10-24 17:13:22 -0400
commitc21ed2b877b7928d4a73c6e68718a5d860f5f637 (patch)
tree287c603849297cba19d3758c7819a36164c13f06 /libs/canvas/line_set.cc
parent9d2e4fbec63b0a0bf49c41b7c46e96d0733214ec (diff)
fix drawing of a canvas LineSet object
Diffstat (limited to 'libs/canvas/line_set.cc')
-rw-r--r--libs/canvas/line_set.cc33
1 files changed, 13 insertions, 20 deletions
diff --git a/libs/canvas/line_set.cc b/libs/canvas/line_set.cc
index bc2c2c100a..dc9f54e10b 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<Rect> ();
- _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;
}
@@ -71,23 +69,18 @@ LineSet::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
for (list<Line>::const_iterator i = _lines.begin(); i != _lines.end(); ++i) {
- 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 (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);
- context->move_to (area.x0, self.y);
- context->line_to (area.x1, self.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<Rect> 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 ();
}
}