1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-08 16:11:14 +02:00

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() void AudacityProject::OnZoomFit()
{ {
const double end = mTracks->GetEndTime(); const double end = mTracks->GetEndTime();
const double start = mScrollBeyondZero const double start = mViewInfo.bScrollBeyondZero
? std::min(mTracks->GetStartTime(), 0.0) ? std::min(mTracks->GetStartTime(), 0.0)
: 0; : 0;
const double len = end - start; const double len = end - start;

View File

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

View File

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

View File

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

View File

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

View File

@ -9,6 +9,7 @@ Paul Licameli
**********************************************************************/ **********************************************************************/
#include "ViewInfo.h" #include "ViewInfo.h"
#include "Experimental.h"
#include <algorithm> #include <algorithm>
@ -110,7 +111,18 @@ ViewInfo::ViewInfo(double start, double screenDuration, double pixelsPerSecond)
, sbarScale(1.0) , sbarScale(1.0)
, scrollStep(16) , scrollStep(16)
, bUpdateTrackIndicator(true) , 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) void ViewInfo::SetBeforeScreenWidth(wxInt64 beforeWidth, wxInt64 screenWidth, double lowerBoundTime)

View File

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