mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-19 17:40:51 +02:00
Bug 986 and other changes for more consistent zoom all and zoom fit...
... when there is audio before time zero.
This commit is contained in:
parent
6e1f76d60d
commit
c84eeabe97
@ -4986,7 +4986,11 @@ void AudacityProject::OnZoomNormal()
|
||||
|
||||
void AudacityProject::OnZoomFit()
|
||||
{
|
||||
double len = mTracks->GetEndTime();
|
||||
const double end = mTracks->GetEndTime();
|
||||
const double start = mScrollBeyondZero
|
||||
? std::min(mTracks->GetStartTime(), 0.0)
|
||||
: 0;
|
||||
const double len = end - start;
|
||||
|
||||
if (len <= 0.0)
|
||||
return;
|
||||
@ -4996,7 +5000,7 @@ void AudacityProject::OnZoomFit()
|
||||
w -= 10;
|
||||
|
||||
Zoom(w / len);
|
||||
TP_ScrollWindow(0.0);
|
||||
TP_ScrollWindow(start);
|
||||
}
|
||||
|
||||
void AudacityProject::DoZoomFitV()
|
||||
@ -5049,7 +5053,11 @@ void AudacityProject::OnZoomFitV()
|
||||
|
||||
void AudacityProject::OnZoomSel()
|
||||
{
|
||||
if (mViewInfo.selectedRegion.isPoint())
|
||||
const double lowerBound =
|
||||
std::max(mViewInfo.selectedRegion.t0(), ScrollingLowerBoundTime());
|
||||
const double denom =
|
||||
mViewInfo.selectedRegion.t1() - lowerBound;
|
||||
if (denom <= 0.0)
|
||||
return;
|
||||
|
||||
// LL: The "-1" is just a hack to get around an issue where zooming to
|
||||
@ -5058,8 +5066,7 @@ void AudacityProject::OnZoomSel()
|
||||
// where the selected region may be scrolled off the left of the screen.
|
||||
// I know this isn't right, but until the real rounding or 1-off issue is
|
||||
// found, this will have to work.
|
||||
Zoom(((mViewInfo.zoom * mViewInfo.screen) - 1) /
|
||||
(mViewInfo.selectedRegion.t1() - mViewInfo.selectedRegion.t0()));
|
||||
Zoom(((mViewInfo.zoom * mViewInfo.screen) - 1) / denom);
|
||||
TP_ScrollWindow(mViewInfo.selectedRegion.t0());
|
||||
}
|
||||
|
||||
|
@ -1459,9 +1459,16 @@ void AudacityProject::OnScrollRightButton(wxScrollEvent & event)
|
||||
}
|
||||
|
||||
|
||||
double AudacityProject::ScrollingLowerBoundTime() const
|
||||
{
|
||||
return mScrollBeyondZero
|
||||
? std::min(mTracks->GetStartTime(), -mViewInfo.screen / 2.0)
|
||||
: 0;
|
||||
}
|
||||
|
||||
void AudacityProject::SetHorizontalThumb(double scrollto)
|
||||
{
|
||||
const double timeOffset = mScrollBeyondZero ? mViewInfo.screen / 2.0 : 0;
|
||||
const double timeOffset = -ScrollingLowerBoundTime();
|
||||
int pos = (int) (
|
||||
(scrollto + timeOffset) * mViewInfo.zoom * mViewInfo.sbarScale
|
||||
);
|
||||
@ -1544,10 +1551,10 @@ void AudacityProject::FixScrollbars()
|
||||
// so that any point within the union of the selection and the track duration
|
||||
// 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
|
||||
? halfScreen + std::max(halfScreen, mViewInfo.screen - LastTime)
|
||||
? -lowerBound + std::max(halfScreen, mViewInfo.screen - LastTime)
|
||||
: mViewInfo.screen / 4.0;
|
||||
const double lowerBound = mScrollBeyondZero ? -halfScreen : 0.0;
|
||||
|
||||
mViewInfo.total = LastTime + additional;
|
||||
|
||||
@ -1823,11 +1830,8 @@ void AudacityProject::OnScroll(wxScrollEvent & WXUNUSED(event))
|
||||
{
|
||||
const wxInt64 hlast = mViewInfo.sbarH;
|
||||
|
||||
const wxInt64 offset = mScrollBeyondZero
|
||||
? (0.5 + (mViewInfo.zoom * mViewInfo.screen / 2.0))
|
||||
: 0.0;
|
||||
const double lowerBound = mScrollBeyondZero
|
||||
? -mViewInfo.screen / 2.0 : 0.0;
|
||||
const double lowerBound = ScrollingLowerBoundTime();
|
||||
const wxInt64 offset = 0.5 + -lowerBound * mViewInfo.zoom;
|
||||
|
||||
mViewInfo.sbarH =
|
||||
(wxInt64)(mHsbar->GetThumbPosition() / mViewInfo.sbarScale) - offset;
|
||||
|
@ -348,6 +348,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
|
||||
void SafeDisplayStatusMessage(const wxChar *msg);
|
||||
|
||||
double ScrollingLowerBoundTime() const;
|
||||
void SetHorizontalThumb(double scrollto);
|
||||
|
||||
// TrackPanel access
|
||||
|
Loading…
x
Reference in New Issue
Block a user