2016-03-27 15:35:42 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2016-2018 Robin Gareus <robin@gareus.org>
|
2016-03-27 15:35:42 -04:00
|
|
|
*
|
2019-08-02 17:26:43 -04:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-03-27 15:35:42 -04:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2019-08-02 17:26:43 -04:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2016-03-27 15:35:42 -04:00
|
|
|
*/
|
|
|
|
|
2016-04-07 08:05:15 -04:00
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
2017-07-16 21:48:18 -04:00
|
|
|
#include <gtkmm/box.h>
|
2016-04-06 11:48:22 -04:00
|
|
|
#include <gtkmm/frame.h>
|
2016-03-31 19:33:22 -04:00
|
|
|
#include <gtkmm/label.h>
|
2018-10-29 16:50:08 -04:00
|
|
|
#include <gtkmm/messagedialog.h>
|
2017-07-16 21:48:18 -04:00
|
|
|
#include <gtkmm/separator.h>
|
|
|
|
#include <gtkmm/table.h>
|
2016-03-31 19:33:22 -04:00
|
|
|
|
2016-04-05 20:31:36 -04:00
|
|
|
#include "pbd/replace_all.h"
|
|
|
|
|
2016-03-27 15:35:42 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
2016-03-28 12:25:17 -04:00
|
|
|
#include "gtkmm2ext/rgb_macros.h"
|
2017-06-28 18:20:55 -04:00
|
|
|
#include "gtkmm2ext/menu_elems.h"
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2017-07-15 11:38:28 -04:00
|
|
|
#include "widgets/tooltips.h"
|
|
|
|
|
2016-04-17 08:10:13 -04:00
|
|
|
#include "ardour/amp.h"
|
2016-04-05 15:53:05 -04:00
|
|
|
#include "ardour/audioengine.h"
|
2016-04-17 08:10:13 -04:00
|
|
|
#include "ardour/pannable.h"
|
2016-04-03 16:44:36 -04:00
|
|
|
#include "ardour/plugin.h"
|
2016-04-05 15:53:05 -04:00
|
|
|
#include "ardour/port.h"
|
2016-04-15 08:53:18 -04:00
|
|
|
#include "ardour/profile.h"
|
2016-04-17 08:10:13 -04:00
|
|
|
#include "ardour/send.h"
|
2016-04-05 15:53:05 -04:00
|
|
|
#include "ardour/session.h"
|
2017-06-21 11:05:03 -04:00
|
|
|
#include "ardour/value_as_string.h"
|
2016-04-03 16:44:36 -04:00
|
|
|
|
2016-03-27 15:35:42 -04:00
|
|
|
#include "plugin_pin_dialog.h"
|
|
|
|
#include "gui_thread.h"
|
2016-04-16 19:39:59 -04:00
|
|
|
#include "timers.h"
|
2016-03-27 15:35:42 -04:00
|
|
|
#include "ui_config.h"
|
2018-11-28 09:17:57 -05:00
|
|
|
#include "utils.h"
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2016-03-27 15:35:42 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace std;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Gtkmm2ext;
|
2017-07-15 11:38:28 -04:00
|
|
|
using namespace ArdourWidgets;
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::PluginPinWidget (boost::shared_ptr<ARDOUR::PluginInsert> pi)
|
|
|
|
: _set_config (_("Manual Config"), ArdourButton::led_default_elements)
|
2016-05-03 08:42:39 -04:00
|
|
|
, _tgl_sidechain (_("Sidechain"), ArdourButton::led_default_elements)
|
2016-03-31 19:33:22 -04:00
|
|
|
, _add_plugin (_("+"))
|
|
|
|
, _del_plugin (_("-"))
|
2016-04-27 17:32:40 -04:00
|
|
|
, _add_input_audio (_("+"))
|
|
|
|
, _del_input_audio (_("-"))
|
|
|
|
, _add_input_midi (_("+"))
|
|
|
|
, _del_input_midi (_("-"))
|
2016-03-31 19:33:22 -04:00
|
|
|
, _add_output_audio (_("+"))
|
|
|
|
, _del_output_audio (_("-"))
|
|
|
|
, _add_output_midi (_("+"))
|
|
|
|
, _del_output_midi (_("-"))
|
2016-04-06 11:48:22 -04:00
|
|
|
, _add_sc_audio (_("Audio"))
|
|
|
|
, _add_sc_midi (_("MIDI"))
|
2016-03-27 15:35:42 -04:00
|
|
|
, _pi (pi)
|
2016-04-05 11:23:03 -04:00
|
|
|
, _pin_box_size (10)
|
|
|
|
, _width (0)
|
|
|
|
, _height (0)
|
|
|
|
, _innerwidth (0)
|
|
|
|
, _margin_x (28)
|
|
|
|
, _margin_y (40)
|
2016-04-02 08:44:05 -04:00
|
|
|
, _min_width (300)
|
2016-04-05 11:23:03 -04:00
|
|
|
, _min_height (200)
|
|
|
|
, _n_inputs (0)
|
|
|
|
, _n_sidechains (0)
|
2016-04-01 16:57:33 -04:00
|
|
|
, _position_valid (false)
|
2016-04-01 20:02:47 -04:00
|
|
|
, _ignore_updates (false)
|
2016-04-04 19:38:31 -04:00
|
|
|
, _sidechain_selector (0)
|
2016-04-06 17:24:11 -04:00
|
|
|
, _dragging (false)
|
2016-03-27 15:35:42 -04:00
|
|
|
{
|
|
|
|
assert (pi->owner ()); // Route
|
|
|
|
|
|
|
|
_pi->PluginIoReConfigure.connect (
|
2016-05-09 06:45:36 -04:00
|
|
|
_plugin_connections, invalidator (*this), boost::bind (&PluginPinWidget::queue_idle_update, this), gui_context ()
|
2016-03-27 15:35:42 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
_pi->PluginMapChanged.connect (
|
2016-05-09 06:45:36 -04:00
|
|
|
_plugin_connections, invalidator (*this), boost::bind (&PluginPinWidget::queue_idle_update, this), gui_context ()
|
2016-03-27 15:35:42 -04:00
|
|
|
);
|
|
|
|
|
2016-03-31 19:33:22 -04:00
|
|
|
_pi->PluginConfigChanged.connect (
|
2016-05-09 06:45:36 -04:00
|
|
|
_plugin_connections, invalidator (*this), boost::bind (&PluginPinWidget::queue_idle_update, this), gui_context ()
|
2016-03-31 19:33:22 -04:00
|
|
|
);
|
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
_pin_box_size = 2 * ceil (max (8., 10. * UIConfiguration::instance ().get_ui_scale ()) * .5);
|
|
|
|
_margin_x = 2 * ceil (max (24., 28. * UIConfiguration::instance ().get_ui_scale ()) * .5);
|
|
|
|
_margin_y = 2 * ceil (max (36., 40. * UIConfiguration::instance ().get_ui_scale ()) * .5);
|
|
|
|
|
|
|
|
_tgl_sidechain.set_name ("pinrouting sidechain");
|
2016-04-06 07:40:18 -04:00
|
|
|
_set_config.set_name ("pinrouting custom");
|
2016-04-05 11:23:03 -04:00
|
|
|
|
2016-04-16 18:09:11 -04:00
|
|
|
Menu_Helpers::MenuList& citems = reset_menu.items ();
|
2016-04-06 11:48:22 -04:00
|
|
|
reset_menu.set_name ("ArdourContextMenu");
|
2016-04-16 18:09:11 -04:00
|
|
|
citems.clear ();
|
2016-05-09 06:45:36 -04:00
|
|
|
citems.push_back (Menu_Helpers::MenuElem (_("Reset"), sigc::mem_fun (*this, &PluginPinWidget::reset_mapping)));
|
2016-04-06 11:48:22 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
_pm_size_group = SizeGroup::create (SIZE_GROUP_BOTH);
|
2016-04-05 15:53:05 -04:00
|
|
|
_add_plugin.set_tweaks (ArdourButton::Square);
|
|
|
|
_del_plugin.set_tweaks (ArdourButton::Square);
|
2016-04-27 17:32:40 -04:00
|
|
|
if (_pi->plugin (0)->get_info()->reconfigurable_io ()) {
|
|
|
|
_pm_size_group->add_widget (_add_input_audio);
|
|
|
|
_pm_size_group->add_widget (_del_input_audio);
|
|
|
|
_pm_size_group->add_widget (_add_input_midi);
|
|
|
|
_pm_size_group->add_widget (_del_input_midi);
|
|
|
|
} else {
|
|
|
|
_pm_size_group->add_widget (_add_plugin);
|
|
|
|
_pm_size_group->add_widget (_del_plugin);
|
|
|
|
}
|
2016-04-05 11:23:03 -04:00
|
|
|
_pm_size_group->add_widget (_add_output_audio);
|
|
|
|
_pm_size_group->add_widget (_del_output_audio);
|
|
|
|
_pm_size_group->add_widget (_add_output_midi);
|
|
|
|
_pm_size_group->add_widget (_del_output_midi);
|
2016-03-31 19:33:22 -04:00
|
|
|
|
2016-04-06 11:48:22 -04:00
|
|
|
Box* box;
|
|
|
|
Frame *f;
|
|
|
|
|
|
|
|
VBox* tl = manage (new VBox ());
|
|
|
|
tl->set_border_width (2);
|
|
|
|
tl->set_spacing (2);
|
|
|
|
|
|
|
|
VBox* tr = manage (new VBox ());
|
|
|
|
tr->set_border_width (2);
|
|
|
|
tr->set_spacing (2);
|
|
|
|
|
|
|
|
/* left side */
|
|
|
|
tl->pack_start (_set_config, false, false);
|
|
|
|
|
2016-04-27 17:32:40 -04:00
|
|
|
if (_pi->plugin (0)->get_info()->reconfigurable_io ()) {
|
|
|
|
box = manage (new HBox ());
|
|
|
|
box->set_border_width (2);
|
|
|
|
box->pack_start (_add_input_audio, true, false);
|
|
|
|
box->pack_start (_del_input_audio, true, false);
|
|
|
|
f = manage (new Frame ());
|
|
|
|
f->set_label (_("Audio Input Pins"));
|
|
|
|
f->add (*box);
|
|
|
|
tl->pack_start (*f, false, false);
|
|
|
|
|
|
|
|
box = manage (new HBox ());
|
|
|
|
box->set_border_width (2);
|
|
|
|
box->pack_start (_add_input_midi, true, false);
|
|
|
|
box->pack_start (_del_input_midi, true, false);
|
|
|
|
f = manage (new Frame ());
|
|
|
|
f->set_label (_("MIDI Input Pins"));
|
|
|
|
f->add (*box);
|
|
|
|
tl->pack_start (*f, false, false);
|
|
|
|
} else {
|
|
|
|
box = manage (new HBox ());
|
|
|
|
box->set_border_width (2);
|
|
|
|
box->pack_start (_add_plugin, true, false);
|
|
|
|
box->pack_start (_del_plugin, true, false);
|
|
|
|
f = manage (new Frame ());
|
|
|
|
f->set_label (_("Instances"));
|
|
|
|
f->add (*box);
|
|
|
|
tl->pack_start (*f, false, false);
|
|
|
|
}
|
2016-04-06 11:48:22 -04:00
|
|
|
|
|
|
|
box = manage (new HBox ());
|
|
|
|
box->set_border_width (2);
|
|
|
|
box->pack_start (_add_output_audio, true, false);
|
|
|
|
box->pack_start (_del_output_audio, true, false);
|
2016-04-16 18:09:11 -04:00
|
|
|
f = manage (new Frame ());
|
2016-04-06 11:48:22 -04:00
|
|
|
f->set_label (_("Audio Out"));
|
|
|
|
f->add (*box);
|
|
|
|
tl->pack_start (*f, false, false);
|
|
|
|
|
|
|
|
box = manage (new HBox ());
|
|
|
|
box->set_border_width (2);
|
|
|
|
box->pack_start (_add_output_midi, true, false);
|
|
|
|
box->pack_start (_del_output_midi, true, false);
|
2016-04-16 18:09:11 -04:00
|
|
|
f = manage (new Frame ());
|
2016-04-06 11:48:22 -04:00
|
|
|
f->set_label (_("MIDI Out"));
|
|
|
|
f->add (*box);
|
|
|
|
tl->pack_start (*f, false, false);
|
|
|
|
|
2016-04-15 12:15:05 -04:00
|
|
|
tl->pack_start (*manage (new Label ("")), true, true); // invisible separator
|
|
|
|
tl->pack_start (*manage (new HSeparator ()), false, false, 4);
|
|
|
|
_out_presets.disable_scrolling ();
|
2017-07-15 11:38:28 -04:00
|
|
|
ArdourWidgets::set_tooltip (_out_presets, _("Output Presets"));
|
2016-04-15 12:15:05 -04:00
|
|
|
tl->pack_start (_out_presets, false, false);
|
2016-04-06 11:48:22 -04:00
|
|
|
|
|
|
|
/* right side */
|
2016-04-05 15:53:05 -04:00
|
|
|
_sidechain_tbl = manage (new Gtk::Table ());
|
|
|
|
_sidechain_tbl->set_spacings (2);
|
|
|
|
|
2016-04-06 11:48:22 -04:00
|
|
|
tr->pack_start (_tgl_sidechain, false, false);
|
|
|
|
tr->pack_start (*_sidechain_tbl, true, true);
|
|
|
|
|
|
|
|
box = manage (new VBox ());
|
|
|
|
box->set_border_width (2);
|
|
|
|
box->set_spacing (2);
|
|
|
|
box->pack_start (_add_sc_audio, false, false);
|
|
|
|
box->pack_start (_add_sc_midi , false, false);
|
2016-04-16 18:09:11 -04:00
|
|
|
f = manage (new Frame ());
|
2016-04-07 08:05:15 -04:00
|
|
|
f->set_label (_("Add Sidechain Input"));
|
2016-04-06 11:48:22 -04:00
|
|
|
f->add (*box);
|
|
|
|
|
|
|
|
tr->pack_start (*f, false, false);
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2016-04-06 11:48:22 -04:00
|
|
|
/* global packing */
|
|
|
|
HBox* hbox = manage (new HBox ());
|
2016-04-05 11:23:03 -04:00
|
|
|
hbox->set_spacing (4);
|
|
|
|
hbox->pack_start (*tl, false, false);
|
2016-03-28 12:25:17 -04:00
|
|
|
hbox->pack_start (darea, true, true);
|
2016-04-05 11:23:03 -04:00
|
|
|
hbox->pack_start (*tr, false, false);
|
2016-03-28 12:25:17 -04:00
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
pack_start (*hbox, true, true);
|
2016-04-05 11:23:03 -04:00
|
|
|
set_border_width (4);
|
2016-05-09 06:45:36 -04:00
|
|
|
show_all ();
|
2016-03-31 19:33:22 -04:00
|
|
|
|
|
|
|
plugin_reconfigured ();
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
darea.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
|
2016-05-09 06:45:36 -04:00
|
|
|
darea.signal_size_request ().connect (sigc::mem_fun (*this, &PluginPinWidget::darea_size_request));
|
|
|
|
darea.signal_size_allocate ().connect (sigc::mem_fun (*this, &PluginPinWidget::darea_size_allocate));
|
|
|
|
darea.signal_expose_event ().connect (sigc::mem_fun (*this, &PluginPinWidget::darea_expose_event));
|
|
|
|
darea.signal_button_press_event ().connect (sigc::mem_fun (*this, &PluginPinWidget::darea_button_press_event));
|
|
|
|
darea.signal_button_release_event ().connect (sigc::mem_fun (*this, &PluginPinWidget::darea_button_release_event));
|
|
|
|
darea.signal_motion_notify_event ().connect (sigc::mem_fun (*this, &PluginPinWidget::darea_motion_notify_event));
|
2016-04-02 08:45:24 -04:00
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
_tgl_sidechain.signal_clicked.connect (sigc::mem_fun (*this, &PluginPinWidget::toggle_sidechain));
|
2016-04-02 23:21:40 -04:00
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
_set_config.signal_clicked.connect (sigc::mem_fun (*this, &PluginPinWidget::reset_configuration));
|
|
|
|
_add_plugin.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_plugin_clicked), true));
|
|
|
|
_del_plugin.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_plugin_clicked), false));
|
2016-04-02 08:45:24 -04:00
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
_add_input_audio.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_inpin_clicked), true, DataType::AUDIO));
|
|
|
|
_del_input_audio.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_inpin_clicked), false, DataType::AUDIO));
|
|
|
|
_add_input_midi.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_inpin_clicked), true, DataType::MIDI));
|
|
|
|
_del_input_midi.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_inpin_clicked), false, DataType::MIDI));
|
2016-04-27 17:32:40 -04:00
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
_add_output_audio.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_port_clicked), true, DataType::AUDIO));
|
|
|
|
_del_output_audio.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_port_clicked), false, DataType::AUDIO));
|
|
|
|
_add_output_midi.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_port_clicked), true, DataType::MIDI));
|
|
|
|
_del_output_midi.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_remove_port_clicked), false, DataType::MIDI));
|
2016-04-27 17:32:40 -04:00
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
_add_sc_audio.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_sidechain_port), DataType::AUDIO));
|
|
|
|
_add_sc_midi.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_sidechain_port), DataType::MIDI));
|
2016-04-06 07:32:06 -04:00
|
|
|
|
2016-04-16 18:09:11 -04:00
|
|
|
AudioEngine::instance ()->PortConnectedOrDisconnected.connect (
|
2016-05-09 06:45:36 -04:00
|
|
|
_io_connection, invalidator (*this), boost::bind (&PluginPinWidget::port_connected_or_disconnected, this, _1, _3), gui_context ()
|
2016-04-06 07:32:06 -04:00
|
|
|
);
|
2021-01-13 13:04:44 -05:00
|
|
|
AudioEngine::instance ()->PortPrettyNameChanged.connect (
|
|
|
|
_io_connection, invalidator (*this), boost::bind (&PluginPinWidget::port_pretty_name_changed, this, _1), gui_context ()
|
|
|
|
);
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::~PluginPinWidget ()
|
2016-03-27 15:35:42 -04:00
|
|
|
{
|
2016-04-04 19:38:31 -04:00
|
|
|
delete _sidechain_selector;
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
|
|
|
|
2016-04-16 19:39:59 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::set_session (ARDOUR::Session *s)
|
2016-04-16 19:39:59 -04:00
|
|
|
{
|
|
|
|
SessionHandlePtr::set_session (s);
|
|
|
|
plugin_reconfigured ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::queue_idle_update ()
|
2016-04-16 19:39:59 -04:00
|
|
|
{
|
|
|
|
/* various actions here are directly executed, in the GUI thread,
|
|
|
|
* with the GUI-thread eventually taking the process and processor lock.
|
|
|
|
* "connect gui_context()" will call back immediately and this
|
|
|
|
* signal-handler will run with the locks held.
|
|
|
|
*
|
|
|
|
* This will lead to a crash with calling nth_send() which takes
|
|
|
|
* a processor read-lock while holding a write lock in the same thread.
|
|
|
|
*
|
|
|
|
* decouple update to GUI idle.
|
|
|
|
*
|
|
|
|
* BUT, do delete existing controls here (in case they're affected by
|
|
|
|
* the change and hit by the Timer before idle comes around)
|
|
|
|
*/
|
|
|
|
for (list<Control*>::iterator i = _controls.begin (); i != _controls.end (); ++i) {
|
|
|
|
_sidechain_tbl->remove ((*i)->box);
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
_controls.clear ();
|
2016-05-09 06:45:36 -04:00
|
|
|
Glib::signal_idle().connect (sigc::mem_fun(*this, &PluginPinWidget::idle_update));
|
2016-04-16 19:39:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::idle_update ()
|
2016-04-16 19:39:59 -04:00
|
|
|
{
|
|
|
|
plugin_reconfigured ();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-29 16:50:08 -04:00
|
|
|
void
|
|
|
|
PluginPinWidget::error_message_dialog (std::string const& msg) const
|
|
|
|
{
|
|
|
|
assert (_session);
|
|
|
|
Gtk::MessageDialog d (
|
|
|
|
_session->actively_recording () ? _("Cannot perform operation while actively recording.") : msg
|
|
|
|
, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
|
|
|
d.run();
|
|
|
|
}
|
|
|
|
|
2016-04-16 19:39:59 -04:00
|
|
|
|
2016-03-27 15:35:42 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::plugin_reconfigured ()
|
2016-03-27 15:35:42 -04:00
|
|
|
{
|
2016-05-09 06:45:36 -04:00
|
|
|
ENSURE_GUI_THREAD (*this, &PluginPinWidget::plugin_reconfigured);
|
2016-04-01 20:02:47 -04:00
|
|
|
if (_ignore_updates) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
_n_plugins = _pi->get_count ();
|
|
|
|
_pi->configured_io (_in, _out);
|
2016-04-02 23:21:40 -04:00
|
|
|
_ins = _pi->internal_streams (); // with sidechain
|
2016-04-01 16:57:33 -04:00
|
|
|
_sinks = _pi->natural_input_streams ();
|
|
|
|
_sources = _pi->natural_output_streams ();
|
|
|
|
|
2016-04-15 12:15:05 -04:00
|
|
|
|
2016-04-02 23:21:40 -04:00
|
|
|
_tgl_sidechain.set_active (_pi->has_sidechain ());
|
2016-04-05 15:53:05 -04:00
|
|
|
_add_sc_audio.set_sensitive (_pi->has_sidechain ());
|
|
|
|
_add_sc_midi.set_sensitive (_pi->has_sidechain ());
|
2016-04-02 08:44:05 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
if (_pi->custom_cfg ()) {
|
2016-04-06 07:39:34 -04:00
|
|
|
_set_config.set_active (true);
|
|
|
|
_add_plugin.set_sensitive (true);
|
2016-04-27 17:32:40 -04:00
|
|
|
_del_plugin.set_sensitive (_n_plugins > 1);
|
2016-04-06 07:39:34 -04:00
|
|
|
_add_output_audio.set_sensitive (true);
|
|
|
|
_add_output_midi.set_sensitive (true);
|
|
|
|
_del_output_audio.set_sensitive (_out.n_audio () > 0 && _out.n_total () > 1);
|
|
|
|
_del_output_midi.set_sensitive (_out.n_midi () > 0 && _out.n_total () > 1);
|
2016-04-27 17:32:40 -04:00
|
|
|
_add_input_audio.set_sensitive (true);
|
|
|
|
_add_input_midi.set_sensitive (true);
|
|
|
|
_del_input_audio.set_sensitive (_sinks.n_audio () > 0 && _sinks.n_total () > 1);
|
|
|
|
_del_input_midi.set_sensitive (_sinks.n_midi () > 0 && _sinks.n_total () > 1);
|
2016-04-15 12:15:05 -04:00
|
|
|
_out_presets.set_sensitive (false);
|
|
|
|
_out_presets.set_text (_("Manual"));
|
2016-04-05 11:23:03 -04:00
|
|
|
} else {
|
2016-04-06 07:39:34 -04:00
|
|
|
_set_config.set_active (false);
|
|
|
|
_add_plugin.set_sensitive (false);
|
2016-04-27 17:32:40 -04:00
|
|
|
_del_plugin.set_sensitive (false);
|
|
|
|
_add_input_audio.set_sensitive (false);
|
|
|
|
_add_input_midi.set_sensitive (false);
|
|
|
|
_del_input_audio.set_sensitive (false);
|
|
|
|
_del_input_midi.set_sensitive (false);
|
2016-04-06 07:39:34 -04:00
|
|
|
_add_output_audio.set_sensitive (false);
|
|
|
|
_add_output_midi.set_sensitive (false);
|
|
|
|
_del_output_audio.set_sensitive (false);
|
|
|
|
_del_output_midi.set_sensitive (false);
|
2016-04-15 12:15:05 -04:00
|
|
|
_out_presets.set_sensitive (true);
|
|
|
|
refill_output_presets ();
|
2016-04-05 11:23:03 -04:00
|
|
|
}
|
|
|
|
|
2016-04-04 19:38:31 -04:00
|
|
|
if (!_pi->has_sidechain () && _sidechain_selector) {
|
|
|
|
delete _sidechain_selector;
|
|
|
|
_sidechain_selector = 0;
|
|
|
|
}
|
2016-04-05 15:53:05 -04:00
|
|
|
|
|
|
|
refill_sidechain_table ();
|
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
/* update elements */
|
2016-04-04 19:38:31 -04:00
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
_elements.clear ();
|
2016-04-02 08:45:24 -04:00
|
|
|
_hover.reset ();
|
|
|
|
_actor.reset ();
|
|
|
|
_selection.reset ();
|
2016-04-16 18:09:11 -04:00
|
|
|
_drag_dst.reset ();
|
2016-04-14 12:30:34 -04:00
|
|
|
_dragging = false;
|
2016-04-01 16:57:33 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
_n_inputs = _n_sidechains = 0;
|
|
|
|
|
2016-04-02 23:21:40 -04:00
|
|
|
for (uint32_t i = 0; i < _ins.n_total (); ++i) {
|
2016-04-05 15:53:05 -04:00
|
|
|
DataType dt = i < _ins.n_midi () ? DataType::MIDI : DataType::AUDIO;
|
|
|
|
uint32_t id = dt == DataType::MIDI ? i : i - _ins.n_midi ();
|
|
|
|
bool sidechain = id >= _in.get (dt) ? true : false;
|
2016-04-05 11:23:03 -04:00
|
|
|
if (sidechain) {
|
|
|
|
++_n_sidechains;
|
|
|
|
} else {
|
|
|
|
++_n_inputs;
|
|
|
|
}
|
2016-04-03 16:44:36 -04:00
|
|
|
|
2016-04-13 17:37:09 -04:00
|
|
|
CtrlWidget cw (CtrlWidget ("", Input, dt, id, 0, sidechain));
|
2016-04-03 16:44:36 -04:00
|
|
|
_elements.push_back (cw);
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < _out.n_total (); ++i) {
|
2016-04-01 21:20:43 -04:00
|
|
|
int id = (i < _out.n_midi ()) ? i : i - _out.n_midi ();
|
2016-04-13 17:37:09 -04:00
|
|
|
_elements.push_back (CtrlWidget ("", Output, (i < _out.n_midi () ? DataType::MIDI : DataType::AUDIO), id));
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
|
|
|
|
2016-04-17 16:21:26 -04:00
|
|
|
_in_map.clear ();
|
|
|
|
_out_map.clear ();
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
for (uint32_t n = 0; n < _n_plugins; ++n) {
|
2016-04-03 16:44:36 -04:00
|
|
|
boost::shared_ptr<Plugin> plugin = _pi->plugin (n);
|
2016-04-02 08:45:24 -04:00
|
|
|
for (uint32_t i = 0; i < _sinks.n_total (); ++i) {
|
2016-04-12 19:16:03 -04:00
|
|
|
DataType dt (i < _sinks.n_midi () ? DataType::MIDI : DataType::AUDIO);
|
|
|
|
int idx = (dt == DataType::MIDI) ? i : i - _sinks.n_midi ();
|
2016-04-03 16:44:36 -04:00
|
|
|
const Plugin::IOPortDescription& iod (plugin->describe_io_port (dt, true, idx));
|
2016-04-13 17:37:09 -04:00
|
|
|
CtrlWidget cw (CtrlWidget (iod.name, Sink, dt, idx, n, iod.is_sidechain));
|
2016-04-03 16:44:36 -04:00
|
|
|
_elements.push_back (cw);
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-04-02 08:45:24 -04:00
|
|
|
for (uint32_t i = 0; i < _sources.n_total (); ++i) {
|
2016-04-12 19:16:03 -04:00
|
|
|
DataType dt (i < _sources.n_midi () ? DataType::MIDI : DataType::AUDIO);
|
|
|
|
int idx = (dt == DataType::MIDI) ? i : i - _sources.n_midi ();
|
2016-04-13 17:37:09 -04:00
|
|
|
const Plugin::IOPortDescription& iod (plugin->describe_io_port (dt, false, idx));
|
|
|
|
_elements.push_back (CtrlWidget (iod.name, Source, dt, idx, n));
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-04-17 16:21:26 -04:00
|
|
|
_in_map[n] = _pi->input_map (n);
|
|
|
|
_out_map[n] = _pi->output_map (n);
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-04-17 16:21:26 -04:00
|
|
|
_has_midi_bypass = _pi->has_midi_bypass ();
|
|
|
|
_thru_map = _pi->thru_map ();
|
|
|
|
|
|
|
|
/* cache maps */
|
2016-04-05 11:23:03 -04:00
|
|
|
|
|
|
|
/* calc minimum size */
|
|
|
|
const uint32_t max_ports = std::max (_ins.n_total (), _out.n_total ());
|
|
|
|
const uint32_t max_pins = std::max ((_sinks * _n_plugins).n_total (), (_sources * _n_plugins).n_total ());
|
|
|
|
uint32_t min_width = std::max (25 * max_ports, (uint32_t)(20 + _pin_box_size) * max_pins);
|
2016-04-05 15:53:05 -04:00
|
|
|
min_width = std::max (min_width, (uint32_t)ceilf (_margin_y * .45 * _n_plugins * 16. / 9.)); // 16 : 9 aspect
|
2016-04-05 11:23:03 -04:00
|
|
|
min_width = std::max ((uint32_t)300, min_width);
|
2016-04-05 15:53:05 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
min_width = 50 + 10 * ceilf (min_width / 10.f);
|
|
|
|
|
|
|
|
uint32_t min_height = 3.5 * _margin_y + 2 * (_n_sidechains + 1) * _pin_box_size;
|
|
|
|
min_height = std::max ((uint32_t)200, min_height);
|
2016-04-05 15:53:05 -04:00
|
|
|
min_height = 4 * ceilf (min_height / 4.f);
|
2016-04-05 11:23:03 -04:00
|
|
|
|
|
|
|
if (min_width != _min_width || min_height != _min_height) {
|
|
|
|
_min_width = min_width;
|
|
|
|
_min_height = min_height;
|
|
|
|
darea.queue_resize ();
|
|
|
|
}
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
_position_valid = false;
|
2016-03-27 15:35:42 -04:00
|
|
|
darea.queue_draw ();
|
|
|
|
}
|
|
|
|
|
2016-04-05 15:53:05 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::refill_sidechain_table ()
|
2016-04-05 15:53:05 -04:00
|
|
|
{
|
|
|
|
Table_Helpers::TableList& kids = _sidechain_tbl->children ();
|
|
|
|
for (Table_Helpers::TableList::iterator i = kids.begin (); i != kids.end ();) {
|
|
|
|
i = kids.erase (i);
|
|
|
|
}
|
|
|
|
_sidechain_tbl->resize (1, 1);
|
2016-04-16 19:39:59 -04:00
|
|
|
for (list<Control*>::iterator i = _controls.begin (); i != _controls.end (); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
_controls.clear ();
|
2016-04-05 15:53:05 -04:00
|
|
|
if (!_pi->has_sidechain () && _sidechain_selector) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
boost::shared_ptr<IO> io = _pi->sidechain_input ();
|
|
|
|
if (!io) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t r = 0;
|
|
|
|
PortSet& p (io->ports ());
|
|
|
|
bool can_remove = p.num_ports () > 1;
|
2016-04-16 19:39:59 -04:00
|
|
|
for (PortSet::iterator i = p.begin (DataType::MIDI); i != p.end (DataType::MIDI); ++i) {
|
|
|
|
r += add_port_to_table (*i, r, can_remove);
|
2016-04-05 15:53:05 -04:00
|
|
|
}
|
2016-04-16 19:39:59 -04:00
|
|
|
for (PortSet::iterator i = p.begin (DataType::AUDIO); i != p.end (DataType::AUDIO); ++i) {
|
|
|
|
r += add_port_to_table (*i, r, can_remove);
|
2016-04-05 15:53:05 -04:00
|
|
|
}
|
|
|
|
_sidechain_tbl->show_all ();
|
|
|
|
}
|
|
|
|
|
2016-04-15 12:15:05 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::refill_output_presets ()
|
2016-04-15 12:15:05 -04:00
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
2016-04-16 18:09:11 -04:00
|
|
|
_out_presets.clear_items ();
|
2016-04-15 17:04:55 -04:00
|
|
|
|
2016-05-18 19:46:49 -04:00
|
|
|
bool need_dropdown = _pi->has_output_presets ();
|
2016-04-15 17:04:55 -04:00
|
|
|
|
|
|
|
if (!need_dropdown) {
|
|
|
|
_out_presets.set_sensitive (false);
|
2016-04-16 18:09:11 -04:00
|
|
|
_out_presets.set_text (_("Automatic"));
|
2016-04-15 17:04:55 -04:00
|
|
|
return;
|
|
|
|
}
|
2016-04-15 12:15:05 -04:00
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
_out_presets.AddMenuElem (MenuElem (_("Automatic"), sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::select_output_preset), 0)));
|
2016-04-15 12:15:05 -04:00
|
|
|
|
|
|
|
const uint32_t n_audio = _pi->preset_out ().n_audio ();
|
|
|
|
if (n_audio == 0) {
|
2016-04-16 18:09:11 -04:00
|
|
|
_out_presets.set_text (_("Automatic"));
|
2016-04-15 12:15:05 -04:00
|
|
|
}
|
|
|
|
|
2016-05-18 19:46:49 -04:00
|
|
|
PluginOutputConfiguration ppc (_pi->plugin (0)->possible_output ());
|
2016-04-15 12:15:05 -04:00
|
|
|
if (ppc.find (0) != ppc.end ()) {
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
// anything goes
|
2016-04-15 12:15:05 -04:00
|
|
|
ppc.clear ();
|
|
|
|
if (n_audio != 0) {
|
|
|
|
ppc.insert (n_audio);
|
|
|
|
}
|
|
|
|
ppc.insert (1);
|
|
|
|
ppc.insert (2);
|
|
|
|
ppc.insert (8);
|
|
|
|
ppc.insert (16);
|
|
|
|
ppc.insert (24);
|
|
|
|
ppc.insert (32);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (PluginOutputConfiguration::const_iterator i = ppc.begin () ; i != ppc.end (); ++i) {
|
|
|
|
assert (*i > 0);
|
|
|
|
std::string tmp;
|
|
|
|
switch (*i) {
|
|
|
|
case 1:
|
|
|
|
tmp = _("Mono");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
tmp = _("Stereo");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tmp = string_compose (P_("%1 Channel", "%1 Channels", *i), *i);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-09 06:45:36 -04:00
|
|
|
_out_presets.AddMenuElem (MenuElem (tmp, sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::select_output_preset), *i)));
|
2016-04-15 12:15:05 -04:00
|
|
|
if (n_audio == *i) {
|
2016-04-16 18:09:11 -04:00
|
|
|
_out_presets.set_text (tmp);
|
2016-04-15 12:15:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-17 08:10:13 -04:00
|
|
|
std::string
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::port_label (const std::string& portname, bool strip)
|
2016-04-17 08:10:13 -04:00
|
|
|
{
|
2022-04-08 20:22:59 -04:00
|
|
|
// compare to IOButton::update
|
|
|
|
string lpn (AudioEngine::instance()->my_name());
|
2016-04-17 08:10:13 -04:00
|
|
|
boost::to_lower (lpn);
|
|
|
|
std::string program_port_prefix = lpn + ":"; // e.g. "ardour:"
|
|
|
|
|
2016-04-17 15:37:43 -04:00
|
|
|
std::string pn = AudioEngine::instance ()->get_pretty_name_by_name (portname);
|
|
|
|
if (!pn.empty ()) {
|
|
|
|
string::size_type slash = pn.find ("/");
|
|
|
|
if (slash != string::npos) {
|
|
|
|
pn = pn.substr (0, slash);
|
|
|
|
}
|
|
|
|
return pn;
|
|
|
|
}
|
2016-04-17 08:10:13 -04:00
|
|
|
std::string label (portname);
|
|
|
|
if (label.find ("system:capture_") == 0) {
|
|
|
|
if (label.empty ()) {
|
|
|
|
label = portname.substr (15);
|
|
|
|
}
|
|
|
|
} else if (label.find ("system:midi_capture_") == 0) {
|
|
|
|
if (label.empty ()) {
|
|
|
|
// "system:midi_capture_123" -> "123"
|
|
|
|
label = "M " + portname.substr (20);
|
|
|
|
}
|
|
|
|
} else if (label.find (program_port_prefix) == 0) {
|
|
|
|
label = label.substr (program_port_prefix.size ());
|
|
|
|
if (strip) {
|
|
|
|
string::size_type slash = label.find ("/");
|
|
|
|
if (slash != string::npos) {
|
|
|
|
label = label.substr (0, slash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2016-04-16 19:39:59 -04:00
|
|
|
uint32_t
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::add_port_to_table (boost::shared_ptr<Port> p, uint32_t r, bool can_remove)
|
2016-04-05 15:53:05 -04:00
|
|
|
{
|
|
|
|
std::string lbl;
|
2017-09-14 13:22:44 -04:00
|
|
|
std::string tip = Gtkmm2ext::markup_escape_text (p->name ());
|
2016-04-05 15:53:05 -04:00
|
|
|
std::vector<std::string> cns;
|
2016-04-17 08:10:13 -04:00
|
|
|
bool single_source = true;
|
2016-04-05 15:53:05 -04:00
|
|
|
p->get_connections (cns);
|
|
|
|
|
2016-04-17 08:10:13 -04:00
|
|
|
for (std::vector<std::string>::const_iterator i = cns.begin (); i != cns.end (); ++i) {
|
|
|
|
if (lbl.empty ()) {
|
|
|
|
lbl = port_label (*i, true);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (port_label (*i, true) != lbl) {
|
|
|
|
lbl = "...";
|
|
|
|
single_source = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-05 15:53:05 -04:00
|
|
|
if (cns.size () == 0) {
|
|
|
|
lbl = "-";
|
2016-04-17 08:10:13 -04:00
|
|
|
single_source = false;
|
|
|
|
} else if (cns.size () == 1) {
|
2016-04-05 20:31:36 -04:00
|
|
|
tip += " <- ";
|
2016-04-17 08:10:13 -04:00
|
|
|
lbl = port_label (cns[0], false);
|
2016-04-05 15:53:05 -04:00
|
|
|
} else {
|
2016-04-05 20:31:36 -04:00
|
|
|
tip += " <- ";
|
2016-04-05 15:53:05 -04:00
|
|
|
}
|
2016-04-17 08:10:13 -04:00
|
|
|
replace_all (lbl, "_", " ");
|
|
|
|
|
2016-04-16 18:09:11 -04:00
|
|
|
for (std::vector<std::string>::const_iterator i = cns.begin (); i != cns.end (); ++i) {
|
2016-04-05 15:53:05 -04:00
|
|
|
tip += *i;
|
|
|
|
tip += " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
ArdourButton *pb = manage (new ArdourButton (lbl));
|
|
|
|
pb->set_text_ellipsize (Pango::ELLIPSIZE_MIDDLE);
|
2016-04-07 08:05:15 -04:00
|
|
|
pb->set_layout_ellipsize_width (108 * PANGO_SCALE);
|
2017-07-15 11:38:28 -04:00
|
|
|
ArdourWidgets::set_tooltip (*pb, tip);
|
2016-04-05 15:53:05 -04:00
|
|
|
_sidechain_tbl->attach (*pb, 0, 1, r, r +1 , EXPAND|FILL, SHRINK);
|
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
pb->signal_button_press_event ().connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::sc_input_press), boost::weak_ptr<Port> (p)), false);
|
|
|
|
pb->signal_button_release_event ().connect (sigc::mem_fun (*this, &PluginPinWidget::sc_input_release), false);
|
2016-04-05 15:53:05 -04:00
|
|
|
|
|
|
|
pb = manage (new ArdourButton ("-"));
|
2016-04-16 18:09:11 -04:00
|
|
|
_sidechain_tbl->attach (*pb, 1, 2, r, r + 1, FILL, SHRINK);
|
2016-04-05 15:53:05 -04:00
|
|
|
if (can_remove) {
|
2016-05-09 06:45:36 -04:00
|
|
|
pb->signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::remove_port), boost::weak_ptr<Port> (p)));
|
2016-04-05 15:53:05 -04:00
|
|
|
} else {
|
|
|
|
pb->set_sensitive (false);
|
|
|
|
}
|
2016-04-16 19:39:59 -04:00
|
|
|
|
|
|
|
uint32_t rv = 1;
|
|
|
|
|
2016-04-17 08:10:13 -04:00
|
|
|
if (single_source && _session) {
|
2016-04-16 19:39:59 -04:00
|
|
|
/* check if it's an Ardour Send feeding.. */
|
|
|
|
boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
|
|
|
|
for (ARDOUR::RouteList::const_iterator i = routes->begin (); i != routes->end (); ++i) {
|
|
|
|
uint32_t nth = 0;
|
|
|
|
boost::shared_ptr<Processor> proc;
|
|
|
|
/* nth_send () takes a processor read-lock */
|
|
|
|
while ((proc = (*i)->nth_send (nth))) {
|
|
|
|
boost::shared_ptr<IOProcessor> send = boost::dynamic_pointer_cast<IOProcessor> (proc);
|
|
|
|
if (!send || !send->output ()) {
|
|
|
|
++nth;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!send->output ()->connected_to (p->name ())) {
|
|
|
|
++nth;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* if processor goes away, we're notified by the port disconnect,
|
|
|
|
* there should be no need to explicily connect to proc->DropReferences
|
|
|
|
*/
|
|
|
|
set<Evoral::Parameter> p = proc->what_can_be_automated ();
|
|
|
|
for (set<Evoral::Parameter>::iterator i = p.begin (); i != p.end (); ++i) {
|
|
|
|
Control* c = new Control (proc->automation_control (*i), _("Send"));
|
|
|
|
_controls.push_back (c);
|
|
|
|
++r; ++rv;
|
|
|
|
_sidechain_tbl->attach (c->box, 0, 2, r, r + 1, EXPAND|FILL, SHRINK);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
2016-04-05 15:53:05 -04:00
|
|
|
}
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::update_element_pos ()
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
|
|
|
/* layout sizes */
|
2016-04-05 11:23:03 -04:00
|
|
|
_innerwidth = _width - 2. * _margin_x;
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
const double yc = rint (_height * .5);
|
2016-04-05 15:53:05 -04:00
|
|
|
const double bxh2 = rint (_margin_y * .45); // TODO grow?
|
2016-04-05 11:23:03 -04:00
|
|
|
const double bxw = rint ((_innerwidth * .95) / ((_n_plugins) + .2 * (_n_plugins - 1)));
|
2016-04-01 16:57:33 -04:00
|
|
|
const double bxw2 = rint (bxw * .5);
|
2016-04-05 11:23:03 -04:00
|
|
|
const double y_in = _margin_y;
|
|
|
|
const double y_out = _height - _margin_y;
|
2016-04-01 16:57:33 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
_bxw2 = bxw2;
|
|
|
|
_bxh2 = bxh2;
|
2016-04-01 16:57:33 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
const double dx = _pin_box_size * .5;
|
|
|
|
|
|
|
|
uint32_t sc_cnt = 0;
|
2016-04-02 08:45:24 -04:00
|
|
|
for (CtrlElemList::iterator i = _elements.begin (); i != _elements.end (); ++i) {
|
2016-04-01 16:57:33 -04:00
|
|
|
switch (i->e->ct) {
|
|
|
|
case Input:
|
2016-04-05 11:23:03 -04:00
|
|
|
if (i->e->sc) {
|
|
|
|
i->x = _innerwidth + _margin_x - dx;
|
|
|
|
i->y = y_in + (sc_cnt + .5) * _pin_box_size;
|
|
|
|
i->h = _pin_box_size;
|
|
|
|
i->w = 1.5 * _pin_box_size;
|
|
|
|
++ sc_cnt;
|
|
|
|
} else {
|
2016-04-01 21:20:43 -04:00
|
|
|
uint32_t idx = i->e->id;
|
2016-04-05 15:53:05 -04:00
|
|
|
if (i->e->dt == DataType::AUDIO) { idx += _in.n_midi (); }
|
2016-04-05 11:23:03 -04:00
|
|
|
i->x = rint ((idx + 1) * _width / (1. + _n_inputs)) - 0.5 - dx;
|
|
|
|
i->w = _pin_box_size;
|
|
|
|
i->h = 1.5 * _pin_box_size;
|
|
|
|
i->y = y_in - i->h;
|
2016-04-01 21:20:43 -04:00
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
break;
|
|
|
|
case Output:
|
2016-04-01 21:20:43 -04:00
|
|
|
{
|
|
|
|
uint32_t idx = i->e->id;
|
|
|
|
if (i->e->dt == DataType::AUDIO) { idx += _out.n_midi (); }
|
2016-04-02 17:08:29 -04:00
|
|
|
i->x = rint ((idx + 1) * _width / (1. + _out.n_total ())) - 0.5 - dx;
|
2016-04-01 21:20:43 -04:00
|
|
|
i->y = y_out;
|
2016-04-05 11:23:03 -04:00
|
|
|
i->w = _pin_box_size;
|
|
|
|
i->h = 1.5 * _pin_box_size;
|
2016-04-01 21:20:43 -04:00
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
break;
|
|
|
|
case Sink:
|
|
|
|
{
|
2016-04-12 19:16:03 -04:00
|
|
|
uint32_t idx = i->e->id;
|
|
|
|
if (i->e->dt == DataType::AUDIO) { idx += _sinks.n_midi (); }
|
2016-04-05 11:23:03 -04:00
|
|
|
const double x0 = rint ((i->e->ip + .5) * _innerwidth / (double)(_n_plugins)) - .5 - bxw2;
|
2016-04-12 19:16:03 -04:00
|
|
|
i->x = _margin_x + rint (x0 + (idx + 1) * bxw / (1. + _sinks.n_total ())) - .5 - dx;
|
2016-04-05 11:23:03 -04:00
|
|
|
i->y = yc - bxh2 - dx;
|
|
|
|
i->w = _pin_box_size;
|
2016-04-01 16:57:33 -04:00
|
|
|
i->h = _pin_box_size;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Source:
|
|
|
|
{
|
2016-04-12 19:16:03 -04:00
|
|
|
uint32_t idx = i->e->id;
|
|
|
|
if (i->e->dt == DataType::AUDIO) { idx += _sources.n_midi (); }
|
2016-04-05 11:23:03 -04:00
|
|
|
const double x0 = rint ((i->e->ip + .5) * _innerwidth / (double)(_n_plugins)) - .5 - bxw2;
|
2016-04-12 19:16:03 -04:00
|
|
|
i->x = _margin_x + rint (x0 + (idx + 1) * bxw / (1. + _sources.n_total ())) - .5 - dx;
|
2016-04-05 11:23:03 -04:00
|
|
|
i->y = yc + bxh2 - dx;
|
|
|
|
i->w = _pin_box_size;
|
2016-04-01 16:57:33 -04:00
|
|
|
i->h = _pin_box_size;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-28 12:25:17 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::set_color (cairo_t* cr, bool midi)
|
2016-03-28 12:25:17 -04:00
|
|
|
{
|
|
|
|
// see also gtk2_ardour/processor_box.cc
|
|
|
|
static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
|
|
|
|
static const uint32_t midi_port_color = 0x960909FF; //Red
|
|
|
|
|
|
|
|
if (midi) {
|
|
|
|
cairo_set_source_rgb (cr,
|
2016-04-02 08:45:24 -04:00
|
|
|
UINT_RGBA_R_FLT (midi_port_color),
|
|
|
|
UINT_RGBA_G_FLT (midi_port_color),
|
|
|
|
UINT_RGBA_B_FLT (midi_port_color));
|
2016-03-28 12:25:17 -04:00
|
|
|
} else {
|
|
|
|
cairo_set_source_rgb (cr,
|
2016-04-02 08:45:24 -04:00
|
|
|
UINT_RGBA_R_FLT (audio_port_color),
|
|
|
|
UINT_RGBA_G_FLT (audio_port_color),
|
|
|
|
UINT_RGBA_B_FLT (audio_port_color));
|
2016-03-28 12:25:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-27 15:35:42 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::draw_io_pin (cairo_t* cr, const CtrlWidget& w)
|
2016-03-27 15:35:42 -04:00
|
|
|
{
|
2016-04-05 11:23:03 -04:00
|
|
|
if (w.e->sc) {
|
|
|
|
const double dy = w.h * .5;
|
|
|
|
const double dx = w.w - dy;
|
|
|
|
cairo_move_to (cr, w.x, w.y + dy);
|
|
|
|
cairo_rel_line_to (cr, dy, -dy);
|
|
|
|
cairo_rel_line_to (cr, dx, 0);
|
|
|
|
cairo_rel_line_to (cr, 0, w.h);
|
|
|
|
cairo_rel_line_to (cr, -dx, 0);
|
|
|
|
} else {
|
|
|
|
const double dir = (w.e->ct == Input) ? 1 : -1;
|
|
|
|
const double dx = w.w * .5;
|
|
|
|
const double dy = w.h - dx;
|
|
|
|
|
|
|
|
cairo_move_to (cr, w.x + dx, w.y + ((w.e->ct == Input) ? w.h : 0));
|
|
|
|
cairo_rel_line_to (cr, -dx, -dx * dir);
|
|
|
|
cairo_rel_line_to (cr, 0., -dy * dir);
|
|
|
|
cairo_rel_line_to (cr, 2. * dx, 0.);
|
|
|
|
cairo_rel_line_to (cr, 0., dy * dir);
|
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
cairo_close_path (cr);
|
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
|
|
|
cairo_stroke_preserve (cr);
|
|
|
|
|
|
|
|
set_color (cr, w.e->dt == DataType::MIDI);
|
2016-04-01 16:57:33 -04:00
|
|
|
|
2016-04-03 16:44:36 -04:00
|
|
|
if (w.e->sc) {
|
2016-04-02 23:21:40 -04:00
|
|
|
assert (w.e->ct == Input);
|
2016-04-05 11:23:03 -04:00
|
|
|
cairo_fill_preserve (cr);
|
|
|
|
cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.4);
|
2016-04-02 23:21:40 -04:00
|
|
|
}
|
2016-04-05 11:23:03 -04:00
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
if (w.e == _selection || w.e == _actor) {
|
2016-04-02 17:08:29 -04:00
|
|
|
cairo_fill_preserve (cr);
|
|
|
|
cairo_set_source_rgba (cr, 0.9, 0.9, 1.0, 0.6);
|
2016-04-01 16:57:33 -04:00
|
|
|
} else if (w.prelight) {
|
|
|
|
cairo_fill_preserve (cr);
|
2016-04-02 17:08:29 -04:00
|
|
|
cairo_set_source_rgba (cr, 0.9, 0.9, 0.9, 0.3);
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-04-05 11:23:03 -04:00
|
|
|
cairo_fill (cr);
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::draw_plugin_pin (cairo_t* cr, const CtrlWidget& w)
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
2016-04-05 11:23:03 -04:00
|
|
|
const double dx = w.w * .5;
|
|
|
|
const double dy = w.h * .5;
|
|
|
|
|
|
|
|
cairo_move_to (cr, w.x + dx, w.y);
|
|
|
|
cairo_rel_line_to (cr, -dx, dy);
|
|
|
|
cairo_rel_line_to (cr, dx, dy);
|
|
|
|
cairo_rel_line_to (cr, dx, -dy);
|
|
|
|
cairo_close_path (cr);
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
|
|
|
cairo_stroke_preserve (cr);
|
|
|
|
|
|
|
|
set_color (cr, w.e->dt == DataType::MIDI);
|
2016-04-03 16:44:36 -04:00
|
|
|
|
|
|
|
if (w.e->sc) {
|
|
|
|
assert (w.e->ct == Sink);
|
2016-04-05 11:23:03 -04:00
|
|
|
cairo_fill_preserve (cr);
|
|
|
|
cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.4);
|
2016-04-03 16:44:36 -04:00
|
|
|
}
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
if (w.e == _selection || w.e == _actor) {
|
2016-04-02 17:08:29 -04:00
|
|
|
cairo_fill_preserve (cr);
|
|
|
|
cairo_set_source_rgba (cr, 0.9, 0.9, 1.0, 0.6);
|
2016-04-01 16:57:33 -04:00
|
|
|
} else if (w.prelight) {
|
|
|
|
cairo_fill_preserve (cr);
|
2016-04-02 17:08:29 -04:00
|
|
|
cairo_set_source_rgba (cr, 0.9, 0.9, 0.9, 0.3);
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
cairo_fill (cr);
|
2016-04-13 17:37:09 -04:00
|
|
|
|
2016-04-16 18:09:11 -04:00
|
|
|
if ((w.prelight || w.e == _selection) && !w.name.empty ()) {
|
2016-04-13 17:37:09 -04:00
|
|
|
int text_width;
|
|
|
|
int text_height;
|
|
|
|
Glib::RefPtr<Pango::Layout> layout;
|
|
|
|
layout = Pango::Layout::create (get_pango_context ());
|
|
|
|
layout->set_text (w.name);
|
|
|
|
layout->get_pixel_size (text_width, text_height);
|
|
|
|
|
|
|
|
rounded_rectangle (cr, w.x + dx - .5 * text_width - 2, w.y - text_height - 2, text_width + 4, text_height + 2, 7);
|
|
|
|
cairo_set_source_rgba (cr, 0, 0, 0, .5);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
cairo_move_to (cr, w.x + dx - .5 * text_width, w.y - text_height - 1);
|
|
|
|
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
|
|
|
|
pango_cairo_show_layout (cr, layout->gobj ());
|
|
|
|
}
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
double
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::pin_x_pos (uint32_t i, double x0, double width, uint32_t n_total, uint32_t n_midi, bool midi)
|
2016-03-27 15:35:42 -04:00
|
|
|
{
|
|
|
|
if (!midi) { i += n_midi; }
|
|
|
|
return rint (x0 + (i + 1) * width / (1. + n_total)) - .5;
|
|
|
|
}
|
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
const PluginPinWidget::CtrlWidget&
|
|
|
|
PluginPinWidget::get_io_ctrl (CtrlType ct, DataType dt, uint32_t id, uint32_t ip) const
|
2016-04-05 11:23:03 -04:00
|
|
|
{
|
|
|
|
for (CtrlElemList::const_iterator i = _elements.begin (); i != _elements.end (); ++i) {
|
|
|
|
if (i->e->ct == ct && i->e->dt == dt && i->e->id == id && i->e->ip == ip) {
|
|
|
|
return *i;
|
|
|
|
}
|
|
|
|
}
|
2016-04-12 19:16:03 -04:00
|
|
|
assert (0);
|
2016-04-05 11:23:03 -04:00
|
|
|
fatal << string_compose (_("programming error: %1"),
|
|
|
|
X_("Invalid Plugin I/O Port."))
|
|
|
|
<< endmsg;
|
2016-04-05 15:53:05 -04:00
|
|
|
abort (); /*NOTREACHED*/
|
2016-04-13 17:37:09 -04:00
|
|
|
static CtrlWidget screw_old_compilers ("", Input, DataType::NIL, 0);
|
2016-04-05 11:23:03 -04:00
|
|
|
return screw_old_compilers;
|
|
|
|
}
|
|
|
|
|
2016-03-27 15:35:42 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::edge_coordinates (const CtrlWidget& w, double &x, double &y)
|
2016-04-05 11:23:03 -04:00
|
|
|
{
|
|
|
|
switch (w.e->ct) {
|
|
|
|
case Input:
|
|
|
|
if (w.e->sc) {
|
|
|
|
x = w.x;
|
|
|
|
y = w.y + w.h * .5;
|
|
|
|
} else {
|
|
|
|
x = w.x + w.w * .5;
|
|
|
|
y = w.y + w.h;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Output:
|
|
|
|
x = w.x + w.w * .5;
|
|
|
|
y = w.y;
|
|
|
|
break;
|
|
|
|
case Sink:
|
|
|
|
x = w.x + w.w * .5;
|
|
|
|
y = w.y;
|
|
|
|
break;
|
|
|
|
case Source:
|
|
|
|
x = w.x + w.w * .5;
|
|
|
|
y = w.y + w.h;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::draw_connection (cairo_t* cr, double x0, double x1, double y0, double y1, bool midi, bool horiz, bool dashed)
|
2016-03-27 15:35:42 -04:00
|
|
|
{
|
2016-04-01 16:57:33 -04:00
|
|
|
const double bz = 2 * _pin_box_size;
|
2016-04-15 16:08:03 -04:00
|
|
|
double bc = (dashed && x0 == x1) ? 1.25 * _pin_box_size : 0;
|
|
|
|
if (x0 > _width * .5) { bc *= -1; }
|
2016-03-28 12:25:17 -04:00
|
|
|
|
2016-03-27 15:35:42 -04:00
|
|
|
cairo_move_to (cr, x0, y0);
|
2016-04-05 11:23:03 -04:00
|
|
|
if (horiz) {
|
|
|
|
cairo_curve_to (cr, x0 - bz, y0 + bc, x1 - bc, y1 - bz, x1, y1);
|
|
|
|
} else {
|
|
|
|
cairo_curve_to (cr, x0 - bc, y0 + bz, x1 - bc, y1 - bz, x1, y1);
|
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
cairo_set_line_width (cr, 3.0);
|
|
|
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
|
2016-03-27 15:35:42 -04:00
|
|
|
cairo_set_source_rgb (cr, 1, 0, 0);
|
2016-03-28 12:25:17 -04:00
|
|
|
if (dashed) {
|
|
|
|
const double dashes[] = { 5, 7 };
|
|
|
|
cairo_set_dash (cr, dashes, 2, 0);
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
2016-03-28 12:25:17 -04:00
|
|
|
set_color (cr, midi);
|
2016-03-27 15:35:42 -04:00
|
|
|
cairo_stroke (cr);
|
2016-03-28 12:25:17 -04:00
|
|
|
if (dashed) {
|
|
|
|
cairo_set_dash (cr, 0, 0, 0);
|
|
|
|
}
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::draw_connection (cairo_t* cr, const CtrlWidget& w0, const CtrlWidget& w1, bool dashed)
|
2016-04-05 11:23:03 -04:00
|
|
|
{
|
|
|
|
double x0, x1, y0, y1;
|
|
|
|
edge_coordinates (w0, x0, y0);
|
|
|
|
edge_coordinates (w1, x1, y1);
|
|
|
|
assert (w0.e->dt == w1.e->dt);
|
|
|
|
draw_connection (cr, x0, x1, y0, y1, w0.e->dt == DataType::MIDI, w0.e->sc, dashed);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-27 15:35:42 -04:00
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::darea_expose_event (GdkEventExpose* ev)
|
2016-03-27 15:35:42 -04:00
|
|
|
{
|
2016-04-02 08:45:24 -04:00
|
|
|
Gtk::Allocation a = darea.get_allocation ();
|
|
|
|
double const width = a.get_width ();
|
|
|
|
double const height = a.get_height ();
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
if (!_position_valid) {
|
|
|
|
_width = width;
|
|
|
|
_height = height;
|
|
|
|
update_element_pos ();
|
|
|
|
_position_valid = true;
|
|
|
|
}
|
2016-03-28 12:25:17 -04:00
|
|
|
|
2016-04-02 08:45:24 -04:00
|
|
|
cairo_t* cr = gdk_cairo_create (darea.get_window ()->gobj ());
|
2016-03-27 15:35:42 -04:00
|
|
|
cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
|
|
|
cairo_clip (cr);
|
|
|
|
|
2016-04-02 08:45:24 -04:00
|
|
|
Gdk::Color const bg = get_style ()->get_bg (STATE_NORMAL);
|
2016-03-27 15:35:42 -04:00
|
|
|
cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
|
|
|
|
cairo_rectangle (cr, 0, 0, width, height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
const double yc = rint (_height * .5);
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
/* processor box */
|
|
|
|
rounded_rectangle (cr, _margin_x, _margin_y - _pin_box_size * .5, _innerwidth, _height - 2 * _margin_y + _pin_box_size, 7);
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_source_rgb (cr, .1, .1, .3);
|
|
|
|
cairo_stroke_preserve (cr);
|
|
|
|
cairo_set_source_rgb (cr, .3, .3, .3);
|
|
|
|
cairo_fill (cr);
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
/* labels */
|
|
|
|
Glib::RefPtr<Pango::Layout> layout;
|
2016-04-05 15:53:05 -04:00
|
|
|
layout = Pango::Layout::create (get_pango_context ());
|
2016-04-05 11:23:03 -04:00
|
|
|
|
2016-04-05 15:53:05 -04:00
|
|
|
layout->set_ellipsize (Pango::ELLIPSIZE_MIDDLE);
|
2016-04-05 11:23:03 -04:00
|
|
|
layout->set_width (_height * PANGO_SCALE);
|
|
|
|
|
|
|
|
int text_width;
|
|
|
|
int text_height;
|
|
|
|
|
|
|
|
layout->set_text (_route ()->name ());
|
|
|
|
layout->get_pixel_size (text_width, text_height);
|
|
|
|
cairo_save (cr);
|
|
|
|
cairo_move_to (cr, .5 * (_margin_x - text_height), .5 * (_height + text_width));
|
2016-04-05 15:53:05 -04:00
|
|
|
cairo_rotate (cr, M_PI * -.5);
|
2016-04-05 11:23:03 -04:00
|
|
|
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
|
2016-04-05 15:53:05 -04:00
|
|
|
pango_cairo_show_layout (cr, layout->gobj ());
|
|
|
|
cairo_new_path (cr);
|
2016-04-05 11:23:03 -04:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
layout->set_width ((_innerwidth - 2 * _pin_box_size) * PANGO_SCALE);
|
|
|
|
layout->set_text (_pi->name ());
|
|
|
|
layout->get_pixel_size (text_width, text_height);
|
|
|
|
cairo_move_to (cr, _margin_x + _innerwidth - text_width - _pin_box_size * .5, _height - _margin_y - text_height);
|
|
|
|
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
|
2016-04-05 15:53:05 -04:00
|
|
|
pango_cairo_show_layout (cr, layout->gobj ());
|
2016-04-05 11:23:03 -04:00
|
|
|
|
2016-04-19 13:02:50 -04:00
|
|
|
#ifndef NDEBUG
|
|
|
|
if (_pi->signal_latency () > 0 || !_pi->inplace()) {
|
2016-04-15 12:15:05 -04:00
|
|
|
layout->set_width ((_innerwidth - 2 * _pin_box_size) * PANGO_SCALE);
|
2016-04-19 13:02:50 -04:00
|
|
|
if (_pi->signal_latency () > 0 && !_pi->inplace()) {
|
|
|
|
layout->set_text (string_compose (_("Latency %1 spl%2 %3"), _pi->signal_latency (), ", ", _("no-inplace")));
|
|
|
|
} else if (_pi->signal_latency () > 0) {
|
|
|
|
layout->set_text (string_compose (_("Latency %1 spl"), _pi->signal_latency ()));
|
|
|
|
} else {
|
|
|
|
layout->set_text (_("no-inplace"));
|
|
|
|
}
|
2016-04-15 12:15:05 -04:00
|
|
|
layout->get_pixel_size (text_width, text_height);
|
|
|
|
cairo_move_to (cr, _margin_x + _pin_box_size * .5, _margin_y + 2);
|
|
|
|
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
|
|
|
|
pango_cairo_show_layout (cr, layout->gobj ());
|
|
|
|
}
|
2016-04-19 13:02:50 -04:00
|
|
|
#endif
|
2016-04-15 12:15:05 -04:00
|
|
|
|
2016-04-15 08:53:18 -04:00
|
|
|
if (_pi->strict_io () && !Profile->get_mixbus ()) {
|
2016-04-05 11:23:03 -04:00
|
|
|
layout->set_text (_("Strict I/O"));
|
|
|
|
layout->get_pixel_size (text_width, text_height);
|
|
|
|
const double sx0 = _margin_x + .5 * (_innerwidth - text_width);
|
|
|
|
const double sy0 = _height - 3 - text_height;
|
|
|
|
|
|
|
|
rounded_rectangle (cr, sx0 - 2, sy0 - 1, text_width + 4, text_height + 2, 7);
|
|
|
|
cairo_set_source_rgba (cr, .4, .3, .1, 1.);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
|
|
|
|
cairo_move_to (cr, sx0, sy0);
|
|
|
|
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
|
2016-04-05 15:53:05 -04:00
|
|
|
pango_cairo_show_layout (cr, layout->gobj ());
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
|
|
|
|
2016-04-15 12:38:11 -04:00
|
|
|
/* draw midi-bypass (behind) */
|
2016-04-17 16:21:26 -04:00
|
|
|
if (_has_midi_bypass) {
|
2016-04-15 12:38:11 -04:00
|
|
|
const CtrlWidget& cw0 = get_io_ctrl (Input, DataType::MIDI, 0);
|
|
|
|
const CtrlWidget& cw1 = get_io_ctrl (Output, DataType::MIDI, 0);
|
|
|
|
draw_connection (cr, cw0, cw1, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* thru connections */
|
2016-04-17 16:21:26 -04:00
|
|
|
const ChanMapping::Mappings thru_map (_thru_map.mappings ());
|
2016-04-15 12:38:11 -04:00
|
|
|
for (ChanMapping::Mappings::const_iterator t = thru_map.begin (); t != thru_map.end (); ++t) {
|
|
|
|
for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
|
|
|
|
const CtrlWidget& cw0 = get_io_ctrl (Output, t->first, c->first);
|
|
|
|
const CtrlWidget& cw1 = get_io_ctrl (Input, t->first, c->second);
|
|
|
|
if (!(_dragging && cw1.e == _selection && cw0.e == _drag_dst)) {
|
|
|
|
draw_connection (cr, cw1, cw0, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
/* plugins & connection wires */
|
|
|
|
for (uint32_t i = 0; i < _n_plugins; ++i) {
|
2016-04-05 11:23:03 -04:00
|
|
|
double x0 = _margin_x + rint ((i + .5) * _innerwidth / (double)(_n_plugins)) - .5;
|
2016-03-27 15:35:42 -04:00
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
/* plugin box */
|
2016-04-05 11:23:03 -04:00
|
|
|
cairo_set_source_rgb (cr, .5, .5, .5);
|
|
|
|
rounded_rectangle (cr, x0 - _bxw2, yc - _bxh2, 2 * _bxw2, 2 * _bxh2, 7);
|
2016-03-27 15:35:42 -04:00
|
|
|
cairo_fill (cr);
|
|
|
|
|
2016-04-15 12:15:05 -04:00
|
|
|
layout->set_width (1.9 * _bxw2 * PANGO_SCALE);
|
2016-04-15 16:08:03 -04:00
|
|
|
layout->set_text (string_compose (_("Instance #%1"), i + 1));
|
2016-04-15 12:15:05 -04:00
|
|
|
layout->get_pixel_size (text_width, text_height);
|
|
|
|
cairo_move_to (cr, x0 - text_width * .5, yc - text_height * .5);
|
|
|
|
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
|
|
|
|
pango_cairo_show_layout (cr, layout->gobj ());
|
|
|
|
|
2016-04-17 16:21:26 -04:00
|
|
|
const ChanMapping::Mappings in_map = _in_map[i].mappings ();
|
|
|
|
const ChanMapping::Mappings out_map = _out_map[i].mappings ();
|
2016-03-27 15:35:42 -04:00
|
|
|
|
|
|
|
for (ChanMapping::Mappings::const_iterator t = in_map.begin (); t != in_map.end (); ++t) {
|
|
|
|
for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
|
2016-04-05 11:23:03 -04:00
|
|
|
const CtrlWidget& cw0 = get_io_ctrl (Input, t->first, c->second);
|
|
|
|
const CtrlWidget& cw1 = get_io_ctrl (Sink, t->first, c->first, i);
|
2016-04-14 12:30:34 -04:00
|
|
|
if (!(_dragging && cw0.e == _selection && cw1.e == _drag_dst)) {
|
|
|
|
draw_connection (cr, cw0, cw1);
|
|
|
|
}
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ChanMapping::Mappings::const_iterator t = out_map.begin (); t != out_map.end (); ++t) {
|
|
|
|
for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
|
2016-04-05 11:23:03 -04:00
|
|
|
const CtrlWidget& cw0 = get_io_ctrl (Source, t->first, c->first, i);
|
|
|
|
const CtrlWidget& cw1 = get_io_ctrl (Output, t->first, c->second);
|
2016-04-14 12:30:34 -04:00
|
|
|
if (!(_dragging && cw0.e == _selection && cw1.e == _drag_dst)) {
|
|
|
|
draw_connection (cr, cw0, cw1);
|
|
|
|
}
|
2016-03-27 15:35:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
/* pins and ports */
|
2016-04-02 08:45:24 -04:00
|
|
|
for (CtrlElemList::const_iterator i = _elements.begin (); i != _elements.end (); ++i) {
|
2016-04-01 16:57:33 -04:00
|
|
|
switch (i->e->ct) {
|
|
|
|
case Input:
|
|
|
|
case Output:
|
|
|
|
draw_io_pin (cr, *i);
|
|
|
|
break;
|
|
|
|
case Sink:
|
|
|
|
case Source:
|
|
|
|
draw_plugin_pin (cr, *i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:30:34 -04:00
|
|
|
/* DnD wire */
|
2016-04-06 17:24:11 -04:00
|
|
|
CtrlWidget *drag_src = NULL;
|
|
|
|
if (_dragging) {
|
|
|
|
for (CtrlElemList::iterator i = _elements.begin (); i != _elements.end (); ++i) {
|
|
|
|
if (i->e == _selection ) {
|
|
|
|
drag_src = &(*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-14 12:30:34 -04:00
|
|
|
|
2016-04-06 17:24:11 -04:00
|
|
|
if (drag_src) {
|
|
|
|
double x0, y0;
|
|
|
|
if (_selection->ct == Input || _selection->ct == Source) {
|
|
|
|
edge_coordinates (*drag_src, x0, y0);
|
|
|
|
draw_connection (cr, x0, _drag_x, y0, _drag_y,
|
|
|
|
_selection->dt == DataType::MIDI, _selection->sc);
|
|
|
|
} else {
|
|
|
|
edge_coordinates (*drag_src, x0, y0);
|
|
|
|
draw_connection (cr, _drag_x, x0, _drag_y, y0,
|
|
|
|
_selection->dt == DataType::MIDI, _selection->sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-27 15:35:42 -04:00
|
|
|
cairo_destroy (cr);
|
|
|
|
return true;
|
|
|
|
}
|
2016-03-31 19:33:22 -04:00
|
|
|
|
2016-04-02 08:44:05 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::darea_size_request (Gtk::Requisition* req)
|
2016-04-02 08:44:05 -04:00
|
|
|
{
|
|
|
|
req->width = _min_width;
|
2016-04-05 11:23:03 -04:00
|
|
|
req->height = _min_height;
|
2016-04-02 08:44:05 -04:00
|
|
|
}
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::darea_size_allocate (Gtk::Allocation&)
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
|
|
|
_position_valid = false;
|
|
|
|
}
|
|
|
|
|
2016-04-06 17:24:11 -04:00
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::drag_type_matches (const CtrlElem& e)
|
2016-04-14 12:30:34 -04:00
|
|
|
{
|
2016-04-06 17:24:11 -04:00
|
|
|
if (!_dragging || !_selection) {
|
|
|
|
return true;
|
|
|
|
}
|
2016-04-07 13:40:54 -04:00
|
|
|
if (_selection->dt != e->dt) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (_selection->ct == Input && e->ct == Sink) { return true; }
|
|
|
|
if (_selection->ct == Sink && e->ct == Input) { return true; }
|
|
|
|
if (_selection->ct == Output && e->ct == Source) { return true; }
|
|
|
|
if (_selection->ct == Source && e->ct == Output) { return true; }
|
|
|
|
if (_selection->ct == Input && e->ct == Output) { return true; }
|
|
|
|
if (_selection->ct == Output && e->ct == Input) { return true; }
|
2016-04-06 17:24:11 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:30:34 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::start_drag (const CtrlElem& e, double x, double y)
|
2016-04-14 12:30:34 -04:00
|
|
|
{
|
|
|
|
assert (_selection == e);
|
|
|
|
_drag_dst.reset ();
|
|
|
|
if (e->ct == Sink) {
|
|
|
|
bool valid;
|
2016-04-17 16:21:26 -04:00
|
|
|
const ChanMapping& map (_in_map[e->ip]);
|
2016-04-14 12:30:34 -04:00
|
|
|
uint32_t idx = map.get (e->dt, e->id, &valid);
|
|
|
|
if (valid) {
|
|
|
|
const CtrlWidget& cw = get_io_ctrl (Input, e->dt, idx, 0);
|
|
|
|
_drag_dst = e;
|
|
|
|
_selection = cw.e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (e->ct == Output) {
|
|
|
|
for (uint32_t i = 0; i < _n_plugins; ++i) {
|
|
|
|
bool valid;
|
2016-04-17 16:21:26 -04:00
|
|
|
const ChanMapping& map (_out_map[i]);
|
2016-04-14 12:30:34 -04:00
|
|
|
uint32_t idx = map.get_src (e->dt, e->id, &valid);
|
|
|
|
if (valid) {
|
|
|
|
const CtrlWidget& cw = get_io_ctrl (Source, e->dt, idx, i);
|
|
|
|
_drag_dst = e;
|
|
|
|
_selection = cw.e;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!_drag_dst) {
|
|
|
|
bool valid;
|
2016-04-17 16:21:26 -04:00
|
|
|
const ChanMapping& map (_thru_map);
|
2016-04-14 12:30:34 -04:00
|
|
|
uint32_t idx = map.get (e->dt, e->id, &valid);
|
|
|
|
if (valid) {
|
|
|
|
const CtrlWidget& cw = get_io_ctrl (Input, e->dt, idx, 0);
|
|
|
|
_drag_dst = e;
|
|
|
|
_selection = cw.e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_dragging = true;
|
|
|
|
_drag_x = x;
|
|
|
|
_drag_y = y;
|
|
|
|
}
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::darea_motion_notify_event (GdkEventMotion* ev)
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
_hover.reset ();
|
2016-04-02 08:45:24 -04:00
|
|
|
for (CtrlElemList::iterator i = _elements.begin (); i != _elements.end (); ++i) {
|
2016-04-01 16:57:33 -04:00
|
|
|
if (ev->x >= i->x && ev->x <= i->x + i->w
|
2016-04-07 13:40:54 -04:00
|
|
|
&& ev->y >= i->y && ev->y <= i->y + i->h
|
|
|
|
&& drag_type_matches (i->e))
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
|
|
|
if (!i->prelight) changed = true;
|
|
|
|
i->prelight = true;
|
|
|
|
_hover = i->e;
|
|
|
|
} else {
|
|
|
|
if (i->prelight) changed = true;
|
|
|
|
i->prelight = false;
|
|
|
|
}
|
|
|
|
}
|
2016-04-06 17:24:11 -04:00
|
|
|
if (_dragging) {
|
|
|
|
_drag_x = ev->x;
|
|
|
|
_drag_y = ev->y;
|
|
|
|
}
|
|
|
|
if (changed || _dragging) {
|
2016-04-01 16:57:33 -04:00
|
|
|
darea.queue_draw ();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::darea_button_press_event (GdkEventButton* ev)
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
|
|
|
if (ev->type != GDK_BUTTON_PRESS) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ev->button) {
|
|
|
|
case 1:
|
2016-04-14 12:30:34 -04:00
|
|
|
_drag_dst.reset ();
|
2016-04-01 16:57:33 -04:00
|
|
|
if (!_selection || (_selection && !_hover)) {
|
|
|
|
_selection = _hover;
|
|
|
|
_actor.reset ();
|
2016-04-06 17:24:11 -04:00
|
|
|
if (_selection) {
|
2016-04-14 12:30:34 -04:00
|
|
|
start_drag (_selection, ev->x, ev->y);
|
2016-04-15 16:08:03 -04:00
|
|
|
} else {
|
|
|
|
darea.queue_draw ();
|
2016-04-06 17:24:11 -04:00
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
} else if (_selection && _hover && _selection != _hover) {
|
|
|
|
if (_selection->dt != _hover->dt) { _actor.reset (); }
|
2016-04-07 12:36:04 -04:00
|
|
|
else if (_selection->ct == Input && _hover->ct == Sink) { _actor = _hover; }
|
|
|
|
else if (_selection->ct == Sink && _hover->ct == Input) { _actor = _hover; }
|
2016-04-01 16:57:33 -04:00
|
|
|
else if (_selection->ct == Output && _hover->ct == Source) { _actor = _hover; }
|
|
|
|
else if (_selection->ct == Source && _hover->ct == Output) { _actor = _hover; }
|
2016-04-07 12:36:04 -04:00
|
|
|
else if (_selection->ct == Input && _hover->ct == Output) { _actor = _hover; }
|
|
|
|
else if (_selection->ct == Output && _hover->ct == Input) { _actor = _hover; }
|
2016-04-01 16:57:33 -04:00
|
|
|
if (!_actor) {
|
2016-04-14 12:30:34 -04:00
|
|
|
_selection = _hover;
|
|
|
|
start_drag (_selection, ev->x, ev->y);
|
2016-04-15 16:08:03 -04:00
|
|
|
} else {
|
|
|
|
darea.queue_draw ();
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-04-06 18:48:57 -04:00
|
|
|
} else if (_hover) {
|
|
|
|
_selection = _hover;
|
|
|
|
_actor.reset ();
|
2016-04-14 12:30:34 -04:00
|
|
|
start_drag (_selection, ev->x, ev->y);
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-04-05 11:23:03 -04:00
|
|
|
break;
|
2016-04-01 16:57:33 -04:00
|
|
|
case 3:
|
2016-04-14 12:30:34 -04:00
|
|
|
_drag_dst.reset ();
|
2016-04-05 11:23:03 -04:00
|
|
|
if (_selection != _hover) {
|
|
|
|
_selection = _hover;
|
|
|
|
darea.queue_draw ();
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-04-05 11:23:03 -04:00
|
|
|
_actor.reset ();
|
2016-04-01 16:57:33 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::darea_button_release_event (GdkEventButton* ev)
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
2016-04-14 12:30:34 -04:00
|
|
|
if (_dragging && _selection && _drag_dst && _drag_dst == _hover) {
|
|
|
|
// select click. (or re-connect same)
|
|
|
|
assert (_selection != _hover);
|
|
|
|
_actor.reset ();
|
|
|
|
_dragging = false;
|
|
|
|
_drag_dst.reset ();
|
|
|
|
_selection =_hover;
|
|
|
|
darea.queue_draw ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-06 17:24:11 -04:00
|
|
|
if (_dragging && _hover && _hover != _selection) {
|
|
|
|
_actor = _hover;
|
|
|
|
}
|
2016-04-14 12:30:34 -04:00
|
|
|
|
2016-04-05 11:23:03 -04:00
|
|
|
if (_hover == _actor && _actor && ev->button == 1) {
|
2016-04-01 16:57:33 -04:00
|
|
|
assert (_selection);
|
|
|
|
assert (_selection->dt == _actor->dt);
|
2016-04-14 12:30:34 -04:00
|
|
|
if (_drag_dst) {
|
|
|
|
assert (_dragging && _selection != _drag_dst);
|
|
|
|
handle_disconnect (_drag_dst, true);
|
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
if (_selection->ct == Input && _actor->ct == Sink) {
|
|
|
|
handle_input_action (_actor, _selection);
|
|
|
|
}
|
|
|
|
else if (_selection->ct == Sink && _actor->ct == Input) {
|
|
|
|
handle_input_action (_selection, _actor);
|
|
|
|
}
|
|
|
|
else if (_selection->ct == Output && _actor->ct == Source) {
|
|
|
|
handle_output_action (_actor, _selection);
|
|
|
|
}
|
|
|
|
else if (_selection->ct == Source && _actor->ct == Output) {
|
|
|
|
handle_output_action (_selection, _actor);
|
|
|
|
}
|
2016-04-07 12:36:04 -04:00
|
|
|
else if (_selection->ct == Input && _actor->ct == Output) {
|
|
|
|
handle_thru_action (_actor, _selection);
|
|
|
|
}
|
|
|
|
else if (_selection->ct == Output && _actor->ct == Input) {
|
|
|
|
handle_thru_action (_selection, _actor);
|
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
_selection.reset ();
|
2016-04-05 11:23:03 -04:00
|
|
|
} else if (_hover == _selection && _selection && ev->button == 3) {
|
|
|
|
handle_disconnect (_selection);
|
2016-04-06 16:06:30 -04:00
|
|
|
} else if (!_hover && ev->button == 3) {
|
2016-04-06 11:48:22 -04:00
|
|
|
reset_menu.popup (1, ev->time);
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
2016-04-14 12:30:34 -04:00
|
|
|
|
|
|
|
if (_dragging && _hover != _selection) {
|
|
|
|
_selection.reset ();
|
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
_actor.reset ();
|
2016-04-06 17:24:11 -04:00
|
|
|
_dragging = false;
|
2016-04-14 12:30:34 -04:00
|
|
|
_drag_dst.reset ();
|
2016-04-01 16:57:33 -04:00
|
|
|
darea.queue_draw ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::handle_input_action (const CtrlElem &s, const CtrlElem &i)
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
|
|
|
const int pc = s->ip;
|
|
|
|
bool valid;
|
|
|
|
ChanMapping in_map (_pi->input_map (pc));
|
|
|
|
uint32_t idx = in_map.get (s->dt, s->id, &valid);
|
|
|
|
|
|
|
|
if (valid && idx == i->id) {
|
|
|
|
// disconnect
|
2016-04-14 12:30:34 -04:00
|
|
|
if (!_dragging) {
|
|
|
|
in_map.unset (s->dt, s->id);
|
|
|
|
_pi->set_input_map (pc, in_map);
|
|
|
|
} else {
|
|
|
|
plugin_reconfigured ();
|
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
|
|
|
else if (!valid) {
|
|
|
|
// connect
|
|
|
|
in_map.set (s->dt, s->id, i->id);
|
|
|
|
_pi->set_input_map (pc, in_map);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// reconnect
|
|
|
|
in_map.unset (s->dt, s->id);
|
|
|
|
in_map.set (s->dt, s->id, i->id);
|
|
|
|
_pi->set_input_map (pc, in_map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-07 12:36:04 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::disconnect_other_outputs (uint32_t skip_pc, DataType dt, uint32_t id)
|
2016-04-07 12:36:04 -04:00
|
|
|
{
|
|
|
|
_ignore_updates = true;
|
|
|
|
for (uint32_t n = 0; n < _n_plugins; ++n) {
|
|
|
|
if (n == skip_pc) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
bool valid;
|
|
|
|
ChanMapping n_out_map (_pi->output_map (n));
|
|
|
|
uint32_t idx = n_out_map.get_src (dt, id, &valid);
|
|
|
|
if (valid) {
|
|
|
|
n_out_map.unset (dt, idx);
|
|
|
|
_pi->set_output_map (n, n_out_map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ignore_updates = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::disconnect_other_thru (DataType dt, uint32_t id)
|
2016-04-07 12:36:04 -04:00
|
|
|
{
|
|
|
|
_ignore_updates = true;
|
|
|
|
bool valid;
|
|
|
|
ChanMapping n_thru_map (_pi->thru_map ());
|
|
|
|
n_thru_map.get (dt, id, &valid);
|
|
|
|
if (valid) {
|
|
|
|
n_thru_map.unset (dt, id);
|
|
|
|
_pi->set_thru_map (n_thru_map);
|
|
|
|
}
|
|
|
|
_ignore_updates = false;
|
|
|
|
}
|
|
|
|
|
2016-04-01 16:57:33 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::handle_output_action (const CtrlElem &s, const CtrlElem &o)
|
2016-04-01 16:57:33 -04:00
|
|
|
{
|
2016-04-02 08:44:05 -04:00
|
|
|
const uint32_t pc = s->ip;
|
2016-04-01 16:57:33 -04:00
|
|
|
bool valid;
|
|
|
|
ChanMapping out_map (_pi->output_map (pc));
|
|
|
|
uint32_t idx = out_map.get (s->dt, s->id, &valid);
|
|
|
|
|
|
|
|
if (valid && idx == o->id) {
|
|
|
|
// disconnect
|
2016-04-14 12:30:34 -04:00
|
|
|
if (!_dragging) {
|
|
|
|
out_map.unset (s->dt, s->id);
|
|
|
|
_pi->set_output_map (pc, out_map);
|
|
|
|
} else {
|
|
|
|
plugin_reconfigured ();
|
|
|
|
}
|
2016-04-01 16:57:33 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// disconnect source
|
2016-04-14 12:30:34 -04:00
|
|
|
disconnect_other_outputs (pc, s->dt, o->id);
|
|
|
|
disconnect_other_thru (s->dt, o->id);
|
|
|
|
out_map = _pi->output_map (pc); // re-read map
|
2016-04-01 16:57:33 -04:00
|
|
|
if (valid) {
|
|
|
|
out_map.unset (s->dt, s->id);
|
|
|
|
}
|
2016-04-01 20:02:47 -04:00
|
|
|
idx = out_map.get_src (s->dt, o->id, &valid);
|
2016-04-01 16:57:33 -04:00
|
|
|
if (valid) {
|
|
|
|
out_map.unset (s->dt, idx);
|
|
|
|
}
|
|
|
|
// connect
|
|
|
|
out_map.set (s->dt, s->id, o->id);
|
|
|
|
_pi->set_output_map (pc, out_map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-07 12:36:04 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::handle_thru_action (const CtrlElem &o, const CtrlElem &i)
|
2016-04-07 12:36:04 -04:00
|
|
|
{
|
|
|
|
bool valid;
|
|
|
|
ChanMapping thru_map (_pi->thru_map ());
|
|
|
|
uint32_t idx = thru_map.get (o->dt, o->id, &valid);
|
|
|
|
|
|
|
|
if (valid && idx == i->id) {
|
2016-04-14 12:30:34 -04:00
|
|
|
if (!_dragging) {
|
|
|
|
thru_map.unset (o->dt, o->id);
|
|
|
|
}
|
2016-04-07 12:36:04 -04:00
|
|
|
} else {
|
|
|
|
// disconnect other outputs first
|
|
|
|
disconnect_other_outputs (UINT32_MAX, o->dt, o->id);
|
|
|
|
disconnect_other_thru (o->dt, o->id);
|
2016-04-14 12:30:34 -04:00
|
|
|
thru_map = _pi->thru_map (); // re-read map
|
2016-04-07 12:36:04 -04:00
|
|
|
|
|
|
|
thru_map.set (o->dt, o->id, i->id);
|
|
|
|
}
|
|
|
|
_pi->set_thru_map (thru_map);
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:30:34 -04:00
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::handle_disconnect (const CtrlElem &e, bool no_signal)
|
2016-04-05 11:23:03 -04:00
|
|
|
{
|
|
|
|
_ignore_updates = true;
|
|
|
|
bool changed = false;
|
|
|
|
bool valid;
|
|
|
|
|
|
|
|
switch (e->ct) {
|
|
|
|
case Input:
|
2016-04-07 12:36:04 -04:00
|
|
|
{
|
|
|
|
ChanMapping n_thru_map (_pi->thru_map ());
|
|
|
|
for (uint32_t i = 0; i < _sources.n_total (); ++i) {
|
|
|
|
uint32_t idx = n_thru_map.get (e->dt, i, &valid);
|
|
|
|
if (valid && idx == e->id) {
|
|
|
|
n_thru_map.unset (e->dt, i);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (changed) {
|
|
|
|
_pi->set_thru_map (n_thru_map);
|
|
|
|
}
|
|
|
|
}
|
2016-04-05 11:23:03 -04:00
|
|
|
for (uint32_t n = 0; n < _n_plugins; ++n) {
|
|
|
|
ChanMapping map (_pi->input_map (n));
|
|
|
|
for (uint32_t i = 0; i < _sinks.n_total (); ++i) {
|
|
|
|
uint32_t idx = map.get (e->dt, i, &valid);
|
|
|
|
if (valid && idx == e->id) {
|
|
|
|
map.unset (e->dt, i);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_pi->set_input_map (n, map);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Sink:
|
|
|
|
{
|
|
|
|
ChanMapping map (_pi->input_map (e->ip));
|
|
|
|
map.get (e->dt, e->id, &valid);
|
|
|
|
if (valid) {
|
|
|
|
map.unset (e->dt, e->id);
|
|
|
|
_pi->set_input_map (e->ip, map);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Source:
|
|
|
|
{
|
|
|
|
ChanMapping map (_pi->output_map (e->ip));
|
|
|
|
map.get (e->dt, e->id, &valid);
|
|
|
|
if (valid) {
|
|
|
|
map.unset (e->dt, e->id);
|
|
|
|
_pi->set_output_map (e->ip, map);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Output:
|
|
|
|
for (uint32_t n = 0; n < _n_plugins; ++n) {
|
|
|
|
ChanMapping map (_pi->output_map (n));
|
|
|
|
for (uint32_t i = 0; i < _sources.n_total (); ++i) {
|
|
|
|
uint32_t idx = map.get (e->dt, i, &valid);
|
|
|
|
if (valid && idx == e->id) {
|
|
|
|
map.unset (e->dt, i);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
2016-04-07 12:36:04 -04:00
|
|
|
if (changed) {
|
|
|
|
_pi->set_output_map (n, map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ChanMapping n_thru_map (_pi->thru_map ());
|
|
|
|
n_thru_map.get (e->dt, e->id, &valid);
|
|
|
|
if (valid) {
|
|
|
|
n_thru_map.unset (e->dt, e->id);
|
|
|
|
changed = true;
|
|
|
|
_pi->set_thru_map (n_thru_map);
|
|
|
|
}
|
2016-04-05 11:23:03 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_ignore_updates = false;
|
2016-04-14 12:30:34 -04:00
|
|
|
if (changed && !no_signal) {
|
2016-04-05 11:23:03 -04:00
|
|
|
plugin_reconfigured ();
|
|
|
|
}
|
2016-04-14 12:30:34 -04:00
|
|
|
return changed;
|
2016-04-05 11:23:03 -04:00
|
|
|
}
|
|
|
|
|
2016-04-02 23:21:40 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::toggle_sidechain ()
|
2016-04-02 23:21:40 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
if (!_route ()->add_remove_sidechain (_pi, !_pi->has_sidechain ())) {
|
|
|
|
error_message_dialog (_("Failed to toggle sidechain."));
|
|
|
|
}
|
2016-04-02 23:21:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::connect_sidechain ()
|
2016-04-02 23:21:40 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
assert (_session);
|
2016-04-04 19:38:31 -04:00
|
|
|
|
|
|
|
if (_sidechain_selector == 0) {
|
|
|
|
_sidechain_selector = new IOSelectorWindow (_session, _pi->sidechain_input ());
|
|
|
|
}
|
|
|
|
|
2022-01-26 15:21:06 -05:00
|
|
|
if (_sidechain_selector->get_visible ()) {
|
2016-04-05 15:53:05 -04:00
|
|
|
_sidechain_selector->get_toplevel ()->get_window ()->raise ();
|
2016-04-04 19:38:31 -04:00
|
|
|
} else {
|
|
|
|
_sidechain_selector->present ();
|
|
|
|
}
|
2016-04-02 23:21:40 -04:00
|
|
|
}
|
|
|
|
|
2016-03-31 19:33:22 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::reset_configuration ()
|
2016-03-31 19:33:22 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
bool rv;
|
2016-04-06 07:39:34 -04:00
|
|
|
if (_set_config.get_active ()) {
|
2018-10-29 16:50:08 -04:00
|
|
|
rv = _route ()->reset_plugin_insert (_pi);
|
2016-04-06 07:39:34 -04:00
|
|
|
} else {
|
2018-10-29 16:50:08 -04:00
|
|
|
rv = _route ()->customize_plugin_insert (_pi, _n_plugins, _out, _sinks);
|
|
|
|
}
|
|
|
|
if (!rv) {
|
|
|
|
error_message_dialog (_("Failed to reset plugin configuration."));
|
2016-04-06 07:39:34 -04:00
|
|
|
}
|
2016-03-31 19:33:22 -04:00
|
|
|
}
|
|
|
|
|
2016-04-02 08:44:05 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::reset_mapping ()
|
2016-04-02 08:44:05 -04:00
|
|
|
{
|
|
|
|
_pi->reset_map ();
|
|
|
|
}
|
|
|
|
|
2016-04-15 12:15:05 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::select_output_preset (uint32_t n_audio)
|
2016-04-15 12:15:05 -04:00
|
|
|
{
|
|
|
|
ChanCount out (DataType::AUDIO, n_audio);
|
2018-10-29 16:50:08 -04:00
|
|
|
if (!_route ()->plugin_preset_output (_pi, out)) {
|
|
|
|
error_message_dialog (_("Failed to change channel preset."));
|
|
|
|
}
|
2016-04-15 12:15:05 -04:00
|
|
|
}
|
|
|
|
|
2016-03-31 19:33:22 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::add_remove_plugin_clicked (bool add)
|
2016-03-31 19:33:22 -04:00
|
|
|
{
|
2016-04-01 16:57:33 -04:00
|
|
|
ChanCount out = _out;
|
2016-04-27 17:32:40 -04:00
|
|
|
ChanCount sinks = _sinks;
|
2016-04-01 16:57:33 -04:00
|
|
|
assert (add || _n_plugins > 0);
|
2018-10-29 16:50:08 -04:00
|
|
|
if (!_route ()->customize_plugin_insert (_pi, _n_plugins + (add ? 1 : -1), out, sinks)) {
|
|
|
|
error_message_dialog (_("Failed to change instance count"));
|
|
|
|
}
|
2016-03-31 19:33:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::add_remove_port_clicked (bool add, ARDOUR::DataType dt)
|
2016-03-31 19:33:22 -04:00
|
|
|
{
|
2016-04-01 16:57:33 -04:00
|
|
|
ChanCount out = _out;
|
2016-04-27 17:32:40 -04:00
|
|
|
ChanCount sinks = _sinks;
|
2016-03-31 19:33:22 -04:00
|
|
|
assert (add || out.get (dt) > 0);
|
2021-07-01 14:15:04 -04:00
|
|
|
uint32_t n_before = std::min (out.get (dt), _sources.get (dt) * _n_plugins);
|
2016-03-31 19:33:22 -04:00
|
|
|
out.set (dt, out.get (dt) + (add ? 1 : -1));
|
2018-10-29 16:50:08 -04:00
|
|
|
if (!_route ()->customize_plugin_insert (_pi, _n_plugins, out, sinks)) {
|
|
|
|
error_message_dialog (_("Failed to alter plugin output configuration."));
|
2021-07-01 14:15:04 -04:00
|
|
|
} else if (add && dt == DataType::AUDIO) {
|
|
|
|
ChanCount ins, outs, src;
|
|
|
|
_pi->configured_io (ins, outs);
|
|
|
|
src = _pi->natural_output_streams ();
|
|
|
|
for (uint32_t i = n_before; i < outs.get (dt); ++i) {
|
|
|
|
uint32_t pc = i / src.get (dt);
|
|
|
|
uint32_t pn = i % src.get (dt);
|
|
|
|
assert (pc <= _n_plugins);
|
|
|
|
ChanMapping map (_pi->output_map (pc));
|
|
|
|
map.set (dt, pn, pn);
|
|
|
|
_pi->set_output_map (pc, map);
|
|
|
|
}
|
2018-10-29 16:50:08 -04:00
|
|
|
}
|
2016-04-27 17:32:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::add_remove_inpin_clicked (bool add, ARDOUR::DataType dt)
|
2016-04-27 17:32:40 -04:00
|
|
|
{
|
|
|
|
ChanCount out = _out;
|
|
|
|
ChanCount sinks = _sinks;
|
|
|
|
assert (add || sinks.get (dt) > 0);
|
|
|
|
sinks.set (dt, sinks.get (dt) + (add ? 1 : -1));
|
2018-10-29 16:50:08 -04:00
|
|
|
if (!_route ()->customize_plugin_insert (_pi, _n_plugins, out, sinks)) {
|
|
|
|
error_message_dialog (_("Failed to alter plugin input configuration."));
|
|
|
|
}
|
2016-03-31 19:33:22 -04:00
|
|
|
}
|
2016-04-05 15:53:05 -04:00
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::add_sidechain_port (DataType dt)
|
2016-04-05 15:53:05 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
assert (_session);
|
|
|
|
if (_session->actively_recording ()) {
|
|
|
|
error_message_dialog (/* unused */ "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-05 15:53:05 -04:00
|
|
|
boost::shared_ptr<IO> io = _pi->sidechain_input ();
|
|
|
|
if (!io) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-16 19:39:59 -04:00
|
|
|
|
|
|
|
// this triggers a PluginIoReConfigure with process and processor write lock held
|
|
|
|
// from /this/ thread.
|
2016-04-05 15:53:05 -04:00
|
|
|
io->add_port ("", this, dt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::remove_port (boost::weak_ptr<ARDOUR::Port> wp)
|
2016-04-05 15:53:05 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
assert (_session);
|
|
|
|
if (_session->actively_recording ()) {
|
|
|
|
error_message_dialog (/* unused */ "");
|
|
|
|
return;
|
|
|
|
}
|
2016-04-05 15:53:05 -04:00
|
|
|
boost::shared_ptr<ARDOUR::Port> p = wp.lock ();
|
|
|
|
boost::shared_ptr<IO> io = _pi->sidechain_input ();
|
|
|
|
if (!io || !p) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
io->remove_port (p, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::disconnect_port (boost::weak_ptr<ARDOUR::Port> wp)
|
2016-04-05 15:53:05 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
assert (_session);
|
|
|
|
if (_session->actively_recording ()) {
|
|
|
|
error_message_dialog (/* unused */ "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-05 15:53:05 -04:00
|
|
|
boost::shared_ptr<ARDOUR::Port> p = wp.lock ();
|
|
|
|
boost::shared_ptr<IO> io = _pi->sidechain_input ();
|
|
|
|
if (!io || !p) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-05 20:31:36 -04:00
|
|
|
p->disconnect_all ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::connect_port (boost::weak_ptr<ARDOUR::Port> wp0, boost::weak_ptr<ARDOUR::Port> wp1)
|
2016-04-05 20:31:36 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
assert (_session);
|
|
|
|
if (_session->actively_recording ()) {
|
|
|
|
error_message_dialog (/* unused */ "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-05 20:31:36 -04:00
|
|
|
boost::shared_ptr<ARDOUR::Port> p0 = wp0.lock ();
|
|
|
|
boost::shared_ptr<ARDOUR::Port> p1 = wp1.lock ();
|
|
|
|
boost::shared_ptr<IO> io = _pi->sidechain_input ();
|
|
|
|
if (!io || !p0 || !p1) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-06 15:25:45 -04:00
|
|
|
_ignore_updates = true;
|
|
|
|
p0->disconnect_all ();
|
|
|
|
_ignore_updates = false;
|
2016-04-05 20:31:36 -04:00
|
|
|
p0->connect (p1->name ());
|
2016-04-05 15:53:05 -04:00
|
|
|
}
|
|
|
|
|
2016-04-17 08:10:13 -04:00
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::add_send_from (boost::weak_ptr<ARDOUR::Port> wp, boost::weak_ptr<ARDOUR::Route> wr)
|
2016-04-17 08:10:13 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
assert (_session);
|
|
|
|
if (_session->actively_recording ()) {
|
|
|
|
error_message_dialog (/* unused */ "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-17 08:10:13 -04:00
|
|
|
boost::shared_ptr<Port> p = wp.lock ();
|
|
|
|
boost::shared_ptr<Route> r = wr.lock ();
|
|
|
|
boost::shared_ptr<IO> io = _pi->sidechain_input ();
|
2018-10-29 16:50:08 -04:00
|
|
|
if (!p || !r || !io) {
|
2016-04-17 08:10:13 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-17 18:52:24 -04:00
|
|
|
boost::shared_ptr<Send> send (new Send (*_session, r->pannable (), r->mute_master ()));
|
2016-04-17 08:10:13 -04:00
|
|
|
const ChanCount& outs (r->amp ()->input_streams ());
|
|
|
|
try {
|
|
|
|
Glib::Threads::Mutex::Lock lm (AudioEngine::instance ()->process_lock ());
|
|
|
|
send->output()->ensure_io (outs, false, this);
|
|
|
|
} catch (AudioEngine::PortRegistrationFailure& err) {
|
|
|
|
error << string_compose (_("Cannot set up new send: %1"), err.what ()) << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-17 15:37:43 -04:00
|
|
|
std::string sendname = send->name ();
|
|
|
|
string::size_type last_letter = sendname.find_last_not_of ("0123456789");
|
|
|
|
if (last_letter != string::npos) {
|
|
|
|
send->output ()->set_pretty_name (string_compose (_("SC %1 (%2)"),
|
|
|
|
r->name (),
|
|
|
|
sendname.substr (last_letter + 1)));
|
|
|
|
}
|
2016-04-17 08:10:13 -04:00
|
|
|
|
2016-04-17 15:37:43 -04:00
|
|
|
_ignore_updates = true;
|
2016-04-17 08:10:13 -04:00
|
|
|
p->disconnect_all ();
|
|
|
|
|
|
|
|
DataType dt = p->type ();
|
|
|
|
PortSet& ps (send->output ()->ports ());
|
|
|
|
for (PortSet::iterator i = ps.begin (dt); i != ps.end (dt); ++i) {
|
|
|
|
p->connect (&(**i));
|
|
|
|
}
|
|
|
|
|
|
|
|
send->set_remove_on_disconnect (true);
|
|
|
|
r->add_processor (send, PreFader);
|
|
|
|
_ignore_updates = false;
|
|
|
|
queue_idle_update ();
|
|
|
|
}
|
|
|
|
|
2016-04-05 20:31:36 -04:00
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::sc_input_release (GdkEventButton *ev)
|
2016-04-05 20:31:36 -04:00
|
|
|
{
|
2018-10-29 16:50:08 -04:00
|
|
|
assert (_session);
|
|
|
|
if (_session->actively_recording ()) {
|
|
|
|
error_message_dialog (/* unused */ "");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-05 20:31:36 -04:00
|
|
|
if (ev->button == 3) {
|
|
|
|
connect_sidechain ();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-05 15:53:05 -04:00
|
|
|
bool
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::sc_input_press (GdkEventButton *ev, boost::weak_ptr<ARDOUR::Port> wp)
|
2016-04-05 15:53:05 -04:00
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
2018-10-29 16:50:08 -04:00
|
|
|
assert (_session);
|
2018-11-28 09:17:57 -05:00
|
|
|
if (!ARDOUR_UI_UTILS::engine_is_running ()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (_session->actively_recording ()) {
|
|
|
|
error_message_dialog (/* unused */ "");
|
2018-10-29 16:50:08 -04:00
|
|
|
return false;
|
|
|
|
}
|
2016-04-05 15:53:05 -04:00
|
|
|
|
|
|
|
if (ev->button == 1) {
|
2016-04-16 18:09:11 -04:00
|
|
|
MenuList& citems = input_menu.items ();
|
2016-04-05 15:53:05 -04:00
|
|
|
input_menu.set_name ("ArdourContextMenu");
|
2016-04-16 18:09:11 -04:00
|
|
|
citems.clear ();
|
2016-04-05 20:31:36 -04:00
|
|
|
|
2016-04-05 15:53:05 -04:00
|
|
|
boost::shared_ptr<Port> p = wp.lock ();
|
|
|
|
if (p && p->connected ()) {
|
2016-05-09 06:45:36 -04:00
|
|
|
citems.push_back (MenuElem (_("Disconnect"), sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::disconnect_port), wp)));
|
2016-04-16 18:09:11 -04:00
|
|
|
citems.push_back (SeparatorElem ());
|
2016-04-05 15:53:05 -04:00
|
|
|
}
|
2016-04-05 20:31:36 -04:00
|
|
|
|
2016-04-06 07:39:34 -04:00
|
|
|
#if 0
|
2016-04-05 20:31:36 -04:00
|
|
|
// TODO add system inputs, too ?!
|
2016-04-06 07:39:34 -04:00
|
|
|
boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
|
|
|
|
for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
|
|
|
|
for (uint32_t j = 0; j < i->nchannels ().n_total (); ++j) {
|
|
|
|
}
|
|
|
|
//maybe_add_bundle_to_input_menu (*i, current);
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-05 20:31:36 -04:00
|
|
|
|
|
|
|
uint32_t added = 0;
|
2020-12-29 10:01:00 -05:00
|
|
|
|
|
|
|
if (p) {
|
|
|
|
RouteList copy = _session->get_routelist ();
|
|
|
|
copy.sort (Stripable::Sorter (true));
|
|
|
|
for (ARDOUR::RouteList::const_iterator i = copy.begin (); i != copy.end (); ++i) {
|
|
|
|
added += maybe_add_route_to_input_menu (*i, p->type (), wp);
|
|
|
|
}
|
2016-04-05 20:31:36 -04:00
|
|
|
}
|
2020-12-29 10:01:00 -05:00
|
|
|
#if 0
|
|
|
|
else {
|
|
|
|
queue_idle_update ():
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-05 20:31:36 -04:00
|
|
|
|
|
|
|
if (added > 0) {
|
2016-04-16 18:09:11 -04:00
|
|
|
citems.push_back (SeparatorElem ());
|
2016-04-05 20:31:36 -04:00
|
|
|
}
|
2016-05-09 06:45:36 -04:00
|
|
|
citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*this, &PluginPinWidget::connect_sidechain)));
|
2016-04-05 15:53:05 -04:00
|
|
|
input_menu.popup (1, ev->time);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-05 20:31:36 -04:00
|
|
|
uint32_t
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::maybe_add_route_to_input_menu (boost::shared_ptr<Route> r, DataType dt, boost::weak_ptr<Port> wp)
|
2016-04-05 15:53:05 -04:00
|
|
|
{
|
2016-04-05 20:31:36 -04:00
|
|
|
uint32_t added = 0;
|
|
|
|
using namespace Menu_Helpers;
|
2016-04-16 18:09:11 -04:00
|
|
|
if (r->output () == _route ()->output ()) {
|
2016-04-05 20:31:36 -04:00
|
|
|
return added;
|
2016-04-05 15:53:05 -04:00
|
|
|
}
|
2016-04-05 20:31:36 -04:00
|
|
|
|
2022-04-28 18:17:35 -04:00
|
|
|
if (_route ()->feeds (r)) {
|
|
|
|
/* do not allow connfeedback */
|
2016-04-05 20:31:36 -04:00
|
|
|
return added;
|
|
|
|
}
|
|
|
|
|
2016-04-16 18:09:11 -04:00
|
|
|
MenuList& citems = input_menu.items ();
|
2016-04-05 20:31:36 -04:00
|
|
|
|
2016-04-17 08:10:13 -04:00
|
|
|
/*check if there's already a send.. */
|
|
|
|
bool already_present = false;
|
|
|
|
uint32_t nth = 0;
|
|
|
|
boost::shared_ptr<Processor> proc;
|
|
|
|
/* Note: nth_send () takes a processor read-lock */
|
|
|
|
while ((proc = r->nth_send (nth))) {
|
|
|
|
boost::shared_ptr<IOProcessor> send = boost::dynamic_pointer_cast<IOProcessor> (proc);
|
|
|
|
if (!send || !send->output ()) {
|
|
|
|
++nth;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (send->output ()->connected_to (_pi->sidechain_input ())) {
|
|
|
|
// only if (send->remove_on_disconnect ()) ??
|
|
|
|
already_present = true;
|
2016-04-17 19:01:49 -04:00
|
|
|
break;
|
2016-04-05 20:31:36 -04:00
|
|
|
}
|
2016-04-17 08:10:13 -04:00
|
|
|
++nth;
|
|
|
|
}
|
|
|
|
/* we're going to create the new send pre-fader, so check the route amp's data type. */
|
|
|
|
const ChanCount& rc (r->amp ()->input_streams ());
|
|
|
|
if (!already_present && rc.get (dt) > 0) {
|
2017-06-28 18:20:55 -04:00
|
|
|
citems.push_back (MenuElemNoMnemonic (r->name (), sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::add_send_from), wp, boost::weak_ptr<Route> (r))));
|
2016-04-17 08:10:13 -04:00
|
|
|
++added;
|
2016-04-05 20:31:36 -04:00
|
|
|
}
|
|
|
|
return added;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::port_connected_or_disconnected (boost::weak_ptr<ARDOUR::Port> w0, boost::weak_ptr<ARDOUR::Port> w1)
|
2016-04-05 20:31:36 -04:00
|
|
|
{
|
2016-04-06 07:32:06 -04:00
|
|
|
boost::shared_ptr<Port> p0 = w0.lock ();
|
|
|
|
boost::shared_ptr<Port> p1 = w1.lock ();
|
|
|
|
|
|
|
|
boost::shared_ptr<IO> io = _pi->sidechain_input ();
|
|
|
|
if (!io) { return; }
|
|
|
|
|
|
|
|
if (p0 && io->has_port (p0)) {
|
2016-04-16 19:39:59 -04:00
|
|
|
queue_idle_update ();
|
2016-04-06 07:32:06 -04:00
|
|
|
}
|
|
|
|
else if (p1 && io->has_port (p1)) {
|
2016-04-16 19:39:59 -04:00
|
|
|
queue_idle_update ();
|
2016-04-06 07:32:06 -04:00
|
|
|
}
|
2016-04-05 15:53:05 -04:00
|
|
|
}
|
2016-04-16 19:39:59 -04:00
|
|
|
|
2021-01-13 13:04:44 -05:00
|
|
|
void
|
|
|
|
PluginPinWidget::port_pretty_name_changed (std::string pn)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<IO> io = _pi->sidechain_input ();
|
|
|
|
if (io && io->connected_to (pn)) {
|
|
|
|
queue_idle_update ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-16 19:39:59 -04:00
|
|
|
/* lifted from ProcessorEntry::Control */
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
|
2016-04-16 19:39:59 -04:00
|
|
|
: _control (c)
|
|
|
|
, _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain ()), 0, 1, 0.01, 0.1)
|
|
|
|
, _slider (&_adjustment, boost::shared_ptr<PBD::Controllable> (), 0, max (13.f, rintf (13.f * UIConfiguration::instance ().get_ui_scale ())))
|
|
|
|
, _slider_persistant_tooltip (&_slider)
|
|
|
|
, _ignore_ui_adjustment (false)
|
|
|
|
, _name (n)
|
|
|
|
{
|
|
|
|
_slider.set_controllable (c);
|
|
|
|
box.set_padding (0, 0, 4, 4);
|
|
|
|
|
|
|
|
_slider.set_name ("ProcessorControlSlider");
|
|
|
|
_slider.set_text (_name);
|
|
|
|
|
|
|
|
box.add (_slider);
|
|
|
|
_slider.show ();
|
|
|
|
|
|
|
|
const ARDOUR::ParameterDescriptor& desc = c->desc ();
|
2017-07-06 10:39:28 -04:00
|
|
|
double const lo = c->internal_to_interface (desc.lower);
|
|
|
|
double const up = c->internal_to_interface (desc.upper);
|
|
|
|
double const normal = c->internal_to_interface (desc.normal);
|
|
|
|
double const smallstep = c->internal_to_interface (desc.lower + desc.smallstep);
|
|
|
|
double const largestep = c->internal_to_interface (desc.lower + desc.largestep);
|
2016-04-16 19:39:59 -04:00
|
|
|
|
|
|
|
_adjustment.set_lower (lo);
|
|
|
|
_adjustment.set_upper (up);
|
|
|
|
_adjustment.set_step_increment (smallstep);
|
|
|
|
_adjustment.set_page_increment (largestep);
|
|
|
|
_slider.set_default_value (normal);
|
|
|
|
|
|
|
|
_adjustment.signal_value_changed ().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
|
|
|
|
// dup. currently timers are used :(
|
|
|
|
//c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
|
|
|
|
|
|
|
|
// yuck, do we really need to do this?
|
|
|
|
// according to c404374 this is only needed for send automation
|
|
|
|
timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
|
|
|
|
|
|
|
|
control_changed ();
|
|
|
|
set_tooltip ();
|
|
|
|
|
|
|
|
/* We're providing our own PersistentTooltip */
|
|
|
|
set_no_tooltip_whatsoever (_slider);
|
|
|
|
}
|
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::Control::~Control ()
|
2016-04-16 19:39:59 -04:00
|
|
|
{
|
|
|
|
timer_connection.disconnect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::Control::set_tooltip ()
|
2016-04-16 19:39:59 -04:00
|
|
|
{
|
|
|
|
boost::shared_ptr<AutomationControl> c = _control.lock ();
|
|
|
|
if (!c) {
|
|
|
|
return;
|
|
|
|
}
|
2017-06-21 11:05:03 -04:00
|
|
|
std::string tt = _name + ": " + ARDOUR::value_as_string (c->desc(), c->get_value ());
|
|
|
|
string sm = Gtkmm2ext::markup_escape_text (tt);
|
2016-04-16 19:39:59 -04:00
|
|
|
_slider_persistant_tooltip.set_tip (sm);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::Control::slider_adjusted ()
|
2016-04-16 19:39:59 -04:00
|
|
|
{
|
|
|
|
if (_ignore_ui_adjustment) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
boost::shared_ptr<AutomationControl> c = _control.lock ();
|
|
|
|
if (!c) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
c->set_value ( c->interface_to_internal (_adjustment.get_value ()) , Controllable::NoGroup);
|
|
|
|
set_tooltip ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinWidget::Control::control_changed ()
|
2016-04-16 19:39:59 -04:00
|
|
|
{
|
|
|
|
boost::shared_ptr<AutomationControl> c = _control.lock ();
|
|
|
|
if (!c) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_ignore_ui_adjustment = true;
|
|
|
|
|
|
|
|
// as long as rapid timers are used, only update the tooltip
|
|
|
|
// if the value has changed.
|
|
|
|
const double nval = c->internal_to_interface (c->get_value ());
|
|
|
|
if (_adjustment.get_value () != nval) {
|
|
|
|
_adjustment.set_value (nval);
|
|
|
|
set_tooltip ();
|
|
|
|
}
|
|
|
|
|
|
|
|
_ignore_ui_adjustment = false;
|
|
|
|
}
|
2016-05-09 06:45:36 -04:00
|
|
|
|
2016-05-10 14:11:08 -04:00
|
|
|
|
|
|
|
|
2016-05-09 06:45:36 -04:00
|
|
|
PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::PluginInsert> pi)
|
|
|
|
: ArdourWindow (string_compose (_("Pin Configuration: %1"), pi->name ()))
|
|
|
|
{
|
2016-05-10 14:11:08 -04:00
|
|
|
ppw.push_back (PluginPinWidgetPtr(new PluginPinWidget (pi)));
|
|
|
|
add (*ppw.back());
|
2020-11-18 10:26:36 -05:00
|
|
|
unset_transient_for ();
|
2016-05-09 06:45:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-10 14:11:08 -04:00
|
|
|
PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::Route> r)
|
|
|
|
: ArdourWindow (string_compose (_("Pin Configuration: %1"), r->name ()))
|
|
|
|
, _route (r)
|
2016-12-20 06:20:15 -05:00
|
|
|
, _height_mapped (false)
|
2016-05-10 14:11:08 -04:00
|
|
|
{
|
|
|
|
vbox = manage (new VBox ());
|
2016-12-20 06:20:15 -05:00
|
|
|
vbox->signal_size_allocate().connect (sigc::mem_fun (*this, &PluginPinDialog::map_height));
|
|
|
|
scroller = manage (new ScrolledWindow);
|
|
|
|
scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
|
|
|
scroller->set_shadow_type (Gtk::SHADOW_NONE);
|
|
|
|
scroller->show ();
|
2016-05-10 14:11:08 -04:00
|
|
|
vbox->show ();
|
2016-12-20 06:20:15 -05:00
|
|
|
scroller->add (*vbox);
|
|
|
|
add (*scroller);
|
|
|
|
|
2016-05-10 14:11:08 -04:00
|
|
|
|
|
|
|
_route->foreach_processor (sigc::mem_fun (*this, &PluginPinDialog::add_processor));
|
|
|
|
|
|
|
|
_route->processors_changed.connect (
|
|
|
|
_route_connections, invalidator (*this), boost::bind (&PluginPinDialog::route_processors_changed, this, _1), gui_context()
|
|
|
|
);
|
|
|
|
|
|
|
|
_route->DropReferences.connect (
|
|
|
|
_route_connections, invalidator (*this), boost::bind (&PluginPinDialog::route_going_away, this), gui_context()
|
|
|
|
);
|
|
|
|
}
|
2016-05-09 06:45:36 -04:00
|
|
|
void
|
|
|
|
PluginPinDialog::set_session (ARDOUR::Session *s)
|
|
|
|
{
|
|
|
|
SessionHandlePtr::set_session (s);
|
2016-05-10 14:11:08 -04:00
|
|
|
for (PluginPinWidgetList::iterator i = ppw.begin(); i != ppw.end(); ++i) {
|
|
|
|
(*i)->set_session (s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-20 06:20:15 -05:00
|
|
|
void
|
|
|
|
PluginPinDialog::map_height (Gtk::Allocation&)
|
|
|
|
{
|
|
|
|
if (!_height_mapped) {
|
|
|
|
scroller->set_size_request (-1, std::min (600, 2 + vbox->get_height()));
|
|
|
|
_height_mapped = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-10 14:11:08 -04:00
|
|
|
void
|
|
|
|
PluginPinDialog::route_processors_changed (ARDOUR::RouteProcessorChange)
|
|
|
|
{
|
|
|
|
ppw.clear ();
|
2016-12-20 06:20:15 -05:00
|
|
|
_height_mapped = false;
|
|
|
|
scroller->remove ();
|
2016-05-10 14:11:08 -04:00
|
|
|
vbox = manage (new VBox ());
|
2016-12-20 06:20:15 -05:00
|
|
|
vbox->signal_size_allocate().connect (sigc::mem_fun (*this, &PluginPinDialog::map_height));
|
|
|
|
scroller->add (*vbox);
|
2016-05-10 14:11:08 -04:00
|
|
|
_route->foreach_processor (sigc::mem_fun (*this, &PluginPinDialog::add_processor));
|
2016-12-20 06:20:15 -05:00
|
|
|
vbox->show ();
|
2016-05-10 14:11:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginPinDialog::route_going_away ()
|
|
|
|
{
|
|
|
|
ppw.clear ();
|
|
|
|
_route.reset ();
|
|
|
|
remove ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginPinDialog::add_processor (boost::weak_ptr<Processor> p)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Processor> proc = p.lock ();
|
|
|
|
if (!proc || !proc->display_to_user ()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
|
2016-09-15 09:32:23 -04:00
|
|
|
#ifdef MIXBUS
|
|
|
|
if (pi && pi->is_channelstrip ()) {
|
|
|
|
pi.reset ();
|
|
|
|
}
|
|
|
|
#endif
|
2016-05-10 14:11:08 -04:00
|
|
|
if (pi) {
|
|
|
|
ppw.push_back (PluginPinWidgetPtr(new PluginPinWidget (pi)));
|
2018-10-28 16:29:52 -04:00
|
|
|
ppw.back()->set_session (_session);
|
2016-05-10 14:11:08 -04:00
|
|
|
vbox->pack_start (*ppw.back());
|
|
|
|
} else {
|
|
|
|
HBox* hbox = manage (new HBox ());
|
|
|
|
hbox->pack_start (*manage (new HSeparator ()));
|
|
|
|
hbox->pack_start (*manage (new Label (proc->display_name ())));
|
|
|
|
hbox->pack_start (*manage (new HSeparator ()));
|
2016-12-20 06:20:15 -05:00
|
|
|
vbox->pack_start (*hbox, false, false);
|
2016-05-10 14:11:08 -04:00
|
|
|
hbox->show_all ();
|
|
|
|
}
|
2016-05-09 06:45:36 -04:00
|
|
|
}
|