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; }
217 bool in_use () const;
218 void set_in_use (bool);
220 /// Keep track of the timeout so it can be updated with more incoming events
221 sigc::connection in_use_connection;
223 /** If we are doing an in_use timeout for a fader without touch, this
224 * is its touch button control; otherwise 0.
226 Control* in_use_touch_control;
236 std::ostream & operator << ( std::ostream & os, const Control & control );
238 class Fader : public Control
241 Fader( int id, int ordinal, std::string name, Group & group )
242 : Control( id, ordinal, name, group )
246 virtual type_t type() const { return type_fader; }
249 class Led : public Control
252 Led( int id, int ordinal, std::string name, Group & group )
253 : Control( id, ordinal, name, group )
257 virtual const Led & led() const { return *this; }
259 virtual type_t type() const { return type_led; }
262 class Button : public Control
265 Button( int id, int ordinal, std::string name, Group & group )
266 : Control( id, ordinal, name, group )
267 , _led( id, ordinal, name + "_led", group )
271 virtual const Led & led() const
276 virtual type_t type() const { return type_button; };
282 class LedRing : public Led
285 LedRing( int id, int ordinal, std::string name, Group & group )
286 : Led( id, ordinal, name, group )
290 virtual type_t type() const { return type_led_ring; }
293 class Pot : public Control
296 Pot( int id, int ordinal, std::string name, Group & group )
297 : Control( id, ordinal, name, group )
298 , _led_ring( id, ordinal, name + "_ring", group )
302 virtual type_t type() const { return type_pot; }
304 virtual const LedRing & led_ring() const
313 class Jog : public Pot
316 Jog( int id, int ordinal, std::string name, Group & group )
317 : Pot( id, ordinal, name, group )
321 virtual bool is_jog() const { return true; }