summaryrefslogtreecommitdiff
path: root/gtk2_ardour/mixer_ui.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-05-06 16:04:05 +0200
committerRobin Gareus <robin@gareus.org>2016-05-06 16:04:05 +0200
commitbaca1fd37711e23d6100c7b8cc946aef13f88ab4 (patch)
tree6655de66f33a577ab93e70b79104d93d19c60388 /gtk2_ardour/mixer_ui.cc
parent70160db4bedc7f782d12125496ec354b1ca35569 (diff)
Create new track by dragging an instrument from the favorites sidebar
Diffstat (limited to 'gtk2_ardour/mixer_ui.cc')
-rw-r--r--gtk2_ardour/mixer_ui.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc
index b037055b63..8457738f1b 100644
--- a/gtk2_ardour/mixer_ui.cc
+++ b/gtk2_ardour/mixer_ui.cc
@@ -117,6 +117,13 @@ Mixer_UI::Mixer_UI ()
scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
scroller_base.set_name ("MixerWindow");
scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
+
+ /* set up drag-n-drop */
+ vector<TargetEntry> target_table;
+ target_table.push_back (TargetEntry ("PluginFavoritePtr"));
+ scroller_base.drag_dest_set (target_table);
+ scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
+
// add as last item of strip packer
strip_packer.pack_end (scroller_base, true, true);
@@ -1622,6 +1629,38 @@ Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
}
void
+Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
+{
+ printf ("Mixer_UI::scroller_drag_data_received\n");
+ if (data.get_target() != "PluginFavoritePtr") {
+ context->drag_finish (false, false, time);
+ return;
+ }
+
+ 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);
+
+ Route::ProcessorList pl;
+ bool ok = false;
+
+ for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
+ PluginPresetPtr ppp = (*i);
+ PluginInfoPtr pip = ppp->_pip;
+ if (!pip->is_instrument ()) {
+ continue;
+ }
+ ARDOUR_UI::instance()->session_add_midi_track (NULL, 1, _("MIDI"), Config->get_strict_io (), pip, ppp->_preset.valid ? &ppp->_preset : 0);
+ ok = true;
+ }
+
+ context->drag_finish (ok, false, time);
+}
+
+void
Mixer_UI::set_strip_width (Width w, bool save)
{
_strip_width = w;