MCP: make BasicUI::rewind() behave symmetrically to BasicUI::ffwd(); basics of route...
[ardour.git] / libs / surfaces / mackie / strip.h
1 #ifndef __ardour_mackie_control_protocol_strip_h__
2 #define __ardour_mackie_control_protocol_strip_h__
3
4 #include <string>
5 #include <iostream>
6
7 #include "pbd/property_basics.h"
8 #include "pbd/signals.h"
9
10 #include "control_group.h"
11 #include "types.h"
12 #include "midi_byte_array.h"
13
14 namespace ARDOUR {
15         class Route;
16 }
17
18 namespace Mackie {
19
20 class Control;
21 class Surface;
22 class Button;
23 class Pot;
24 class Fader;
25 class Meter;
26 class SurfacePort;
27
28 struct StripControlDefinition {
29     const char* name;
30     uint32_t base_id;
31     Control* (*factory)(Surface&, int index, const char* name, Group&);
32 };
33
34 struct GlobalControlDefinition {
35     const char* name;
36     uint32_t id;
37     Control* (*factory)(Surface&, int index, const char* name, Group&);
38     const char* group_name;
39 };
40
41 /**
42         This is the set of controls that make up a strip.
43 */
44 class Strip : public Group
45 {
46 public:
47         Strip (Surface&, const std::string & name, int index, StripControlDefinition* ctls);
48         ~Strip();
49
50         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
51
52         void add (Control & control);
53         int index() const { return _index; } // zero based
54         
55         Button & solo();
56         Button & recenable();
57         Button & mute();
58         Button & select();
59         Button & vselect();
60         Button & fader_touch();
61         Pot & vpot();
62         Fader & gain();
63         Meter& meter ();
64
65         bool has_solo() const { return _solo != 0; }
66         bool has_recenable() const { return _recenable != 0; }
67         bool has_mute() const { return _mute != 0; }
68         bool has_select() const { return _select != 0; }
69         bool has_vselect() const { return _vselect != 0; }
70         bool has_fader_touch() const { return _fader_touch != 0; }
71         bool has_vpot() const { return _vpot != 0; }
72         bool has_gain() const { return _gain != 0; }
73         bool has_meter() const { return _meter != 0; }
74
75         void set_route (boost::shared_ptr<ARDOUR::Route>);
76
77         // call all signal handlers manually
78         void notify_all();
79
80         void handle_button (Button&, ButtonState bs);
81         void handle_fader (Fader&, float position);
82         void handle_pot (Pot&, float delta);
83
84         void periodic ();
85
86         MidiByteArray display (uint32_t line_number, const std::string&);
87         MidiByteArray blank_display (uint32_t line_number);
88         MidiByteArray zero ();
89
90         void lock_route ();
91         void unlock_route ();
92         
93 private:
94         Button* _solo;
95         Button* _recenable;
96         Button* _mute;
97         Button* _select;
98         Button* _vselect;
99         Button* _fader_touch;
100         Pot*    _vpot;
101         Fader*  _gain;
102         Meter*  _meter;
103         int     _index;
104         Surface* _surface;
105         bool     _route_locked;
106
107         boost::shared_ptr<ARDOUR::Route> _route;
108         PBD::ScopedConnectionList route_connections;
109
110         // Last written values for the gain and pan, to avoid overloading
111         // the midi connection to the surface
112         float         _last_gain_written;
113         MidiByteArray _last_pan_written;
114
115
116         void notify_solo_changed ();
117         void notify_mute_changed ();
118         void notify_record_enable_changed ();
119         void notify_gain_changed (bool force_update = true);
120         void notify_property_changed (const PBD::PropertyChange&);
121         void notify_panner_changed (bool force_update = true);
122         void notify_active_changed ();
123         void notify_route_deleted ();
124         
125         void update_automation ();
126         void update_meter ();
127
128 };
129
130 std::ostream & operator <<  (std::ostream &, const Strip &);
131
132 }
133
134 #endif /* __ardour_mackie_control_protocol_strip_h__ */