{
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;
}
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) {
- 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<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 ();
}
}
_bounding_box_dirty = true;
end_change ();
}
+
+bool
+LineSet::covers (Duple const & /*point*/) const
+{
+ return false;
+}