From 7eb5767a4693b68469f4f507e4a91d8d88ac1946 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 10 Oct 2013 15:03:41 +0100 Subject: [PATCH] Small tidy-up. --- src/wx/timeline.cc | 90 +++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 1f0aee4e8..def52ad9d 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -590,61 +590,63 @@ Timeline::set_position_from_event (wxMouseEvent& ev) _first_move = true; } - if (_down_view) { - Time new_position = _down_view_position + (p.x - _down_point.x) / _pixels_per_time_unit; + if (!_down_view) { + return; + } + + Time new_position = _down_view_position + (p.x - _down_point.x) / _pixels_per_time_unit; + + if (_snap) { - if (_snap) { - - bool first = true; - Time nearest_distance = TIME_MAX; - Time nearest_new_position = TIME_MAX; + bool first = true; + Time nearest_distance = TIME_MAX; + Time nearest_new_position = TIME_MAX; + + /* Find the nearest content edge; this is inefficient */ + for (ViewList::iterator i = _views.begin(); i != _views.end(); ++i) { + shared_ptr cv = dynamic_pointer_cast (*i); + if (!cv || cv == _down_view) { + continue; + } - /* Find the nearest content edge; this is inefficient */ - for (ViewList::iterator i = _views.begin(); i != _views.end(); ++i) { - shared_ptr cv = dynamic_pointer_cast (*i); - if (!cv || cv == _down_view) { - continue; - } - - { - /* Snap starts to ends */ - Time const d = abs (cv->content()->end() - new_position); - if (first || d < nearest_distance) { - nearest_distance = d; - nearest_new_position = cv->content()->end(); - } + { + /* Snap starts to ends */ + Time const d = abs (cv->content()->end() - new_position); + if (first || d < nearest_distance) { + nearest_distance = d; + nearest_new_position = cv->content()->end(); } - - { - /* Snap ends to starts */ - Time const d = abs (cv->content()->position() - (new_position + _down_view->content()->length_after_trim())); - if (d < nearest_distance) { - nearest_distance = d; - nearest_new_position = cv->content()->position() - _down_view->content()->length_after_trim (); - } - } - - first = false; } - - if (!first) { - /* Snap if it's close; `close' means within a proportion of the time on the timeline */ - if (nearest_distance < (width() / pixels_per_time_unit()) / 32) { - new_position = nearest_new_position; + + { + /* Snap ends to starts */ + Time const d = abs (cv->content()->position() - (new_position + _down_view->content()->length_after_trim())); + if (d < nearest_distance) { + nearest_distance = d; + nearest_new_position = cv->content()->position() - _down_view->content()->length_after_trim (); } } + + first = false; } - if (new_position < 0) { - new_position = 0; + if (!first) { + /* Snap if it's close; `close' means within a proportion of the time on the timeline */ + if (nearest_distance < (width() / pixels_per_time_unit()) / 32) { + new_position = nearest_new_position; + } } + } - _down_view->content()->set_position (new_position); - - shared_ptr film = _film.lock (); - assert (film); - film->set_sequence_video (false); + if (new_position < 0) { + new_position = 0; } + + _down_view->content()->set_position (new_position); + + shared_ptr film = _film.lock (); + assert (film); + film->set_sequence_video (false); } void -- 2.30.2