1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 17:14:07 +01: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

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

View File

@@ -96,7 +96,7 @@ UIHandle::Result TrackSelectHandle::Click
result |= Cancelled;
else {
mRearrangeCount = 0;
CalculateRearrangingThresholds(event);
CalculateRearrangingThresholds(event, 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
// track is fully on-screen.
CalculateRearrangingThresholds(event);
CalculateRearrangingThresholds(event, pProject);
result |= EnsureVisible | RefreshAll;
return result;
@@ -154,7 +154,7 @@ HitTestPreview TrackSelectHandle::Preview
::MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16);
const bool unsafe =
ProjectAudioIO::Get( *GetActiveProject() ).IsAudioActive();
ProjectAudioIO::Get( *project ).IsAudioActive();
return {
message,
(unsafe
@@ -176,12 +176,11 @@ HitTestPreview TrackSelectHandle::Preview
}
UIHandle::Result TrackSelectHandle::Release
(const TrackPanelMouseEvent &, AudacityProject *, wxWindow *)
(const TrackPanelMouseEvent &, AudacityProject *project, wxWindow *)
{
// If we're releasing, surely we are dragging a track?
wxASSERT( mpTrack );
if (mRearrangeCount != 0) {
AudacityProject *const project = ::GetActiveProject();
ProjectHistory::Get( *project ).PushState(
/* i18n-hint: will substitute name of track for %s */
( 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
/// 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
// not sure what formula will have the best feel for the
// user.
AudacityProject *const project = ::GetActiveProject();
auto &tracks = TrackList::Get( *project );
if (tracks.CanMoveUp(mpTrack.get()))

View File

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