From 1661f6479fd4b505219b1339e0ed14c9a5140a41 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 11 Jan 2022 01:53:27 +0100 Subject: [PATCH] TriggerBox: allow to receive Regions by ID via DnD --- gtk2_ardour/triggerbox_ui.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index f7270b40af..b0b4845a3b 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -36,6 +36,7 @@ #include "ardour/directory_names.h" #include "ardour/filesystem_paths.h" #include "ardour/region.h" +#include "ardour/region_factory.h" #include "ardour/triggerbox.h" #include "canvas/polygon.h" @@ -738,6 +739,7 @@ TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb) std::vector target_table; target_table.push_back (Gtk::TargetEntry ("x-ardour/region.erl", Gtk::TARGET_SAME_APP)); target_table.push_back (Gtk::TargetEntry ("x-ardour/region.esl", Gtk::TARGET_SAME_APP)); + target_table.push_back (Gtk::TargetEntry ("x-ardour/region.pbdid", Gtk::TARGET_SAME_APP)); target_table.push_back (Gtk::TargetEntry ("text/uri-list")); target_table.push_back (Gtk::TargetEntry ("text/plain")); target_table.push_back (Gtk::TargetEntry ("application/x-rootwin-drop")); @@ -882,6 +884,21 @@ TriggerBoxUI::drag_data_received (Glib::RefPtr const& context, return; } + if (data.get_target () == "x-ardour/region.pbdid") { + /* Long term goal is to receive all information from another TriggerBox Slot, + * not just the region. + */ + PBD::ID rid (data.get_data_as_string ()); + boost::shared_ptr region = RegionFactory::region_by_id (rid); + if (region) { + _triggerbox.set_from_selection (n, region); + context->drag_finish (true, false, time); + } else { + context->drag_finish (false, false, time); + } + return; + } + std::vector paths; if (ARDOUR_UI_UTILS::convert_drop_to_paths (paths, data)) { for (std::vector::iterator s = paths.begin (); s != paths.end (); ++s) {