Put the scroll-beyond-zero flag in just one place, ViewInfo

This commit is contained in:
Paul Licameli 2015-08-26 23:17:20 -04:00
parent d635ff36c4
commit 6c6fc360ca
7 changed files with 21 additions and 15 deletions

View File

@ -4955,7 +4955,7 @@ void AudacityProject::OnZoomNormal()
void AudacityProject::OnZoomFit()
{
const double end = mTracks->GetEndTime();
const double start = mScrollBeyondZero
const double start = mViewInfo.bScrollBeyondZero
? std::min(mTracks->GetStartTime(), 0.0)
: 0;
const double len = end - start;

View File

@ -780,7 +780,6 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
mIsDeleting(false),
mTracksFitVerticallyZoomed(false), //lda
mShowId3Dialog(true), //lda
mScrollBeyondZero(false),
mLastFocusedWindow(NULL),
mKeyboardCaptureHandler(NULL),
mImportXMLTagHandler(NULL),
@ -1052,9 +1051,6 @@ AudioIOStartStreamOptions AudacityProject::GetDefaultPlayOptions()
void AudacityProject::UpdatePrefsVariables()
{
#ifdef EXPERIMENTAL_SCROLLING_LIMITS
gPrefs->Read(wxT("/GUI/ScrollBeyondZero"), &mScrollBeyondZero, false);
#endif
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true);
gPrefs->Read(wxT("/AudioFiles/NormalizeOnLoad"),&mNormalizeOnLoad, false);
gPrefs->Read(wxT("/GUI/AutoScroll"), &mViewInfo.bUpdateTrackIndicator, true);
@ -1474,7 +1470,7 @@ void AudacityProject::OnScrollRightButton(wxScrollEvent & event)
double AudacityProject::ScrollingLowerBoundTime() const
{
if (!mScrollBeyondZero)
if (!mViewInfo.bScrollBeyondZero)
return 0;
const double screen = mTrackPanel->GetScreenEndTime() - mViewInfo.h;
return std::min(mTracks->GetStartTime(), -screen / 2.0);
@ -1583,7 +1579,7 @@ void AudacityProject::FixScrollbars()
// may be scrolled to the midline.
// May add even more to the end, so that you can always scroll the starting time to zero.
const double lowerBound = ScrollingLowerBoundTime();
const double additional = mScrollBeyondZero
const double additional = mViewInfo.bScrollBeyondZero
? -lowerBound + std::max(halfScreen, screen - LastTime)
: screen / 4.0;
@ -1921,7 +1917,7 @@ void AudacityProject::OnScroll(wxScrollEvent & WXUNUSED(event))
}
if (mScrollBeyondZero) {
if (mViewInfo.bScrollBeyondZero) {
enum { SCROLL_PIXEL_TOLERANCE = 10 };
if (std::abs(mViewInfo.TimeToPosition(0.0, 0
)) < SCROLL_PIXEL_TOLERANCE) {

View File

@ -606,8 +606,6 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
bool mShowId3Dialog; //lda
bool mEmptyCanBeDirty;
bool mScrollBeyondZero;
bool mSelectAllOnNone;
bool mIsSyncLocked;

View File

@ -888,9 +888,6 @@ void TrackPanel::UpdateVirtualStereoOrder()
void TrackPanel::UpdatePrefs()
{
#ifdef EXPERIMENTAL_SCROLLING_LIMITS
gPrefs->Read(wxT("/GUI/ScrollBeyondZero"), &mScrollBeyondZero, false);
#endif
gPrefs->Read(wxT("/GUI/AutoScroll"), &mViewInfo->bUpdateTrackIndicator,
true);
gPrefs->Read(wxT("/GUI/AdjustSelectionEdges"), &mAdjustSelectionEdges,
@ -7527,7 +7524,7 @@ void TrackPanel::TimerUpdateScrubbing(double playPos)
const int deltaX = posX - width / 2;
mViewInfo->h =
mViewInfo->OffsetTimeByPixels(mViewInfo->h, deltaX, true);
if (!mScrollBeyondZero)
if (!mViewInfo->bScrollBeyondZero)
// Can't scroll too far left
mViewInfo->h = std::max(0.0, mViewInfo->h);
Refresh(false);

View File

@ -808,7 +808,6 @@ protected:
enum MouseCaptureEnum mMouseCapture;
virtual void SetCapturedTrack( Track * t, enum MouseCaptureEnum MouseCapture=IsUncaptured );
bool mScrollBeyondZero;
bool mAdjustSelectionEdges;
bool mSlideUpDownOnly;
bool mCircularTrackNavigation;

View File

@ -9,6 +9,7 @@ Paul Licameli
**********************************************************************/
#include "ViewInfo.h"
#include "Experimental.h"
#include <algorithm>
@ -110,7 +111,18 @@ ViewInfo::ViewInfo(double start, double screenDuration, double pixelsPerSecond)
, sbarScale(1.0)
, scrollStep(16)
, bUpdateTrackIndicator(true)
, bScrollBeyondZero(false)
{
UpdatePrefs();
}
void ViewInfo::UpdatePrefs()
{
ZoomInfo::UpdatePrefs();
#ifdef EXPERIMENTAL_SCROLLING_LIMITS
gPrefs->Read(wxT("/GUI/ScrollBeyondZero"), &bScrollBeyondZero, false);
#endif
}
void ViewInfo::SetBeforeScreenWidth(wxInt64 beforeWidth, wxInt64 screenWidth, double lowerBoundTime)

View File

@ -130,6 +130,8 @@ class AUDACITY_DLL_API ViewInfo
public:
ViewInfo(double start, double screenDuration, double pixelsPerSecond);
void UpdatePrefs();
double GetBeforeScreenWidth() const
{
return h * zoom;
@ -167,6 +169,8 @@ public:
bool bUpdateTrackIndicator;
bool bScrollBeyondZero;
void WriteXMLAttributes(XMLWriter &xmlFile);
bool ReadXMLAttribute(const wxChar *attr, const wxChar *value);
};