mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-10 17:37:45 +02:00
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);
|
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();
|
const double lowerBound = ScrollingLowerBoundTime();
|
||||||
return
|
return
|
||||||
mViewInfo.TimeToPosition(scrollto, 0
|
// Ignoring fisheye is correct here
|
||||||
, true
|
mViewInfo.TimeRangeToPixelWidth(scrollto - lowerBound);
|
||||||
) -
|
|
||||||
mViewInfo.TimeToPosition(lowerBound, 0
|
|
||||||
, true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudacityProject::SetHorizontalThumb(double scrollto)
|
void AudacityProject::SetHorizontalThumb(double scrollto)
|
||||||
{
|
{
|
||||||
wxInt64 max = mHsbar->GetRange() - mHsbar->GetThumbSize();
|
const int max = mHsbar->GetRange() - mHsbar->GetThumbSize();
|
||||||
int pos = std::min(max,
|
const int pos =
|
||||||
std::max(wxInt64(0),
|
std::min(max,
|
||||||
wxInt64(PixelWidthBeforeTime(scrollto) * mViewInfo.sbarScale)));
|
std::max(0,
|
||||||
|
int(floor(0.5 + PixelWidthBeforeTime(scrollto) * mViewInfo.sbarScale))));
|
||||||
mHsbar->SetThumbPosition(pos);
|
mHsbar->SetThumbPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1751,7 +1750,8 @@ void AudacityProject::FixScrollbars()
|
|||||||
int scaledSbarH = (int)(mViewInfo.sbarH * mViewInfo.sbarScale);
|
int scaledSbarH = (int)(mViewInfo.sbarH * mViewInfo.sbarScale);
|
||||||
int scaledSbarScreen = (int)(mViewInfo.sbarScreen * mViewInfo.sbarScale);
|
int scaledSbarScreen = (int)(mViewInfo.sbarScreen * mViewInfo.sbarScale);
|
||||||
int scaledSbarTotal = (int)(mViewInfo.sbarTotal * 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,
|
mHsbar->SetScrollbar(scaledSbarH + offset, scaledSbarScreen, scaledSbarTotal,
|
||||||
scaledSbarScreen, TRUE);
|
scaledSbarScreen, TRUE);
|
||||||
|
@ -384,7 +384,8 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
|||||||
|
|
||||||
double ScrollingLowerBoundTime() const;
|
double ScrollingLowerBoundTime() const;
|
||||||
// How many pixels are covered by the period from lowermost scrollable time, to the given time:
|
// 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);
|
void SetHorizontalThumb(double scrollto);
|
||||||
|
|
||||||
// TrackPanel access
|
// TrackPanel access
|
||||||
|
@ -67,6 +67,13 @@ wxInt64 ZoomInfo::TimeToPosition(double projectTime,
|
|||||||
return t;
|
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
|
bool ZoomInfo::ZoomInAvailable() const
|
||||||
{
|
{
|
||||||
return zoom < gMaxZoom;
|
return zoom < gMaxZoom;
|
||||||
|
@ -62,6 +62,10 @@ public:
|
|||||||
, bool ignoreFisheye = false
|
, bool ignoreFisheye = false
|
||||||
) const;
|
) 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
|
double OffsetTimeByPixels(double time, wxInt64 offset, bool ignoreFisheye = false) const
|
||||||
{
|
{
|
||||||
return PositionToTime(offset + TimeToPosition(time, ignoreFisheye), ignoreFisheye);
|
return PositionToTime(offset + TimeToPosition(time, ignoreFisheye), ignoreFisheye);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user