13
0

TriggerBox: allow to receive Regions by ID via DnD

This commit is contained in:
Robin Gareus 2022-01-11 01:53:27 +01:00
parent 1db6e9edca
commit 1661f6479f
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -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<Gtk::TargetEntry> 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<Gdk::DragContext> 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> 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<std::string> paths;
if (ARDOUR_UI_UTILS::convert_drop_to_paths (paths, data)) {
for (std::vector<std::string>::iterator s = paths.begin (); s != paths.end (); ++s) {