diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 33b4b77f88..ab5aa45cb3 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -1897,16 +1897,31 @@ TrimDrag::aborted () pair TrimDrag::extent () const { - pair e = make_pair (INT64_MAX, 0); - - for (list::const_iterator i = _views.begin(); i != _views.end(); ++i) { - boost::shared_ptr r = (*i)->region (); - pair const t = make_pair (r->position(), r->position() + r->length ()); - e.first = min (e.first, t.first); - e.second = max (e.second, t.second); - } + /* we only want to autoscroll to keep the most `outward' region edge on-screen, + not the whole region(s) that is/are being trimmed. + */ - return e; + nframes64_t f = 0; + + switch (_operation) { + case StartTrim: + f = INT64_MAX; + for (list::const_iterator i = _views.begin(); i != _views.end(); ++i) { + f = min (f, (nframes64_t) (*i)->region()->position()); + } + break; + case ContentsTrim: + f = adjusted_current_frame (0); + break; + case EndTrim: + f = 0; + for (list::const_iterator i = _views.begin(); i != _views.end(); ++i) { + f = max (f, (nframes64_t) (*i)->region()->position() + (*i)->region()->length()); + } + break; + } + + return make_pair (f, f); }