2 * Copyright (C) 2018 Ben Loftis <ben@harrisonconsoles.com>
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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "pbd/compose.h"
21 #include "canvas/canvas.h"
22 #include "canvas/debug.h"
23 #include "canvas/ruler.h"
25 #include "grid_lines.h"
26 #include "public_editor.h"
27 #include "rgb_macros.h"
28 #include "ui_config.h"
31 using namespace ArdourCanvas;
33 GridLines::GridLines (Container* group, double)
34 : lines (group, LineSet::Vertical)
36 lines.set_extent (COORD_MAX);
39 GridLines::~GridLines ()
56 GridLines::draw (std::vector<Ruler::Mark> marks)
60 const uint32_t major_color = UIConfiguration::instance().color_mod("grid line major", "grid line");
61 const uint32_t minor_color = UIConfiguration::instance().color_mod("grid line minor", "grid line");
62 const uint32_t micro_color = UIConfiguration::instance().color_mod("grid line micro", "grid line");
64 for (vector<Ruler::Mark>::const_iterator m = marks.begin(); m != marks.end(); ++m) {
66 samplepos_t s = m->position;
68 if ((*m).style == ArdourCanvas::Ruler::Mark::Major) {
69 lines.add (PublicEditor::instance().sample_to_pixel_unrounded (s), 1.0, major_color);
70 } else if ((*m).style == ArdourCanvas::Ruler::Mark::Minor) {
71 lines.add (PublicEditor::instance().sample_to_pixel_unrounded (s), 1.0, minor_color);
73 lines.add (PublicEditor::instance().sample_to_pixel_unrounded (s), 1.0, micro_color);