2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef __gtkardour_plugin_pin_dialog_h__
20 #define __gtkardour_plugin_pin_dialog_h__
22 #include <gtkmm/drawingarea.h>
24 #include "pbd/stateful.h"
25 #include "pbd/signals.h"
27 #include "ardour/plugin_insert.h"
28 #include "ardour/route.h"
30 #include "ardour_button.h"
31 #include "ardour_window.h"
33 class PluginPinDialog : public ArdourWindow
36 PluginPinDialog (boost::shared_ptr<ARDOUR::PluginInsert>);
48 _CtrlElem (CtrlType c, ARDOUR::DataType d, uint32_t i, uint32_t p = -1)
49 : ct (c), dt (d), id (i), ip (p) {}
52 uint32_t id; // port/pin ID
53 uint32_t ip; // plugin ID (for Sink, Source only)
56 typedef boost::shared_ptr<_CtrlElem> CtrlElem;
59 CtrlWidget (CtrlType ct, ARDOUR::DataType dt, uint32_t id, uint32_t ip = 0)
60 : x(0), y(0), w (0), h (0), prelight (false)
62 e = CtrlElem (new _CtrlElem (ct, dt, id, ip));
70 typedef std::vector<CtrlWidget> CtrlElemList;
75 CtrlElemList _elements;
78 Gtk::DrawingArea darea;
79 ArdourButton _ind_strict_io;
80 ArdourButton _ind_customized;
81 ArdourButton _rst_config;
82 ArdourButton _rst_mapping;
83 ArdourButton _add_plugin;
84 ArdourButton _del_plugin;
85 ArdourButton _add_output_audio;
86 ArdourButton _del_output_audio;
87 ArdourButton _add_output_midi;
88 ArdourButton _del_output_midi;
90 void plugin_reconfigured ();
91 void update_elements ();
92 void update_element_pos ();
94 void darea_size_request (Gtk::Requisition*);
95 void darea_size_allocate (Gtk::Allocation&);
96 bool darea_expose_event (GdkEventExpose*);
97 bool darea_motion_notify_event (GdkEventMotion*);
98 bool darea_button_press_event (GdkEventButton*);
99 bool darea_button_release_event (GdkEventButton*);
101 void draw_io_pin (cairo_t*, const CtrlWidget&);
102 void draw_plugin_pin (cairo_t*, const CtrlWidget&);
104 void set_color (cairo_t*, bool);
105 double pin_x_pos (uint32_t, double, double, uint32_t, uint32_t, bool);
106 void draw_connection (cairo_t*, double, double, double, double, bool, bool dashed = false);
108 void reset_mapping ();
109 void reset_configuration ();
110 void add_remove_plugin_clicked (bool);
111 void add_remove_port_clicked (bool, ARDOUR::DataType);
112 void handle_input_action (const CtrlElem &, const CtrlElem &);
113 void handle_output_action (const CtrlElem &, const CtrlElem &);
115 PBD::ScopedConnectionList _plugin_connections;
116 boost::shared_ptr<ARDOUR::PluginInsert> _pi;
119 ARDOUR::ChanCount _in, _out;
120 ARDOUR::ChanCount _sinks, _sources;
122 double _pin_box_size;
123 double _width, _height;
125 bool _position_valid;
126 bool _ignore_updates;
127 ARDOUR::Route* _route () { return static_cast<ARDOUR::Route*> (_pi->owner ()); }