diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index ec5f4c50e5..383241aec0 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -495,15 +495,6 @@ Editor::drop_paths (const RefPtr& context, context->drag_finish (true, false, time); } -void -Editor::drop_regions (const RefPtr& /*context*/, - int /*x*/, int /*y*/, - const SelectionData& /*data*/, - guint /*info*/, guint /*time*/) -{ - _drags->end_grab (0); -} - /** If the editor window is arranged such that the edge of the trackview is right up * against the edge of the screen, autoscroll will not work very well. In this situation, * we start autoscrolling some distance in from the right-hand-side of the screen edge; diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 9d092ebc8f..631137fd2f 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -1002,63 +1002,124 @@ Editor::canvas_note_event (GdkEvent *event, ArdourCanvas::Item* item) } bool -Editor::track_canvas_drag_motion (Glib::RefPtr const & /*c*/, int x, int y, guint /*time*/) +Editor::track_canvas_drag_motion (Glib::RefPtr const& context, int x, int y, guint time) { double wx; double wy; + boost::shared_ptr region; + boost::shared_ptr region_copy; + RouteTimeAxisView* rtav; + GdkEvent event; + double px; + double py; + + string target = track_canvas->drag_dest_find_target (context, track_canvas->drag_dest_get_target_list()); + + if (target.empty()) { + return false; + } + track_canvas->window_to_world (x, y, wx, wy); - GdkEvent event; event.type = GDK_MOTION_NOTIFY; event.button.x = wx; event.button.y = wy; /* assume we're dragging with button 1 */ event.motion.state = Gdk::BUTTON1_MASK; - if (!_drags->active ()) { + (void) event_frame (&event, &px, &py); - double px; - double py; - framepos_t const pos = event_frame (&event, &px, &py); + std::pair const tv = trackview_by_y_position (py); - std::pair const tv = trackview_by_y_position (py); - if (tv.first == 0) { - return true; + if (tv.first != 0) { + + rtav = dynamic_cast (tv.first); + + if (rtav != 0 && rtav->is_track ()) { + + region = _regions->get_dragged_region (); + + if (region) { + + 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; + } + } } - - RouteTimeAxisView* rtav = dynamic_cast (tv.first); - if (rtav == 0 || !rtav->is_track ()) { - return true; - } - - boost::shared_ptr region = _regions->get_dragged_region (); - - if (!region) { - return true; - } - - boost::shared_ptr region_copy = RegionFactory::create (region, true); - - if (boost::dynamic_pointer_cast (region_copy) != 0 && - dynamic_cast (tv.first) == 0) { - - /* audio -> non-audio */ - return true; - } - - if (boost::dynamic_pointer_cast (region_copy) != 0 && - dynamic_cast (tv.first) == 0) { - - /* MIDI -> non-MIDI */ - return true; - } - - _drags->set (new RegionInsertDrag (this, region_copy, rtav, pos), &event); } - _drags->motion_handler (&event, false); + /* no drop here */ + context->drag_status (Gdk::DragAction (0), time); + return false; +} - return true; +void +Editor::drop_regions (const Glib::RefPtr& /*context*/, + int x, int y, + const SelectionData& /*data*/, + guint /*info*/, guint /*time*/) +{ + double wx; + double wy; + boost::shared_ptr region; + boost::shared_ptr region_copy; + RouteTimeAxisView* rtav; + GdkEvent event; + double px; + double py; + + track_canvas->window_to_world (x, y, wx, wy); + + event.type = GDK_MOTION_NOTIFY; + event.button.x = wx; + event.button.y = wy; + /* assume we're dragging with button 1 */ + event.motion.state = Gdk::BUTTON1_MASK; + + framepos_t const pos = event_frame (&event, &px, &py); + + std::pair const tv = trackview_by_y_position (py); + + if (tv.first != 0) { + + rtav = dynamic_cast (tv.first); + + if (rtav != 0 && rtav->is_track ()) { + + boost::shared_ptr region = _regions->get_dragged_region (); + + if (region) { + + region_copy = RegionFactory::create (region, true); + + + if ((boost::dynamic_pointer_cast (region_copy) != 0 && + dynamic_cast (tv.first) != 0) || + (boost::dynamic_pointer_cast (region_copy) != 0 && + dynamic_cast (tv.first) != 0)) { + + /* audio to audio + OR + midi to midi + */ + + + _drags->set (new RegionInsertDrag (this, region_copy, rtav, pos), &event); + _drags->end_grab (0); + } + } + } + } } bool