Ardour  9.0-rc1-12-g0f3760a8d1
subview.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2007 John Anderson
3  * Copyright (C) 2012-2015 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __ardour_mackie_control_protocol_subview_h__
21 #define __ardour_mackie_control_protocol_subview_h__
22 
23 #include "pbd/signals.h"
24 #include "ardour/types.h"
25 
26 namespace ARDOUR {
27  struct ParameterDescriptor;
28  class Plugin;
29  class PluginInsert;
30 }
31 
32 namespace ArdourSurface { namespace MACKIE_NAMESPACE {
33 
34 class MackieControlProtocol;
35 
36 class Pot;
37 class Strip;
38 class Subview;
39 class Surface;
40 class SubviewFactory;
41 
45 class Subview {
46  public:
47 
48  enum Mode {
50  EQ,
55  };
56 
57 
58  Subview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
59  virtual ~Subview();
60 
61  virtual Mode subview_mode () const = 0;
62  virtual void update_global_buttons() = 0;
63  virtual bool permit_flipping_faders_and_pots() { return false; }
64  virtual void init_params(){}
65  virtual void setup_vpot(
66  Strip* strip,
67  Pot* vpot,
68  std::string pending_display[2]) = 0;
69  virtual void handle_vselect_event(uint32_t global_strip_position);
70  // returns true if press was handled in the subview, default is false
71  virtual bool handle_cursor_right_press() { return false; }
72  // returns true if press was handled in the subview, default is false
73  virtual bool handle_cursor_left_press() { return false; }
74 
75  static bool subview_mode_would_be_ok (Subview::Mode, std::shared_ptr<ARDOUR::Stripable>, std::string& reason_why_not);
76  std::shared_ptr<ARDOUR::Stripable> subview_stripable() const { return _subview_stripable; }
77 
79  MackieControlProtocol& mcp() { return _mcp; }
80 
83 
84  void do_parameter_display(std::string& display, const ARDOUR::ParameterDescriptor& pd, float param_val, Strip* strip, bool screen_hold);
85 
86  protected:
88  void store_pointers(Strip* strip, Pot* vpot, std::string* pending_display, uint32_t global_strip_position);
89  bool retrieve_pointers(Strip** strip, Pot** vpot, std::string** pending_display, uint32_t global_strip_position);
90 
91  MackieControlProtocol& _mcp;
92  std::shared_ptr<ARDOUR::Stripable> _subview_stripable;
94 
95  std::vector<Strip*> _strips_over_all_surfaces;
96  std::vector<Pot*> _strip_vpots_over_all_surfaces;
97  std::vector<std::string*> _strip_pending_displays_over_all_surfaces;
99  private:
101 };
102 
103 class NoneSubview : public Subview {
104  public:
105  NoneSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
106  virtual ~NoneSubview();
107 
108  virtual Mode subview_mode () const { return Subview::None; }
109  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
110 
111  virtual void update_global_buttons();
112  virtual void setup_vpot(
113  Strip* strip,
114  Pot* vpot,
115  std::string pending_display[2]);
116 };
117 
118 class EQSubview : public Subview {
119  public:
120  EQSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
121  virtual ~EQSubview();
122 
123  virtual Mode subview_mode () const { return Subview::EQ; }
124  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
125  virtual void update_global_buttons();
126  virtual void init_params();
127  virtual void setup_vpot(
128  Strip* strip,
129  Pot* vpot,
130  std::string pending_display[2]);
131  void notify_change (std::weak_ptr<ARDOUR::AutomationControl>, uint32_t global_strip_position, bool force);
132  virtual bool handle_cursor_left_press();
134  protected:
135  uint32_t _current_bank;
136  std::vector<std::pair<std::shared_ptr<ARDOUR::AutomationControl>, std::string>> available;
137 };
138 
139 class DynamicsSubview : public Subview {
140  public:
141  DynamicsSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
142  virtual ~DynamicsSubview();
143 
144  virtual Subview::Mode subview_mode () const { return Subview::Dynamics; }
145  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
146  virtual void update_global_buttons();
147  virtual void init_params();
148  virtual void setup_vpot(
149  Strip* strip,
150  Pot* vpot,
151  std::string pending_display[2]);
152  void notify_change (std::weak_ptr<ARDOUR::AutomationControl>, uint32_t global_strip_position, bool force, bool propagate_mode_change);
153  virtual bool handle_cursor_left_press();
155  protected:
156  uint32_t _current_bank;
157  std::vector<std::pair<std::shared_ptr<ARDOUR::AutomationControl>, std::string>> available;
158 };
159 
160 class SendsSubview : public Subview {
161  public:
162  SendsSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
163  virtual ~SendsSubview();
164 
165  virtual Subview::Mode subview_mode () const { return Subview::Sends; }
166  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
167  virtual void update_global_buttons();
168  virtual bool permit_flipping_faders_and_pots() { return true; }
169  virtual void setup_vpot(
170  Strip* strip,
171  Pot* vpot,
172  std::string pending_display[2]);
173  void notify_send_level_change (uint32_t global_strip_position, bool force);
174  void notify_send_enable_change (uint32_t global_strip_position, bool force);
175 
176  virtual void handle_vselect_event(uint32_t global_strip_position);
178  virtual bool handle_cursor_left_press();
179  protected:
180  uint32_t _current_bank;
181 
182 };
183 
184 class TrackViewSubview : public Subview {
185  public:
186  TrackViewSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
187  virtual ~TrackViewSubview();
188 
189  virtual Subview::Mode subview_mode () const { return Subview::TrackView; }
190  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
191  virtual void update_global_buttons();
192  virtual void setup_vpot(
193  Strip* strip,
194  Pot* vpot,
195  std::string pending_display[2]);
196  void notify_change (ARDOUR::AutomationType, uint32_t global_strip_position, bool force);
197 };
198 
199 class PluginSubviewState;
200 
201 class PluginSubview : public Subview {
202  public:
203  PluginSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
204  virtual ~PluginSubview();
205 
206  virtual Subview::Mode subview_mode () const { return Subview::Plugin; }
207  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
208  virtual void update_global_buttons();
210  virtual void setup_vpot(
211  Strip* strip,
212  Pot* vpot,
213  std::string pending_display[2]);
214  virtual void handle_vselect_event(uint32_t global_strip_position);
216  virtual bool handle_cursor_left_press();
217 
218  void set_state(std::shared_ptr<PluginSubviewState> new_state);
219 
220  protected:
223 
224  std::shared_ptr<PluginSubviewState> _plugin_subview_state;
225 };
226 
228  public:
231 
232  virtual bool permit_flipping_faders_and_pots() { return false; }
233  virtual void setup_vpot(
234  Strip* strip,
235  Pot* vpot,
236  std::string pending_display[2],
237  uint32_t global_strip_position,
238  std::shared_ptr<ARDOUR::Stripable> subview_stripable) = 0;
239  virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr<ARDOUR::Stripable> subview_stripable) = 0;
240  static std::string shorten_display_text(const std::string& text, std::string::size_type target_length);
241  virtual bool handle_cursor_right_press() = 0;
242  virtual bool handle_cursor_left_press();
243  virtual void bank_changed() = 0;
244 
245  protected:
246  uint32_t calculate_virtual_strip_position(uint32_t strip_index) const;
247 
249  const uint32_t _bank_size;
250  uint32_t _current_bank;
251 };
252 
254  public:
256  virtual ~PluginSelect();
257 
258  virtual void setup_vpot(
259  Strip* strip,
260  Pot* vpot,
261  std::string pending_display[2],
262  uint32_t global_strip_position,
263  std::shared_ptr<ARDOUR::Stripable> subview_stripable);
264  virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
266  virtual void bank_changed();
267  private:
268  const uint32_t _bank_size;
269 };
270 
272  public:
273  PluginEdit(PluginSubview& context, std::weak_ptr<ARDOUR::PluginInsert> weak_subview_plugin);
274  virtual ~PluginEdit();
275 
276  virtual bool permit_flipping_faders_and_pots() { return true; }
277  virtual void setup_vpot(
278  Strip* strip,
279  Pot* vpot,
280  std::string pending_display[2],
281  uint32_t global_strip_position,
282  std::shared_ptr<ARDOUR::Stripable> subview_stripable);
283  virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
285  virtual void bank_changed();
286 
287  void notify_parameter_change(Strip* strip, Pot* vpot, std::string pending_display[2], uint32_t global_strip_position);
288  void init();
289  bool plugin_went_away() const;
291 
292  std::shared_ptr<ARDOUR::AutomationControl> parameter_control(uint32_t global_strip_position) const;
293 
294  std::weak_ptr<ARDOUR::PluginInsert> _weak_subview_plugin_insert;
295  std::weak_ptr<ARDOUR::Plugin> _weak_subview_plugin;
296  std::vector<uint32_t> _plugin_input_parameter_indices;
297 };
298 
300  public:
302 
303  std::shared_ptr<Subview> create_subview(Subview::Mode svm,
304  MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
305  protected:
307  private:
309 };
310 
311 } /* namespace Mackie */
312 } /* namespace ArdourSurface */
313 
314 #endif /* __ardour_mackie_control_protocol_subview_h__ */
std::vector< std::pair< std::shared_ptr< ARDOUR::AutomationControl >, std::string > > available
Definition: subview.h:157
DynamicsSubview(MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
void notify_change(std::weak_ptr< ARDOUR::AutomationControl >, uint32_t global_strip_position, bool force, bool propagate_mode_change)
static bool subview_mode_would_be_ok(std::shared_ptr< ARDOUR::Stripable > r, std::string &reason_why_not)
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2])
virtual Subview::Mode subview_mode() const
Definition: subview.h:144
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2])
static bool subview_mode_would_be_ok(std::shared_ptr< ARDOUR::Stripable > r, std::string &reason_why_not)
std::vector< std::pair< std::shared_ptr< ARDOUR::AutomationControl >, std::string > > available
Definition: subview.h:136
EQSubview(MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
void notify_change(std::weak_ptr< ARDOUR::AutomationControl >, uint32_t global_strip_position, bool force)
static bool subview_mode_would_be_ok(std::shared_ptr< ARDOUR::Stripable > r, std::string &reason_why_not)
NoneSubview(MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2])
std::shared_ptr< ARDOUR::AutomationControl > parameter_control(uint32_t global_strip_position) const
std::weak_ptr< ARDOUR::Plugin > _weak_subview_plugin
Definition: subview.h:295
std::vector< uint32_t > _plugin_input_parameter_indices
Definition: subview.h:296
void notify_parameter_change(Strip *strip, Pot *vpot, std::string pending_display[2], uint32_t global_strip_position)
virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
PluginEdit(PluginSubview &context, std::weak_ptr< ARDOUR::PluginInsert > weak_subview_plugin)
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2], uint32_t global_strip_position, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
std::weak_ptr< ARDOUR::PluginInsert > _weak_subview_plugin_insert
Definition: subview.h:294
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2], uint32_t global_strip_position, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2], uint32_t global_strip_position, std::shared_ptr< ARDOUR::Stripable > subview_stripable)=0
static std::string shorten_display_text(const std::string &text, std::string::size_type target_length)
virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr< ARDOUR::Stripable > subview_stripable)=0
uint32_t calculate_virtual_strip_position(uint32_t strip_index) const
void set_state(std::shared_ptr< PluginSubviewState > new_state)
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2])
static bool subview_mode_would_be_ok(std::shared_ptr< ARDOUR::Stripable > r, std::string &reason_why_not)
virtual Subview::Mode subview_mode() const
Definition: subview.h:206
std::shared_ptr< PluginSubviewState > _plugin_subview_state
Definition: subview.h:224
virtual void handle_vselect_event(uint32_t global_strip_position)
PluginSubview(MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
virtual Subview::Mode subview_mode() const
Definition: subview.h:165
void notify_send_enable_change(uint32_t global_strip_position, bool force)
SendsSubview(MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
virtual void handle_vselect_event(uint32_t global_strip_position)
static bool subview_mode_would_be_ok(std::shared_ptr< ARDOUR::Stripable > r, std::string &reason_why_not)
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2])
void notify_send_level_change(uint32_t global_strip_position, bool force)
std::shared_ptr< Subview > create_subview(Subview::Mode svm, MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
std::vector< std::string * > _strip_pending_displays_over_all_surfaces
Definition: subview.h:97
PBD::ScopedConnectionList & subview_connections()
Definition: subview.h:82
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2])=0
bool retrieve_pointers(Strip **strip, Pot **vpot, std::string **pending_display, uint32_t global_strip_position)
PBD::ScopedConnectionList _subview_stripable_connections
Definition: subview.h:93
std::vector< Strip * > _strips_over_all_surfaces
Definition: subview.h:95
virtual Mode subview_mode() const =0
void do_parameter_display(std::string &display, const ARDOUR::ParameterDescriptor &pd, float param_val, Strip *strip, bool screen_hold)
MackieControlProtocol & _mcp
Definition: subview.h:91
PBD::ScopedConnectionList _subview_connections
Definition: subview.h:98
PBD::ScopedConnectionList & subview_stripable_connections()
Definition: subview.h:81
virtual bool permit_flipping_faders_and_pots()
Definition: subview.h:63
std::shared_ptr< ARDOUR::Stripable > _subview_stripable
Definition: subview.h:92
virtual void handle_vselect_event(uint32_t global_strip_position)
static bool subview_mode_would_be_ok(Subview::Mode, std::shared_ptr< ARDOUR::Stripable >, std::string &reason_why_not)
std::vector< Pot * > _strip_vpots_over_all_surfaces
Definition: subview.h:96
void store_pointers(Strip *strip, Pot *vpot, std::string *pending_display, uint32_t global_strip_position)
std::shared_ptr< ARDOUR::Stripable > subview_stripable() const
Definition: subview.h:76
Subview(MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
MackieControlProtocol & mcp()
Definition: subview.h:79
virtual void setup_vpot(Strip *strip, Pot *vpot, std::string pending_display[2])
static bool subview_mode_would_be_ok(std::shared_ptr< ARDOUR::Stripable > r, std::string &reason_why_not)
TrackViewSubview(MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
void notify_change(ARDOUR::AutomationType, uint32_t global_strip_position, bool force)
virtual Subview::Mode subview_mode() const
Definition: subview.h:189
#define MACKIE_NAMESPACE