diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 9b6791889f..b669e818f9 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -5875,16 +5875,6 @@ Editor::consider_auditioning (boost::shared_ptr region) last_audition_region = r; } -boost::shared_ptr -Editor::get_dragged_region_from_sidebar () -{ - boost::shared_ptr rv = _regions->get_dragged_region (); - if (!rv) { - rv = _sources->get_dragged_region (); - } - return rv; -} - void Editor::hide_a_region (boost::shared_ptr r) { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 4c0606e26c..2386074b10 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -226,8 +226,6 @@ public: void hide_a_region (boost::shared_ptr); void show_a_region (boost::shared_ptr); - boost::shared_ptr get_dragged_region_from_sidebar (); - #ifdef USE_RUBBERBAND std::vector rb_opt_strings; int rb_current_opt; @@ -2123,16 +2121,7 @@ private: gint y, const Gtk::SelectionData& data, guint info, - guint time, - bool from_region_list); - - void drop_routes ( - const Glib::RefPtr& context, - gint x, - gint y, - const Gtk::SelectionData& data, - guint info, - guint time); + guint time); /* audio export */ diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 85e0183c12..ef29af4ac2 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -268,8 +268,7 @@ Editor::initialize_canvas () vector target_table; - target_table.push_back (TargetEntry ("x-ardour/region.erl", TARGET_SAME_APP)); // DnD from the region list will generate this target - target_table.push_back (TargetEntry ("x-ardour/region.esl", TARGET_SAME_APP)); // DnD from the source list will generate this target + target_table.push_back (TargetEntry ("x-ardour/region.pbdid", TARGET_SAME_APP)); target_table.push_back (TargetEntry ("text/uri-list")); target_table.push_back (TargetEntry ("text/plain")); target_table.push_back (TargetEntry ("application/x-rootwin-drop")); @@ -391,10 +390,8 @@ Editor::track_canvas_drag_data_received (const RefPtr& context if (!ARDOUR_UI_UTILS::engine_is_running ()) { return; } - if (data.get_target() == "x-ardour/region.erl") { - drop_regions (context, x, y, data, info, time, true); - } else if (data.get_target() == "x-ardour/region.esl") { - drop_regions (context, x, y, data, info, time, false); + if (data.get_target() == "x-ardour/region.pbdid") { + drop_regions (context, x, y, data, info, time); } else { drop_paths (context, x, y, data, info, time); } diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 31fcb4c538..0fd8b6393d 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -1210,39 +1210,27 @@ Editor::track_canvas_drag_motion (Glib::RefPtr const& context, if (can_drop) { - if (target == "x-ardour/region.erl") { - region = _regions->get_dragged_region (); - } else if (target == "x-ardour/region.esl") { - region = _sources->get_dragged_region (); - } + if (target == "x-ardour/region.pbdid") { +#if 0 + // TODO check drag_source::drag_data_get() -> SelectionData& region - if (region) { - - if (tv.first == 0 - && ( - boost::dynamic_pointer_cast (region) != 0 || - boost::dynamic_pointer_cast (region) != 0 - ) - ) - { + if (tv.first == 0 && region) { /* drop to drop-zone */ context->drag_status (context->get_suggested_action(), time); return true; } - if ((boost::dynamic_pointer_cast (region) != 0 && - dynamic_cast (tv.first) != 0) || - (boost::dynamic_pointer_cast (region) != 0 && - dynamic_cast (tv.first) != 0)) { - - /* audio to audio - OR - midi to midi - */ - + if ((boost::dynamic_pointer_cast (region) != 0 && dynamic_cast (tv.first) != 0) || + (boost::dynamic_pointer_cast (region) != 0 && dynamic_cast (tv.first) != 0)) { + /* audio to audio OR MIDI to MIDI */ context->drag_status (context->get_suggested_action(), time); return true; } +#else + /* region drop always works */ + context->drag_status (context->get_suggested_action(), time); +#endif + return true; } else { /* DND originating from outside ardour * @@ -1270,9 +1258,8 @@ Editor::track_canvas_drag_motion (Glib::RefPtr const& context, void Editor::drop_regions (const Glib::RefPtr& /*context*/, int x, int y, - const SelectionData& /*data*/, - guint /*info*/, guint /*time*/, - bool from_region_list) + const SelectionData& data, + guint /*info*/, guint /*time*/) { GdkEvent event; double px; @@ -1285,13 +1272,8 @@ Editor::drop_regions (const Glib::RefPtr& /*context*/, event.motion.state = Gdk::BUTTON1_MASK; samplepos_t const pos = window_event_sample (&event, &px, &py); - boost::shared_ptr region; - - if (from_region_list) { - region = _regions->get_dragged_region (); - } else { - region = _sources->get_dragged_region (); - } + PBD::ID rid (data.get_data_as_string ()); + boost::shared_ptr region = RegionFactory::region_by_id (rid); if (!region) { return; } diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc index 3f946dc1c2..4ffe2adbbb 100644 --- a/gtk2_ardour/editor_regions.cc +++ b/gtk2_ardour/editor_regions.cc @@ -55,9 +55,6 @@ EditorRegions::EditorRegions (Editor* e) _change_connection = _display.get_selection ()->signal_changed ().connect (sigc::mem_fun (*this, &EditorRegions::selection_changed)); - _display.add_object_drag (_columns.region.index (), "x-ardour/region.erl", TARGET_SAME_APP); - _display.set_drag_column (_columns.name.index ()); - e->EditorFreeze.connect (_editor_freeze_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::freeze_tree_model, this), gui_context ()); e->EditorThaw.connect (_editor_thaw_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::thaw_tree_model, this), gui_context ()); } @@ -244,21 +241,6 @@ EditorRegions::regions_changed (boost::shared_ptr rl, const Property RegionListBase::regions_changed (rl, what_changed); } -/** @return Region that has been dragged out of the list, or 0 */ -boost::shared_ptr -EditorRegions::get_dragged_region () -{ - list> regions; - TreeView* source; - _display.get_object_drag_data (regions, &source); - - if (regions.empty ()) { - return boost::shared_ptr (); - } - - return regions.front (); -} - boost::shared_ptr EditorRegions::get_single_selection () { diff --git a/gtk2_ardour/editor_regions.h b/gtk2_ardour/editor_regions.h index 3eba9e1586..2227646f5d 100644 --- a/gtk2_ardour/editor_regions.h +++ b/gtk2_ardour/editor_regions.h @@ -35,7 +35,6 @@ public: void selection_mapover (sigc::slot>); void remove_unused_regions (); - boost::shared_ptr get_dragged_region (); boost::shared_ptr get_single_selection (); void unselect_all () diff --git a/gtk2_ardour/editor_sources.cc b/gtk2_ardour/editor_sources.cc index 7499edeeda..86cf876112 100644 --- a/gtk2_ardour/editor_sources.cc +++ b/gtk2_ardour/editor_sources.cc @@ -227,11 +227,13 @@ EditorSources::EditorSources (Editor* e) tv_col->set_expand (true); _display.get_selection()->set_mode (SELECTION_MULTIPLE); - _display.add_object_drag (_columns.region.index (), "x-ardour/region.esl", TARGET_SAME_APP); + + /* Set up DnD Source */ + _display.add_object_drag (_columns.region.index (), "x-ardour/region.pbdid", TARGET_SAME_APP); _display.set_drag_column (_columns.name.index()); + _display.signal_drag_data_get ().connect (sigc::mem_fun (*this, &EditorSources::drag_data_get)); - /* setup DnD handling */ - + /* setup DnD Receive */ list source_list_target_table; source_list_target_table.push_back (TargetEntry ("text/plain")); @@ -949,20 +951,21 @@ EditorSources::drag_data_received (const RefPtr& context, } } -/** @return Region that has been dragged out of the list, or 0 */ -boost::shared_ptr -EditorSources::get_dragged_region () +void +EditorSources::drag_data_get (Glib::RefPtr const&, Gtk::SelectionData& data, guint, guint) { + if (data.get_target () != "x-ardour/region.pbdid") { + return; + } + list > regions; TreeView* region; _display.get_object_drag_data (regions, ®ion); - if (regions.empty()) { - return boost::shared_ptr (); + if (!regions.empty ()) { + assert (regions.size() == 1); + data.set (data.get_target (), regions.front()->id ().to_s ()); } - - assert (regions.size() == 1); - return regions.front (); } void diff --git a/gtk2_ardour/editor_sources.h b/gtk2_ardour/editor_sources.h index 2e5b9493bf..01ced48efe 100644 --- a/gtk2_ardour/editor_sources.h +++ b/gtk2_ardour/editor_sources.h @@ -25,6 +25,8 @@ #include #include +#include "gtkmm2ext/dndtreeview.h" + #include "editor_component.h" #include "selection.h" @@ -42,7 +44,6 @@ public: void clear (); - boost::shared_ptr get_dragged_region (); boost::shared_ptr get_single_selection (); void unselect_all () { @@ -132,9 +133,8 @@ private: void redisplay (); - void drag_data_received ( - Glib::RefPtr const &, gint, gint, Gtk::SelectionData const &, guint, guint - ); + void drag_data_get (Glib::RefPtr const&, Gtk::SelectionData&, guint, guint); + void drag_data_received (Glib::RefPtr const &, gint, gint, Gtk::SelectionData const &, guint, guint); Gtk::ScrolledWindow _scroller; diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 323baf2bf5..d2c52305d4 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -203,9 +203,6 @@ public: */ virtual void consider_auditioning (boost::shared_ptr r) = 0; - /* Editor::_regions DnD */ - virtual boost::shared_ptr get_dragged_region_from_sidebar () = 0; - /* import dialogs -> ardour-ui ?! */ virtual void external_audio_dialog () = 0; virtual void session_import_dialog () = 0; diff --git a/gtk2_ardour/region_list_base.cc b/gtk2_ardour/region_list_base.cc index 7dfb5701b3..cc3b6ea89e 100644 --- a/gtk2_ardour/region_list_base.cc +++ b/gtk2_ardour/region_list_base.cc @@ -77,6 +77,10 @@ RegionListBase::RegionListBase () _model = TreeStore::create (_columns); _model->set_sort_column (0, SORT_ASCENDING); + _display.add_object_drag (_columns.region.index (), "x-ardour/region.pbdid", Gtk::TARGET_SAME_APP); + _display.set_drag_column (_columns.name.index ()); + _display.signal_drag_data_get ().connect (sigc::mem_fun (*this, &RegionListBase::drag_data_get)); + _display.set_model (_model); _display.set_headers_visible (true); @@ -217,6 +221,22 @@ RegionListBase::leave_notify (GdkEventCrossing*) return false; } +void +RegionListBase::drag_data_get (Glib::RefPtr const&, Gtk::SelectionData& data, guint, guint) +{ + if (data.get_target () != "x-ardour/region.pbdid") { + return; + } + + list> regions; + TreeView* source; + _display.get_object_drag_data (regions, &source); + + if (!regions.empty ()) { + data.set (data.get_target (), regions.front ()->id ().to_s ()); + } +} + void RegionListBase::set_session (ARDOUR::Session* s) { diff --git a/gtk2_ardour/region_list_base.h b/gtk2_ardour/region_list_base.h index e6542def03..8393c9b946 100644 --- a/gtk2_ardour/region_list_base.h +++ b/gtk2_ardour/region_list_base.h @@ -213,6 +213,8 @@ protected: void clock_format_changed (); + void drag_data_get (Glib::RefPtr const&, Gtk::SelectionData&, guint, guint); + Columns _columns; int _sort_col_id; diff --git a/gtk2_ardour/trigger_page.cc b/gtk2_ardour/trigger_page.cc index d31aa03ce5..ed4b12095c 100644 --- a/gtk2_ardour/trigger_page.cc +++ b/gtk2_ardour/trigger_page.cc @@ -108,8 +108,7 @@ TriggerPage::TriggerPage () _no_strips.signal_drag_data_received ().connect (sigc::mem_fun (*this, &TriggerPage::no_strip_drag_data_received)); 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")); @@ -527,8 +526,9 @@ TriggerPage::no_strip_drag_motion (Glib::RefPtr const& context void TriggerPage::no_strip_drag_data_received (Glib::RefPtr const& context, int /*x*/, int y, Gtk::SelectionData const& data, guint /*info*/, guint time) { - if (data.get_target () == "x-ardour/region.erl" || data.get_target () == "x-ardour/region.esl") { - boost::shared_ptr region = PublicEditor::instance ().get_dragged_region_from_sidebar (); + if (data.get_target () == "x-ardour/region.pbdid") { + PBD::ID rid (data.get_data_as_string ()); + boost::shared_ptr region = RegionFactory::region_by_id (rid); boost::shared_ptr triggerbox; if (boost::dynamic_pointer_cast (region)) { diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index a6293e4dcc..52451a8809 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -855,8 +855,6 @@ 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")); @@ -986,21 +984,8 @@ TriggerBoxUI::drag_data_received (Glib::RefPtr const& context, context->drag_finish (false, false, time); return; } - if (data.get_target () == "x-ardour/region.erl" || data.get_target () == "x-ardour/region.esl") { - boost::shared_ptr region = PublicEditor::instance ().get_dragged_region_from_sidebar (); - if (region) { - _triggerbox.set_from_selection (n, region); - context->drag_finish (true, false, time); - } else { - context->drag_finish (false, false, time); - } - 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) {