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