From 69962f62d3c023126749fbb882d1fa39a33fd5b4 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 27 Mar 2019 04:29:27 -0400 Subject: [PATCH] Remove AudacityProject::GetScreenEndTime --- src/Project.cpp | 27 +++++++++++++------------- src/Project.h | 1 - src/menus/ViewMenus.cpp | 6 ++++-- src/tracks/ui/CommonTrackPanelCell.cpp | 3 ++- src/tracks/ui/EditCursorOverlay.cpp | 2 +- src/tracks/ui/PlayIndicatorOverlay.cpp | 4 ++-- src/tracks/ui/Scrubbing.cpp | 3 ++- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Project.cpp b/src/Project.cpp index 3d7a40467..733261b46 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -1983,7 +1983,8 @@ void AudacityProject::FixScrollbars() LastTime = std::max(LastTime, mViewInfo.selectedRegion.t1()); - const double screen = GetScreenEndTime() - mViewInfo.h; + const double screen = + GetTrackPanel()->GetScreenEndTime() - mViewInfo.h; const double halfScreen = screen / 2.0; // If we can scroll beyond zero, @@ -2029,7 +2030,8 @@ void AudacityProject::FixScrollbars() bool oldhstate; bool oldvstate; - bool newhstate = (GetScreenEndTime() - mViewInfo.h) < mViewInfo.total; + bool newhstate = + (GetTrackPanel()->GetScreenEndTime() - mViewInfo.h) < mViewInfo.total; bool newvstate = panelHeight < totalHeight; #ifdef __WXGTK__ @@ -2088,7 +2090,7 @@ void AudacityProject::FixScrollbars() panelHeight / mViewInfo.scrollStep, TRUE); if (refresh || (rescroll && - (GetScreenEndTime() - mViewInfo.h) < mViewInfo.total)) { + (GetTrackPanel()->GetScreenEndTime() - mViewInfo.h) < mViewInfo.total)) { mTrackPanel->Refresh(false); } @@ -4745,7 +4747,7 @@ void AudacityProject::Zoom(double level) // tOnLeft is the amount of time we would need before the selection left edge to center it. float t0 = mViewInfo.selectedRegion.t0(); float t1 = mViewInfo.selectedRegion.t1(); - float tAvailable = GetScreenEndTime() - mViewInfo.h; + float tAvailable = GetTrackPanel()->GetScreenEndTime() - mViewInfo.h; float tOnLeft = (tAvailable - t0 + t1)/2.0; // Bug 1292 (Enh) is effectively a request to do this scrolling of the selection into view. // If tOnLeft is positive, then we have room for the selection, so scroll to it. @@ -5605,11 +5607,6 @@ ContrastDialog *AudacityProject::GetContrastDialog(bool create) return mContrastDialog.get(); } -double AudacityProject::GetScreenEndTime() const -{ - return mTrackPanel->GetScreenEndTime(); -} - void AudacityProject::SelectNone() { for (auto t : GetTracks()->Any()) @@ -5634,7 +5631,7 @@ void AudacityProject::ZoomInByFactor( double ZoomFactor ) // when there's a selection that's currently at least // partially on-screen - const double endTime = GetScreenEndTime(); + const double endTime = GetTrackPanel()->GetScreenEndTime(); const double duration = endTime - mViewInfo.h; bool selectionIsOnscreen = @@ -5661,7 +5658,8 @@ void AudacityProject::ZoomInByFactor( double ZoomFactor ) // Zoom in ZoomBy(ZoomFactor); - const double newDuration = GetScreenEndTime() - mViewInfo.h; + const double newDuration = + GetTrackPanel()->GetScreenEndTime() - mViewInfo.h; // Recenter on selCenter TP_ScrollWindow(selCenter - newDuration / 2); @@ -5673,7 +5671,8 @@ void AudacityProject::ZoomInByFactor( double ZoomFactor ) double origWidth = duration; ZoomBy(ZoomFactor); - const double newDuration = GetScreenEndTime() - mViewInfo.h; + const double newDuration = + GetTrackPanel()->GetScreenEndTime() - mViewInfo.h; double newh = origLeft + (origWidth - newDuration) / 2; // MM: Commented this out because it was confusing users @@ -5696,10 +5695,10 @@ void AudacityProject::ZoomOutByFactor( double ZoomFactor ) { //Zoom() may change these, so record original values: const double origLeft = mViewInfo.h; - const double origWidth = GetScreenEndTime() - origLeft; + const double origWidth = GetTrackPanel()->GetScreenEndTime() - origLeft; ZoomBy(ZoomFactor); - const double newWidth = GetScreenEndTime() - mViewInfo.h; + const double newWidth = GetTrackPanel()->GetScreenEndTime() - mViewInfo.h; const double newh = origLeft + (origWidth - newWidth) / 2; // newh = (newh > 0) ? newh : 0; diff --git a/src/Project.h b/src/Project.h index e9aa4feab..0ac530eb1 100644 --- a/src/Project.h +++ b/src/Project.h @@ -393,7 +393,6 @@ public: void HandleResize(); void UpdateLayout(); - double GetScreenEndTime() const; void ZoomInByFactor( double ZoomFactor ); void ZoomOutByFactor( double ZoomFactor ); diff --git a/src/menus/ViewMenus.cpp b/src/menus/ViewMenus.cpp index de2d6c766..9917676bb 100644 --- a/src/menus/ViewMenus.cpp +++ b/src/menus/ViewMenus.cpp @@ -290,12 +290,13 @@ void OnGoSelStart(const CommandContext &context) auto &project = context.project; auto &viewInfo = project.GetViewInfo(); auto &selectedRegion = viewInfo.selectedRegion; + auto &trackPanel = *project.GetTrackPanel(); if (selectedRegion.isPoint()) return; project.TP_ScrollWindow( - selectedRegion.t0() - ((project.GetScreenEndTime() - viewInfo.h) / 2)); + selectedRegion.t0() - ((trackPanel.GetScreenEndTime() - viewInfo.h) / 2)); } void OnGoSelEnd(const CommandContext &context) @@ -303,12 +304,13 @@ void OnGoSelEnd(const CommandContext &context) auto &project = context.project; auto &viewInfo = project.GetViewInfo(); auto &selectedRegion = viewInfo.selectedRegion; + auto &trackPanel = *project.GetTrackPanel(); if (selectedRegion.isPoint()) return; project.TP_ScrollWindow( - selectedRegion.t1() - ((project.GetScreenEndTime() - viewInfo.h) / 2)); + selectedRegion.t1() - ((trackPanel.GetScreenEndTime() - viewInfo.h) / 2)); } void OnHistory(const CommandContext &context) diff --git a/src/tracks/ui/CommonTrackPanelCell.cpp b/src/tracks/ui/CommonTrackPanelCell.cpp index 37225e655..d3ed455a6 100644 --- a/src/tracks/ui/CommonTrackPanelCell.cpp +++ b/src/tracks/ui/CommonTrackPanelCell.cpp @@ -87,7 +87,8 @@ unsigned CommonTrackPanelCell::HandleWheelRotation // Scrubbing? Expand or contract about the center, ignoring mouse position if (scrubber.IsScrollScrubbing()) - center_h = viewInfo.h + (pProject->GetScreenEndTime() - viewInfo.h) / 2.0; + center_h = viewInfo.h + + (pProject->GetTrackPanel()->GetScreenEndTime() - viewInfo.h) / 2.0; // Zooming out? Focus on mouse. else if( steps <= 0 ) center_h = mouse_h; diff --git a/src/tracks/ui/EditCursorOverlay.cpp b/src/tracks/ui/EditCursorOverlay.cpp index b587a6b19..8d37b46b5 100644 --- a/src/tracks/ui/EditCursorOverlay.cpp +++ b/src/tracks/ui/EditCursorOverlay.cpp @@ -80,7 +80,7 @@ void EditCursorOverlay::Draw(OverlayPanel &panel, wxDC &dc) const bool onScreen = between_incexc(viewInfo.h, mCursorTime, - mProject->GetScreenEndTime()); + mProject->GetTrackPanel()->GetScreenEndTime()); if (!onScreen) return; diff --git a/src/tracks/ui/PlayIndicatorOverlay.cpp b/src/tracks/ui/PlayIndicatorOverlay.cpp index 6e69289ef..1b99d0c9f 100644 --- a/src/tracks/ui/PlayIndicatorOverlay.cpp +++ b/src/tracks/ui/PlayIndicatorOverlay.cpp @@ -161,7 +161,7 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event) bool onScreen = playPos >= 0.0 && between_incexc(viewInfo.h - tolerance, playPos, - mProject->GetScreenEndTime() + tolerance); + mProject->GetTrackPanel()->GetScreenEndTime() + tolerance); // This displays the audio time, too... mProject->TP_DisplaySelection(); @@ -190,7 +190,7 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event) onScreen = playPos >= 0.0 && between_incexc(viewInfo.h, playPos, - mProject->GetScreenEndTime()); + mProject->GetTrackPanel()->GetScreenEndTime()); } } diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index 19e550fc9..91b4d7096 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -792,7 +792,8 @@ bool Scrubber::ShouldDrawScrubSpeed() double Scrubber::FindScrubSpeed(bool seeking, double time) const { ViewInfo &viewInfo = mProject->GetViewInfo(); - const double screen = mProject->GetScreenEndTime() - viewInfo.h; + const double screen = + mProject->GetTrackPanel()->GetScreenEndTime() - viewInfo.h; return (seeking ? FindSeekSpeed : FindScrubbingSpeed) (viewInfo, mMaxSpeed, screen, time); }