From ccc9147af71ea93195b10e0f6de040fff9ae7746 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 29 Apr 2015 22:17:16 +0100 Subject: [PATCH] Hand-apply 2ee558ec90623b570360e8e55c918b5bb37f9aac from master; various snapping fixes. --- ChangeLog | 5 +++++ TO_PORT | 1 - src/wx/timeline.cc | 21 +++++++++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9375527c..5c3522869 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-04-29 Carl Hetherington + + * Various fixes to bad timeline drag behaviour when + snapping (from master). + 2015-04-29 c.hetherington * Hand-apply 291179175729b62e17a9c322cd27ae134d1310d9, diff --git a/TO_PORT b/TO_PORT index 0449d9157..d92f7b500 100644 --- a/TO_PORT +++ b/TO_PORT @@ -1,4 +1,3 @@ -1114df4c0d2167f6b7b394bfbf85890cd0a4a3e3 03bee41ebb15a9ddd61af1607426d22d906ad226 6cb9a4fd6b8ec1141bffa9294347e80baa3445dd 8471ccb29ff258722ea27405dc10312e625c132d diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 2c032b8d3..9c70a001e 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -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 cv = dynamic_pointer_cast (*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) { -- 2.30.2