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