summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-12-22 04:24:20 +0100
committerRobin Gareus <robin@gareus.org>2015-12-22 04:24:20 +0100
commita7b236561c8a6ca83f00121fdf435fdb26b7998e (patch)
treee8d353f0fa57e28e7eee0da1468d8bec47f753ad
parentd5c275e78e981cf74a73c252b9d92dd8715ffbe7 (diff)
ProcessorBox: allow to receive PluginInfoPtr drops
-rw-r--r--gtk2_ardour/processor_box.cc70
-rw-r--r--gtk2_ardour/processor_box.h1
2 files changed, 71 insertions, 0 deletions
diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc
index 049cfaaa18..f6f3bd86ec 100644
--- a/gtk2_ardour/processor_box.cc
+++ b/gtk2_ardour/processor_box.cc
@@ -1045,6 +1045,7 @@ static std::list<Gtk::TargetEntry> drop_targets()
{
std::list<Gtk::TargetEntry> tmp;
tmp.push_back (Gtk::TargetEntry ("processor"));
+ tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr"));
return tmp;
}
@@ -1085,6 +1086,7 @@ ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelecto
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 ();
@@ -1148,6 +1150,74 @@ ProcessorBox::route_going_away ()
}
void
+ProcessorBox::plugin_drop(Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+{
+ if (data.get_target() != "PluginInfoPtr") {
+ return;
+ }
+ if (!_session) {
+ return;
+ }
+
+ 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 */
+ list<ProcessorEntry*> c = processor_display.children ();
+ list<ProcessorEntry*>::iterator i = c.begin ();
+
+ assert (i != c.end ());
+ p = (*i)->processor ();
+ assert (p);
+ }
+ }
+
+ const void * d = data.get_data();
+ const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr> * tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
+
+ std::list<ARDOUR::PluginInfoPtr> nfos;
+ TreeView* source;
+ tv->get_object_drag_data (nfos, &source);
+
+ Route::ProcessorStreams err;
+ Route::ProcessorList pl;
+
+ 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);
+ }
+
+ if (_route->add_processors (pl, p, &err)) {
+ string msg = _(
+ "Adding the given processor(s) failed probably,\n\
+because the I/O configuration of the plugins could\n\
+not match the configuration of this track.");
+ MessageDialog am (msg);
+ am.run ();
+ } else if (pl.size() == 1 && Config->get_open_gui_after_adding_plugin()) {
+ boost::shared_ptr<Processor> processor = pl.front();
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
+ if (_session->engine().connected () && processor_can_be_edited (processor)) {
+ if (pi && pi->plugin()->has_editor ()) {
+ edit_processor (processor);
+ } else {
+ generic_edit_processor (processor);
+ }
+ }
+ }
+}
+
+void
ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
{
boost::shared_ptr<Processor> p;
diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h
index 015afca4a9..3367534b07 100644
--- a/gtk2_ardour/processor_box.h
+++ b/gtk2_ardour/processor_box.h
@@ -348,6 +348,7 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
Gtkmm2ext::DnDVBox<ProcessorEntry> processor_display;
Gtk::ScrolledWindow processor_scroller;
+ void plugin_drop (Gtk::SelectionData const &, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context);
void object_drop (Gtkmm2ext::DnDVBox<ProcessorEntry> *, ProcessorEntry *, Glib::RefPtr<Gdk::DragContext> const &);
Width _width;