From c22c3fc31e544c1776a2f2ba6f63bb5b51477a65 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 15 Jan 2010 23:19:46 +0000 Subject: [PATCH] Hopefully further improve the autoscroll on trim drag. git-svn-id: svn://localhost/ardour2/branches/3.0@6500 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_drag.cc | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) 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); }