MCP: maybe fix vpot display behavior for pan width
[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 "ardour/types.h"
11 #include "control_protocol/types.h"
12
13 #include "control_group.h"
14 #include "types.h"
15 #include "midi_byte_array.h"
16 #include "device_info.h"
17
18 namespace ARDOUR {
19         class Route;
20         class Bundle;
21         class ChannelCount;
22 }
23
24 namespace Mackie {
25
26 class Control;
27 class Surface;
28 class Button;
29 class Pot;
30 class Fader;
31 class Meter;
32 class SurfacePort;
33
34 struct StripControlDefinition {
35     const char* name;
36     uint32_t base_id;
37     Control* (*factory)(Surface&, int index, const char* name, Group&);
38 };
39
40 struct GlobalControlDefinition {
41     const char* name;
42     uint32_t id;
43     Control* (*factory)(Surface&, int index, const char* name, Group&);
44     const char* group_name;
45 };
46
47 /**
48         This is the set of controls that make up a strip.
49 */
50 class Strip : public Group
51 {
52 public:
53         Strip (Surface&, const std::string & name, int index, const std::map<Button::ID,StripButtonInfo>&);
54         ~Strip();
55
56         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
57
58         void add (Control & control);
59         int index() const { return _index; } // zero based
60         
61         void set_route (boost::shared_ptr<ARDOUR::Route>);
62
63         // call all signal handlers manually
64         void notify_all();
65
66         void handle_button (Button&, ButtonState bs);
67         void handle_fader (Fader&, float position);
68         void handle_pot (Pot&, float delta);
69
70         void periodic (uint64_t now_usecs);
71
72         MidiByteArray display (uint32_t line_number, const std::string&);
73         MidiByteArray blank_display (uint32_t line_number);
74         MidiByteArray zero ();
75
76         void flip_mode_changed (bool notify=false);
77
78         void lock_controls ();
79         void unlock_controls ();
80         
81         MidiByteArray gui_selection_changed (ARDOUR::RouteNotificationListPtr);
82
83 private:
84         enum PotMode {
85                 Gain,
86                 PanAzimuth,
87                 PanWidth,
88                 PanElevation,
89                 PanFrontBack,
90                 PanLFE,
91                 Input,
92                 Output,
93                 Send1,
94                 Send2,
95                 Send3,
96                 Send4,
97                 Send5,
98                 Send6,
99                 Send7,
100                 Send8,
101         };
102                 
103         Button*  _solo;
104         Button*  _recenable;
105         Button*  _mute;
106         Button*  _select;
107         Button*  _vselect;
108         Button*  _fader_touch;
109         Pot*     _vpot;
110         PotMode  _vpot_mode;
111         PotMode  _preflip_vpot_mode;
112         Fader*   _fader;
113         Meter*   _meter;
114         int      _index;
115         Surface* _surface;
116         bool     _controls_locked;
117         uint64_t _reset_display_at;
118         boost::shared_ptr<ARDOUR::Route> _route;
119         PBD::ScopedConnectionList route_connections;
120
121         float _last_gain_position_written;
122         float _last_pan_position_written;
123
124         void notify_solo_changed ();
125         void notify_mute_changed ();
126         void notify_record_enable_changed ();
127         void notify_gain_changed (bool force_update = true);
128         void notify_property_changed (const PBD::PropertyChange&);
129         void notify_panner_azi_changed (bool force_update = true);
130         void notify_panner_width_changed (bool force_update = true);
131         void notify_active_changed ();
132         void notify_route_deleted ();
133         
134         void update_automation ();
135         void update_meter ();
136
137         std::string vpot_mode_string () const;
138
139         void queue_display_reset (uint32_t msecs);
140         void clear_display_reset ();
141         void reset_display ();
142         void do_parameter_display (ARDOUR::AutomationType, float val);
143         
144         typedef std::map<std::string,boost::shared_ptr<ARDOUR::Bundle> > BundleMap;
145         BundleMap input_bundles;
146         BundleMap output_bundles;
147
148         void build_input_list (const ARDOUR::ChanCount&);
149         void build_output_list (const ARDOUR::ChanCount&);
150         void maybe_add_to_bundle_map (BundleMap& bm, boost::shared_ptr<ARDOUR::Bundle>, bool for_input, const ARDOUR::ChanCount&);
151
152         void select_event (Button&, ButtonState);
153         void vselect_event (Button&, ButtonState);
154         void fader_touch_event (Button&, ButtonState);
155
156         std::vector<PotMode> current_pot_modes;
157         void next_pot_mode ();
158         void set_vpot_mode (PotMode);
159 };
160
161 }
162
163 #endif /* __ardour_mackie_control_protocol_strip_h__ */