summaryrefslogtreecommitdiff
path: root/gtk2_ardour/processor_box.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-12-28 04:11:45 +0100
committerRobin Gareus <robin@gareus.org>2015-12-28 04:11:45 +0100
commit4758de37cd734d2c94ececb0ac4a613ace68730b (patch)
tree1a6d4e480b315440f24efa8ea9890e568eb778de /gtk2_ardour/processor_box.cc
parent0aba08594c9151c4a8859bf92a134d63bb1e7786 (diff)
allow creating plugin-presets by dragging a plugin to the sidebar
Diffstat (limited to 'gtk2_ardour/processor_box.cc')
-rw-r--r--gtk2_ardour/processor_box.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc
index a997795cde..96d291e725 100644
--- a/gtk2_ardour/processor_box.cc
+++ b/gtk2_ardour/processor_box.cc
@@ -75,6 +75,7 @@
#include "send_ui.h"
#include "timers.h"
#include "tooltips.h"
+#include "new_plugin_preset_dialog.h"
#include "i18n.h"
@@ -132,6 +133,12 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
_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);
@@ -211,6 +218,41 @@ ProcessorEntry::drag_text () const
{
return name (Wide);
}
+bool
+ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
+{
+ if (data.get_target() == "PluginPresetPtr" && _plugin_preset_pointer) {
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
+ boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
+ assert (plugin);
+ NewPluginPresetDialog d (plugin);
+
+ _plugin_preset_pointer->_preset.valid = false;
+
+ switch (d.run ()) {
+ 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)