use new method in MidiPatchManager to use MIDNAM data when setting a MidiTimeAxisView
[ardour.git] / gtk2_ardour / clock_group.cc
1 /*
2  * Copyright (C) 2011-2017 Paul Davis <paul@linuxaudiosystems.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 "clock_group.h"
20
21 ClockGroup::ClockGroup ()
22         : ignore_changes (false)
23         , _clock_mode (AudioClock::Samples)
24 {
25 }
26
27 ClockGroup::~ClockGroup()
28 {
29 }
30
31 void
32 ClockGroup::add (AudioClock& clock)
33 {
34         if (clocks.insert (&clock).second) {
35                 clock.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &ClockGroup::one_clock_changed), &clock));
36                 clock.set_mode (_clock_mode);
37         }
38 }
39
40 void
41 ClockGroup::remove (AudioClock& clock)
42 {
43         clocks.erase (&clock);
44 }
45
46 void
47 ClockGroup::one_clock_changed (AudioClock* clock)
48 {
49         if (!ignore_changes) {
50                 set_clock_mode (clock->mode());
51         }
52 }
53
54 void
55 ClockGroup::set_clock_mode (AudioClock::Mode mode)
56 {
57         _clock_mode = mode;
58
59         ignore_changes = true;
60         for (std::set<AudioClock*>::iterator c = clocks.begin(); c != clocks.end(); ++c) {
61                 (*c)->set_mode (mode);
62         }
63         ignore_changes = false;
64 }
65