use session stripable selection API
[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/ringbuffer.h"
11 #include "pbd/signals.h"
12
13 #include "ardour/types.h"
14 #include "control_protocol/types.h"
15
16 #include "control_group.h"
17 #include "types.h"
18 #include "mackie_control_protocol.h"
19 #include "midi_byte_array.h"
20 #include "device_info.h"
21
22 namespace ARDOUR {
23         class Stripable;
24         class Bundle;
25         class ChannelCount;
26 }
27
28 namespace ArdourSurface {
29
30 namespace Mackie {
31
32 class Control;
33 class Surface;
34 class Button;
35 class Pot;
36 class Fader;
37 class Meter;
38 class SurfacePort;
39
40 struct GlobalControlDefinition {
41     const char* name;
42     int 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::Stripable> stripable() const { return _stripable; }
57
58         void add (Control & control);
59         int index() const { return _index; } // zero based
60         Surface* surface() const { return _surface; }
61
62         void set_stripable (boost::shared_ptr<ARDOUR::Stripable>, bool with_messages = true);
63
64         // call all signal handlers manually
65         void notify_all ();
66
67         void handle_button (Button&, ButtonState bs);
68         void handle_fader (Fader&, float position);
69         void handle_fader_touch (Fader&, bool touch_on);
70         void handle_pot (Pot&, float delta);
71
72         void periodic (ARDOUR::microseconds_t now_usecs);
73         void redisplay (ARDOUR::microseconds_t now_usecs, bool force = true);
74
75         MidiByteArray display (uint32_t line_number, const std::string&);
76         MidiByteArray blank_display (uint32_t line_number);
77
78         void zero ();
79
80         void flip_mode_changed ();
81         void subview_mode_changed ();
82
83         void lock_controls ();
84         void unlock_controls ();
85         bool locked() const { return _controls_locked; }
86
87         void notify_metering_state_changed();
88
89         void block_screen_display_for (uint32_t msecs);
90         void block_vpot_mode_display_for (uint32_t msecs);
91
92 private:
93         enum VPotDisplayMode {
94                 Name,
95                 Value
96         };
97
98         Button*  _solo;
99         Button*  _recenable;
100         Button*  _mute;
101         Button*  _select;
102         Button*  _vselect;
103         Button*  _fader_touch;
104         Pot*     _vpot;
105         Fader*   _fader;
106         Meter*   _meter;
107         int      _index;
108         Surface* _surface;
109         bool     _controls_locked;
110         bool     _transport_is_rolling;
111         bool     _metering_active;
112         std::string pending_display[2];
113         std::string current_display[2];
114         uint64_t _block_screen_redisplay_until;
115         uint64_t return_to_vpot_mode_display_at;
116         boost::shared_ptr<ARDOUR::Stripable> _stripable;
117         PBD::ScopedConnectionList stripable_connections;
118         PBD::ScopedConnectionList subview_connections;
119         PBD::ScopedConnectionList send_connections;
120         int       eq_band;
121
122         ARDOUR::AutomationType  _pan_mode;
123
124         float _last_gain_position_written;
125         float _last_pan_azi_position_written;
126         float _last_pan_width_position_written;
127         float _last_trim_position_written;
128
129         void notify_solo_changed ();
130         void notify_mute_changed ();
131         void notify_record_enable_changed ();
132         void notify_gain_changed (bool force_update = true);
133         void notify_property_changed (const PBD::PropertyChange&);
134         void notify_panner_azi_changed (bool force_update = true);
135         void notify_panner_width_changed (bool force_update = true);
136         void notify_stripable_deleted ();
137         void notify_processor_changed (bool force_update = true);
138         void update_automation ();
139         void update_meter ();
140         std::string vpot_mode_string ();
141
142         boost::shared_ptr<ARDOUR::AutomationControl> mb_pan_controllable;
143
144         void return_to_vpot_mode_display ();
145         void next_pot_mode ();
146
147         void do_parameter_display (ARDOUR::AutomationType, float val);
148         void select_event (Button&, ButtonState);
149         void vselect_event (Button&, ButtonState);
150         void fader_touch_event (Button&, ButtonState);
151
152         std::vector<ARDOUR::AutomationType> possible_pot_parameters;
153         std::vector<ARDOUR::AutomationType> possible_trim_parameters;
154         void set_vpot_parameter (ARDOUR::AutomationType);
155         void show_stripable_name ();
156
157         void reset_saved_values ();
158
159         bool is_midi_track () const;
160
161         void notify_eq_change (ARDOUR::AutomationType, uint32_t band, bool force);
162         void setup_eq_vpot (boost::shared_ptr<ARDOUR::Stripable>);
163
164         void notify_dyn_change (ARDOUR::AutomationType, bool force, bool propagate_mode_change);
165         void setup_dyn_vpot (boost::shared_ptr<ARDOUR::Stripable>);
166
167         void notify_send_level_change (ARDOUR::AutomationType, uint32_t band, bool force);
168         void setup_sends_vpot (boost::shared_ptr<ARDOUR::Stripable>);
169
170         void notify_trackview_change (ARDOUR::AutomationType, uint32_t band, bool force);
171         void setup_trackview_vpot (boost::shared_ptr<ARDOUR::Stripable>);
172 };
173
174 }
175 }
176
177 #endif /* __ardour_mackie_control_protocol_strip_h__ */