2 Copyright (C) 2011-2013 Paul Davis
3 Author: Carl Hetherington <cth@carlh.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "canvas/line_set.h"
21 #include "canvas/utils.h"
24 using namespace ArdourCanvas;
26 /* XXX: hard-wired to horizontal only */
30 bool operator() (LineSet::Line& a, LineSet::Line& b) {
35 LineSet::LineSet (Group* parent)
44 LineSet::compute_bounding_box () const
46 if (_lines.empty ()) {
47 _bounding_box = boost::optional<Rect> ();
48 _bounding_box_dirty = false;
52 _bounding_box = Rect (0, _lines.front().y, COORD_MAX, min (_height, _lines.back().y));
53 _bounding_box_dirty = false;
57 LineSet::set_height (Distance height)
63 _bounding_box_dirty = true;
68 LineSet::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
70 for (list<Line>::const_iterator i = _lines.begin(); i != _lines.end(); ++i) {
73 } else if (i->y > area.y0) {
74 set_source_rgba (context, i->color);
75 context->set_line_width (i->width);
76 context->move_to (area.x0, i->y);
77 context->line_to (area.x1, i->y);
84 LineSet::add (Coord y, Distance width, Color color)
88 _lines.push_back (Line (y, width, color));
89 _lines.sort (LineSorter ());
91 _bounding_box_dirty = true;
100 _bounding_box_dirty = true;