From eee58d944907f3b0e31693b1d094c3785d40f912 Mon Sep 17 00:00:00 2001 From: James Crook Date: Sat, 5 Aug 2017 17:46:52 +0100 Subject: [PATCH] Bug 1292 - Enh: Zoom Normal (Ctrl+2) may move selection off screen Selection is now centred after any zoom, if it will fit on screen. --- src/Project.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Project.cpp b/src/Project.cpp index 144079c8f..b0a346ceb 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -4673,6 +4673,16 @@ void AudacityProject::Zoom(double level) { mViewInfo.SetZoom(level); FixScrollbars(); + // See if we can center the selection on screen, and have it actually fit. + // tOnLeft is the amount of time we would need before the selection left edge to center it. + float t0 = mViewInfo.selectedRegion.t0(); + float t1 = mViewInfo.selectedRegion.t1(); + float tAvailable = GetScreenEndTime() - mViewInfo.h; + float tOnLeft = (tAvailable - t0 + t1)/2.0; + // Bug 1292 (Enh) is effectively a request to do this scrolling of the selection into view. + // If tOnLeft is positive, then we have room for the selection, so scroll to it. + if( tOnLeft >=0 ) + TP_ScrollWindow( t0-tOnLeft); } // Utility function called by other zoom methods