Merge branch 'bug1197'
This commit is contained in:
commit
c9fa5000fc
|
@ -1560,24 +1560,23 @@ double AudacityProject::ScrollingLowerBoundTime() const
|
|||
return std::min(mTracks->GetStartTime(), -screen / 2.0);
|
||||
}
|
||||
|
||||
wxInt64 AudacityProject::PixelWidthBeforeTime(double scrollto) const
|
||||
// PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac
|
||||
// That's why ViewInfo::TimeRangeToPixelWidth was defined, with some regret.
|
||||
double AudacityProject::PixelWidthBeforeTime(double scrollto) const
|
||||
{
|
||||
const double lowerBound = ScrollingLowerBoundTime();
|
||||
return
|
||||
mViewInfo.TimeToPosition(scrollto, 0
|
||||
, true
|
||||
) -
|
||||
mViewInfo.TimeToPosition(lowerBound, 0
|
||||
, true
|
||||
);
|
||||
// Ignoring fisheye is correct here
|
||||
mViewInfo.TimeRangeToPixelWidth(scrollto - lowerBound);
|
||||
}
|
||||
|
||||
void AudacityProject::SetHorizontalThumb(double scrollto)
|
||||
{
|
||||
wxInt64 max = mHsbar->GetRange() - mHsbar->GetThumbSize();
|
||||
int pos = std::min(max,
|
||||
std::max(wxInt64(0),
|
||||
wxInt64(PixelWidthBeforeTime(scrollto) * mViewInfo.sbarScale)));
|
||||
const int max = mHsbar->GetRange() - mHsbar->GetThumbSize();
|
||||
const int pos =
|
||||
std::min(max,
|
||||
std::max(0,
|
||||
int(floor(0.5 + PixelWidthBeforeTime(scrollto) * mViewInfo.sbarScale))));
|
||||
mHsbar->SetThumbPosition(pos);
|
||||
}
|
||||
|
||||
|
@ -1751,7 +1750,8 @@ void AudacityProject::FixScrollbars()
|
|||
int scaledSbarH = (int)(mViewInfo.sbarH * mViewInfo.sbarScale);
|
||||
int scaledSbarScreen = (int)(mViewInfo.sbarScreen * mViewInfo.sbarScale);
|
||||
int scaledSbarTotal = (int)(mViewInfo.sbarTotal * mViewInfo.sbarScale);
|
||||
const int offset = mViewInfo.sbarScale * PixelWidthBeforeTime(0.0);
|
||||
const int offset =
|
||||
int(floor(0.5 + mViewInfo.sbarScale * PixelWidthBeforeTime(0.0)));
|
||||
|
||||
mHsbar->SetScrollbar(scaledSbarH + offset, scaledSbarScreen, scaledSbarTotal,
|
||||
scaledSbarScreen, TRUE);
|
||||
|
|
|
@ -384,7 +384,8 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
|||
|
||||
double ScrollingLowerBoundTime() const;
|
||||
// How many pixels are covered by the period from lowermost scrollable time, to the given time:
|
||||
wxInt64 PixelWidthBeforeTime(double scrollto) const;
|
||||
// PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac
|
||||
double PixelWidthBeforeTime(double scrollto) const;
|
||||
void SetHorizontalThumb(double scrollto);
|
||||
|
||||
// TrackPanel access
|
||||
|
|
|
@ -67,6 +67,13 @@ wxInt64 ZoomInfo::TimeToPosition(double projectTime,
|
|||
return t;
|
||||
}
|
||||
|
||||
// This always ignores the fisheye. Use with caution!
|
||||
// You should prefer to call TimeToPosition twice, for endpoints, and take the difference!
|
||||
double ZoomInfo::TimeRangeToPixelWidth(double timeRange) const
|
||||
{
|
||||
return timeRange * zoom;
|
||||
}
|
||||
|
||||
bool ZoomInfo::ZoomInAvailable() const
|
||||
{
|
||||
return zoom < gMaxZoom;
|
||||
|
|
|
@ -62,6 +62,10 @@ public:
|
|||
, bool ignoreFisheye = false
|
||||
) const;
|
||||
|
||||
// This always ignores the fisheye. Use with caution!
|
||||
// You should prefer to call TimeToPosition twice, for endpoints, and take the difference!
|
||||
double TimeRangeToPixelWidth(double timeRange) const;
|
||||
|
||||
double OffsetTimeByPixels(double time, wxInt64 offset, bool ignoreFisheye = false) const
|
||||
{
|
||||
return PositionToTime(offset + TimeToPosition(time, ignoreFisheye), ignoreFisheye);
|
||||
|
|
Loading…
Reference in New Issue