mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-11 22:27:42 +02:00
Remove various calls to GetActiveProject
This commit is contained in:
commit
dd4870b83f
@ -1582,7 +1582,6 @@ bool AudacityApp::OnInit()
|
||||
// seemed to arrive with wx3.
|
||||
{
|
||||
project = ProjectManager::New();
|
||||
mCmdHandler->SetProject(project);
|
||||
wxWindow * pWnd = MakeHijackPanel();
|
||||
if (pWnd)
|
||||
{
|
||||
|
@ -213,10 +213,6 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
|
||||
mRate = 0;
|
||||
mDataLen = 0;
|
||||
|
||||
p = GetActiveProject();
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
TranslatableStrings algChoices{
|
||||
XO("Spectrum") ,
|
||||
XO("Standard Autocorrelation") ,
|
||||
|
@ -95,6 +95,7 @@ BEGIN_EVENT_TABLE(LabelDialog, wxDialogWrapper)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
LabelDialog::LabelDialog(wxWindow *parent,
|
||||
AudacityProject &project,
|
||||
TrackFactory &factory,
|
||||
TrackList *tracks,
|
||||
LabelTrack *selectedTrack,
|
||||
@ -108,9 +109,10 @@ LabelDialog::LabelDialog(wxWindow *parent,
|
||||
XO("Edit Labels"),
|
||||
wxDefaultPosition,
|
||||
wxSize(800, 600),
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
|
||||
mFactory(factory),
|
||||
mTracks(tracks)
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, mProject{ project }
|
||||
, mFactory(factory)
|
||||
, mTracks(tracks)
|
||||
, mSelectedTrack(selectedTrack)
|
||||
, mIndex(index)
|
||||
, mViewInfo(&viewinfo),
|
||||
@ -748,7 +750,7 @@ void LabelDialog::OnSelectCell(wxGridEvent &event)
|
||||
RowData &rd = mData[event.GetRow()];
|
||||
mViewInfo->selectedRegion = rd.selectedRegion;
|
||||
|
||||
ProjectWindow::Get( *GetActiveProject() ).RedrawProject();
|
||||
ProjectWindow::Get( mProject ).RedrawProject();
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
class wxArrayString;
|
||||
class wxGridEvent;
|
||||
class AudacityProject;
|
||||
class ChoiceEditor;
|
||||
class Grid;
|
||||
class NumericEditor;
|
||||
@ -37,6 +38,7 @@ class LabelDialog final : public wxDialogWrapper
|
||||
public:
|
||||
|
||||
LabelDialog(wxWindow *parent,
|
||||
AudacityProject &project,
|
||||
TrackFactory &factory,
|
||||
TrackList *tracks,
|
||||
|
||||
@ -93,6 +95,8 @@ class LabelDialog final : public wxDialogWrapper
|
||||
|
||||
private:
|
||||
|
||||
AudacityProject &mProject;
|
||||
|
||||
Grid *mGrid;
|
||||
ChoiceEditor *mChoiceEditor;
|
||||
NumericEditor *mTimeEditor;
|
||||
|
@ -20,7 +20,8 @@
|
||||
#include <wx/mimetype.h>
|
||||
|
||||
#include "AudioIO.h"
|
||||
#include "Project.h" // for GetActiveProject
|
||||
#include "Project.h"
|
||||
#include "ProjectWindowBase.h"
|
||||
#include "LabelTrack.h"
|
||||
#include "commands/CommandManager.h"
|
||||
#include "UndoManager.h"
|
||||
@ -57,7 +58,7 @@ void HighlightTextCtrl::OnMouseEvent(wxMouseEvent& event)
|
||||
if (nNewSyl != nCurSyl)
|
||||
{
|
||||
Syllable* pCurSyl = mLyricsPanel->GetSyllable(nNewSyl);
|
||||
AudacityProject* pProj = GetActiveProject();
|
||||
auto pProj = FindProjectFromWindow( this );
|
||||
auto &selectedRegion = ViewInfo::Get( *pProj ).selectedRegion;
|
||||
selectedRegion.setT0( pCurSyl->t );
|
||||
|
||||
@ -440,7 +441,7 @@ void LyricsPanel::Update(double t)
|
||||
{
|
||||
// TrackPanel::OnTimer passes gAudioIO->GetStreamTime(), which is -DBL_MAX if !IsStreamActive().
|
||||
// In that case, use the selection start time.
|
||||
AudacityProject* pProj = GetActiveProject();
|
||||
auto pProj = FindProjectFromWindow( this );
|
||||
const auto &selectedRegion = ViewInfo::Get( *pProj ).selectedRegion;
|
||||
mT = selectedRegion.t0();
|
||||
}
|
||||
@ -529,7 +530,7 @@ void LyricsPanel::OnShow(wxShowEvent &e)
|
||||
|
||||
void LyricsPanel::OnKeyEvent(wxKeyEvent & event)
|
||||
{
|
||||
AudacityProject *project = GetActiveProject();
|
||||
auto project = FindProjectFromWindow( this );
|
||||
auto &commandManager = CommandManager::Get( *project );
|
||||
commandManager.FilterKeyEvent(project, event, true);
|
||||
event.Skip();
|
||||
|
@ -24,3 +24,26 @@ ProjectWindowBase::ProjectWindowBase(wxWindow * parent, wxWindowID id,
|
||||
ProjectWindowBase::~ProjectWindowBase()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
ProjectWindowBase *FindProjectWindow( wxWindow *pWindow )
|
||||
{
|
||||
while ( pWindow && pWindow->GetParent() )
|
||||
pWindow = pWindow->GetParent();
|
||||
return dynamic_cast< ProjectWindowBase* >( pWindow );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AudacityProject *FindProjectFromWindow( wxWindow *pWindow )
|
||||
{
|
||||
auto pProjectWindow = FindProjectWindow( pWindow );
|
||||
return pProjectWindow ? &pProjectWindow->GetProject() : nullptr;
|
||||
}
|
||||
|
||||
const AudacityProject *FindProjectFromWindow( const wxWindow *pWindow )
|
||||
{
|
||||
return FindProjectFromWindow( const_cast< wxWindow* >( pWindow ) );
|
||||
}
|
||||
|
||||
|
@ -33,5 +33,8 @@ protected:
|
||||
AudacityProject &mProject;
|
||||
};
|
||||
|
||||
AudacityProject *FindProjectFromWindow( wxWindow *pWindow );
|
||||
const AudacityProject *FindProjectFromWindow( const wxWindow *pWindow );
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -58,7 +58,8 @@ class ScreenshotBigDialog final : public wxFrame
|
||||
{
|
||||
public:
|
||||
// constructors and destructors
|
||||
ScreenshotBigDialog(wxWindow *parent, wxWindowID id);
|
||||
ScreenshotBigDialog(
|
||||
wxWindow *parent, wxWindowID id, AudacityProject &project);
|
||||
virtual ~ScreenshotBigDialog();
|
||||
|
||||
bool ProcessEvent(wxEvent & event) override;
|
||||
@ -95,6 +96,8 @@ class ScreenshotBigDialog final : public wxFrame
|
||||
void OnMedTracks(wxCommandEvent & event);
|
||||
void OnTallTracks(wxCommandEvent & event);
|
||||
|
||||
AudacityProject &mProject;
|
||||
|
||||
std::unique_ptr<ScreenshotCommand> CreateCommand();
|
||||
|
||||
wxCheckBox *mDelayCheckBox;
|
||||
@ -118,7 +121,7 @@ ScreenshotBigDialogPtr mFrame;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OpenScreenshotTools()
|
||||
void OpenScreenshotTools( AudacityProject &project )
|
||||
{
|
||||
if (!mFrame) {
|
||||
auto parent = wxTheApp->GetTopWindow();
|
||||
@ -126,7 +129,8 @@ void OpenScreenshotTools()
|
||||
wxASSERT(false);
|
||||
return;
|
||||
}
|
||||
mFrame = ScreenshotBigDialogPtr{ safenew ScreenshotBigDialog(parent, -1) };
|
||||
mFrame = ScreenshotBigDialogPtr{
|
||||
safenew ScreenshotBigDialog(parent, -1, project) };
|
||||
}
|
||||
mFrame->Show();
|
||||
mFrame->Raise();
|
||||
@ -263,7 +267,8 @@ std::unique_ptr<ScreenshotCommand> ScreenshotBigDialog::CreateCommand()
|
||||
return std::make_unique<ScreenshotCommand>();//*type, std::move(output), this);
|
||||
}
|
||||
|
||||
ScreenshotBigDialog::ScreenshotBigDialog(wxWindow * parent, wxWindowID id)
|
||||
ScreenshotBigDialog::ScreenshotBigDialog(
|
||||
wxWindow * parent, wxWindowID id, AudacityProject &project)
|
||||
: wxFrame(parent, id, _("Screen Capture Frame"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
|
||||
@ -279,8 +284,9 @@ ScreenshotBigDialog::ScreenshotBigDialog(wxWindow * parent, wxWindowID id)
|
||||
|
||||
#endif
|
||||
|
||||
wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX),
|
||||
mContext( *GetActiveProject() )
|
||||
wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX)
|
||||
, mProject{ project }
|
||||
, mContext( project )
|
||||
{
|
||||
mDelayCheckBox = NULL;
|
||||
mDirectoryTextBox = NULL;
|
||||
@ -530,7 +536,7 @@ void ScreenshotBigDialog::OnGetURL(wxCommandEvent & WXUNUSED(event))
|
||||
void ScreenshotBigDialog::OnUIUpdate(wxUpdateUIEvent & WXUNUSED(event))
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
wxTopLevelWindow *top = mCommand->GetFrontWindow(GetActiveProject());
|
||||
wxTopLevelWindow *top = mCommand->GetFrontWindow(&mProject);
|
||||
bool needupdate = false;
|
||||
bool enable = false;
|
||||
|
||||
|
@ -23,7 +23,9 @@
|
||||
|
||||
#include <wx/defs.h>
|
||||
|
||||
void OpenScreenshotTools();
|
||||
class AudacityProject;
|
||||
|
||||
void OpenScreenshotTools( AudacityProject &project );
|
||||
void CloseScreenshotTools();
|
||||
|
||||
#endif // __AUDACITY_SCREENSHOT__
|
||||
|
@ -35,21 +35,11 @@ CommandHandler::~CommandHandler()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandHandler::SetProject(AudacityProject *)
|
||||
{
|
||||
// TODO: Review if the extend command handling is ever utilized
|
||||
}
|
||||
|
||||
void CommandHandler::OnReceiveCommand(AppCommandEvent &event)
|
||||
{
|
||||
// First retrieve the actual command from the event 'envelope'.
|
||||
OldStyleCommandPointer cmd = event.GetCommand();
|
||||
|
||||
// JKC: In case the user changed the project, let us track that.
|
||||
// This saves us the embarrassment (crash) of a NEW project
|
||||
// being opened, the old one closed and still trying to act
|
||||
// on the old one.
|
||||
SetProject( GetActiveProject() );
|
||||
// Then apply it to current application & project. Note that the
|
||||
// command may change the context - for example, switching to a
|
||||
// different project.
|
||||
|
@ -24,16 +24,10 @@ class CommandContext;
|
||||
|
||||
class CommandHandler
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<const CommandContext> mCurrentContext;
|
||||
|
||||
public:
|
||||
CommandHandler();
|
||||
~CommandHandler();
|
||||
|
||||
// This should only be used during initialization
|
||||
void SetProject(AudacityProject *proj);
|
||||
|
||||
// Whenever a command is received, process it.
|
||||
void OnReceiveCommand(AppCommandEvent &event);
|
||||
};
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "../Prefs.h"
|
||||
#include "../Project.h"
|
||||
#include "../ProjectSettings.h"
|
||||
#include "../ProjectWindowBase.h"
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../FileNames.h"
|
||||
#include "../ViewInfo.h"
|
||||
@ -52,7 +53,7 @@ bool ContrastDialog::GetDB(float &dB)
|
||||
// For stereo tracks: sqrt((mean(L)+mean(R))/2)
|
||||
double meanSq = 0.0;
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto p = FindProjectFromWindow( this );
|
||||
auto range =
|
||||
TrackList::Get( *p ).SelectedLeaders< const WaveTrack >();
|
||||
auto numberSelectedTracks = range.size();
|
||||
@ -132,7 +133,7 @@ bool ContrastDialog::GetDB(float &dB)
|
||||
|
||||
void ContrastDialog::SetStartAndEndTime()
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto p = FindProjectFromWindow( this );
|
||||
auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
|
||||
mT0 = selectedRegion.t0();
|
||||
mT1 = selectedRegion.t1();
|
||||
@ -211,7 +212,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
|
||||
wxTextValidator vld(wxFILTER_NUMERIC);
|
||||
wxString number;
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto p = FindProjectFromWindow( this );
|
||||
const auto &settings = ProjectSettings::Get( *p );
|
||||
mProjectRate = settings.GetRate();
|
||||
|
||||
@ -374,7 +375,7 @@ void ContrastDialog::OnClose(wxCommandEvent & WXUNUSED(event))
|
||||
|
||||
void ContrastDialog::OnGetForeground(wxCommandEvent & /*event*/)
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto p = FindProjectFromWindow( this );
|
||||
auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
|
||||
|
||||
if( TrackList::Get( *p ).Selected< const WaveTrack >() ) {
|
||||
@ -390,7 +391,7 @@ void ContrastDialog::OnGetForeground(wxCommandEvent & /*event*/)
|
||||
|
||||
void ContrastDialog::OnGetBackground(wxCommandEvent & /*event*/)
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto p = FindProjectFromWindow( this );
|
||||
auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
|
||||
|
||||
if( TrackList::Get( *p ).Selected< const WaveTrack >() ) {
|
||||
@ -528,7 +529,7 @@ void ContrastDialog::results()
|
||||
void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
// TODO: Handle silence checks better (-infinity dB)
|
||||
AudacityProject * project = GetActiveProject();
|
||||
auto project = FindProjectFromWindow( this );
|
||||
wxString fName = wxT("contrast.txt");
|
||||
|
||||
fName = FileNames::SelectFile(FileNames::Operation::Export,
|
||||
|
@ -143,8 +143,7 @@ bool DoPasteNothingSelected(AudacityProject &project)
|
||||
// Select some pasted samples, which is probably impossible to get right
|
||||
// with various project and track sample rates.
|
||||
// So do it at the sample rate of the project
|
||||
AudacityProject *p = GetActiveProject();
|
||||
double projRate = ProjectSettings::Get( *p ).GetRate();
|
||||
double projRate = ProjectSettings::Get( project ).GetRate();
|
||||
double quantT0 = QUANTIZED_TIME(clipboard.T0(), projRate);
|
||||
double quantT1 = QUANTIZED_TIME(clipboard.T1(), projRate);
|
||||
selectedRegion.setTimes(
|
||||
|
@ -88,7 +88,7 @@ void ShowDiagnostics(
|
||||
class QuickFixDialog : public wxDialogWrapper
|
||||
{
|
||||
public:
|
||||
QuickFixDialog(wxWindow * pParent);
|
||||
QuickFixDialog(wxWindow * pParent, AudacityProject &project);
|
||||
void Populate();
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
void AddStuck( ShuttleGui & S, bool & bBool, wxString Pref,
|
||||
@ -101,6 +101,8 @@ public:
|
||||
|
||||
wxString StringFromEvent( wxCommandEvent &event );
|
||||
|
||||
AudacityProject &mProject;
|
||||
|
||||
int mItem;
|
||||
bool mbSyncLocked;
|
||||
bool mbInSnapTo;
|
||||
@ -120,10 +122,11 @@ BEGIN_EVENT_TABLE(QuickFixDialog, wxDialogWrapper)
|
||||
EVT_COMMAND_RANGE(HelpButtonID, FakeButtonID-1, wxEVT_BUTTON, QuickFixDialog::OnHelp)
|
||||
END_EVENT_TABLE();
|
||||
|
||||
QuickFixDialog::QuickFixDialog(wxWindow * pParent) :
|
||||
QuickFixDialog::QuickFixDialog(wxWindow * pParent, AudacityProject &project) :
|
||||
wxDialogWrapper(pParent, wxID_ANY, XO("Do you have these problems?"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE )
|
||||
, mProject{ project }
|
||||
{
|
||||
const long SNAP_OFF = 0;
|
||||
|
||||
@ -255,19 +258,19 @@ void QuickFixDialog::OnFix(wxCommandEvent &event)
|
||||
gPrefs->Write( Str, 0);
|
||||
gPrefs->Flush();
|
||||
|
||||
if ( auto pProject = GetActiveProject() ) {
|
||||
{
|
||||
// Sadly SnapTo has to be handled specially, as it is not part of the standard
|
||||
// preference dialogs.
|
||||
if( Str == "/SnapTo" )
|
||||
{
|
||||
ProjectSelectionManager::Get( *pProject ).AS_SetSnapTo( 0 );
|
||||
ProjectSelectionManager::Get( mProject ).AS_SetSnapTo( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is overkill (aka slow), as all preferences are reloaded and all
|
||||
// toolbars recreated.
|
||||
// Overkill probably doesn't matter, as this command is infrequently used.
|
||||
DoReloadPreferences( *pProject );
|
||||
DoReloadPreferences( mProject );
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,7 +298,7 @@ struct Handler : CommandHandlerObject {
|
||||
void OnQuickFix(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
QuickFixDialog dlg( &GetProjectFrame( project ) );
|
||||
QuickFixDialog dlg( &GetProjectFrame( project ), project );
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
|
@ -503,9 +503,9 @@ void OnApplyMacrosPalette(const CommandContext &context )
|
||||
}
|
||||
}
|
||||
|
||||
void OnScreenshot(const CommandContext &WXUNUSED(context) )
|
||||
void OnScreenshot(const CommandContext &context )
|
||||
{
|
||||
::OpenScreenshotTools();
|
||||
::OpenScreenshotTools( context.project );
|
||||
}
|
||||
|
||||
void OnBenchmark(const CommandContext &context)
|
||||
|
@ -80,7 +80,8 @@ BEGIN_EVENT_TABLE(KeyConfigPrefs, PrefsPanel)
|
||||
EVT_TIMER(FilterTimerID, KeyConfigPrefs::OnFilterTimer)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid,
|
||||
KeyConfigPrefs::KeyConfigPrefs(
|
||||
wxWindow * parent, wxWindowID winid, AudacityProject *pProject,
|
||||
const CommandID &name)
|
||||
/* i18n-hint: as in computer keyboard (not musical!) */
|
||||
: PrefsPanel(parent, winid, XO("Keyboard")),
|
||||
@ -89,6 +90,7 @@ KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid,
|
||||
mFilter(NULL),
|
||||
mFilterTimer(this, FilterTimerID),
|
||||
mFilterPending(false)
|
||||
, mProject{ pProject }
|
||||
{
|
||||
Populate();
|
||||
if (!name.empty()) {
|
||||
@ -115,9 +117,8 @@ wxString KeyConfigPrefs::HelpPageName()
|
||||
void KeyConfigPrefs::Populate()
|
||||
{
|
||||
ShuttleGui S(this, eIsCreatingFromPrefs);
|
||||
AudacityProject *project = GetActiveProject();
|
||||
|
||||
if (!project) {
|
||||
if (!mProject) {
|
||||
S.StartVerticalLay(true);
|
||||
{
|
||||
S.StartStatic( {}, true);
|
||||
@ -136,7 +137,7 @@ void KeyConfigPrefs::Populate()
|
||||
|
||||
mCommandSelected = wxNOT_FOUND;
|
||||
|
||||
mManager = &CommandManager::Get( *project );
|
||||
mManager = &CommandManager::Get( *mProject );
|
||||
|
||||
// For speed, don't sort here. We're just creating.
|
||||
// Instead sort when we do SetView later in this function.
|
||||
@ -669,7 +670,7 @@ bool KeyConfigPrefs::Commit()
|
||||
// either. So we can't attempt to save preferences, otherwise
|
||||
// NULL ptr dereferences will happen in ShuttleGui because the
|
||||
// radio buttons are never created. (See Populate() above.)
|
||||
if (!GetActiveProject()) {
|
||||
if ( !mProject ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -714,10 +715,10 @@ void KeyConfigPrefs::Cancel()
|
||||
PrefsPanel::Factory
|
||||
KeyConfigPrefsFactory( const CommandID &name )
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *pProject)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
auto result = safenew KeyConfigPrefs{ parent, winid, name };
|
||||
auto result = safenew KeyConfigPrefs{ parent, winid, pProject, name };
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
@ -32,7 +32,9 @@ enum ViewByType : int;
|
||||
class KeyConfigPrefs final : public PrefsPanel
|
||||
{
|
||||
public:
|
||||
KeyConfigPrefs(wxWindow * parent, wxWindowID winid, const CommandID &name);
|
||||
KeyConfigPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject,
|
||||
const CommandID &name);
|
||||
ComponentInterfaceSymbol GetSymbol() override;
|
||||
TranslatableString GetDescription() override;
|
||||
|
||||
@ -80,6 +82,8 @@ private:
|
||||
wxRadioButton *mViewByName;
|
||||
wxRadioButton *mViewByKey;
|
||||
|
||||
AudacityProject *mProject{};
|
||||
|
||||
CommandManager *mManager;
|
||||
int mCommandSelected;
|
||||
|
||||
|
@ -37,8 +37,10 @@
|
||||
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
|
||||
SpectrumPrefs::SpectrumPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt)
|
||||
SpectrumPrefs::SpectrumPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject, WaveTrack *wt)
|
||||
: PrefsPanel(parent, winid, wt ? XO("Spectrogram Settings") : XO("Spectrograms"))
|
||||
, mProject{ pProject }
|
||||
, mWt(wt)
|
||||
, mPopulating(false)
|
||||
{
|
||||
@ -429,9 +431,8 @@ void SpectrumPrefs::Rollback()
|
||||
}
|
||||
|
||||
if (isOpenPage) {
|
||||
auto pProject = ::GetActiveProject();
|
||||
if ( pProject ) {
|
||||
auto &tp = TrackPanel::Get ( *pProject );
|
||||
if ( mProject ) {
|
||||
auto &tp = TrackPanel::Get ( *mProject );
|
||||
tp.UpdateVRulers();
|
||||
tp.Refresh(false);
|
||||
}
|
||||
@ -480,9 +481,8 @@ void SpectrumPrefs::Preview()
|
||||
}
|
||||
|
||||
if (isOpenPage) {
|
||||
auto pProject = ::GetActiveProject();
|
||||
if ( pProject ) {
|
||||
auto &tp = TrackPanel::Get( *pProject );
|
||||
if ( mProject ) {
|
||||
auto &tp = TrackPanel::Get( *mProject );
|
||||
tp.UpdateVRulers();
|
||||
tp.Refresh(false);
|
||||
}
|
||||
@ -506,7 +506,7 @@ bool SpectrumPrefs::Commit()
|
||||
|
||||
bool SpectrumPrefs::ShowsPreviewButton()
|
||||
{
|
||||
return GetActiveProject() != nullptr;
|
||||
return mProject != nullptr;
|
||||
}
|
||||
|
||||
void SpectrumPrefs::OnControl(wxCommandEvent&)
|
||||
@ -588,9 +588,9 @@ END_EVENT_TABLE()
|
||||
PrefsPanel::Factory
|
||||
SpectrumPrefsFactory( WaveTrack *wt )
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *pProject)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew SpectrumPrefs(parent, winid, wt);
|
||||
return safenew SpectrumPrefs(parent, winid, pProject, wt);
|
||||
};
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ struct WaveTrackSubViewPlacement;
|
||||
class SpectrumPrefs final : public PrefsPanel
|
||||
{
|
||||
public:
|
||||
SpectrumPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt);
|
||||
SpectrumPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject, WaveTrack *wt);
|
||||
virtual ~SpectrumPrefs();
|
||||
ComponentInterfaceSymbol GetSymbol() override;
|
||||
TranslatableString GetDescription() override;
|
||||
@ -71,6 +72,8 @@ class SpectrumPrefs final : public PrefsPanel
|
||||
|
||||
void EnableDisableSTFTOnlyControls();
|
||||
|
||||
AudacityProject *mProject{};
|
||||
|
||||
WaveTrack *const mWt;
|
||||
bool mDefaulted, mOrigDefaulted;
|
||||
|
||||
|
@ -30,9 +30,11 @@ Paul Licameli
|
||||
#include "../tracks/playabletrack/wavetrack/ui/WaveTrackView.h"
|
||||
#include "../tracks/playabletrack/wavetrack/ui/WaveTrackViewConstants.h"
|
||||
|
||||
WaveformPrefs::WaveformPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt)
|
||||
WaveformPrefs::WaveformPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject, WaveTrack *wt)
|
||||
/* i18n-hint: A waveform is a visual representation of vibration */
|
||||
: PrefsPanel(parent, winid, XO("Waveforms"))
|
||||
, mProject{ pProject }
|
||||
, mWt(wt)
|
||||
, mPopulating(false)
|
||||
{
|
||||
@ -191,9 +193,8 @@ bool WaveformPrefs::Commit()
|
||||
}
|
||||
|
||||
if (isOpenPage) {
|
||||
auto pProject = ::GetActiveProject();
|
||||
if ( pProject ) {
|
||||
auto &tp = TrackPanel::Get( *pProject );
|
||||
if ( mProject ) {
|
||||
auto &tp = TrackPanel::Get( *mProject );
|
||||
tp.UpdateVRulers();
|
||||
tp.Refresh(false);
|
||||
}
|
||||
@ -256,9 +257,9 @@ END_EVENT_TABLE()
|
||||
PrefsPanel::Factory
|
||||
WaveformPrefsFactory(WaveTrack *wt)
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *pProject)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew WaveformPrefs(parent, winid, wt);
|
||||
return safenew WaveformPrefs(parent, winid, pProject, wt);
|
||||
};
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ class wxArrayStringEx;
|
||||
class WaveformPrefs final : public PrefsPanel
|
||||
{
|
||||
public:
|
||||
WaveformPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt);
|
||||
WaveformPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject, WaveTrack *wt);
|
||||
virtual ~WaveformPrefs();
|
||||
ComponentInterfaceSymbol GetSymbol() override;
|
||||
TranslatableString GetDescription() override;
|
||||
@ -48,6 +49,8 @@ private:
|
||||
|
||||
void EnableDisableRange();
|
||||
|
||||
AudacityProject *mProject{};
|
||||
|
||||
WaveTrack *const mWt;
|
||||
bool mDefaulted;
|
||||
|
||||
|
@ -2049,7 +2049,7 @@ void LabelTrackView::DoEditLabels
|
||||
auto &viewInfo = ViewInfo::Get( project );
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
LabelDialog dlg(&window, trackFactory, &tracks,
|
||||
LabelDialog dlg(&window, project, trackFactory, &tracks,
|
||||
lt, index,
|
||||
viewInfo, rate,
|
||||
format, freqFormat);
|
||||
|
@ -42,16 +42,15 @@ UIHandle::Result MuteButtonHandle::CommitChanges
|
||||
}
|
||||
|
||||
TranslatableString MuteButtonHandle::Tip(
|
||||
const wxMouseState &, AudacityProject &) const
|
||||
const wxMouseState &, AudacityProject &project) const
|
||||
{
|
||||
auto name = XO("Mute");
|
||||
auto project = ::GetActiveProject();
|
||||
auto focused =
|
||||
TrackFocus::Get( *project ).Get() == GetTrack().get();
|
||||
TrackFocus::Get( project ).Get() == GetTrack().get();
|
||||
if (!focused)
|
||||
return name;
|
||||
|
||||
auto &commandManager = CommandManager::Get( *project );
|
||||
auto &commandManager = CommandManager::Get( project );
|
||||
ComponentInterfaceSymbol command{ wxT("TrackMute"), name };
|
||||
return commandManager.DescribeCommandsAndShortcuts(&command, 1u);
|
||||
}
|
||||
@ -99,16 +98,15 @@ UIHandle::Result SoloButtonHandle::CommitChanges
|
||||
}
|
||||
|
||||
TranslatableString SoloButtonHandle::Tip(
|
||||
const wxMouseState &, AudacityProject &) const
|
||||
const wxMouseState &, AudacityProject &project) const
|
||||
{
|
||||
auto name = XO("Solo");
|
||||
auto project = ::GetActiveProject();
|
||||
auto focused =
|
||||
TrackFocus::Get( *project ).Get() == GetTrack().get();
|
||||
TrackFocus::Get( project ).Get() == GetTrack().get();
|
||||
if (!focused)
|
||||
return name;
|
||||
|
||||
auto &commandManager = CommandManager::Get( *project );
|
||||
auto &commandManager = CommandManager::Get( project );
|
||||
ComponentInterfaceSymbol command{ wxT("TrackSolo"), name };
|
||||
return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ protected:
|
||||
|
||||
// Define a message for the status bar and tooltip.
|
||||
virtual TranslatableString Tip(
|
||||
const wxMouseState &state, AudacityProject &) const = 0;
|
||||
const wxMouseState &state, AudacityProject &project) const = 0;
|
||||
|
||||
void Enter(bool forward, AudacityProject *) final override;
|
||||
|
||||
|
@ -487,12 +487,12 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void SelectHandle::Enter(bool, AudacityProject *)
|
||||
void SelectHandle::Enter(bool, AudacityProject *project)
|
||||
{
|
||||
SetUseSnap(true);
|
||||
SetUseSnap(true, project);
|
||||
}
|
||||
|
||||
void SelectHandle::SetUseSnap(bool use)
|
||||
void SelectHandle::SetUseSnap(bool use, AudacityProject *project)
|
||||
{
|
||||
mUseSnap = use;
|
||||
|
||||
@ -504,7 +504,7 @@ void SelectHandle::SetUseSnap(bool use)
|
||||
if (IsClicked()) {
|
||||
// Readjust the moving selection end
|
||||
AssignSelection(
|
||||
ViewInfo::Get( *::GetActiveProject() ),
|
||||
ViewInfo::Get( *project ),
|
||||
mUseSnap ? mSnapEnd.outTime : mSnapEnd.timeSnappedTime,
|
||||
nullptr);
|
||||
}
|
||||
@ -521,10 +521,10 @@ bool SelectHandle::HasEscape() const
|
||||
return HasSnap() && mUseSnap;
|
||||
}
|
||||
|
||||
bool SelectHandle::Escape(AudacityProject *)
|
||||
bool SelectHandle::Escape(AudacityProject *project)
|
||||
{
|
||||
if (SelectHandle::HasEscape()) {
|
||||
SetUseSnap(false);
|
||||
SetUseSnap(false, project);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -50,13 +50,13 @@ public:
|
||||
|
||||
bool IsClicked() const;
|
||||
|
||||
void SetUseSnap(bool use);
|
||||
void Enter(bool forward, AudacityProject *) override;
|
||||
void SetUseSnap(bool use, AudacityProject *pProject);
|
||||
void Enter(bool forward, AudacityProject *pProject) override;
|
||||
|
||||
bool HasSnap() const;
|
||||
bool HasEscape() const override;
|
||||
|
||||
bool Escape(AudacityProject *) override;
|
||||
bool Escape(AudacityProject *pProject) override;
|
||||
|
||||
Result Click
|
||||
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
|
||||
|
@ -173,16 +173,15 @@ UIHandle::Result CloseButtonHandle::CommitChanges
|
||||
}
|
||||
|
||||
TranslatableString CloseButtonHandle::Tip(
|
||||
const wxMouseState &, AudacityProject &) const
|
||||
const wxMouseState &, AudacityProject &project) const
|
||||
{
|
||||
auto name = XO("Close");
|
||||
auto project = ::GetActiveProject();
|
||||
auto focused =
|
||||
TrackFocus::Get( *project ).Get() == GetTrack().get();
|
||||
TrackFocus::Get( project ).Get() == GetTrack().get();
|
||||
if (!focused)
|
||||
return name;
|
||||
|
||||
auto &commandManager = CommandManager::Get( *project );
|
||||
auto &commandManager = CommandManager::Get( project );
|
||||
ComponentInterfaceSymbol command{ wxT("TrackClose"), name };
|
||||
return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
|
||||
}
|
||||
@ -234,16 +233,15 @@ UIHandle::Result MenuButtonHandle::CommitChanges
|
||||
}
|
||||
|
||||
TranslatableString MenuButtonHandle::Tip(
|
||||
const wxMouseState &, AudacityProject&) const
|
||||
const wxMouseState &, AudacityProject &project) const
|
||||
{
|
||||
auto name = XO("Open menu...");
|
||||
auto project = ::GetActiveProject();
|
||||
auto focused =
|
||||
TrackFocus::Get( *project ).Get() == GetTrack().get();
|
||||
TrackFocus::Get( project ).Get() == GetTrack().get();
|
||||
if (!focused)
|
||||
return name;
|
||||
|
||||
auto &commandManager = CommandManager::Get( *project );
|
||||
auto &commandManager = CommandManager::Get( project );
|
||||
ComponentInterfaceSymbol command{ wxT("TrackMenu"), name };
|
||||
return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
//This is needed for tooltips
|
||||
#include "../Project.h"
|
||||
#include "../ProjectStatus.h"
|
||||
#include "../ProjectWindowBase.h"
|
||||
#include <wx/tooltip.h>
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
@ -502,7 +503,9 @@ void AButton::OnMouseEvent(wxMouseEvent & event)
|
||||
if (mCursorIsInWindow)
|
||||
UpdateStatus();
|
||||
else {
|
||||
ProjectStatus::Get( *GetActiveProject() ).Set({});
|
||||
auto pProject = FindProjectFromWindow( this );
|
||||
if (pProject)
|
||||
ProjectStatus::Get( *pProject ).Set({});
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -519,7 +522,9 @@ void AButton::UpdateStatus()
|
||||
auto tipText = Verbatim( pTip->GetTip() );
|
||||
if (!mEnabled)
|
||||
tipText.Join( XO("(disabled)"), " " );
|
||||
ProjectStatus::Get( *GetActiveProject() ).Set(tipText);
|
||||
auto pProject = FindProjectFromWindow( this );
|
||||
if (pProject)
|
||||
ProjectStatus::Get( *pProject ).Set( tipText );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ or ASlider.
|
||||
#include "../ImageManipulation.h"
|
||||
#include "../Project.h"
|
||||
#include "../ProjectStatus.h"
|
||||
#include "../ProjectWindowBase.h"
|
||||
#include "../ShuttleGui.h"
|
||||
|
||||
#include "../AllThemeResources.h"
|
||||
@ -1094,7 +1095,9 @@ void LWSlider::OnMouseEvent(wxMouseEvent & event)
|
||||
{
|
||||
// Display the tooltip in the status bar
|
||||
auto tip = GetTip(mCurrentValue);
|
||||
ProjectStatus::Get( *GetActiveProject() ).Set(tip);
|
||||
auto pProject = FindProjectFromWindow( mParent );
|
||||
if (pProject)
|
||||
ProjectStatus::Get( *pProject ).Set( tip );
|
||||
Refresh();
|
||||
}
|
||||
else if (event.Leaving())
|
||||
@ -1103,7 +1106,9 @@ void LWSlider::OnMouseEvent(wxMouseEvent & event)
|
||||
{
|
||||
ShowTip(false);
|
||||
}
|
||||
ProjectStatus::Get( *GetActiveProject() ).Set({});
|
||||
auto pProject = FindProjectFromWindow( mParent );
|
||||
if (pProject)
|
||||
ProjectStatus::Get( *pProject ).Set({});
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user