propagate GUI track selection to control protocols; make MCP update when GUI track...
[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_protocol/types.h"
11
12 #include "control_group.h"
13 #include "types.h"
14 #include "midi_byte_array.h"
15
16 namespace ARDOUR {
17         class Route;
18 }
19
20 namespace Mackie {
21
22 class Control;
23 class Surface;
24 class Button;
25 class Pot;
26 class Fader;
27 class Meter;
28 class SurfacePort;
29
30 struct StripControlDefinition {
31     const char* name;
32     uint32_t base_id;
33     Control* (*factory)(Surface&, int index, const char* name, Group&);
34 };
35
36 struct GlobalControlDefinition {
37     const char* name;
38     uint32_t id;
39     Control* (*factory)(Surface&, int index, const char* name, Group&);
40     const char* group_name;
41 };
42
43 /**
44         This is the set of controls that make up a strip.
45 */
46 class Strip : public Group
47 {
48 public:
49         Strip (Surface&, const std::string & name, int index, StripControlDefinition* ctls);
50         ~Strip();
51
52         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
53
54         void add (Control & control);
55         int index() const { return _index; } // zero based
56         
57         void set_route (boost::shared_ptr<ARDOUR::Route>);
58
59         // call all signal handlers manually
60         void notify_all();
61
62         void handle_button (Button&, ButtonState bs);
63         void handle_fader (Fader&, float position);
64         void handle_pot (Pot&, float delta);
65
66         void periodic ();
67
68         MidiByteArray display (uint32_t line_number, const std::string&);
69         MidiByteArray blank_display (uint32_t line_number);
70         MidiByteArray zero ();
71
72         void lock_route ();
73         void unlock_route ();
74         
75         MidiByteArray gui_selection_changed (ARDOUR::RouteNotificationListPtr);
76
77 private:
78         Button* _solo;
79         Button* _recenable;
80         Button* _mute;
81         Button* _select;
82         Button* _vselect;
83         Button* _fader_touch;
84         Pot*    _vpot;
85         Fader*  _fader;
86         Meter*  _meter;
87         int     _index;
88         Surface* _surface;
89         bool     _route_locked;
90
91         boost::shared_ptr<ARDOUR::Route> _route;
92         PBD::ScopedConnectionList route_connections;
93
94         float _last_fader_position_written;
95         float _last_vpot_position_written;
96
97         void notify_solo_changed ();
98         void notify_mute_changed ();
99         void notify_record_enable_changed ();
100         void notify_gain_changed (bool force_update = true);
101         void notify_property_changed (const PBD::PropertyChange&);
102         void notify_panner_changed (bool force_update = true);
103         void notify_active_changed ();
104         void notify_route_deleted ();
105         
106         void update_automation ();
107         void update_meter ();
108 };
109
110 }
111
112 #endif /* __ardour_mackie_control_protocol_strip_h__ */