Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
20 
21 #include <gtkmm/drawingarea.h>
22 
23 #include "pbd/stateful.h"
24 #include "pbd/signals.h"
25 
26 #include "ardour/plugin_insert.h"
27 #include "ardour/route.h"
28 
29 #include <gtkmm/alignment.h>
30 #include <gtkmm/box.h>
31 #include <gtkmm/drawingarea.h>
32 #include <gtkmm/scrolledwindow.h>
33 #include <gtkmm/sizegroup.h>
34 
36 
37 #include "widgets/ardour_button.h"
39 #include "widgets/ardour_fader.h"
41 
42 #include "ardour_window.h"
43 #include "io_selector.h"
44 
46 {
47 public:
48  PluginPinWidget (std::shared_ptr<ARDOUR::PluginInsert>);
51 private:
52  typedef enum {
56  Output
58 
59  typedef enum {
62  DisconnectAll = 3, // includes thru
63  } ClearMode;
64 
65 
66  struct _CtrlElem {
67  _CtrlElem (CtrlType c, ARDOUR::DataType d, uint32_t i, uint32_t p, uint32_t b, bool s)
68  : ct (c), dt (d), id (i), ip (p), bn (b), sc (s) {}
71  uint32_t id; // port/pin ID
72  uint32_t ip; // plugin ID (for Sink, Source only);
73  uint32_t bn; // bus-number
74  bool sc; // sidechain
75  };
76 
77  typedef std::shared_ptr<_CtrlElem> CtrlElem;
78 
79  struct CtrlWidget {
80  CtrlWidget (const std::string& n, CtrlType ct, ARDOUR::DataType dt, uint32_t id, uint32_t ip = 0, uint32_t bn = 0, bool sc = false)
81  : name (n), x(0), y(0), w (0), h (0), prelight (false)
82  {
83  e = CtrlElem (new _CtrlElem (ct, dt, id, ip, bn, sc));
84  }
85  std::string name;
86  double x,y;
87  double w,h;
88  bool prelight;
90  };
91 
92  typedef std::vector<CtrlWidget> CtrlElemList;
93 
99 
100  /* cache settings for expose */
101  typedef std::map <uint32_t, ARDOUR::ChanMapping> Mappings;
106 
107 
109 
124 
126 
130  Glib::RefPtr<Gtk::SizeGroup> _pm_size_group;
131 
136 
143  bool drag_type_matches (const CtrlElem& ct);
144 
145  void start_drag (const CtrlElem&, double, double);
146 
147  void draw_io_pin (cairo_t*, const CtrlWidget&) const;
148  void draw_plugin_pin (cairo_t*, const CtrlWidget&);
149  void draw_plugin_bus (cairo_t*, const CtrlWidget&, const CtrlWidget&) const;
150 
151  void set_color (cairo_t*, bool) const;
152  double pin_x_pos (uint32_t, double, double, uint32_t, uint32_t, bool);
153  void draw_connection (cairo_t*, double, double, double, double, bool, bool, bool dashed = false) const;
154  void draw_connection (cairo_t*, const CtrlWidget&, const CtrlWidget&, bool dashed = false) const;
155  void draw_bus_groups (cairo_t*, const CtrlType) const;
156  const CtrlWidget& get_io_ctrl (CtrlType ct, ARDOUR::DataType dt, uint32_t id, uint32_t ip = 0) const;
157 
158  static void edge_coordinates (const CtrlWidget& w, double &x, double &y);
159  static std::string port_label (const std::string&, bool);
160 
161  void reset_mapping ();
170  void select_output_preset (uint32_t n_audio);
171  void handle_input_action (const CtrlElem &, const CtrlElem &);
172  void handle_output_action (const CtrlElem &, const CtrlElem &);
173  void handle_thru_action (const CtrlElem &, const CtrlElem &);
174  bool handle_disconnect (const CtrlElem &, bool no_signal = false);
175  void disconnect_other_outputs (uint32_t skip_pc, ARDOUR::DataType dt, uint32_t id);
176  void disconnect_other_thru (ARDOUR::DataType dt, uint32_t id);
177  void remove_port (std::weak_ptr<ARDOUR::Port>);
178  void disconnect_port (std::weak_ptr<ARDOUR::Port>);
179  void connect_port (std::weak_ptr<ARDOUR::Port>, std::weak_ptr<ARDOUR::Port>);
180  void add_send_from (std::weak_ptr<ARDOUR::Port>, std::weak_ptr<ARDOUR::Route>);
181  uint32_t add_port_to_table (std::shared_ptr<ARDOUR::Port>, uint32_t, bool);
182  uint32_t maybe_add_route_to_input_menu (std::shared_ptr<ARDOUR::Route>, ARDOUR::DataType, std::weak_ptr<ARDOUR::Port>);
183  void port_connected_or_disconnected (std::weak_ptr<ARDOUR::Port>, std::weak_ptr<ARDOUR::Port>);
184  void port_pretty_name_changed (std::string);
186 
187  bool sc_input_press (GdkEventButton *, std::weak_ptr<ARDOUR::Port>);
189 
192  std::shared_ptr<ARDOUR::PluginInsert> _pi;
193 
195  bool idle_update ();
196 
197  void error_message_dialog (std::string const&) const;
198 
199  uint32_t _n_plugins;
202 
203  double _bxw2, _bxh2;
205  double _width, _height;
207  double _min_width;
208  double _min_height;
209  uint32_t _n_inputs;
210  uint32_t _n_sidechains;
213  ARDOUR::Route* _route () { return static_cast<ARDOUR::Route*> (_pi->owner ()); }
215 
216  bool _dragging;
217  double _drag_x, _drag_y;
218 
219  class Control: public sigc::trackable {
220  public:
221  Control (std::shared_ptr<ARDOUR::AutomationControl>, std::string const &);
224  private:
227  void set_tooltip ();
228 
229  std::weak_ptr<ARDOUR::AutomationControl> _control;
233 
235  sigc::connection timer_connection;
236  std::string _name;
237  };
238  std::list<Control*> _controls;
239 };
240 
241 
243 {
244 public:
245  PluginPinDialog (std::shared_ptr<ARDOUR::PluginInsert>);
246  PluginPinDialog (std::shared_ptr<ARDOUR::Route>);
247 
249 private:
252  typedef std::shared_ptr<PluginPinWidget> PluginPinWidgetPtr;
253  typedef std::vector<PluginPinWidgetPtr> PluginPinWidgetList;
254 
255  void going_away ();
259  void add_processor (std::weak_ptr<ARDOUR::Processor>);
261 
262  std::shared_ptr<ARDOUR::PluginInsert> _pi;
263  std::shared_ptr<ARDOUR::Route> _route;
267 };
268 
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)