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 "pbd/compose.h"
22 #include "canvas/canvas.h"
23 #include "canvas/debug.h"
25 #include "tempo_lines.h"
26 #include "ardour_ui.h"
27 #include "public_editor.h"
31 TempoLines::TempoLines (ArdourCanvas::Container* group, double)
32 : lines (group, ArdourCanvas::LineSet::Vertical)
34 lines.set_extent (ArdourCanvas::COORD_MAX);
38 TempoLines::tempo_map_changed()
56 TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
57 const ARDOUR::TempoMap::BBTPointList::const_iterator& end)
59 ARDOUR::TempoMap::BBTPointList::const_iterator i;
66 /* get the first bar spacing */
70 bars = (*i).bar - (*begin).bar;
71 beats = distance (begin, end) - bars;
73 beat_density = (beats * 10.0f) / lines.canvas()->width();
75 if (beat_density > 4.0f) {
76 /* if the lines are too close together, they become useless */
83 for (i = begin; i != end; ++i) {
86 color = ARDOUR_UI::config()->get_canvasvar_MeasureLineBar();
88 if (beat_density > 0.3) {
89 continue; /* only draw beat lines if the gaps between beats are large. */
91 color = ARDOUR_UI::config()->get_canvasvar_MeasureLineBeat();
94 ArdourCanvas::Coord xpos = PublicEditor::instance().sample_to_pixel_unrounded ((*i).frame);
96 lines.add (xpos, 1.0, color);