X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fmackie%2Fcontrols.h;h=c53be76891df4d3d7fb18cf7e5949ed927cae89a;hb=9740fb7d760c96acf9794e0e6bca710c7782c71b;hp=84283f301697ea1299db941ebe7331de14ceb1e9;hpb=51625b2474e72850d19ff521d1b9f80be8b24136;p=ardour.git diff --git a/libs/surfaces/mackie/controls.h b/libs/surfaces/mackie/controls.h index 84283f3016..c53be76891 100644 --- a/libs/surfaces/mackie/controls.h +++ b/libs/surfaces/mackie/controls.h @@ -1,5 +1,6 @@ /* Copyright (C) 2006,2007 John Anderson + Copyright (C) 2012 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,318 +16,79 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef mackie_controls_h -#define mackie_controls_h -#include +#ifndef __mackie_controls_h__ +#define __mackie_controls_h__ #include #include #include +#include -#include "mackie_control_exception.h" - -namespace Mackie -{ - -class Control; +#include -/** - This is a loose group of controls, eg cursor buttons, - transport buttons, functions buttons etc. -*/ -class Group -{ -public: - Group( const std::string & name ) - : _name( name ) - { - } - - virtual ~Group() {} - - virtual bool is_strip() const - { - return false; - } - - virtual bool is_master() const - { - return false; - } - - virtual void add( Control & control ); - - const std::string & name() const - { - return _name; - } - - // This is for Surface only - void name( const std::string & rhs ) { _name = rhs; } - - typedef std::vector Controls; - const Controls & controls() const { return _controls; } - -protected: - Controls _controls; - -private: - std::string _name; -}; +#include "pbd/controllable.h" +#include "pbd/signals.h" -class Button; -class Pot; -class Fader; +#include "mackie_control_exception.h" +#include "midi_byte_array.h" -/** - This is the set of controls that make up a strip. -*/ -class Strip : public Group -{ -public: - /** - \param is the index of the strip. 0-based. - */ - Strip( const std::string & name, int index ); - - virtual bool is_strip() const - { - return true; - } - - virtual void add( Control & control ); - - /// This is the index of the strip. zero-based. - int index() const { return _index; } - - /// This is for Surface only - /// index is zero-based - void index( int rhs ) { _index = rhs; } - - Button & solo(); - Button & recenable(); - Button & mute(); - Button & select(); - Button & vselect(); - Button & fader_touch(); - Pot & vpot(); - Fader & gain(); - - bool has_solo() const { return _solo != 0; } - bool has_recenable() const { return _recenable != 0; } - bool has_mute() const { return _mute != 0; } - bool has_select() const { return _select != 0; } - bool has_vselect() const { return _vselect != 0; } - bool has_fader_touch() const { return _fader_touch != 0; } - bool has_vpot() const { return _vpot != 0; } - bool has_gain() const { return _gain != 0; } - -private: - Button * _solo; - Button * _recenable; - Button * _mute; - Button * _select; - Button * _vselect; - Button * _fader_touch; - Pot * _vpot; - Fader * _gain; - int _index; -}; +namespace ARDOUR { + class AutomationControl; +} -std::ostream & operator << ( std::ostream &, const Strip & ); +namespace ArdourSurface { -class MasterStrip : public Strip -{ -public: - MasterStrip( const std::string & name, int index ) - : Strip( name, index ) - { - } - - virtual bool is_master() const - { - return true; - } -}; +namespace Mackie { -class Led; +class Strip; +class Group; +class Surface; -/** - The base class for controls on the surface. They deliberately - don't know the midi protocol for updating them. -*/ -class Control -{ +class Control { public: - enum type_t { type_led, type_led_ring, type_fader = 0xe0, type_button = 0x90, type_pot = 0xb0 }; - - Control( int id, int ordinal, std::string name, Group & group ); + Control (int id, std::string name, Group& group); virtual ~Control() {} - - virtual const Led & led() const - { - throw MackieControlException( "no led available" ); - } - /// type() << 8 + midi id of the control. This - /// provides a unique id for any control on the surface. - int id() const - { - return ( type() << 8 ) + _id; - } - - /// the value of the second bytes of the message. It's - /// the id of the control, but only guaranteed to be - /// unique within the control type. - int raw_id() const { return _id; } - - /// The 1-based number of the control - int ordinal() const { return _ordinal; } - - const std::string & name() const - { - return _name; - } - - const Group & group() const - { - return _group; - } - - const Strip & strip() const - { - return dynamic_cast( _group ); - } - - Strip & strip() - { - return dynamic_cast( _group ); - } - - virtual bool accepts_feedback() const - { - return true; - } - - virtual type_t type() const = 0; - - /// Return true if this control is the one and only Jog Wheel - virtual bool is_jog() const { return false; } + int id() const { return _id; } + const std::string & name() const { return _name; } + Group & group() const { return _group; } - /** - Return true if the controlis in use, or false otherwise. For buttons - this returns true if the button is currently being held down. For - faders, the touch button has not been released. For pots, this returns - true from the first move event until a timeout after the last move event. - */ - virtual bool in_use() const; - virtual Control & in_use( bool ); - - /// The timeout value for this control. Normally defaulted to 250ms, but - /// certain controls (ie jog wheel) may want to override it. - virtual unsigned int in_use_timeout() { return _in_use_timeout; } + bool in_use () const; + void set_in_use (bool); - /// Keep track of the timeout so it can be updated with more incoming events + // Keep track of the timeout so it can be updated with more incoming events sigc::connection in_use_connection; - -private: - int _id; - int _ordinal; - std::string _name; - Group & _group; - bool _in_use; - unsigned int _in_use_timeout; -}; -std::ostream & operator << ( std::ostream & os, const Control & control ); + virtual MidiByteArray zero() = 0; -class Fader : public Control -{ -public: - Fader( int id, int ordinal, std::string name, Group & group ) - : Control( id, ordinal, name, group ) - { - } - - virtual type_t type() const { return type_fader; } -}; + /** If we are doing an in_use timeout for a fader without touch, this + * is its touch button control; otherwise 0. + */ + Control* in_use_touch_control; -class Led : public Control -{ -public: - Led( int id, int ordinal, std::string name, Group & group ) - : Control( id, ordinal, name, group ) - { - } - - virtual const Led & led() const { return *this; } - - virtual type_t type() const { return type_led; } -}; - -class Button : public Control -{ -public: - Button( int id, int ordinal, std::string name, Group & group ) - : Control( id, ordinal, name, group ) - , _led( id, ordinal, name + "_led", group ) - { - } - - virtual const Led & led() const - { - return _led; - } - - virtual type_t type() const { return type_button; }; - -private: - Led _led; -}; + boost::shared_ptr control () const { return normal_ac; } + virtual void set_control (boost::shared_ptr); -class LedRing : public Led -{ -public: - LedRing( int id, int ordinal, std::string name, Group & group ) - : Led( id, ordinal, name, group ) - { - } + float get_value (); + void set_value (float val, PBD::Controllable::GroupControlDisposition gcd = PBD::Controllable::UseGroup); - virtual type_t type() const { return type_led_ring; } -}; - -class Pot : public Control -{ -public: - Pot( int id, int ordinal, std::string name, Group & group ) - : Control( id, ordinal, name, group ) - , _led_ring( id, ordinal, name + "_ring", group ) - { - } + virtual void start_touch (double when); + virtual void stop_touch (bool mark, double when); - virtual type_t type() const { return type_pot; } + protected: + boost::shared_ptr normal_ac; - virtual const LedRing & led_ring() const - { - return _led_ring; - } - -private: - LedRing _led_ring; -}; - -class Jog : public Pot -{ -public: - Jog( int id, int ordinal, std::string name, Group & group ) - : Pot( id, ordinal, name, group ) - { - } - - virtual bool is_jog() const { return true; } + private: + int _id; /* possibly device-dependent ID */ + std::string _name; + Group& _group; + bool _in_use; }; } +} + +std::ostream & operator << (std::ostream & os, const ArdourSurface::Mackie::Control & control); -#endif +#endif /* __mackie_controls_h__ */