use session stripable selection API
[ardour.git] / libs / surfaces / mackie / button.h
1 /*
2         Copyright (C) 2006,2007 John Anderson
3         Copyright (C) 2012 Paul Davis
4
5         This program is free software; you can redistribute it and/or modify
6         it under the terms of the GNU General Public License as published by
7         the Free Software Foundation; either version 2 of the License, or
8         (at your option) any later version.
9
10         This program is distributed in the hope that it will be useful,
11         but WITHOUT ANY WARRANTY; without even the implied warranty of
12         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13         GNU General Public License for more details.
14
15         You should have received a copy of the GNU General Public License
16         along with this program; if not, write to the Free Software
17         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __ardour_mackie_control_protocol_button_h__
21 #define __ardour_mackie_control_protocol_button_h__
22
23 #include "ardour/types.h"
24
25 #include "controls.h"
26 #include "led.h"
27
28 namespace ArdourSurface {
29
30 namespace Mackie {
31
32 class Surface;
33
34 class Button : public Control
35 {
36 public:
37 /* These values uniquely identify each possible button that an MCP device may
38    send. Each DeviceInfo object contains its own set of button definitions that
39    define what device ID will be sent for each button, and there is no reason
40    for them to be the same.  */
41
42         enum ID {
43                 /* Global Buttons */
44
45                 Track,
46                 Send,
47                 Pan,
48                 Plugin,
49                 Eq,
50                 Dyn,
51                 Left,
52                 Right,
53                 ChannelLeft,
54                 ChannelRight,
55                 Flip,
56                 View,
57                 NameValue,
58                 TimecodeBeats,
59                 F1,
60                 F2,
61                 F3,
62                 F4,
63                 F5,
64                 F6,
65                 F7,
66                 F8,
67                 MidiTracks,
68                 Inputs,
69                 AudioTracks,
70                 AudioInstruments,
71                 Aux,
72                 Busses,
73                 Outputs,
74                 User,
75                 Read,
76                 Write,
77                 Trim,
78                 Touch,
79                 Latch,
80                 Grp,
81                 Save,
82                 Undo,
83                 Cancel,
84                 Enter,
85                 Marker,
86                 Nudge,
87                 Loop,
88                 Drop,
89                 Replace,
90                 Click,
91                 ClearSolo,
92                 Rewind,
93                 Ffwd,
94                 Stop,
95                 Play,
96                 Record,
97                 CursorUp,
98                 CursorDown,
99                 CursorLeft,
100                 CursorRight,
101                 Zoom,
102                 Scrub,
103                 UserA,
104                 UserB,
105
106                 FinalGlobalButton,
107
108                 /* Global buttons that users should not redefine */
109
110                 Shift,
111                 Option,
112                 Ctrl,
113                 CmdAlt,
114
115                 /* Strip buttons */
116
117                 RecEnable,
118                 Solo,
119                 Mute,
120                 Select,
121                 VSelect,
122                 FaderTouch,
123
124                 /* Master fader */
125
126                 MasterFaderTouch,
127         };
128
129
130         Button (Surface& s, ID bid, int did, std::string name, Group & group)
131                 : Control (did, name, group)
132                 , _surface (s)
133                 , _bid (bid)
134                 , _led  (did, name + "_led", group)
135                 , press_time (0) {}
136
137         MidiByteArray zero() { return _led.zero (); }
138         MidiByteArray set_state (LedState ls) { return _led.set_state (ls); }
139
140         ID bid() const { return _bid; }
141
142         static Control* factory (Surface& surface, Button::ID bid, int id, const std::string&, Group& group);
143         static int name_to_id (const std::string& name);
144         static std::string id_to_name (Button::ID);
145
146         Surface& surface() const { return _surface; }
147
148         void pressed ();
149         void released ();
150
151         int32_t long_press_count ();
152
153 private:
154         Surface& _surface;
155         ID  _bid; /* device independent button ID */
156         Led _led;
157         ARDOUR::microseconds_t press_time;
158 };
159
160 } // Mackie namespace
161 } // ArdourSurface namespace
162
163 #endif