2 Copyright (C) 2002-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <libgnomecanvasmm/canvas.h>
21 #include <libgnomecanvasmm/group.h>
22 #include "tempo_lines.h"
23 #include "ardour_ui.h"
26 ArdourCanvas::SimpleLine *
27 TempoLines::get_line ()
29 ArdourCanvas::SimpleLine *line;
31 if (_free_lines.empty()) {
32 line = new ArdourCanvas::SimpleLine (*_group);
33 _used_lines.push_back (line);
35 line = _free_lines.front();
36 _free_lines.erase (_free_lines.begin());
37 _used_lines.push_back (line);
47 for (Lines::iterator i = _used_lines.begin(); i != _used_lines.end(); ++i) {
49 _free_lines.push_back (*i);
56 TempoLines::draw (ARDOUR::TempoMap::BBTPointList& points, double frames_per_unit)
58 ARDOUR::TempoMap::BBTPointList::iterator i;
59 ArdourCanvas::SimpleLine *line;
62 double x1, x2, y1, y2, beat_density;
68 _canvas.get_scroll_region (x1, y1, x2, who_cares);
69 _canvas.root()->get_bounds(who_cares, who_cares, who_cares, y2);
71 // FIXME use canvas height
72 //y2 = TimeAxisView::hLargest*5000; // five thousand largest tracks should be enough.. :)
73 //y2 = 500000; // five thousand largest tracks should be enough.. :)
75 /* get the first bar spacing */
79 bars = (*i).bar - (*points.begin()).bar;
80 beats = points.size() - bars;
82 beat_density = (beats * 10.0f) / _canvas.get_width ();
84 if (beat_density > 4.0f) {
85 /* if the lines are too close together, they become useless
90 for (i = points.begin(); i != points.end(); ++i) {
93 case ARDOUR::TempoMap::Bar:
96 case ARDOUR::TempoMap::Beat:
99 color = ARDOUR_UI::config()->canvasvar_MeasureLineBar.get();
101 color = ARDOUR_UI::config()->canvasvar_MeasureLineBeat.get();
103 if (beat_density > 2.0) {
104 /* only draw beat lines if the gaps between beats are large.
110 xpos = rint((*i).frame / (double)frames_per_unit);
112 line->property_x1() = xpos;
113 line->property_x2() = xpos;
114 line->property_y2() = y2;
115 line->property_color_rgba() = color;
116 //line->raise_to_top();