Hand-apply 2ee558ec90623b570360e8e55c918b5bb37f9aac from master; various snapping...
authorCarl Hetherington <cth@carlh.net>
Wed, 29 Apr 2015 21:17:16 +0000 (22:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Apr 2015 21:17:16 +0000 (22:17 +0100)
ChangeLog
TO_PORT
src/wx/timeline.cc

index d9375527ccf8274c296d2dc61d13df273e4f45ee..5c352286996ba8c76ce09c5fd3e69f73c0d74413 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-29  Carl Hetherington  <cth@carlh.net>
+
+       * Various fixes to bad timeline drag behaviour when
+       snapping (from master).
+
 2015-04-29  c.hetherington  <cth@carlh.net>
 
        * Hand-apply 291179175729b62e17a9c322cd27ae134d1310d9,
diff --git a/TO_PORT b/TO_PORT
index 0449d9157ee7709a7baf0ea7f4c4f7e5fe5edabc..d92f7b500033737db652f1606ccb5249e3005656 100644 (file)
--- a/TO_PORT
+++ b/TO_PORT
@@ -1,4 +1,3 @@
-1114df4c0d2167f6b7b394bfbf85890cd0a4a3e3
 03bee41ebb15a9ddd61af1607426d22d906ad226
 6cb9a4fd6b8ec1141bffa9294347e80baa3445dd
 8471ccb29ff258722ea27405dc10312e625c132d
index 2c032b8d33dee556f00f43a64e696adab3c5082b..9c70a001e0bc2709ebfea53cfe91fa02568056a6 100644 (file)
@@ -137,7 +137,10 @@ Timeline::playlist_content_changed (int property)
 
        if (property == ContentProperty::POSITION) {
                assign_tracks ();
-               setup_pixels_per_second ();
+               if (!_left_down) {
+                       /* Only do this if we are not dragging, as it's confusing otherwise */
+                       setup_pixels_per_second ();
+               }
                Refresh ();
        } else if (property == AudioContentProperty::AUDIO_MAPPING) {
                recreate_views ();
@@ -286,6 +289,12 @@ Timeline::left_up (wxMouseEvent& ev)
        }
 
        set_position_from_event (ev);
+
+       /* We don't do this during drag, and set_position_from_event above
+          might not have changed the position, so do it now.
+       */
+       setup_pixels_per_second ();
+       Refresh ();
 }
 
 void
@@ -354,7 +363,7 @@ Timeline::set_position_from_event (wxMouseEvent& ev)
        
        if (_snap) {
 
-               DCPTime const new_end = new_position + _down_view->content()->length_after_trim ();
+               DCPTime const new_end = new_position + _down_view->content()->length_after_trim () - 1;
                /* Signed `distance' to nearest thing (i.e. negative is left on the timeline,
                   positive is right).
                */
@@ -363,14 +372,14 @@ Timeline::set_position_from_event (wxMouseEvent& ev)
                /* Find the nearest content edge; this is inefficient */
                for (TimelineViewList::iterator i = _views.begin(); i != _views.end(); ++i) {
                        shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView> (*i);
-                       if (!cv || cv == _down_view) {
+                       if (!cv || cv == _down_view || cv->content() == _down_view->content()) {
                                continue;
                        }
 
                        maybe_snap (cv->content()->position(), new_position, nearest_distance);
-                       maybe_snap (cv->content()->position(), new_end, nearest_distance);
-                       maybe_snap (cv->content()->end(), new_position, nearest_distance);
-                       maybe_snap (cv->content()->end(), new_end, nearest_distance);
+                       maybe_snap (cv->content()->position(), new_end + 1, nearest_distance);
+                       maybe_snap (cv->content()->end() + 1, new_position, nearest_distance);
+                       maybe_snap (cv->content()->end() + 1, new_end, nearest_distance);
                }
                
                if (nearest_distance) {