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