mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +02:00
ViewInfo does not redundantly (or inconsistently!) store the screen width
This commit is contained in:
parent
a9ab31dedb
commit
1b8f44d053
@ -4824,6 +4824,11 @@ void AudacityProject::OnZoomIn()
|
||||
ZoomInByFactor( 2.0 );
|
||||
}
|
||||
|
||||
double AudacityProject::GetScreenEndTime() const
|
||||
{
|
||||
return mTrackPanel->GetScreenEndTime();
|
||||
}
|
||||
|
||||
void AudacityProject::ZoomInByFactor( double ZoomFactor )
|
||||
{
|
||||
// LLL: Handling positioning differently when audio is active
|
||||
@ -4838,13 +4843,16 @@ void AudacityProject::ZoomInByFactor( double ZoomFactor )
|
||||
// when there's a selection that's currently at least
|
||||
// partially on-screen
|
||||
|
||||
const double endTime = GetScreenEndTime();
|
||||
const double duration = endTime - mViewInfo.h;
|
||||
|
||||
bool selectionIsOnscreen =
|
||||
(mViewInfo.selectedRegion.t0() < mViewInfo.h + mViewInfo.screen) &&
|
||||
(mViewInfo.selectedRegion.t0() < endTime) &&
|
||||
(mViewInfo.selectedRegion.t1() >= mViewInfo.h);
|
||||
|
||||
bool selectionFillsScreen =
|
||||
(mViewInfo.selectedRegion.t0() < mViewInfo.h) &&
|
||||
(mViewInfo.selectedRegion.t1() > mViewInfo.h + mViewInfo.screen);
|
||||
(mViewInfo.selectedRegion.t1() > endTime);
|
||||
|
||||
if (selectionIsOnscreen && !selectionFillsScreen) {
|
||||
// Start with the center of the selection
|
||||
@ -4856,24 +4864,26 @@ void AudacityProject::ZoomInByFactor( double ZoomFactor )
|
||||
if (selCenter < mViewInfo.h)
|
||||
selCenter = mViewInfo.h +
|
||||
(mViewInfo.selectedRegion.t1() - mViewInfo.h) / 2;
|
||||
if (selCenter > mViewInfo.h + mViewInfo.screen)
|
||||
selCenter = mViewInfo.h + mViewInfo.screen -
|
||||
(mViewInfo.h + mViewInfo.screen - mViewInfo.selectedRegion.t0()) / 2;
|
||||
if (selCenter > endTime)
|
||||
selCenter = endTime -
|
||||
(endTime - mViewInfo.selectedRegion.t0()) / 2;
|
||||
|
||||
// Zoom in
|
||||
ZoomBy(ZoomFactor);
|
||||
const double newDuration = GetScreenEndTime() - mViewInfo.h;
|
||||
|
||||
// Recenter on selCenter
|
||||
TP_ScrollWindow(selCenter - mViewInfo.screen / 2);
|
||||
TP_ScrollWindow(selCenter - newDuration / 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
double origLeft = mViewInfo.h;
|
||||
double origWidth = mViewInfo.screen;
|
||||
double origWidth = duration;
|
||||
ZoomBy(ZoomFactor);
|
||||
|
||||
double newh = origLeft + (origWidth - mViewInfo.screen) / 2;
|
||||
const double newDuration = GetScreenEndTime() - mViewInfo.h;
|
||||
double newh = origLeft + (origWidth - newDuration) / 2;
|
||||
|
||||
// MM: Commented this out because it was confusing users
|
||||
/*
|
||||
@ -4900,12 +4910,13 @@ void AudacityProject::OnZoomOut()
|
||||
void AudacityProject::ZoomOutByFactor( double ZoomFactor )
|
||||
{
|
||||
//Zoom() may change these, so record original values:
|
||||
double origLeft = mViewInfo.h;
|
||||
double origWidth = mViewInfo.screen;
|
||||
const double origLeft = mViewInfo.h;
|
||||
const double origWidth = GetScreenEndTime() - origLeft;
|
||||
|
||||
ZoomBy(ZoomFactor);
|
||||
const double newWidth = GetScreenEndTime() - mViewInfo.h;
|
||||
|
||||
double newh = origLeft + (origWidth - mViewInfo.screen) / 2;
|
||||
const double newh = origLeft + (origWidth - newWidth) / 2;
|
||||
// newh = (newh > 0) ? newh : 0;
|
||||
TP_ScrollWindow(newh);
|
||||
|
||||
@ -5023,7 +5034,10 @@ 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.GetScreenWidth() - 1) / denom);
|
||||
// PRL: Did I fix this? I am not sure, so I leave the hack in place.
|
||||
int width;
|
||||
mTrackPanel->GetTracksUsableArea(&width, NULL);
|
||||
Zoom((width - 1) / denom);
|
||||
TP_ScrollWindow(mViewInfo.selectedRegion.t0());
|
||||
}
|
||||
|
||||
@ -5032,7 +5046,7 @@ void AudacityProject::OnGoSelStart()
|
||||
if (mViewInfo.selectedRegion.isPoint())
|
||||
return;
|
||||
|
||||
TP_ScrollWindow(mViewInfo.selectedRegion.t0() - (mViewInfo.screen / 2));
|
||||
TP_ScrollWindow(mViewInfo.selectedRegion.t0() - ((GetScreenEndTime() - mViewInfo.h) / 2));
|
||||
}
|
||||
|
||||
void AudacityProject::OnGoSelEnd()
|
||||
@ -5040,7 +5054,7 @@ void AudacityProject::OnGoSelEnd()
|
||||
if (mViewInfo.selectedRegion.isPoint())
|
||||
return;
|
||||
|
||||
TP_ScrollWindow(mViewInfo.selectedRegion.t1() - (mViewInfo.screen / 2));
|
||||
TP_ScrollWindow(mViewInfo.selectedRegion.t1() - ((GetScreenEndTime() - mViewInfo.h) / 2));
|
||||
}
|
||||
|
||||
void AudacityProject::OnShowClipping()
|
||||
|
@ -80,7 +80,7 @@ bool AudacityPrintout::OnPrintPage(int WXUNUSED(page))
|
||||
artist.SetBackgroundBrushes(*wxWHITE_BRUSH, *wxWHITE_BRUSH,
|
||||
*wxWHITE_PEN, *wxWHITE_PEN);
|
||||
const double screenDuration = mTracks->GetEndTime();
|
||||
ZoomInfo zoomInfo(0.0, screenDuration, width / screenDuration);
|
||||
ZoomInfo zoomInfo(0.0, width / screenDuration);
|
||||
int y = rulerPageHeight;
|
||||
|
||||
TrackListIterator iter(mTracks);
|
||||
|
@ -1472,9 +1472,10 @@ void AudacityProject::OnScrollRightButton(wxScrollEvent & event)
|
||||
|
||||
double AudacityProject::ScrollingLowerBoundTime() const
|
||||
{
|
||||
return mScrollBeyondZero
|
||||
? std::min(mTracks->GetStartTime(), -mViewInfo.screen / 2.0)
|
||||
: 0;
|
||||
if (!mScrollBeyondZero)
|
||||
return 0;
|
||||
const double screen = mTrackPanel->GetScreenEndTime() - mViewInfo.h;
|
||||
return std::min(mTracks->GetStartTime(), -screen / 2.0);
|
||||
}
|
||||
|
||||
wxInt64 AudacityProject::PixelWidthBeforeTime(double scrollto) const
|
||||
@ -1556,8 +1557,8 @@ void AudacityProject::FixScrollbars()
|
||||
double LastTime =
|
||||
std::max(mTracks->GetEndTime(), mViewInfo.selectedRegion.t1());
|
||||
|
||||
mViewInfo.SetScreenWidth(panelWidth);
|
||||
const double halfScreen = mViewInfo.screen / 2.0;
|
||||
const double screen = GetScreenEndTime() - mViewInfo.h;
|
||||
const double halfScreen = screen / 2.0;
|
||||
|
||||
// If we can scroll beyond zero,
|
||||
// Add 1/2 of a screen of blank space to the end
|
||||
@ -1567,13 +1568,13 @@ void AudacityProject::FixScrollbars()
|
||||
// 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
|
||||
? -lowerBound + std::max(halfScreen, mViewInfo.screen - LastTime)
|
||||
: mViewInfo.screen / 4.0;
|
||||
? -lowerBound + std::max(halfScreen, screen - LastTime)
|
||||
: screen / 4.0;
|
||||
|
||||
mViewInfo.total = LastTime + additional;
|
||||
|
||||
// Don't remove time from total that's still on the screen
|
||||
mViewInfo.total = std::max(mViewInfo.total, mViewInfo.h + mViewInfo.screen);
|
||||
mViewInfo.total = std::max(mViewInfo.total, mViewInfo.h + screen);
|
||||
|
||||
if (mViewInfo.h < lowerBound) {
|
||||
mViewInfo.h = lowerBound;
|
||||
@ -1581,7 +1582,7 @@ void AudacityProject::FixScrollbars()
|
||||
}
|
||||
|
||||
mViewInfo.sbarTotal = (wxInt64) (mViewInfo.GetTotalWidth());
|
||||
mViewInfo.sbarScreen = (wxInt64) (mViewInfo.GetScreenWidth());
|
||||
mViewInfo.sbarScreen = (wxInt64)(panelWidth);
|
||||
mViewInfo.sbarH = (wxInt64) (mViewInfo.GetBeforeScreenWidth());
|
||||
|
||||
int lastv = mViewInfo.vpos;
|
||||
@ -1603,7 +1604,7 @@ void AudacityProject::FixScrollbars()
|
||||
|
||||
bool oldhstate;
|
||||
bool oldvstate;
|
||||
bool newhstate = !mViewInfo.ZoomedAll();
|
||||
bool newhstate = (GetScreenEndTime() - mViewInfo.h) < mViewInfo.total;
|
||||
bool newvstate = panelHeight < totalHeight;
|
||||
|
||||
#ifdef __WXGTK__
|
||||
@ -1614,7 +1615,7 @@ void AudacityProject::FixScrollbars()
|
||||
#else
|
||||
oldhstate = mHsbar->IsEnabled();
|
||||
oldvstate = mVsbar->IsEnabled();
|
||||
mHsbar->Enable(!mViewInfo.ZoomedAll());
|
||||
mHsbar->Enable(newhstate);
|
||||
mVsbar->Enable(panelHeight < totalHeight);
|
||||
#endif
|
||||
|
||||
@ -1624,7 +1625,7 @@ void AudacityProject::FixScrollbars()
|
||||
refresh = true;
|
||||
rescroll = false;
|
||||
}
|
||||
if (mViewInfo.ZoomedAll() && mViewInfo.sbarH != 0) {
|
||||
if (!newhstate && mViewInfo.sbarH != 0) {
|
||||
mViewInfo.sbarH = 0;
|
||||
|
||||
refresh = true;
|
||||
@ -1666,7 +1667,8 @@ void AudacityProject::FixScrollbars()
|
||||
panelHeight / mViewInfo.scrollStep, TRUE);
|
||||
mVsbar->Refresh();
|
||||
|
||||
if (refresh || (rescroll && !mViewInfo.ZoomedAll())) {
|
||||
if (refresh || (rescroll &&
|
||||
(GetScreenEndTime() - mViewInfo.h) < mViewInfo.total)) {
|
||||
mTrackPanel->Refresh(false);
|
||||
}
|
||||
|
||||
@ -1849,8 +1851,12 @@ void AudacityProject::OnScroll(wxScrollEvent & WXUNUSED(event))
|
||||
mViewInfo.sbarH =
|
||||
(wxInt64)(mHsbar->GetThumbPosition() / mViewInfo.sbarScale) - offset;
|
||||
|
||||
if (mViewInfo.sbarH != hlast)
|
||||
mViewInfo.SetBeforeScreenWidth(mViewInfo.sbarH, lowerBound);
|
||||
if (mViewInfo.sbarH != hlast) {
|
||||
int width;
|
||||
mTrackPanel->GetTracksUsableArea(&width, NULL);
|
||||
mViewInfo.SetBeforeScreenWidth(mViewInfo.sbarH, width, lowerBound);
|
||||
}
|
||||
|
||||
|
||||
if (mScrollBeyondZero) {
|
||||
enum { SCROLL_PIXEL_TOLERANCE = 10 };
|
||||
|
@ -301,6 +301,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
|
||||
void HandleResize();
|
||||
void UpdateLayout();
|
||||
double GetScreenEndTime() const;
|
||||
void ZoomInByFactor( double ZoomFactor );
|
||||
void ZoomOutByFactor( double ZoomFactor );
|
||||
|
||||
|
@ -1663,7 +1663,7 @@ void FindWavePortions
|
||||
// the fisheye.
|
||||
|
||||
ZoomInfo::Intervals intervals;
|
||||
zoomInfo.FindIntervals(params.rate, intervals, rect.x);
|
||||
zoomInfo.FindIntervals(params.rate, intervals, rect.width, rect.x);
|
||||
ZoomInfo::Intervals::const_iterator it = intervals.begin(), end = intervals.end(), prev;
|
||||
wxASSERT(it != end && it->position == rect.x);
|
||||
const int rightmost = rect.x + rect.width;
|
||||
|
@ -1259,6 +1259,13 @@ void TrackPanel::DrawQuickPlayIndicator(wxDC & dc, double pos)
|
||||
}
|
||||
}
|
||||
|
||||
double TrackPanel::GetScreenEndTime() const
|
||||
{
|
||||
int width;
|
||||
GetTracksUsableArea(&width, NULL);
|
||||
return mViewInfo->PositionToTime(width, true);
|
||||
}
|
||||
|
||||
void TrackPanel::TimerUpdateIndicator()
|
||||
{
|
||||
double pos = 0.0;
|
||||
@ -1272,7 +1279,8 @@ void TrackPanel::TimerUpdateIndicator()
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||
if (mSmoothScrollingScrub) {
|
||||
// Pan the view, so that we center the play indicator.
|
||||
mViewInfo->h = pos - mViewInfo->screen / 2.0;
|
||||
const double duration = GetScreenEndTime() - mViewInfo->h;
|
||||
mViewInfo->h = pos - duration / 2.0;
|
||||
if (!mScrollBeyondZero)
|
||||
// Can't scroll too far left
|
||||
mViewInfo->h = std::max(0.0, mViewInfo->h);
|
||||
@ -1283,7 +1291,7 @@ void TrackPanel::TimerUpdateIndicator()
|
||||
const bool
|
||||
onScreen = between_inclusive(mViewInfo->h,
|
||||
pos,
|
||||
mViewInfo->h + mViewInfo->screen);
|
||||
GetScreenEndTime());
|
||||
|
||||
// This displays the audio time, too...
|
||||
DisplaySelection();
|
||||
@ -1326,10 +1334,12 @@ void TrackPanel::UndrawIndicator(wxDC & dc)
|
||||
// Erase the old indicator.
|
||||
if (mLastIndicatorX != -1)
|
||||
{
|
||||
int width;
|
||||
GetTracksUsableArea(&width, NULL);
|
||||
const bool
|
||||
onScreen = between_inclusive(GetLeftOffset(),
|
||||
mLastIndicatorX,
|
||||
GetLeftOffset() + mViewInfo->GetScreenWidth());
|
||||
GetLeftOffset() + width);
|
||||
if (onScreen)
|
||||
{
|
||||
// LL: Keep from trying to blit outsize of the source DC. This results in a crash on
|
||||
@ -1429,9 +1439,11 @@ void TrackPanel::UndrawCursor(wxDC & dc)
|
||||
|
||||
if( mLastCursorX != -1 )
|
||||
{
|
||||
int width;
|
||||
GetTracksUsableArea(&width, NULL);
|
||||
onScreen = between_inclusive(GetLeftOffset(),
|
||||
mLastCursorX,
|
||||
GetLeftOffset() + mViewInfo->GetScreenWidth());
|
||||
GetLeftOffset() + width);
|
||||
if( onScreen )
|
||||
dc.Blit(mLastCursorX, 0, 1, mBacking->GetHeight(), &mBackingDC, mLastCursorX, 0);
|
||||
}
|
||||
@ -1446,7 +1458,7 @@ void TrackPanel::DoDrawCursor(wxDC & dc)
|
||||
const bool
|
||||
onScreen = between_inclusive( mViewInfo->h,
|
||||
mCursorTime,
|
||||
mViewInfo->h + mViewInfo->screen );
|
||||
GetScreenEndTime() );
|
||||
|
||||
if( !onScreen )
|
||||
return;
|
||||
@ -1672,12 +1684,12 @@ void TrackPanel::HandleControlKey(bool down)
|
||||
|
||||
void TrackPanel::HandlePageUpKey()
|
||||
{
|
||||
mListener->TP_ScrollWindow(mViewInfo->h + mViewInfo->screen);
|
||||
mListener->TP_ScrollWindow(GetScreenEndTime());
|
||||
}
|
||||
|
||||
void TrackPanel::HandlePageDownKey()
|
||||
{
|
||||
mListener->TP_ScrollWindow(mViewInfo->h - mViewInfo->screen);
|
||||
mListener->TP_ScrollWindow(2 * mViewInfo->h - GetScreenEndTime());
|
||||
}
|
||||
|
||||
void TrackPanel::HandleCursorForLastMouseEvent()
|
||||
@ -2316,7 +2328,7 @@ double TrackPanel::FindScrubSpeed(double timeAtMouse) const
|
||||
// and the extremes to the maximum scrub speed.
|
||||
|
||||
// Width of visible track area, in time terms:
|
||||
const double screen = mViewInfo->screen;
|
||||
const double screen = GetScreenEndTime() - mViewInfo->h;
|
||||
const double origin = mViewInfo->h + screen / 2.0;
|
||||
|
||||
// There are various snapping zones that are this fraction of screen:
|
||||
@ -2363,7 +2375,7 @@ double TrackPanel::FindSeekSpeed(double timeAtMouse) const
|
||||
const double extreme = std::max(1.0, mMaxScrubSpeed * ARBITRARY_MULTIPLIER);
|
||||
|
||||
// Width of visible track area, in time terms:
|
||||
const double screen = mViewInfo->screen;
|
||||
const double screen = GetScreenEndTime() - mViewInfo->h;
|
||||
const double halfScreen = screen / 2.0;
|
||||
const double origin = mViewInfo->h + halfScreen;
|
||||
|
||||
@ -4463,11 +4475,8 @@ void TrackPanel::HandleZoomDrag(wxMouseEvent & event)
|
||||
/// Zoom button up
|
||||
void TrackPanel::HandleZoomButtonUp(wxMouseEvent & event)
|
||||
{
|
||||
if (mZoomEnd < mZoomStart) {
|
||||
int temp = mZoomEnd;
|
||||
mZoomEnd = mZoomStart;
|
||||
mZoomStart = temp;
|
||||
}
|
||||
if (mZoomEnd < mZoomStart)
|
||||
std::swap(mZoomStart, mZoomEnd);
|
||||
|
||||
if (IsDragZooming())
|
||||
DragZoom(event, GetLeftOffset());
|
||||
@ -4501,8 +4510,7 @@ void TrackPanel::DragZoom(wxMouseEvent & event, int trackLeftEdge)
|
||||
{
|
||||
double left = mViewInfo->PositionToTime(mZoomStart, trackLeftEdge);
|
||||
double right = mViewInfo->PositionToTime(mZoomEnd, trackLeftEdge);
|
||||
|
||||
double multiplier = mViewInfo->screen / (right - left);
|
||||
double multiplier = (GetScreenEndTime() - mViewInfo->h) / (right - left);
|
||||
if (event.ShiftDown())
|
||||
multiplier = 1.0 / multiplier;
|
||||
|
||||
@ -4883,14 +4891,14 @@ void TrackPanel::HandleWaveTrackVZoom
|
||||
namespace {
|
||||
// Is the sample horizontally nearest to the cursor sufficiently separated from
|
||||
// its neighbors that the pencil tool should be allowed to drag it?
|
||||
bool SampleResolutionTest(const ViewInfo &viewInfo, const WaveTrack *wt, double time, double rate)
|
||||
bool SampleResolutionTest(const ViewInfo &viewInfo, const WaveTrack *wt, double time, double rate, int width)
|
||||
{
|
||||
// Require more than 3 pixels per sample
|
||||
// Round to an exact sample time
|
||||
const double adjustedTime = wt->LongSamplesToTime(wt->TimeToLongSamples(time));
|
||||
const wxInt64 xx = std::max(wxInt64(0), viewInfo.TimeToPosition(adjustedTime));
|
||||
ZoomInfo::Intervals intervals;
|
||||
viewInfo.FindIntervals(rate, intervals);
|
||||
viewInfo.FindIntervals(rate, intervals, width);
|
||||
ZoomInfo::Intervals::const_iterator it = intervals.begin(), end = intervals.end(), prev;
|
||||
wxASSERT(it != end && it->position == 0);
|
||||
do
|
||||
@ -4932,7 +4940,9 @@ bool TrackPanel::IsSampleEditingPossible( wxMouseEvent &event, Track * t )
|
||||
WaveTrack *const wt = static_cast<WaveTrack*>(t);
|
||||
const double rate = wt->GetRate();
|
||||
const double time = mViewInfo->PositionToTime(event.m_x, rect.x);
|
||||
showPoints = SampleResolutionTest(*mViewInfo, wt, time, rate);
|
||||
int width;
|
||||
GetTracksUsableArea(&width, NULL);
|
||||
showPoints = SampleResolutionTest(*mViewInfo, wt, time, rate, width);
|
||||
}
|
||||
|
||||
//If we aren't zoomed in far enough, show a message dialog.
|
||||
@ -6290,7 +6300,7 @@ void TrackPanel::HandleWheelRotation(wxMouseEvent & event)
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||
if (mSmoothScrollingScrub) {
|
||||
// Expand or contract about the center, ignoring mouse position
|
||||
center_h = mViewInfo->h + mViewInfo->screen / 2.0;
|
||||
center_h = mViewInfo->h + (GetScreenEndTime() - mViewInfo->h) / 2.0;
|
||||
xx = mViewInfo->TimeToPosition(center_h, trackLeftEdge);
|
||||
}
|
||||
else
|
||||
@ -7169,7 +7179,9 @@ bool TrackPanel::HitTestSamples(Track *track, wxRect &rect, wxMouseEvent & event
|
||||
const bool dB = !wavetrack->GetWaveformSettings().isLinear();
|
||||
|
||||
const double tt = mViewInfo->PositionToTime(event.m_x, rect.x);
|
||||
if (!SampleResolutionTest(*mViewInfo, wavetrack, tt, rate))
|
||||
int width;
|
||||
GetTracksUsableArea(&width, NULL);
|
||||
if (!SampleResolutionTest(*mViewInfo, wavetrack, tt, rate, width))
|
||||
return false;
|
||||
|
||||
// Just get one sample.
|
||||
@ -7632,8 +7644,6 @@ void TrackPanel::DrawZooming(wxDC * dc, const wxRect & clip)
|
||||
dc->SetPen(*wxBLACK_DASHED_PEN);
|
||||
|
||||
if (mMouseCapture==IsVZooming) {
|
||||
int width, height;
|
||||
|
||||
rect.y = std::min(mZoomStart, mZoomEnd);
|
||||
rect.height = 1 + abs(mZoomEnd - mZoomStart);
|
||||
|
||||
@ -8254,14 +8264,11 @@ void TrackPanel::OnToggle()
|
||||
// Make sure selection edge is in view
|
||||
void TrackPanel::ScrollIntoView(double pos)
|
||||
{
|
||||
const int screenWidth = rint(mViewInfo->GetScreenWidth());
|
||||
|
||||
int w;
|
||||
GetTracksUsableArea( &w, NULL );
|
||||
// Or should we just set w = screenWidth ?
|
||||
|
||||
int pixel = mViewInfo->TimeToPosition(pos);
|
||||
if (pixel < 0 || pixel >= screenWidth)
|
||||
if (pixel < 0 || pixel >= w)
|
||||
{
|
||||
mListener->TP_ScrollWindow
|
||||
(mViewInfo->OffsetTimeByPixels(pos, -(w / 2)));
|
||||
|
@ -234,6 +234,10 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel {
|
||||
|
||||
virtual void DrawQuickPlayIndicator(wxDC & dc, double pos);
|
||||
|
||||
// Returns the time corresponding to the pixel column one past the track area
|
||||
// (ignoring any fisheye)
|
||||
virtual double GetScreenEndTime() const;
|
||||
|
||||
protected:
|
||||
virtual MixerBoard* GetMixerBoard();
|
||||
/** @brief Populates the track pop-down menu with the common set of
|
||||
|
@ -22,10 +22,9 @@ static const double gMaxZoom = 6000000;
|
||||
static const double gMinZoom = 0.001;
|
||||
}
|
||||
|
||||
ZoomInfo::ZoomInfo(double start, double screenDuration, double pixelsPerSecond)
|
||||
ZoomInfo::ZoomInfo(double start, double pixelsPerSecond)
|
||||
: vpos(0)
|
||||
, h(start)
|
||||
, screen(screenDuration)
|
||||
, zoom(pixelsPerSecond)
|
||||
{
|
||||
UpdatePrefs();
|
||||
@ -84,12 +83,12 @@ void ZoomInfo::ZoomBy(double multiplier)
|
||||
}
|
||||
|
||||
void ZoomInfo::FindIntervals
|
||||
(double /*rate*/, Intervals &results, wxInt64 origin) const
|
||||
(double /*rate*/, Intervals &results, wxInt64 width, wxInt64 origin) const
|
||||
{
|
||||
results.clear();
|
||||
results.reserve(2);
|
||||
|
||||
const wxInt64 rightmost(origin + (0.5 + screen * zoom));
|
||||
const wxInt64 rightmost(origin + (0.5 + width));
|
||||
wxASSERT(origin <= rightmost);
|
||||
{
|
||||
results.push_back(Interval(origin, zoom, false));
|
||||
@ -101,10 +100,10 @@ void ZoomInfo::FindIntervals
|
||||
}
|
||||
|
||||
ViewInfo::ViewInfo(double start, double screenDuration, double pixelsPerSecond)
|
||||
: ZoomInfo(start, screenDuration, pixelsPerSecond)
|
||||
: ZoomInfo(start, pixelsPerSecond)
|
||||
, selectedRegion()
|
||||
, track(NULL)
|
||||
, total(screen)
|
||||
, total(screenDuration)
|
||||
, sbarH(0)
|
||||
, sbarScreen(1)
|
||||
, sbarTotal(1)
|
||||
@ -114,12 +113,12 @@ ViewInfo::ViewInfo(double start, double screenDuration, double pixelsPerSecond)
|
||||
{
|
||||
}
|
||||
|
||||
void ViewInfo::SetBeforeScreenWidth(wxInt64 width, double lowerBoundTime)
|
||||
void ViewInfo::SetBeforeScreenWidth(wxInt64 beforeWidth, wxInt64 screenWidth, double lowerBoundTime)
|
||||
{
|
||||
h =
|
||||
std::max(lowerBoundTime,
|
||||
std::min(total - screen,
|
||||
width / zoom));
|
||||
std::min(total - screenWidth / zoom,
|
||||
beforeWidth / zoom));
|
||||
}
|
||||
|
||||
void ViewInfo::WriteXMLAttributes(XMLWriter &xmlFile)
|
||||
|
@ -29,7 +29,7 @@ class Track;
|
||||
class AUDACITY_DLL_API ZoomInfo
|
||||
{
|
||||
public:
|
||||
ZoomInfo(double start, double duration, double pixelsPerSecond);
|
||||
ZoomInfo(double start, double pixelsPerSecond);
|
||||
~ZoomInfo();
|
||||
|
||||
void UpdatePrefs();
|
||||
@ -38,8 +38,6 @@ public:
|
||||
|
||||
double h; // h pos in secs
|
||||
|
||||
double screen; // screen width in secs
|
||||
|
||||
protected:
|
||||
double zoom; // pixels per second
|
||||
|
||||
@ -72,13 +70,6 @@ public:
|
||||
bool ZoomInAvailable() const;
|
||||
bool ZoomOutAvailable() const;
|
||||
|
||||
// Return pixels, but maybe not a whole number
|
||||
double GetScreenWidth() const
|
||||
{ return screen * zoom; }
|
||||
|
||||
void SetScreenWidth(wxInt64 width)
|
||||
{ screen = width / zoom; }
|
||||
|
||||
static double GetDefaultZoom()
|
||||
{ return 44100.0 / 512.0; }
|
||||
|
||||
@ -107,7 +98,7 @@ public:
|
||||
// first entry equals origin.
|
||||
// @param origin specifies the pixel position corresponding to time ViewInfo::h.
|
||||
void FindIntervals
|
||||
(double rate, Intervals &results, wxInt64 origin = 0) const;
|
||||
(double rate, Intervals &results, wxInt64 width, wxInt64 origin = 0) const;
|
||||
|
||||
enum FisheyeState {
|
||||
HIDDEN,
|
||||
@ -120,7 +111,7 @@ public:
|
||||
|
||||
// Return true if the mouse position is anywhere in the fisheye
|
||||
// origin specifies the pixel corresponding to time h
|
||||
bool InFisheye(wxInt64 position, wxInt64 WXUNUSED(origin = 0)) const
|
||||
bool InFisheye(wxInt64 /*position*/, wxInt64 WXUNUSED(origin = 0)) const
|
||||
{return false;} // stub
|
||||
|
||||
// These accessors ignore the fisheye hiding state.
|
||||
@ -143,14 +134,11 @@ public:
|
||||
{
|
||||
return h * zoom;
|
||||
}
|
||||
void SetBeforeScreenWidth(wxInt64 width, double lowerBoundTime = 0.0);
|
||||
void SetBeforeScreenWidth(wxInt64 beforeWidth, wxInt64 screenWidth, double lowerBoundTime = 0.0);
|
||||
|
||||
double GetTotalWidth() const
|
||||
{ return total * zoom; }
|
||||
|
||||
bool ZoomedAll() const
|
||||
{ return screen >= total; }
|
||||
|
||||
// Current selection
|
||||
|
||||
SelectedRegion selectedRegion;
|
||||
|
@ -2908,7 +2908,7 @@ void EqualizationPanel::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
memDC.SetPen(*wxBLACK_PEN);
|
||||
if( mEffect->mDraw->GetValue() )
|
||||
{
|
||||
mEffect->mEnvelope->DrawPoints(memDC, mEnvRect, ZoomInfo(0.0, 1.0, mEnvRect.width-1), false, 0.0,
|
||||
mEffect->mEnvelope->DrawPoints(memDC, mEnvRect, ZoomInfo(0.0, mEnvRect.width-1), false, 0.0,
|
||||
mEffect->mdBMin, mEffect->mdBMax);
|
||||
}
|
||||
|
||||
@ -2927,7 +2927,7 @@ void EqualizationPanel::OnMouseEvent(wxMouseEvent & event)
|
||||
CaptureMouse();
|
||||
}
|
||||
|
||||
if (mEffect->mEnvelope->MouseEvent(event, mEnvRect, ZoomInfo(0.0, 1.0, mEnvRect.width),
|
||||
if (mEffect->mEnvelope->MouseEvent(event, mEnvRect, ZoomInfo(0.0, mEnvRect.width),
|
||||
false, 0.0,
|
||||
mEffect->mdBMin, mEffect->mdBMax))
|
||||
{
|
||||
|
@ -56,6 +56,8 @@ AttachableScrollBar::~AttachableScrollBar(void)
|
||||
// Essentially a float to int conversion.
|
||||
void AttachableScrollBar::SetScrollBarFromViewInfo()
|
||||
{
|
||||
// fix me
|
||||
#if 0
|
||||
ViewInfo & mViewInfo = *mpViewInfo;
|
||||
|
||||
mViewInfo.sbarTotal = (int) (mViewInfo.GetTotalWidth());
|
||||
@ -64,11 +66,14 @@ void AttachableScrollBar::SetScrollBarFromViewInfo()
|
||||
|
||||
SetScrollbar(mViewInfo.sbarH, mViewInfo.sbarScreen,
|
||||
mViewInfo.sbarTotal, mViewInfo.sbarScreen, TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Essentially an int to float conversion.
|
||||
void AttachableScrollBar::SetViewInfoFromScrollBar()
|
||||
{
|
||||
// fixme
|
||||
#if 0
|
||||
ViewInfo & mViewInfo = *mpViewInfo;
|
||||
|
||||
int hlast = mViewInfo.sbarH;
|
||||
@ -77,6 +82,7 @@ void AttachableScrollBar::SetViewInfoFromScrollBar()
|
||||
|
||||
if (mViewInfo.sbarH != hlast)
|
||||
mViewInfo.SetBeforeScreenWidth(mViewInfo.sbarH);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Used to associated a ViewInfo structure with a scrollbar.
|
||||
|
Loading…
x
Reference in New Issue
Block a user