Remove unused "mark" parameter from stop_touch() API
[ardour.git] / libs / surfaces / mackie / controls.cc
1  /*
2         Copyright (C) 2006,2007 John Anderson
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 #include <iostream>
20 #include <iomanip>
21 #include <sstream>
22
23 #include "ardour/automation_control.h"
24 #include "pbd/enumwriter.h"
25
26 #include "controls.h"
27 #include "types.h"
28 #include "surface.h"
29 #include "control_group.h"
30 #include "button.h"
31 #include "led.h"
32 #include "pot.h"
33 #include "fader.h"
34 #include "jog.h"
35 #include "meter.h"
36
37
38 using namespace std;
39 using namespace ArdourSurface;
40 using namespace Mackie;
41
42 using ARDOUR::AutomationControl;
43
44 void Group::add (Control& control)
45 {
46         _controls.push_back (&control);
47 }
48
49 Control::Control (int id, std::string name, Group & group)
50         : _id (id)
51         , _name (name)
52         , _group (group)
53         , _in_use (false)
54 {
55 }
56
57 /** @return true if the control is in use, or false otherwise.
58     Buttons are `in use' when they are held down.
59     Faders with touch support are `in use' when they are being touched.
60     Pots, or faders without touch support, are `in use' from the first move
61     event until a timeout after the last move event.
62 */
63 bool
64 Control::in_use () const
65 {
66         return _in_use;
67 }
68
69 void
70 Control::set_in_use (bool in_use)
71 {
72         _in_use = in_use;
73 }
74
75 void
76 Control::set_control (boost::shared_ptr<AutomationControl> ac)
77 {
78         normal_ac = ac;
79 }
80
81 void
82 Control::set_value (float val, PBD::Controllable::GroupControlDisposition group_override)
83 {
84         if (normal_ac) {
85                 normal_ac->set_value (normal_ac->interface_to_internal (val), group_override);
86         }
87 }
88
89 float
90 Control::get_value ()
91 {
92         if (!normal_ac) {
93                 return 0.0f;
94         }
95         return normal_ac->internal_to_interface (normal_ac->get_value());
96 }
97
98 void
99 Control::start_touch (double when)
100 {
101         if (normal_ac) {
102                 return normal_ac->start_touch (when);
103         }
104 }
105
106 void
107 Control::stop_touch (double when)
108 {
109         if (normal_ac) {
110                 return normal_ac->stop_touch (when);
111         }
112 }
113
114 ostream & operator <<  (ostream & os, const ArdourSurface::Mackie::Control & control)
115 {
116         os << typeid (control).name();
117         os << " { ";
118         os << "name: " << control.name();
119         os << ", ";
120         os << "id: " << "0x" << setw(2) << setfill('0') << hex << control.id() << setfill(' ');
121         os << ", ";
122         os << "group: " << control.group().name();
123         os << " }";
124
125         return os;
126 }
127