#include "send_ui.h"
#include "timers.h"
#include "tooltips.h"
+#include "new_plugin_preset_dialog.h"
#include "i18n.h"
_button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
_unknown_processor = true;
}
+ {
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
+ if (pi && pi->plugin()) {
+ _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
+ }
+ }
if (_processor) {
_vbox.pack_start (_routing_icon);
{
return name (Wide);
}
+bool
+ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
+{
+ if (data.get_target() == "PluginPresetPtr") {
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
+
+ if (!_plugin_preset_pointer || !pi) {
+ data.set (data.get_target(), 8, NULL, 0);
+ return true;
+ }
+
+ boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
+ assert (plugin);
+
+ PluginManager& manager (PluginManager::instance());
+ bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
+
+ NewPluginPresetDialog d (plugin,
+ string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
+
+ _plugin_preset_pointer->_preset.valid = false;
+
+ switch (d.run ()) {
+ case Gtk::RESPONSE_CANCEL:
+ data.set (data.get_target(), 8, NULL, 0);
+ return true;
+ break;
+
+ case Gtk::RESPONSE_NO:
+ break;
+
+ case Gtk::RESPONSE_ACCEPT:
+ if (d.name().empty()) {
+ break;
+ }
+
+ if (d.replace ()) {
+ plugin->remove_preset (d.name ());
+ }
+
+ Plugin::PresetRecord const r = plugin->save_preset (d.name());
+
+ if (!r.uri.empty ()) {
+ _plugin_preset_pointer->_preset.uri = r.uri;
+ _plugin_preset_pointer->_preset.label = r.label;
+ _plugin_preset_pointer->_preset.user = r.user;
+ _plugin_preset_pointer->_preset.valid = r.valid;
+ }
+ }
+ data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
+ return true;
+ }
+ return false;
+}
void
ProcessorEntry::set_position (Position p, uint32_t num)
return;
}
- c->set_value ( c->interface_to_internal(_adjustment.get_value ()) );
+ c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
set_tooltip ();
}
bool const n = _button.get_active ();
- c->set_value (n ? 0 : 1);
+ c->set_value (n ? 0 : 1, Controllable::NoGroup);
_button.set_active (!n);
set_tooltip ();
}
static std::list<Gtk::TargetEntry> drop_targets()
{
std::list<Gtk::TargetEntry> tmp;
- tmp.push_back (Gtk::TargetEntry ("processor"));
+ tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
+ tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
+ tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // from sidebar
+ return tmp;
+}
+
+static std::list<Gtk::TargetEntry> drag_targets()
+{
+ std::list<Gtk::TargetEntry> tmp;
+ tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
+ tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
+ return tmp;
+}
+
+static std::list<Gtk::TargetEntry> drag_targets_noplugin()
+{
+ std::list<Gtk::TargetEntry> tmp;
+ tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
return tmp;
}
processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
+ processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
processor_scroller.show ();
processor_display.show ();
_route.reset ();
}
-void
-ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+boost::shared_ptr<Processor>
+ProcessorBox::find_drop_position (ProcessorEntry* position)
{
boost::shared_ptr<Processor> p;
if (position) {
p = position->processor ();
if (!p) {
/* dropped on the blank entry (which will be before the
- fader), so use the first non-blank child as our
- `dropped on' processor */
+ fader), so use the first non-blank child as our
+ `dropped on' processor */
list<ProcessorEntry*> c = processor_display.children ();
list<ProcessorEntry*>::iterator i = c.begin ();
assert (p);
}
}
+ return p;
+}
+
+void
+ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
+{
+ const void * d = data.get_data();
+ const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
+
+ PluginPresetList nfos;
+ TreeView* source;
+ tv->get_object_drag_data (nfos, &source);
+
+ for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
+ PluginPresetPtr ppp = (*i);
+ PluginInfoPtr pip = ppp->_pip;
+ PluginPtr p = pip->load (*_session);
+ if (!p) {
+ continue;
+ }
+
+ if (ppp->_preset.valid) {
+ p->load_preset (ppp->_preset);
+ }
+
+ boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
+ if (Config->get_new_plugins_active ()) {
+ processor->activate ();
+ }
+ pl.push_back (processor);
+ }
+}
+
+void
+ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
+{
+ const void * d = data.get_data();
+ const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
+ PluginInfoList nfos;
+
+ TreeView* source;
+ tv->get_object_drag_data (nfos, &source);
+
+ for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
+ PluginPtr p = (*i)->load (*_session);
+ if (!p) {
+ continue;
+ }
+ boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
+ if (Config->get_new_plugins_active ()) {
+ processor->activate ();
+ }
+ pl.push_back (processor);
+ }
+}
+
+void
+ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+{
+ if (!_session) {
+ return;
+ }
+
+ boost::shared_ptr<Processor> p = find_drop_position (position);
+ Route::ProcessorList pl;
+
+ if (data.get_target() == "PluginInfoPtr") {
+ _drop_plugin (data, pl);
+ }
+ else if (data.get_target() == "PluginPresetPtr") {
+ _drop_plugin_preset (data, pl);
+ }
+ else {
+ return;
+ }
+
+ Route::ProcessorStreams err;
+ if (_route->add_processors (pl, p, &err)) {
+ string msg = _(
+ "Processor Drag/Drop failed. Probably because\n\
+the I/O configuration of the plugins could\n\
+not match the configuration of this track.");
+ MessageDialog am (msg);
+ am.run ();
+ }
+}
+
+void
+ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+{
+ boost::shared_ptr<Processor> p = find_drop_position (position);
list<ProcessorEntry*> children = source->selection ();
list<boost::shared_ptr<Processor> > procs;
const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
if (ui_xml) {
- wp->set_state (*ui_xml);
+ wp->set_state (*ui_xml, 0);
}
void* existing_ui = p->get_ui ();
)
) {
- if (boost::dynamic_pointer_cast<Amp>(processor) && boost::dynamic_pointer_cast<Amp>(processor)->type() == X_("amp")) {
+ if (boost::dynamic_pointer_cast<Amp>(processor) &&
+ boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
*amp_seen = true;
} else {
if (!*amp_seen) {
e->show_all_controls ();
}
- processor_display.add_child (e);
+ if (plugin_insert
+#ifdef MIXBUS
+ && !plugin_insert->plugin(0)->is_channelstrip()
+#endif
+ )
+ {
+ processor_display.add_child (e, drag_targets());
+ } else {
+ processor_display.add_child (e, drag_targets_noplugin());
+ }
}
void
uint32_t num = 0;
for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
- if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && boost::dynamic_pointer_cast<Amp>((*i)->processor())->type() == X_("amp")) {
+ if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) &&
+ boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
pre_fader = false;
(*i)->set_position (ProcessorEntry::Fader, num++);
} else {
}
}
- if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->type() == X_("amp")) {
+ if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
if (_parent_strip) {
_parent_strip->revert_to_default_display ();
}
XMLNode&
-ProcessorWindowProxy::get_state () const
+ProcessorWindowProxy::get_state ()
{
XMLNode *node;
node = &ProxyBase::get_state();
return *node;
}
-void
-ProcessorWindowProxy::set_state (const XMLNode& node)
+int
+ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
{
XMLNodeList children = node.children ();
XMLNodeList::const_iterator i = children.begin ();
}
}
- ProxyBase::set_state(node);
+ return ProxyBase::set_state (node, 0);
}
Gtk::Window*