missing initialization
[ardour.git] / gtk2_ardour / editor_drag.cc
index 9591de95dec522963a7beabe41759283621e20f0..9c65892ebde46cdb2c140c194149756a712d3910 100644 (file)
@@ -22,6 +22,7 @@
 #endif
 
 #include <stdint.h>
+#include <algorithm>
 
 #include "pbd/memento_command.h"
 #include "pbd/basename.h"
@@ -658,11 +659,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
 
                RegionView* rv = i->view;
 
-               if (rv->region()->locked()
-#ifdef WITH_VIDEOTIMELINE
-                               || rv->region()->video_locked()
-#endif
-                               ) {
+               if (rv->region()->locked() || rv->region()->video_locked()) {
                        continue;
                }
 
@@ -933,11 +930,7 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const /*changed
        /* insert the regions into their new playlists */
        for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
 
-               if (i->view->region()->locked()
-#ifdef WITH_VIDEOTIMELINE
-                               || i->view->region()->video_locked()
-#endif
-                               ) {
+               if (i->view->region()->locked() || i->view->region()->video_locked()) {
                        continue;
                }
 
@@ -1016,11 +1009,7 @@ RegionMoveDrag::finished_no_copy (
                RouteTimeAxisView* const dest_rtv = dynamic_cast<RouteTimeAxisView*> (_time_axis_views[i->time_axis_view]);
                double const dest_layer = i->layer;
 
-               if (rv->region()->locked()
-#ifdef WITH_VIDEOTIMELINE
-                               || rv->region()->video_locked()
-#endif
-                               ) {
+               if (rv->region()->locked() || rv->region()->video_locked()) {
                        ++i;
                        continue;
                }
@@ -1609,8 +1598,6 @@ NoteResizeDrag::aborted (bool)
        }
 }
 
-#ifdef WITH_VIDEOTIMELINE
-
 AVDraggingView::AVDraggingView (RegionView* v)
        : view (v)
 {
@@ -1622,16 +1609,12 @@ VideoTimeLineDrag::VideoTimeLineDrag (Editor* e, ArdourCanvas::Item* i)
 {
        DEBUG_TRACE (DEBUG::Drags, "New VideoTimeLineDrag\n");
 
-       /* create a list of regions to move along */
-#if 1 /* all reagions -- with video_locked() */
        RegionSelection rs;
        TrackViewList empty;
        empty.clear();
        _editor->get_regions_after(rs, (framepos_t) 0, empty);
        std::list<RegionView*> views = rs.by_layer();
-#else /* selected regions -- with video_locked() */
-       std::list<RegionView*> views = _editor->selection->regions.by_layer();
-#endif
+
        for (list<RegionView*>::iterator i = views.begin(); i != views.end(); ++i) {
                RegionView* rv = (*i);
                if (!rv->region()->video_locked()) {
@@ -1682,7 +1665,7 @@ VideoTimeLineDrag::motion (GdkEvent* event, bool first_move)
        }
 
        framecnt_t dt = adjusted_current_frame (event) - raw_grab_frame() + _pointer_frame_offset;
-       dt = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(dt);
+       dt = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(_startdrag_video_offset+dt) - _startdrag_video_offset;
 
        if (_max_backwards_drag >= 0 && dt <= - _max_backwards_drag) {
                dt = - _max_backwards_drag;
@@ -1724,7 +1707,7 @@ VideoTimeLineDrag::motion (GdkEvent* event, bool first_move)
 }
 
 void
-VideoTimeLineDrag::finished (GdkEvent *event, bool movement_occurred)
+VideoTimeLineDrag::finished (GdkEvent * /*event*/, bool movement_occurred)
 {
        if (ARDOUR_UI::instance()->video_timeline->is_offset_locked()) {
                return;
@@ -1751,6 +1734,12 @@ VideoTimeLineDrag::finished (GdkEvent *event, bool movement_occurred)
                _editor->session()->add_command (new StatefulDiffCommand (i->view->region()));
        }
 
+       _editor->session()->maybe_update_session_range(
+                       std::max(ARDOUR_UI::instance()->video_timeline->get_offset(), (ARDOUR::frameoffset_t) 0),
+                       std::max(ARDOUR_UI::instance()->video_timeline->get_offset() + ARDOUR_UI::instance()->video_timeline->get_duration(), (ARDOUR::frameoffset_t) 0)
+                       );
+
+
        _editor->commit_reversible_command ();
        _editor->update_canvas_now ();
 }
@@ -1769,7 +1758,6 @@ VideoTimeLineDrag::aborted (bool)
                i->view->region()->set_position(i->initial_position);
        }
 }
-#endif
 
 TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool preserve_fade_anchor)
        : RegionDrag (e, i, p, v)
@@ -2383,8 +2371,14 @@ CursorDrag::fake_locate (framepos_t t)
        Session* s = _editor->session ();
        if (s->timecode_transmission_suspended ()) {
                framepos_t const f = _editor->playhead_cursor->current_frame;
+               /* This is asynchronous so it will be sent "now"
+                */
                s->send_mmc_locate (f);
-               s->send_full_time_code (f);
+               /* These are synchronous and will be sent during the next
+                  process cycle
+               */
+               s->queue_full_time_code ();
+               s->queue_song_position_pointer ();
        }
 
        show_verbose_cursor_time (t);