2 Copyright (C) 2006,2007 John Anderson
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.
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.
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.
18 #ifndef mackie_controls_h
19 #define mackie_controls_h
25 #include "pbd/signals.h"
27 #include "mackie_control_exception.h"
35 This is a loose group of controls, eg cursor buttons,
36 transport buttons, functions buttons etc.
41 Group( const std::string & name )
48 virtual bool is_strip() const
53 virtual bool is_master() const
58 virtual void add( Control & control );
60 const std::string & name() const
65 // This is for Surface only
66 void name( const std::string & rhs ) { _name = rhs; }
68 typedef std::vector<Control*> Controls;
69 const Controls & controls() const { return _controls; }
83 This is the set of controls that make up a strip.
85 class Strip : public Group
89 \param is the index of the strip. 0-based.
91 Strip( const std::string & name, int index );
93 virtual bool is_strip() const
98 virtual void add( Control & control );
100 /// This is the index of the strip. zero-based.
101 int index() const { return _index; }
103 /// This is for Surface only
104 /// index is zero-based
105 void index( int rhs ) { _index = rhs; }
108 Button & recenable();
112 Button & fader_touch();
116 bool has_solo() const { return _solo != 0; }
117 bool has_recenable() const { return _recenable != 0; }
118 bool has_mute() const { return _mute != 0; }
119 bool has_select() const { return _select != 0; }
120 bool has_vselect() const { return _vselect != 0; }
121 bool has_fader_touch() const { return _fader_touch != 0; }
122 bool has_vpot() const { return _vpot != 0; }
123 bool has_gain() const { return _gain != 0; }
131 Button * _fader_touch;
137 std::ostream & operator << ( std::ostream &, const Strip & );
139 class MasterStrip : public Strip
142 MasterStrip( const std::string & name, int index )
143 : Strip( name, index )
147 virtual bool is_master() const
156 The base class for controls on the surface. They deliberately
157 don't know the midi protocol for updating them.
162 enum type_t { type_led, type_led_ring, type_fader = 0xe0, type_button = 0x90, type_pot = 0xb0 };
164 Control( int id, int ordinal, std::string name, Group & group );
165 virtual ~Control() {}
167 virtual const Led & led() const
169 throw MackieControlException( "no led available" );
172 /// type() << 8 + midi id of the control. This
173 /// provides a unique id for any control on the surface.
176 return ( type() << 8 ) + _id;
179 /// the value of the second bytes of the message. It's
180 /// the id of the control, but only guaranteed to be
181 /// unique within the control type.
182 int raw_id() const { return _id; }
184 /// The 1-based number of the control
185 int ordinal() const { return _ordinal; }
187 const std::string & name() const
192 const Group & group() const
197 const Strip & strip() const
199 return dynamic_cast<const Strip&>( _group );
204 return dynamic_cast<Strip&>( _group );
207 virtual bool accepts_feedback() const
212 virtual type_t type() const = 0;
214 /// Return true if this control is the one and only Jog Wheel
215 virtual bool is_jog() const { return false; }
218 Return true if the controlis in use, or false otherwise. For buttons
219 this returns true if the button is currently being held down. For
220 faders, the touch button has not been released. For pots, this returns
221 true from the first move event until a timeout after the last move event.
223 virtual bool in_use() const;
224 virtual Control & in_use( bool );
226 /// The timeout value for this control. Normally defaulted to 250ms, but
227 /// certain controls (ie jog wheel) may want to override it.
228 virtual unsigned int in_use_timeout() { return _in_use_timeout; }
230 /// Keep track of the timeout so it can be updated with more incoming events
231 sigc::connection in_use_connection;
239 unsigned int _in_use_timeout;
242 std::ostream & operator << ( std::ostream & os, const Control & control );
244 class Fader : public Control
247 Fader( int id, int ordinal, std::string name, Group & group )
248 : Control( id, ordinal, name, group )
252 virtual type_t type() const { return type_fader; }
255 class Led : public Control
258 Led( int id, int ordinal, std::string name, Group & group )
259 : Control( id, ordinal, name, group )
263 virtual const Led & led() const { return *this; }
265 virtual type_t type() const { return type_led; }
268 class Button : public Control
271 Button( int id, int ordinal, std::string name, Group & group )
272 : Control( id, ordinal, name, group )
273 , _led( id, ordinal, name + "_led", group )
277 virtual const Led & led() const
282 virtual type_t type() const { return type_button; };
288 class LedRing : public Led
291 LedRing( int id, int ordinal, std::string name, Group & group )
292 : Led( id, ordinal, name, group )
296 virtual type_t type() const { return type_led_ring; }
299 class Pot : public Control
302 Pot( int id, int ordinal, std::string name, Group & group )
303 : Control( id, ordinal, name, group )
304 , _led_ring( id, ordinal, name + "_ring", group )
308 virtual type_t type() const { return type_pot; }
310 virtual const LedRing & led_ring() const
319 class Jog : public Pot
322 Jog( int id, int ordinal, std::string name, Group & group )
323 : Pot( id, ordinal, name, group )
327 virtual bool is_jog() const { return true; }