2 Copyright (C) 2002-2018 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"
24 #include "canvas/ruler.h"
26 #include "grid_lines.h"
27 #include "public_editor.h"
28 #include "rgb_macros.h"
29 #include "ui_config.h"
32 using namespace ArdourCanvas;
34 GridLines::GridLines (Container* group, double)
35 : lines (group, LineSet::Vertical)
37 lines.set_extent (COORD_MAX);
40 GridLines::~GridLines ()
57 GridLines::draw (std::vector<Ruler::Mark> marks)
61 const uint32_t major_color = UIConfiguration::instance().color_mod("grid line major", "grid line");
62 const uint32_t minor_color = UIConfiguration::instance().color_mod("grid line minor", "grid line");
63 const uint32_t micro_color = UIConfiguration::instance().color_mod("grid line micro", "grid line");
65 for (vector<Ruler::Mark>::const_iterator m = marks.begin(); m != marks.end(); ++m) {
67 samplepos_t s = m->position;
69 if ((*m).style == ArdourCanvas::Ruler::Mark::Major) {
70 lines.add (PublicEditor::instance().sample_to_pixel_unrounded (s), 1.0, major_color);
71 } else if ((*m).style == ArdourCanvas::Ruler::Mark::Minor) {
72 lines.add (PublicEditor::instance().sample_to_pixel_unrounded (s), 1.0, minor_color);
74 lines.add (PublicEditor::instance().sample_to_pixel_unrounded (s), 1.0, micro_color);