Relent a bit and make adding a route to a group which already contains that group...
[ardour.git] / gtk2_ardour / editor_canvas.cc
index 0b19b2c86ea3e4f2251594c85ca60ce107a8f072..031e58bf615e415d273449ea9717472c44eddd1e 100644 (file)
@@ -541,17 +541,14 @@ Editor::drop_regions (const RefPtr<Gdk::DragContext>& /*context*/,
                      const SelectionData& /*data*/,
                      guint /*info*/, guint /*time*/)
 {
-       assert (_drag);
-       _drag->end_grab (0);
-       delete _drag;
-       _drag = 0;
+       _drags->end_grab (0);
 }
 
 void
 Editor::maybe_autoscroll (GdkEventMotion* event, bool allow_vert)
 {
        nframes64_t rightmost_frame = leftmost_frame + current_page_frames();
-       nframes64_t frame = _drag->adjusted_current_frame (0);
+       pair<nframes64_t, nframes64_t> frames = _drags->extent ();
        bool startit = false;
 
        autoscroll_y = 0;
@@ -564,14 +561,14 @@ Editor::maybe_autoscroll (GdkEventMotion* event, bool allow_vert)
                startit = true;
        }
 
-       if (frame > rightmost_frame) {
+       if (frames.second > rightmost_frame) {
 
                if (rightmost_frame < max_frames) {
                        autoscroll_x = 1;
                        startit = true;
                }
 
-       } else if (frame < leftmost_frame) {
+       } else if (frames.first < leftmost_frame) {
                if (leftmost_frame > 0) {
                        autoscroll_x = -1;
                        startit = true;
@@ -610,23 +607,24 @@ Editor::autoscroll_canvas ()
        double new_pixel;
        double target_pixel;
 
-       assert (_drag);
-
        if (autoscroll_x_distance != 0) {
+
+               pair<nframes64_t, nframes64_t> const e = _drags->extent ();
+               
                if (autoscroll_x > 0) {
-                       autoscroll_x_distance = (unit_to_frame (_drag->current_pointer_x()) - (leftmost_frame + current_page_frames())) / 3;
+                       autoscroll_x_distance = (e.second - (leftmost_frame + current_page_frames())) / 3;
                } else if (autoscroll_x < 0) {
-                       autoscroll_x_distance = (leftmost_frame - unit_to_frame (_drag->current_pointer_x())) / 3;
+                       autoscroll_x_distance = (leftmost_frame - e.first) / 3;
 
                }
        }
 
        if (autoscroll_y_distance != 0) {
                if (autoscroll_y > 0) {
-                       autoscroll_y_distance = (_drag->current_pointer_y() - (get_trackview_group_vertical_offset() + _canvas_height)) / 3;
+                       autoscroll_y_distance = (_drags->current_pointer_y() - (get_trackview_group_vertical_offset() + _canvas_height)) / 3;
                } else if (autoscroll_y < 0) {
 
-                       autoscroll_y_distance = (vertical_adjustment.get_value () - _drag->current_pointer_y()) / 3;
+                       autoscroll_y_distance = (vertical_adjustment.get_value () - _drags->current_pointer_y()) / 3;
                }
        }
 
@@ -656,7 +654,7 @@ Editor::autoscroll_canvas ()
                        new_pixel = vertical_pos - autoscroll_y_distance;
                }
 
-               target_pixel = _drag->current_pointer_y() - autoscroll_y_distance;
+               target_pixel = _drags->current_pointer_y() - autoscroll_y_distance;
                target_pixel = max (target_pixel, 0.0);
 
        } else if (autoscroll_y > 0) {
@@ -671,7 +669,7 @@ Editor::autoscroll_canvas ()
 
                new_pixel = min (top_of_bottom_of_canvas, new_pixel);
 
-               target_pixel = _drag->current_pointer_y() + autoscroll_y_distance;
+               target_pixel = _drags->current_pointer_y() + autoscroll_y_distance;
 
                /* don't move to the full canvas height because the item will be invisible
                   (its top edge will line up with the bottom of the visible canvas.
@@ -680,7 +678,7 @@ Editor::autoscroll_canvas ()
                target_pixel = min (target_pixel, full_canvas_height - 10);
 
        } else {
-               target_pixel = _drag->current_pointer_y();
+               target_pixel = _drags->current_pointer_y();
                new_pixel = vertical_pos;
        }
 
@@ -702,11 +700,11 @@ Editor::autoscroll_canvas ()
        Gdk::ModifierType mask;
        canvas_window->get_pointer (x, y, mask);
        ev.type = GDK_MOTION_NOTIFY;
-       ev.state &= Gdk::BUTTON1_MASK;
+       ev.state = Gdk::BUTTON1_MASK;
        ev.x = x;
        ev.y = y;
 
-       motion_handler (_drag->item(), (GdkEvent*) &ev, true);
+       motion_handler (0, (GdkEvent*) &ev, true);
 
        autoscroll_cnt++;