Ardour  8.12
plugin_pin_dialog.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2023 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __gtkardour_plugin_pin_dialog_h__
20 #define __gtkardour_plugin_pin_dialog_h__
21 
22 #include <gtkmm/drawingarea.h>
23 
24 #include "pbd/stateful.h"
25 #include "pbd/signals.h"
26 
27 #include "ardour/plugin_insert.h"
28 #include "ardour/route.h"
29 
30 #include <gtkmm/alignment.h>
31 #include <gtkmm/box.h>
32 #include <gtkmm/drawingarea.h>
33 #include <gtkmm/scrolledwindow.h>
34 #include <gtkmm/sizegroup.h>
35 
37 
38 #include "widgets/ardour_button.h"
40 #include "widgets/ardour_fader.h"
42 
43 #include "ardour_window.h"
44 #include "io_selector.h"
45 
47 {
48 public:
49  PluginPinWidget (std::shared_ptr<ARDOUR::PluginInsert>);
52 private:
53  typedef enum {
57  Output
59 
60  typedef enum {
63  DisconnectAll = 3, // includes thru
64  } ClearMode;
65 
66 
67  struct _CtrlElem {
68  _CtrlElem (CtrlType c, ARDOUR::DataType d, uint32_t i, uint32_t p, uint32_t b, bool s)
69  : ct (c), dt (d), id (i), ip (p), bn (b), sc (s) {}
72  uint32_t id; // port/pin ID
73  uint32_t ip; // plugin ID (for Sink, Source only);
74  uint32_t bn; // bus-number
75  bool sc; // sidechain
76  };
77 
78  typedef std::shared_ptr<_CtrlElem> CtrlElem;
79 
80  struct CtrlWidget {
81  CtrlWidget (const std::string& n, CtrlType ct, ARDOUR::DataType dt, uint32_t id, uint32_t ip = 0, uint32_t bn = 0, bool sc = false)
82  : name (n), x(0), y(0), w (0), h (0), prelight (false)
83  {
84  e = CtrlElem (new _CtrlElem (ct, dt, id, ip, bn, sc));
85  }
86  std::string name;
87  double x,y;
88  double w,h;
89  bool prelight;
91  };
92 
93  typedef std::vector<CtrlWidget> CtrlElemList;
94 
100 
101  /* cache settings for expose */
102  typedef std::map <uint32_t, ARDOUR::ChanMapping> Mappings;
107 
108 
110 
125 
127 
131  Glib::RefPtr<Gtk::SizeGroup> _pm_size_group;
132 
137 
144  bool drag_type_matches (const CtrlElem& ct);
145 
146  void start_drag (const CtrlElem&, double, double);
147 
148  void draw_io_pin (cairo_t*, const CtrlWidget&) const;
149  void draw_plugin_pin (cairo_t*, const CtrlWidget&);
150  void draw_plugin_bus (cairo_t*, const CtrlWidget&, const CtrlWidget&) const;
151 
152  void set_color (cairo_t*, bool) const;
153  double pin_x_pos (uint32_t, double, double, uint32_t, uint32_t, bool);
154  void draw_connection (cairo_t*, double, double, double, double, bool, bool, bool dashed = false) const;
155  void draw_connection (cairo_t*, const CtrlWidget&, const CtrlWidget&, bool dashed = false) const;
156  void draw_bus_groups (cairo_t*, const CtrlType) const;
157  const CtrlWidget& get_io_ctrl (CtrlType ct, ARDOUR::DataType dt, uint32_t id, uint32_t ip = 0) const;
158 
159  static void edge_coordinates (const CtrlWidget& w, double &x, double &y);
160  static std::string port_label (const std::string&, bool);
161 
162  void reset_mapping ();
171  void select_output_preset (uint32_t n_audio);
172  void handle_input_action (const CtrlElem &, const CtrlElem &);
173  void handle_output_action (const CtrlElem &, const CtrlElem &);
174  void handle_thru_action (const CtrlElem &, const CtrlElem &);
175  bool handle_disconnect (const CtrlElem &, bool no_signal = false);
176  void disconnect_other_outputs (uint32_t skip_pc, ARDOUR::DataType dt, uint32_t id);
177  void disconnect_other_thru (ARDOUR::DataType dt, uint32_t id);
178  void remove_port (std::weak_ptr<ARDOUR::Port>);
179  void disconnect_port (std::weak_ptr<ARDOUR::Port>);
180  void connect_port (std::weak_ptr<ARDOUR::Port>, std::weak_ptr<ARDOUR::Port>);
181  void add_send_from (std::weak_ptr<ARDOUR::Port>, std::weak_ptr<ARDOUR::Route>);
182  uint32_t add_port_to_table (std::shared_ptr<ARDOUR::Port>, uint32_t, bool);
183  uint32_t maybe_add_route_to_input_menu (std::shared_ptr<ARDOUR::Route>, ARDOUR::DataType, std::weak_ptr<ARDOUR::Port>);
184  void port_connected_or_disconnected (std::weak_ptr<ARDOUR::Port>, std::weak_ptr<ARDOUR::Port>);
185  void port_pretty_name_changed (std::string);
187 
188  bool sc_input_press (GdkEventButton *, std::weak_ptr<ARDOUR::Port>);
190 
193  std::shared_ptr<ARDOUR::PluginInsert> _pi;
194 
196  bool idle_update ();
197 
198  void error_message_dialog (std::string const&) const;
199 
200  uint32_t _n_plugins;
203 
204  double _bxw2, _bxh2;
206  double _width, _height;
208  double _min_width;
209  double _min_height;
210  uint32_t _n_inputs;
211  uint32_t _n_sidechains;
214  ARDOUR::Route* _route () { return static_cast<ARDOUR::Route*> (_pi->owner ()); }
216 
217  bool _dragging;
218  double _drag_x, _drag_y;
219 
220  class Control: public sigc::trackable {
221  public:
222  Control (std::shared_ptr<ARDOUR::AutomationControl>, std::string const &);
225  private:
228  void set_tooltip ();
229 
230  std::weak_ptr<ARDOUR::AutomationControl> _control;
234 
236  sigc::connection timer_connection;
237  std::string _name;
238  };
239  std::list<Control*> _controls;
240 };
241 
242 
244 {
245 public:
246  PluginPinDialog (std::shared_ptr<ARDOUR::PluginInsert>);
247  PluginPinDialog (std::shared_ptr<ARDOUR::Route>);
248 
250 private:
253  typedef std::shared_ptr<PluginPinWidget> PluginPinWidgetPtr;
254  typedef std::vector<PluginPinWidgetPtr> PluginPinWidgetList;
255 
256  void going_away ();
260  void add_processor (std::weak_ptr<ARDOUR::Processor>);
262 
263  std::shared_ptr<ARDOUR::PluginInsert> _pi;
264  std::shared_ptr<ARDOUR::Route> _route;
268 };
269 
270 #endif
std::shared_ptr< ARDOUR::Route > _route
void set_session(ARDOUR::Session *)
std::shared_ptr< ARDOUR::PluginInsert > _pi
Gtk::ScrolledWindow * scroller
void route_property_changed(PBD::PropertyChange const &)
PBD::ScopedConnectionList _connections
void processor_property_changed(PBD::PropertyChange const &)
PluginPinDialog(std::shared_ptr< ARDOUR::Route >)
void route_processors_changed(ARDOUR::RouteProcessorChange)
PluginPinDialog(std::shared_ptr< ARDOUR::PluginInsert >)
std::shared_ptr< PluginPinWidget > PluginPinWidgetPtr
PluginPinWidgetList ppw
void add_processor(std::weak_ptr< ARDOUR::Processor >)
void map_height(Gtk::Allocation &)
std::vector< PluginPinWidgetPtr > PluginPinWidgetList
Control(std::shared_ptr< ARDOUR::AutomationControl >, std::string const &)
sigc::connection timer_connection
Gtkmm2ext::PersistentTooltip _slider_persistant_tooltip
std::weak_ptr< ARDOUR::AutomationControl > _control
ArdourWidgets::HSliderController _slider
void handle_input_action(const CtrlElem &, const CtrlElem &)
void draw_plugin_pin(cairo_t *, const CtrlWidget &)
ArdourWidgets::ArdourButton _add_plugin
void plugin_reconfigured()
bool darea_expose_event(GdkEventExpose *)
ArdourWidgets::ArdourButton _add_output_audio
void disconnect_port(std::weak_ptr< ARDOUR::Port >)
uint32_t add_port_to_table(std::shared_ptr< ARDOUR::Port >, uint32_t, bool)
void start_drag(const CtrlElem &, double, double)
static void edge_coordinates(const CtrlWidget &w, double &x, double &y)
std::shared_ptr< ARDOUR::PluginInsert > _pi
void error_message_dialog(std::string const &) const
ArdourWidgets::ArdourButton _add_output_midi
ArdourWidgets::ArdourButton _del_output_audio
void set_color(cairo_t *, bool) const
void darea_size_allocate(Gtk::Allocation &)
PluginPinWidget(std::shared_ptr< ARDOUR::PluginInsert >)
ArdourWidgets::ArdourButton _tgl_sidechain
CtrlElemList _elements
Gtk::DrawingArea darea
void port_pretty_name_changed(std::string)
void draw_connection(cairo_t *, double, double, double, double, bool, bool, bool dashed=false) const
ArdourWidgets::ArdourButton _add_sc_midi
void reset_mapping()
ARDOUR::ChanCount _sinks
bool sc_input_press(GdkEventButton *, std::weak_ptr< ARDOUR::Port >)
Glib::RefPtr< Gtk::SizeGroup > _pm_size_group
bool drag_type_matches(const CtrlElem &ct)
ArdourWidgets::ArdourButton _add_input_midi
std::vector< CtrlWidget > CtrlElemList
void add_send_from(std::weak_ptr< ARDOUR::Port >, std::weak_ptr< ARDOUR::Route >)
PBD::ScopedConnectionList _io_connection
ArdourWidgets::ArdourButton _set_config
ARDOUR::ChanCount _sources
void refill_sidechain_table()
ARDOUR::ChanCount _out
void add_remove_port_clicked(bool, ARDOUR::DataType)
void reset_configuration()
void handle_thru_action(const CtrlElem &, const CtrlElem &)
void add_remove_plugin_clicked(bool)
void add_sidechain_port(ARDOUR::DataType)
void refill_output_presets()
void remove_port(std::weak_ptr< ARDOUR::Port >)
void connect_sidechain()
void draw_plugin_bus(cairo_t *, const CtrlWidget &, const CtrlWidget &) const
void connect_port(std::weak_ptr< ARDOUR::Port >, std::weak_ptr< ARDOUR::Port >)
ArdourWidgets::ArdourButton _del_plugin
void draw_connection(cairo_t *, const CtrlWidget &, const CtrlWidget &, bool dashed=false) const
void update_element_pos()
ArdourWidgets::ArdourButton _add_sc_audio
void select_output_preset(uint32_t n_audio)
bool sc_input_release(GdkEventButton *)
const CtrlWidget & get_io_ctrl(CtrlType ct, ARDOUR::DataType dt, uint32_t id, uint32_t ip=0) const
bool handle_disconnect(const CtrlElem &, bool no_signal=false)
ArdourWidgets::ArdourButton _del_output_midi
static std::string port_label(const std::string &, bool)
double pin_x_pos(uint32_t, double, double, uint32_t, uint32_t, bool)
ARDOUR::ChanMapping _thru_map
void draw_bus_groups(cairo_t *, const CtrlType) const
ArdourWidgets::ArdourButton _del_input_audio
ARDOUR::Route * _route()
void darea_size_request(Gtk::Requisition *)
void queue_idle_update()
IOSelectorWindow * _sidechain_selector
ArdourWidgets::ArdourDropdown _out_presets
Gtk::Table * _sidechain_tbl
uint32_t maybe_add_route_to_input_menu(std::shared_ptr< ARDOUR::Route >, ARDOUR::DataType, std::weak_ptr< ARDOUR::Port >)
ARDOUR::ChanCount _ins
void disconnect_other_outputs(uint32_t skip_pc, ARDOUR::DataType dt, uint32_t id)
ARDOUR::ChanCount _in
bool darea_button_press_event(GdkEventButton *)
void add_remove_inpin_clicked(bool, ARDOUR::DataType)
std::map< uint32_t, ARDOUR::ChanMapping > Mappings
ArdourWidgets::ArdourButton _add_input_audio
PBD::ScopedConnectionList _plugin_connections
void clear_mapping(ClearMode)
bool darea_button_release_event(GdkEventButton *)
void toggle_sidechain()
ArdourWidgets::ArdourButton _del_input_midi
void handle_output_action(const CtrlElem &, const CtrlElem &)
void draw_io_pin(cairo_t *, const CtrlWidget &) const
bool darea_motion_notify_event(GdkEventMotion *)
void disconnect_other_thru(ARDOUR::DataType dt, uint32_t id)
void property_changed(PBD::PropertyChange const &)
void set_session(ARDOUR::Session *)
void port_connected_or_disconnected(std::weak_ptr< ARDOUR::Port >, std::weak_ptr< ARDOUR::Port >)
std::shared_ptr< _CtrlElem > CtrlElem
std::list< Control * > _controls
CtrlWidget(const std::string &n, CtrlType ct, ARDOUR::DataType dt, uint32_t id, uint32_t ip=0, uint32_t bn=0, bool sc=false)
_CtrlElem(CtrlType c, ARDOUR::DataType d, uint32_t i, uint32_t p, uint32_t b, bool s)