Ardour  9.0-pre0-582-g084a23a80d
surfaces/mackie/button.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2007 John Anderson
3  * Copyright (C) 2012-2015 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2015 Len Ovens <len@ovenwerks.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __ardour_mackie_control_protocol_button_h__
22 #define __ardour_mackie_control_protocol_button_h__
23 
24 #include "ardour/types.h"
25 
26 #include "controls.h"
27 #include "led.h"
28 
29 namespace ArdourSurface { namespace MACKIE_NAMESPACE {
30 
31 class Surface;
32 
33 class Button : public Control
34 {
35 public:
36 /* These values uniquely identify each possible button that an MCP device may
37  send. Each DeviceInfo object contains its own set of button definitions that
38  define what device ID will be sent for each button, and there is no reason
39  for them to be the same. */
40 
41  enum ID {
42  /* Global Buttons */
43 
46  Pan,
48  Eq,
49  Dyn,
58  F1,
59  F2,
60  F3,
61  F4,
62  F5,
63  F6,
64  F7,
65  F8,
70  Aux,
79  Grp,
104 
106 
107  /* Global buttons that users should not redefine */
108 
113 
114  /* Strip buttons */
115 
122 
123  /* Master fader */
124 
126  };
127 
128 
129  Button (Surface& s, ID bid, int did, std::string name, Group & group)
130  : Control (did, name, group)
131  , _surface (s)
132  , _bid (bid)
133  , _led (did, name + "_led", group)
134  , press_time (0) {}
135 
136  MidiByteArray zero() { return _led.zero (); }
137  MidiByteArray set_state (LedState ls) { return _led.set_state (ls); }
138 
139  ID bid() const { return _bid; }
140 
141  static Control* factory (Surface& surface, Button::ID bid, int id, const std::string&, Group& group);
142  static int name_to_id (const std::string& name);
143  static std::string id_to_name (Button::ID);
144 
145  Surface& surface() const { return _surface; }
146 
147  void pressed ();
148  void released ();
149 
150  int32_t long_press_count ();
151 
152 private:
154  ID _bid; /* device independent button ID */
157 };
158 
159 } // Mackie namespace
160 } // ArdourSurface namespace
161 
162 #endif
static Control * factory(Surface &surface, Button::ID bid, int id, const std::string &, Group &group)
Button(Surface &s, ID bid, int did, std::string name, Group &group)
static int name_to_id(const std::string &name)
MidiByteArray set_state(LedState ls)
static std::string id_to_name(Button::ID)
GtkImageIconNameData name
Definition: gtkimage.h:6
int64_t microseconds_t
Definition: microseconds.h:28
#define MACKIE_NAMESPACE