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