Ardour  9.0-pre0-384-ga76afae0e9
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 setup_vpot(
65  Strip* strip,
66  Pot* vpot,
67  std::string pending_display[2]) = 0;
68  virtual void handle_vselect_event(uint32_t global_strip_position);
69  // returns true if press was handled in the subview, default is false
70  virtual bool handle_cursor_right_press() { return false; }
71  // returns true if press was handled in the subview, default is false
72  virtual bool handle_cursor_left_press() { return false; }
73 
74  static bool subview_mode_would_be_ok (Subview::Mode, std::shared_ptr<ARDOUR::Stripable>, std::string& reason_why_not);
75  std::shared_ptr<ARDOUR::Stripable> subview_stripable() const { return _subview_stripable; }
76 
78  MackieControlProtocol& mcp() { return _mcp; }
79 
82 
83  void do_parameter_display(std::string& display, const ARDOUR::ParameterDescriptor& pd, float param_val, Strip* strip, bool screen_hold);
84 
85  protected:
87  void store_pointers(Strip* strip, Pot* vpot, std::string* pending_display, uint32_t global_strip_position);
88  bool retrieve_pointers(Strip** strip, Pot** vpot, std::string** pending_display, uint32_t global_strip_position);
89 
90  MackieControlProtocol& _mcp;
91  std::shared_ptr<ARDOUR::Stripable> _subview_stripable;
93 
94  std::vector<Strip*> _strips_over_all_surfaces;
95  std::vector<Pot*> _strip_vpots_over_all_surfaces;
96  std::vector<std::string*> _strip_pending_displays_over_all_surfaces;
98  private:
100 };
101 
102 class NoneSubview : public Subview {
103  public:
104  NoneSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
105  virtual ~NoneSubview();
106 
107  virtual Mode subview_mode () const { return Subview::None; }
108  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
109 
110  virtual void update_global_buttons();
111  virtual void setup_vpot(
112  Strip* strip,
113  Pot* vpot,
114  std::string pending_display[2]);
115 };
116 
117 class EQSubview : public Subview {
118  public:
119  EQSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
120  virtual ~EQSubview();
121 
122  virtual Mode subview_mode () const { return Subview::EQ; }
123  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
124  virtual void update_global_buttons();
125  virtual void setup_vpot(
126  Strip* strip,
127  Pot* vpot,
128  std::string pending_display[2]);
129  void notify_change (std::weak_ptr<ARDOUR::AutomationControl>, uint32_t global_strip_position, bool force);
130 };
131 
132 class DynamicsSubview : public Subview {
133  public:
134  DynamicsSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
135  virtual ~DynamicsSubview();
136 
137  virtual Subview::Mode subview_mode () const { return Subview::Dynamics; }
138  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
139  virtual void update_global_buttons();
140  virtual void setup_vpot(
141  Strip* strip,
142  Pot* vpot,
143  std::string pending_display[2]);
144  void notify_change (std::weak_ptr<ARDOUR::AutomationControl>, uint32_t global_strip_position, bool force, bool propagate_mode_change);
145 };
146 
147 class SendsSubview : public Subview {
148  public:
149  SendsSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
150  virtual ~SendsSubview();
151 
152  virtual Subview::Mode subview_mode () const { return Subview::Sends; }
153  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
154  virtual void update_global_buttons();
155  virtual bool permit_flipping_faders_and_pots() { return true; }
156  virtual void setup_vpot(
157  Strip* strip,
158  Pot* vpot,
159  std::string pending_display[2]);
160  void notify_send_level_change (uint32_t global_strip_position, bool force);
161 
162  virtual void handle_vselect_event(uint32_t global_strip_position);
164  virtual bool handle_cursor_left_press();
165  protected:
166  uint32_t _current_bank;
167 
168 };
169 
170 class TrackViewSubview : public Subview {
171  public:
172  TrackViewSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
173  virtual ~TrackViewSubview();
174 
175  virtual Subview::Mode subview_mode () const { return Subview::TrackView; }
176  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
177  virtual void update_global_buttons();
178  virtual void setup_vpot(
179  Strip* strip,
180  Pot* vpot,
181  std::string pending_display[2]);
182  void notify_change (ARDOUR::AutomationType, uint32_t global_strip_position, bool force);
183 };
184 
185 class PluginSubviewState;
186 
187 class PluginSubview : public Subview {
188  public:
189  PluginSubview(MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
190  virtual ~PluginSubview();
191 
192  virtual Subview::Mode subview_mode () const { return Subview::Plugin; }
193  static bool subview_mode_would_be_ok (std::shared_ptr<ARDOUR::Stripable> r, std::string& reason_why_not);
194  virtual void update_global_buttons();
196  virtual void setup_vpot(
197  Strip* strip,
198  Pot* vpot,
199  std::string pending_display[2]);
200  virtual void handle_vselect_event(uint32_t global_strip_position);
202  virtual bool handle_cursor_left_press();
203 
204  void set_state(std::shared_ptr<PluginSubviewState> new_state);
205 
206  protected:
209 
210  std::shared_ptr<PluginSubviewState> _plugin_subview_state;
211 };
212 
214  public:
217 
218  virtual bool permit_flipping_faders_and_pots() { return false; }
219  virtual void setup_vpot(
220  Strip* strip,
221  Pot* vpot,
222  std::string pending_display[2],
223  uint32_t global_strip_position,
224  std::shared_ptr<ARDOUR::Stripable> subview_stripable) = 0;
225  virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr<ARDOUR::Stripable> subview_stripable) = 0;
226  static std::string shorten_display_text(const std::string& text, std::string::size_type target_length);
227  virtual bool handle_cursor_right_press() = 0;
228  virtual bool handle_cursor_left_press();
229  virtual void bank_changed() = 0;
230 
231  protected:
232  uint32_t calculate_virtual_strip_position(uint32_t strip_index) const;
233 
235  const uint32_t _bank_size;
236  uint32_t _current_bank;
237 };
238 
240  public:
242  virtual ~PluginSelect();
243 
244  virtual void setup_vpot(
245  Strip* strip,
246  Pot* vpot,
247  std::string pending_display[2],
248  uint32_t global_strip_position,
249  std::shared_ptr<ARDOUR::Stripable> subview_stripable);
250  virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
252  virtual void bank_changed();
253  private:
254  const uint32_t _bank_size;
255 };
256 
258  public:
259  PluginEdit(PluginSubview& context, std::weak_ptr<ARDOUR::PluginInsert> weak_subview_plugin);
260  virtual ~PluginEdit();
261 
262  virtual bool permit_flipping_faders_and_pots() { return true; }
263  virtual void setup_vpot(
264  Strip* strip,
265  Pot* vpot,
266  std::string pending_display[2],
267  uint32_t global_strip_position,
268  std::shared_ptr<ARDOUR::Stripable> subview_stripable);
269  virtual void handle_vselect_event(uint32_t global_strip_position, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
271  virtual void bank_changed();
272 
273  void notify_parameter_change(Strip* strip, Pot* vpot, std::string pending_display[2], uint32_t global_strip_position);
274  void init();
275  bool plugin_went_away() const;
277 
278  std::shared_ptr<ARDOUR::AutomationControl> parameter_control(uint32_t global_strip_position) const;
279 
280  std::weak_ptr<ARDOUR::PluginInsert> _weak_subview_plugin_insert;
281  std::weak_ptr<ARDOUR::Plugin> _weak_subview_plugin;
282  std::vector<uint32_t> _plugin_input_parameter_indices;
283 };
284 
286  public:
288 
289  std::shared_ptr<Subview> create_subview(Subview::Mode svm,
290  MackieControlProtocol& mcp, std::shared_ptr<ARDOUR::Stripable> subview_stripable);
291  protected:
293  private:
295 };
296 
297 } /* namespace Mackie */
298 } /* namespace ArdourSurface */
299 
300 #endif /* __ardour_mackie_control_protocol_subview_h__ */
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:137
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)
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:281
std::vector< uint32_t > _plugin_input_parameter_indices
Definition: subview.h:282
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:280
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:192
std::shared_ptr< PluginSubviewState > _plugin_subview_state
Definition: subview.h:210
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:152
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:96
PBD::ScopedConnectionList & subview_connections()
Definition: subview.h:81
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:92
std::vector< Strip * > _strips_over_all_surfaces
Definition: subview.h:94
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:90
PBD::ScopedConnectionList _subview_connections
Definition: subview.h:97
PBD::ScopedConnectionList & subview_stripable_connections()
Definition: subview.h:80
virtual bool permit_flipping_faders_and_pots()
Definition: subview.h:63
std::shared_ptr< ARDOUR::Stripable > _subview_stripable
Definition: subview.h:91
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:95
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:75
Subview(MackieControlProtocol &mcp, std::shared_ptr< ARDOUR::Stripable > subview_stripable)
MackieControlProtocol & mcp()
Definition: subview.h:78
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:175
#define MACKIE_NAMESPACE