patch from lincoln to make MIDI track height changes no longer just grow note height...
[ardour.git] / gtk2_ardour / editor_canvas.cc
index f5eb29195fece7b2d8217c3fba25c548215e163d..2b5e0163783c05accef923c283e3eb54b2a7cb6e 100644 (file)
@@ -361,7 +361,6 @@ Editor::track_canvas_size_allocated ()
                }
        }
 
-       handle_new_duration ();
        update_fixed_rulers();
        redisplay_tempo (false);
        _summary->set_overlays_dirty ();
@@ -438,6 +437,7 @@ Editor::track_canvas_map_handler (GdkEventAny* /*ev*/)
        return false;
 }
 
+/** This is called when something is dropped onto the track canvas */
 void
 Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context,
                                         int x, int y,
@@ -480,7 +480,7 @@ Editor::drop_paths_part_two (const vector<ustring>& paths, nframes64_t frame, do
 
                /* check that its an audio track, not a bus */
 
-               if (tv->get_diskstream()) {
+               if (tv->track()) {
                        /* select the track, then embed/import */
                        selection->set (tv);
 
@@ -541,17 +541,13 @@ 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->current_pointer_frame();
        bool startit = false;
 
        autoscroll_y = 0;
@@ -564,19 +560,16 @@ Editor::maybe_autoscroll (GdkEventMotion* event, bool allow_vert)
                startit = true;
        }
 
-       if (frame > rightmost_frame) {
-
+       if (_drags->current_pointer_frame() > rightmost_frame) {
                if (rightmost_frame < max_frames) {
                        autoscroll_x = 1;
                        startit = true;
                }
-
-       } else if (frame < leftmost_frame) {
+       } else if (_drags->current_pointer_frame() < leftmost_frame) {
                if (leftmost_frame > 0) {
                        autoscroll_x = -1;
                        startit = true;
                }
-
        }
 
        if (!allow_vertical_scroll) {
@@ -610,23 +603,22 @@ Editor::autoscroll_canvas ()
        double new_pixel;
        double target_pixel;
 
-       assert (_drag);
-
        if (autoscroll_x_distance != 0) {
+
                if (autoscroll_x > 0) {
-                       autoscroll_x_distance = (unit_to_frame (_drag->current_pointer_x()) - (leftmost_frame + current_page_frames())) / 3;
+                       autoscroll_x_distance = (_drags->current_pointer_frame() - (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 - _drags->current_pointer_frame()) / 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 +648,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 +663,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 +672,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 +694,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++;
 
@@ -758,6 +750,7 @@ Editor::stop_canvas_autoscroll ()
 bool
 Editor::left_track_canvas (GdkEventCrossing */*ev*/)
 {
+        DropDownKeys ();
        set_entered_track (0);
        set_entered_regionview (0);
        reset_canvas_action_sensitivity (false);
@@ -786,20 +779,20 @@ Editor::tie_vertical_scrolling ()
 }
 
 void
-Editor::scroll_canvas_horizontally ()
+Editor::set_horizontal_position (double p)
 {
        /* horizontal scrolling only */
        double x1, y1, x2, y2, x_delta;
        _master_group->get_bounds (x1, y1, x2, y2);
 
-       x_delta = - (x1 +  horizontal_adjustment.get_value());
+       x_delta = - (x1 + p);
 
        _master_group->move (x_delta, 0);
        timebar_group->move (x_delta, 0);
        time_line_group->move (x_delta, 0);
        cursor_group->move (x_delta, 0);
 
-       leftmost_frame = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
+       leftmost_frame = (nframes64_t) floor (p * frames_per_unit);
 
        update_fixed_rulers ();
        redisplay_tempo (true);
@@ -809,7 +802,7 @@ Editor::scroll_canvas_horizontally ()
        }
 
 #ifndef GTKOSX
-       if (!autoscroll_active) {
+       if (!autoscroll_active && !_stationary_playhead) {
                /* force rulers and canvas to move in lock step */
                while (gtk_events_pending ()) {
                        gtk_main_iteration ();
@@ -927,3 +920,9 @@ Editor::update_canvas_now ()
                track_canvas->update_now ();
        }
 }
+
+double
+Editor::horizontal_position () const
+{
+       return frame_to_unit (leftmost_frame);
+}