refactor Processor-Box plugin drag/drop: allow presets
This commit is contained in:
parent
b92f208b52
commit
e762fe36be
@ -1046,6 +1046,7 @@ static std::list<Gtk::TargetEntry> drop_targets()
|
|||||||
std::list<Gtk::TargetEntry> tmp;
|
std::list<Gtk::TargetEntry> tmp;
|
||||||
tmp.push_back (Gtk::TargetEntry ("processor"));
|
tmp.push_back (Gtk::TargetEntry ("processor"));
|
||||||
tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr"));
|
tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr"));
|
||||||
|
tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr"));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1149,16 +1150,9 @@ ProcessorBox::route_going_away ()
|
|||||||
_route.reset ();
|
_route.reset ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
boost::shared_ptr<Processor>
|
||||||
ProcessorBox::plugin_drop(Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
|
ProcessorBox::find_drop_position (ProcessorEntry* position)
|
||||||
{
|
{
|
||||||
if (data.get_target() != "PluginInfoPtr") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!_session) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<Processor> p;
|
boost::shared_ptr<Processor> p;
|
||||||
if (position) {
|
if (position) {
|
||||||
p = position->processor ();
|
p = position->processor ();
|
||||||
@ -1174,16 +1168,48 @@ ProcessorBox::plugin_drop(Gtk::SelectionData const &data, ProcessorEntry* positi
|
|||||||
assert (p);
|
assert (p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
|
||||||
|
{
|
||||||
const void * d = data.get_data();
|
const void * d = data.get_data();
|
||||||
const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr> * tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
|
const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
|
||||||
|
|
||||||
std::list<ARDOUR::PluginInfoPtr> nfos;
|
PluginPresetList nfos;
|
||||||
TreeView* source;
|
TreeView* source;
|
||||||
tv->get_object_drag_data (nfos, &source);
|
tv->get_object_drag_data (nfos, &source);
|
||||||
|
|
||||||
Route::ProcessorStreams err;
|
for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
|
||||||
Route::ProcessorList pl;
|
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) {
|
for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
|
||||||
PluginPtr p = (*i)->load (*_session);
|
PluginPtr p = (*i)->load (*_session);
|
||||||
@ -1196,11 +1222,33 @@ ProcessorBox::plugin_drop(Gtk::SelectionData const &data, ProcessorEntry* positi
|
|||||||
}
|
}
|
||||||
pl.push_back (processor);
|
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)) {
|
if (_route->add_processors (pl, p, &err)) {
|
||||||
string msg = _(
|
string msg = _(
|
||||||
"Adding the given processor(s) failed probably,\n\
|
"Processor Drag/Drop failed. Probably because\n\
|
||||||
because the I/O configuration of the plugins could\n\
|
the I/O configuration of the plugins could\n\
|
||||||
not match the configuration of this track.");
|
not match the configuration of this track.");
|
||||||
MessageDialog am (msg);
|
MessageDialog am (msg);
|
||||||
am.run ();
|
am.run ();
|
||||||
@ -1208,23 +1256,9 @@ not match the configuration of this track.");
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
|
ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Processor> p;
|
boost::shared_ptr<Processor> p = find_drop_position (position);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list<ProcessorEntry*> children = source->selection ();
|
list<ProcessorEntry*> children = source->selection ();
|
||||||
list<boost::shared_ptr<Processor> > procs;
|
list<boost::shared_ptr<Processor> > procs;
|
||||||
|
@ -348,6 +348,11 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
|
|||||||
Gtkmm2ext::DnDVBox<ProcessorEntry> processor_display;
|
Gtkmm2ext::DnDVBox<ProcessorEntry> processor_display;
|
||||||
Gtk::ScrolledWindow processor_scroller;
|
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 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 &);
|
void object_drop (Gtkmm2ext::DnDVBox<ProcessorEntry> *, ProcessorEntry *, Glib::RefPtr<Gdk::DragContext> const &);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user