Only show user-presets in favorite sidebar
[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 update_selection_state ();
90
91         void block_screen_display_for (uint32_t msecs);
92         void block_vpot_mode_display_for (uint32_t msecs);
93
94 private:
95         enum VPotDisplayMode {
96                 Name,
97                 Value
98         };
99
100         Button*  _solo;
101         Button*  _recenable;
102         Button*  _mute;
103         Button*  _select;
104         Button*  _vselect;
105         Button*  _fader_touch;
106         Pot*     _vpot;
107         Fader*   _fader;
108         Meter*   _meter;
109         int      _index;
110         Surface* _surface;
111         bool     _controls_locked;
112         bool     _transport_is_rolling;
113         bool     _metering_active;
114         std::string pending_display[2];
115         std::string current_display[2];
116         uint64_t _block_screen_redisplay_until;
117         uint64_t return_to_vpot_mode_display_at;
118         boost::shared_ptr<ARDOUR::Stripable> _stripable;
119         PBD::ScopedConnectionList stripable_connections;
120         PBD::ScopedConnectionList subview_connections;
121         PBD::ScopedConnectionList send_connections;
122         int       eq_band;
123
124         ARDOUR::AutomationType  _pan_mode;
125
126         float _last_gain_position_written;
127         float _last_pan_azi_position_written;
128         float _last_pan_width_position_written;
129         float _last_trim_position_written;
130
131         void notify_solo_changed ();
132         void notify_mute_changed ();
133         void notify_record_enable_changed ();
134         void notify_gain_changed (bool force_update = true);
135         void notify_property_changed (const PBD::PropertyChange&);
136         void notify_panner_azi_changed (bool force_update = true);
137         void notify_panner_width_changed (bool force_update = true);
138         void notify_stripable_deleted ();
139         void notify_processor_changed (bool force_update = true);
140         void update_automation ();
141         void update_meter ();
142         std::string vpot_mode_string ();
143
144         boost::shared_ptr<ARDOUR::AutomationControl> mb_pan_controllable;
145
146         void return_to_vpot_mode_display ();
147         void next_pot_mode ();
148
149         void do_parameter_display (ARDOUR::ParameterDescriptor const&, float val, bool screen_hold = false);
150         void select_event (Button&, ButtonState);
151         void vselect_event (Button&, ButtonState);
152         void fader_touch_event (Button&, ButtonState);
153
154         std::vector<ARDOUR::AutomationType> possible_pot_parameters;
155         std::vector<ARDOUR::AutomationType> possible_trim_parameters;
156         void set_vpot_parameter (ARDOUR::AutomationType);
157         void show_stripable_name ();
158
159         void reset_saved_values ();
160
161         bool is_midi_track () const;
162
163         void notify_eq_change (boost::weak_ptr<ARDOUR::AutomationControl>, bool force);
164         void setup_eq_vpot (boost::shared_ptr<ARDOUR::Stripable>);
165
166         void notify_dyn_change (boost::weak_ptr<ARDOUR::AutomationControl>, bool force, bool propagate_mode_change);
167         void setup_dyn_vpot (boost::shared_ptr<ARDOUR::Stripable>);
168
169         void notify_send_level_change (uint32_t band, bool force);
170         void setup_sends_vpot (boost::shared_ptr<ARDOUR::Stripable>);
171
172         void notify_trackview_change (ARDOUR::AutomationType, uint32_t band, bool force);
173         void setup_trackview_vpot (boost::shared_ptr<ARDOUR::Stripable>);
174 };
175
176 }
177 }
178
179 #endif /* __ardour_mackie_control_protocol_strip_h__ */