1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-18 09:00:52 +02:00

Eliminate some uses of GetActiveProject...

... where there was already a project at hand
This commit is contained in:
Paul Licameli 2019-05-21 10:53:09 -04:00
parent d23569ca10
commit 83f7bc6b5c
5 changed files with 12 additions and 13 deletions

View File

@ -398,7 +398,7 @@ bool SetTrackVisualsCommand::ApplyInner(const CommandContext & context, Track *
mVZoomTop = c + ZOOMLIMIT / 2.0; mVZoomTop = c + ZOOMLIMIT / 2.0;
} }
wt->SetDisplayBounds(mVZoomBottom, mVZoomTop); wt->SetDisplayBounds(mVZoomBottom, mVZoomTop);
auto &tp = TrackPanel::Get( *::GetActiveProject() ); auto &tp = TrackPanel::Get( context.project );
tp.UpdateVRulers(); tp.UpdateVRulers();
} }

View File

@ -1029,10 +1029,10 @@ void OnScoreAlign(const CommandContext &context)
params.mAudioStart, params.mAudioEnd) ); params.mAudioStart, params.mAudioEnd) );
} else if (result == SA_CANCEL) { } else if (result == SA_CANCEL) {
// wrong way to recover... // wrong way to recover...
//GetActiveProject()->OnUndo(); // recover any changes to note track //project.OnUndo(); // recover any changes to note track
return; // no message when user cancels alignment return; // no message when user cancels alignment
} else { } else {
//GetActiveProject()->OnUndo(); // recover any changes to note track //project.OnUndo(); // recover any changes to note track
AudacityMessageBox( XO("Internal error reported by alignment process.") ); AudacityMessageBox( XO("Internal error reported by alignment process.") );
} }
} }

View File

@ -26,7 +26,6 @@ Paul Licameli split from TrackPanel.cpp
#include "../../../include/audacity/Types.h" #include "../../../include/audacity/Types.h"
class AudacityProject; class AudacityProject;
extern AudacityProject *GetActiveProject();
class TranslatableString; class TranslatableString;
// Conditionally compile either a separate thead, or else use a timer in the main // Conditionally compile either a separate thead, or else use a timer in the main
@ -127,7 +126,7 @@ public:
// Convenience wrapper for the above // Convenience wrapper for the above
template<void (Scrubber::*pfn)(const CommandContext&)> template<void (Scrubber::*pfn)(const CommandContext&)>
void Thunk(wxCommandEvent &) void Thunk(wxCommandEvent &)
{ (this->*pfn)(*GetActiveProject()); } { (this->*pfn)(*mProject); }
// A string to put in the leftmost part of the status bar // A string to put in the leftmost part of the status bar
// when scrub or seek is in progress, or else empty. // when scrub or seek is in progress, or else empty.

View File

@ -96,7 +96,7 @@ UIHandle::Result TrackSelectHandle::Click
result |= Cancelled; result |= Cancelled;
else { else {
mRearrangeCount = 0; mRearrangeCount = 0;
CalculateRearrangingThresholds(event); CalculateRearrangingThresholds(event, pProject);
} }
SelectUtilities::DoListSelection(*pProject, SelectUtilities::DoListSelection(*pProject,
@ -135,7 +135,7 @@ UIHandle::Result TrackSelectHandle::Drag
// JH: if we moved up or down, recalculate the thresholds and make sure the // JH: if we moved up or down, recalculate the thresholds and make sure the
// track is fully on-screen. // track is fully on-screen.
CalculateRearrangingThresholds(event); CalculateRearrangingThresholds(event, pProject);
result |= EnsureVisible | RefreshAll; result |= EnsureVisible | RefreshAll;
return result; return result;
@ -154,7 +154,7 @@ HitTestPreview TrackSelectHandle::Preview
::MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16); ::MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16);
const bool unsafe = const bool unsafe =
ProjectAudioIO::Get( *GetActiveProject() ).IsAudioActive(); ProjectAudioIO::Get( *project ).IsAudioActive();
return { return {
message, message,
(unsafe (unsafe
@ -176,12 +176,11 @@ HitTestPreview TrackSelectHandle::Preview
} }
UIHandle::Result TrackSelectHandle::Release UIHandle::Result TrackSelectHandle::Release
(const TrackPanelMouseEvent &, AudacityProject *, wxWindow *) (const TrackPanelMouseEvent &, AudacityProject *project, wxWindow *)
{ {
// If we're releasing, surely we are dragging a track? // If we're releasing, surely we are dragging a track?
wxASSERT( mpTrack ); wxASSERT( mpTrack );
if (mRearrangeCount != 0) { if (mRearrangeCount != 0) {
AudacityProject *const project = ::GetActiveProject();
ProjectHistory::Get( *project ).PushState( ProjectHistory::Get( *project ).PushState(
/* i18n-hint: will substitute name of track for %s */ /* i18n-hint: will substitute name of track for %s */
( mRearrangeCount < 0 ? XO("Moved '%s' up") : XO("Moved '%s' down") ) ( mRearrangeCount < 0 ? XO("Moved '%s' up") : XO("Moved '%s' down") )
@ -207,13 +206,13 @@ UIHandle::Result TrackSelectHandle::Cancel(AudacityProject *pProject)
/// Figure out how far the user must drag the mouse up or down /// Figure out how far the user must drag the mouse up or down
/// before the track will swap with the one above or below /// before the track will swap with the one above or below
void TrackSelectHandle::CalculateRearrangingThresholds(const wxMouseEvent & event) void TrackSelectHandle::CalculateRearrangingThresholds(
const wxMouseEvent & event, AudacityProject *project)
{ {
// JH: this will probably need to be tweaked a bit, I'm just // JH: this will probably need to be tweaked a bit, I'm just
// not sure what formula will have the best feel for the // not sure what formula will have the best feel for the
// user. // user.
AudacityProject *const project = ::GetActiveProject();
auto &tracks = TrackList::Get( *project ); auto &tracks = TrackList::Get( *project );
if (tracks.CanMoveUp(mpTrack.get())) if (tracks.CanMoveUp(mpTrack.get()))

View File

@ -59,7 +59,8 @@ private:
int mMoveDownThreshold {}; int mMoveDownThreshold {};
int mRearrangeCount {}; int mRearrangeCount {};
void CalculateRearrangingThresholds(const wxMouseEvent & event); void CalculateRearrangingThresholds(
const wxMouseEvent & event, AudacityProject *project);
}; };
#endif #endif