2 #include "canvas/line_set.h"
3 #include "canvas/utils.h"
6 using namespace ArdourCanvas;
8 /* XXX: hard-wired to horizontal only */
12 bool operator() (LineSet::Line& a, LineSet::Line& b) {
17 LineSet::LineSet (Group* parent)
25 LineSet::get_state () const
28 return new XMLNode ("LineSet");
32 LineSet::compute_bounding_box () const
34 if (_lines.empty ()) {
35 _bounding_box = boost::optional<Rect> ();
36 _bounding_box_dirty = false;
40 _bounding_box = Rect (0, _lines.front().y, COORD_MAX, min (_height, _lines.back().y));
41 _bounding_box_dirty = false;
45 LineSet::set_height (Distance height)
51 _bounding_box_dirty = true;
56 LineSet::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
58 for (list<Line>::const_iterator i = _lines.begin(); i != _lines.end(); ++i) {
61 } else if (i->y > area.y0) {
62 set_source_rgba (context, i->color);
63 context->set_line_width (i->width);
64 context->move_to (area.x0, i->y);
65 context->line_to (area.x1, i->y);
72 LineSet::add (Coord y, Distance width, Color color)
76 _lines.push_back (Line (y, width, color));
77 _lines.sort (LineSorter ());
79 _bounding_box_dirty = true;
88 _bounding_box_dirty = true;