use new action map API instead of ActionManager::get_action
[ardour.git] / gtk2_ardour / grid_lines.cc
1 /*
2     Copyright (C) 2002-2018 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include "pbd/compose.h"
21
22 #include "canvas/canvas.h"
23 #include "canvas/debug.h"
24 #include "canvas/ruler.h"
25
26 #include "grid_lines.h"
27 #include "public_editor.h"
28 #include "rgb_macros.h"
29 #include "ui_config.h"
30
31 using namespace std;
32 using namespace ArdourCanvas;
33
34 GridLines::GridLines (Container* group, double)
35         : lines (group, LineSet::Vertical)
36 {
37         lines.set_extent (COORD_MAX);
38 }
39
40 GridLines::~GridLines ()
41 {
42 }
43
44 void
45 GridLines::show ()
46 {
47         lines.show ();
48 }
49
50 void
51 GridLines::hide ()
52 {
53         lines.hide ();
54 }
55
56 void
57 GridLines::draw (std::vector<Ruler::Mark>     marks)
58 {
59         lines.clear();
60         
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");
64
65         for (vector<Ruler::Mark>::const_iterator m = marks.begin(); m != marks.end(); ++m) {
66
67                 samplepos_t s = m->position;
68
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);
73                 } else {
74                         lines.add (PublicEditor::instance().sample_to_pixel_unrounded (s), 1.0, micro_color);
75                 }
76         }
77 }
78