summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-12-25 17:13:00 +0100
committerRobin Gareus <robin@gareus.org>2015-12-25 17:13:00 +0100
commite762fe36be82c93847447e8691217ea7e522f785 (patch)
tree3fe32acf42ff96bedaf6cbac3e86e18a292c14a2
parentb92f208b521f0e733b123ef5e7552ee26b4d439d (diff)
refactor Processor-Box plugin drag/drop: allow presets
-rw-r--r--gtk2_ardour/processor_box.cc128
-rw-r--r--gtk2_ardour/processor_box.h5
2 files changed, 86 insertions, 47 deletions
diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc
index 666d770fd2..a997795cde 100644
--- a/gtk2_ardour/processor_box.cc
+++ b/gtk2_ardour/processor_box.cc
@@ -1046,6 +1046,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"));
+ tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr"));
return tmp;
}
@@ -1149,42 +1150,67 @@ ProcessorBox::route_going_away ()
_route.reset ();
}
-void
-ProcessorBox::plugin_drop(Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+boost::shared_ptr<Processor>
+ProcessorBox::find_drop_position (ProcessorEntry* position)
{
- 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);
}
+ }
+ return p;
+}
- boost::shared_ptr<Processor> p;
- if (position) {
- p = position->processor ();
+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) {
- /* 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);
+ 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);
+ const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
+ PluginInfoList nfos;
- 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) {
@@ -1196,35 +1222,43 @@ ProcessorBox::plugin_drop(Gtk::SelectionData const &data, ProcessorEntry* positi
}
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 ();
- }
}
void
-ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
{
- 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 ();
+ if (!_session) {
+ return;
+ }
- assert (i != c.end ());
- p = (*i)->processor ();
- assert (p);
- }
+ 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;
diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h
index 3367534b07..872f58ce61 100644
--- a/gtk2_ardour/processor_box.h
+++ b/gtk2_ardour/processor_box.h
@@ -348,6 +348,11 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
Gtkmm2ext::DnDVBox<ProcessorEntry> processor_display;
Gtk::ScrolledWindow processor_scroller;
+ boost::shared_ptr<ARDOUR::Processor> find_drop_position (ProcessorEntry* position);
+
+ void _drop_plugin_preset (Gtk::SelectionData const &, ARDOUR::Route::ProcessorList &);
+ void _drop_plugin (Gtk::SelectionData const &, ARDOUR::Route::ProcessorList &);
+
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 &);