1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 07:40:23 +02:00

Accessors to get the project window...

... as a preparation for splitting up class AudacityProject.

Use ProjectWindow as an alias for AudacityProject, and fetch it from the
project with a static member function, where certain of its services are used;
pretending they are not the same class.

Use global accessor functions to get wxFrame from the project where only
wxFrame's member functions are needed, so there will be less dependency on
ProjectWindow when it becomes a distinct class.
This commit is contained in:
Paul Licameli 2019-05-28 13:12:56 -04:00
parent 02afcbca8c
commit 82663892dc
49 changed files with 451 additions and 296 deletions

View File

@ -152,7 +152,7 @@ int ModuleDispatch(ModuleDispatchTypes type)
if( p== NULL ) if( p== NULL )
return 0; return 0;
wxMenuBar * pBar = p->GetMenuBar(); wxMenuBar * pBar = GetProjectFrame( *p ).GetMenuBar();
wxMenu * pMenu = pBar->GetMenu( 8 ); // Menu 8 is the Analyze Menu. wxMenu * pMenu = pBar->GetMenu( 8 ); // Menu 8 is the Analyze Menu.
CommandManager * c = &CommandManager::Get( *p ); CommandManager * c = &CommandManager::Get( *p );

View File

@ -844,7 +844,7 @@ namespace{
AudacityProject::AttachedWindows::RegisteredFactory sKey{ AudacityProject::AttachedWindows::RegisteredFactory sKey{
[]( AudacityProject &project ) -> wxWeakRef< wxWindow > { []( AudacityProject &project ) -> wxWeakRef< wxWindow > {
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &window = project; auto &window = ProjectWindow::Get( project );
return safenew AdornedRulerPanel( &project, window.GetTopPanel(), return safenew AdornedRulerPanel( &project, window.GetTopPanel(),
wxID_ANY, wxID_ANY,

View File

@ -956,9 +956,10 @@ void AudacityApp::OnTimer(wxTimerEvent& WXUNUSED(event))
// Get the users attention // Get the users attention
AudacityProject *project = GetActiveProject(); AudacityProject *project = GetActiveProject();
if (project) { if (project) {
project->Maximize(); auto &window = GetProjectFrame( *project );
project->Raise(); window.Maximize();
project->RequestUserAttention(); window.Raise();
window.RequestUserAttention();
} }
continue; continue;
} }
@ -989,8 +990,9 @@ void AudacityApp::OnTimer(wxTimerEvent& WXUNUSED(event))
// if there are no projects open, don't show the warning (user has closed it) // if there are no projects open, don't show the warning (user has closed it)
if (offendingProject) { if (offendingProject) {
offendingProject->Iconize(false); auto &window = GetProjectFrame( *offendingProject );
offendingProject->Raise(); window.Iconize(false);
window.Raise();
wxString errorMessage = wxString::Format(_( wxString errorMessage = wxString::Format(_(
"One or more external audio files could not be found.\n\ "One or more external audio files could not be found.\n\
@ -1074,7 +1076,7 @@ bool AudacityApp::OnExceptionInMainLoop()
// Forget pending changes in the TrackList // Forget pending changes in the TrackList
TrackList::Get( *pProject ).ClearPendingTracks(); TrackList::Get( *pProject ).ClearPendingTracks();
pProject->RedrawProject(); ProjectWindow::Get( *pProject ).RedrawProject();
} }
// Give the user an alert // Give the user an alert
@ -1512,8 +1514,9 @@ bool AudacityApp::OnInit()
wxWindow * pWnd = MakeHijackPanel(); wxWindow * pWnd = MakeHijackPanel();
if (pWnd) if (pWnd)
{ {
project->Show(false); auto &window = GetProjectFrame( *project );
pWnd->SetParent(project); window.Show(false);
pWnd->SetParent( &window );
SetTopWindow(pWnd); SetTopWindow(pWnd);
pWnd->Show(true); pWnd->Show(true);
} }

View File

@ -1700,7 +1700,8 @@ void AudioIO::StartMonitoring(double sampleRate)
if (!success) { if (!success) {
wxString msg = wxString::Format(_("Error opening recording device.\nError code: %s"), gAudioIO->LastPaErrorString()); wxString msg = wxString::Format(_("Error opening recording device.\nError code: %s"), gAudioIO->LastPaErrorString());
ShowErrorDialog(mOwningProject, _("Error"), msg, wxT("Error_opening_sound_device")); ShowErrorDialog( ProjectWindow::Find( mOwningProject ),
_("Error"), msg, wxT("Error_opening_sound_device"));
return; return;
} }

View File

@ -462,7 +462,7 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
auto success = GuardedCall< bool >( [&] { auto success = GuardedCall< bool >( [&] {
project->Import(files[i]); project->Import(files[i]);
project->ZoomAfterImport(nullptr); ProjectWindow::Get( *project ).ZoomAfterImport(nullptr);
SelectActions::DoSelectAll(*project); SelectActions::DoSelectAll(*project);
if (!mMacroCommands.ApplyMacro(mCatalog)) if (!mMacroCommands.ApplyMacro(mCatalog))
return false; return false;

View File

@ -597,6 +597,7 @@ void DependencyDialog::SaveFutureActionChoice()
bool ShowDependencyDialogIfNeeded(AudacityProject *project, bool ShowDependencyDialogIfNeeded(AudacityProject *project,
bool isSaving) bool isSaving)
{ {
auto pWindow = ProjectWindow::Find( project );
AliasedFileArray aliasedFiles; AliasedFileArray aliasedFiles;
FindDependencies(project, aliasedFiles); FindDependencies(project, aliasedFiles);
@ -611,7 +612,7 @@ you may lose data.");
AudacityMessageBox(msg, AudacityMessageBox(msg,
_("Dependency Check"), _("Dependency Check"),
wxOK | wxICON_INFORMATION, wxOK | wxICON_INFORMATION,
project); pWindow);
} }
return true; // Nothing to do. return true; // Nothing to do.
} }
@ -633,7 +634,7 @@ you may lose data.");
return true; return true;
} }
DependencyDialog dlog(project, -1, project, aliasedFiles, isSaving); DependencyDialog dlog(pWindow, -1, project, aliasedFiles, isSaving);
int returnCode = dlog.ShowModal(); int returnCode = dlog.ShowModal();
if (returnCode == wxID_CANCEL) if (returnCode == wxID_CANCEL)
return false; return false;

View File

@ -746,7 +746,7 @@ void LabelDialog::OnSelectCell(wxGridEvent &event)
RowData &rd = mData[event.GetRow()]; RowData &rd = mData[event.GetRow()];
mViewInfo->selectedRegion = rd.selectedRegion; mViewInfo->selectedRegion = rd.selectedRegion;
GetActiveProject()->RedrawProject(); ProjectWindow::Get( *GetActiveProject() ).RedrawProject();
} }
event.Skip(); event.Skip();

View File

@ -2180,7 +2180,7 @@ void LabelTrack::ShowContextMenu()
// Bug 2044. parent can be nullptr after a context switch. // Bug 2044. parent can be nullptr after a context switch.
if( !parent ) if( !parent )
parent = GetActiveProject(); parent = FindProjectFrame( GetActiveProject() );
if( parent ) if( parent )
{ {
@ -3091,8 +3091,9 @@ void LabelTrack::DoEditLabels
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto rate = project.GetRate(); auto rate = project.GetRate();
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &window = ProjectWindow::Get( project );
LabelDialog dlg(&project, trackFactory, &tracks, LabelDialog dlg(&window, trackFactory, &tracks,
lt, index, lt, index,
viewInfo, rate, viewInfo, rate,
format, freqFormat); format, freqFormat);
@ -3102,7 +3103,7 @@ void LabelTrack::DoEditLabels
if (dlg.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK) {
project.PushState(_("Edited labels"), _("Label")); project.PushState(_("Edited labels"), _("Label"));
project.RedrawProject(); window.RedrawProject();
} }
} }
@ -3121,7 +3122,8 @@ int LabelTrack::DialogForLabelName(
-40; -40;
position.y += 2; // just below the bottom of the track position.y += 2; // just below the bottom of the track
position = trackPanel.ClientToScreen(position); position = trackPanel.ClientToScreen(position);
AudacityTextEntryDialog dialog{ &project, auto &window = GetProjectFrame( project );
AudacityTextEntryDialog dialog{ &window,
_("Name:"), _("Name:"),
_("New label"), _("New label"),
initialValue, initialValue,
@ -3130,7 +3132,7 @@ int LabelTrack::DialogForLabelName(
// keep the dialog within Audacity's window, so that the dialog is always fully visible // keep the dialog within Audacity's window, so that the dialog is always fully visible
wxRect dialogScreenRect = dialog.GetScreenRect(); wxRect dialogScreenRect = dialog.GetScreenRect();
wxRect projScreenRect = project.GetScreenRect(); wxRect projScreenRect = window.GetScreenRect();
wxPoint max = projScreenRect.GetBottomRight() + wxPoint{ -dialogScreenRect.width, -dialogScreenRect.height }; wxPoint max = projScreenRect.GetBottomRight() + wxPoint{ -dialogScreenRect.width, -dialogScreenRect.height };
if (dialogScreenRect.x > max.x) { if (dialogScreenRect.x > max.x) {
position.x = max.x; position.x = max.x;

View File

@ -44,8 +44,8 @@ END_EVENT_TABLE()
const wxSize gSize = wxSize(LYRICS_DEFAULT_WIDTH, LYRICS_DEFAULT_HEIGHT); const wxSize gSize = wxSize(LYRICS_DEFAULT_WIDTH, LYRICS_DEFAULT_HEIGHT);
LyricsWindow::LyricsWindow(AudacityProject *parent): LyricsWindow::LyricsWindow(AudacityProject *parent)
wxFrame(parent, -1, : wxFrame( &GetProjectFrame( *parent ), -1,
wxString::Format(_("Audacity Karaoke%s"), wxString::Format(_("Audacity Karaoke%s"),
((parent->GetProjectName().empty()) ? ((parent->GetProjectName().empty()) ?
wxT("") : wxT("") :

View File

@ -51,6 +51,7 @@
#include "widgets/FileHistory.h" #include "widgets/FileHistory.h"
#include <wx/menu.h> #include <wx/menu.h>
#include <wx/windowptr.h>
MenuCreator::MenuCreator() MenuCreator::MenuCreator()
{ {
@ -302,7 +303,7 @@ void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
VisitItem( project, menuTree.get() ); VisitItem( project, menuTree.get() );
project.SetMenuBar(menubar.release()); GetProjectFrame( project ).SetMenuBar(menubar.release());
mLastFlags = AlwaysEnabledFlag; mLastFlags = AlwaysEnabledFlag;
@ -361,8 +362,9 @@ void MenuCreator::RebuildMenuBar(AudacityProject &project)
// Delete the menus, since we will soon recreate them. // Delete the menus, since we will soon recreate them.
// Rather oddly, the menus don't vanish as a result of doing this. // Rather oddly, the menus don't vanish as a result of doing this.
{ {
std::unique_ptr<wxMenuBar> menuBar{ project.GetMenuBar() }; auto &window = ProjectWindow::Get( project );
project.DetachMenuBar(); wxWindowPtr<wxMenuBar> menuBar{ window.GetMenuBar() };
window.DetachMenuBar();
// menuBar gets deleted here // menuBar gets deleted here
} }
@ -411,7 +413,8 @@ CommandFlag MenuManager::GetUpdateFlags
static auto lastFlags = flags; static auto lastFlags = flags;
// if (auto focus = wxWindow::FindFocus()) { // if (auto focus = wxWindow::FindFocus()) {
if (wxWindow * focus = &project) { auto &window = GetProjectFrame( project );
if (wxWindow * focus = &window) {
while (focus && focus->GetParent()) while (focus && focus->GetParent())
focus = focus->GetParent(); focus = focus->GetParent();
if (focus && !static_cast<wxTopLevelWindow*>(focus)->IsIconized()) if (focus && !static_cast<wxTopLevelWindow*>(focus)->IsIconized())
@ -430,7 +433,7 @@ CommandFlag MenuManager::GetUpdateFlags
flags |= NotPausedFlag; flags |= NotPausedFlag;
// quick 'short-circuit' return. // quick 'short-circuit' return.
if ( checkActive && !project.IsActive() ){ if ( checkActive && !window.IsActive() ){
const auto checkedFlags = const auto checkedFlags =
NotMinimizedFlag | AudioIONotBusyFlag | AudioIOBusyFlag | NotMinimizedFlag | AudioIONotBusyFlag | AudioIOBusyFlag |
PausedFlag | NotPausedFlag; PausedFlag | NotPausedFlag;
@ -749,9 +752,10 @@ void MenuCreator::RebuildAllMenuBars()
// http://bugzilla.audacityteam.org/show_bug.cgi?id=458 // http://bugzilla.audacityteam.org/show_bug.cgi?id=458
// //
// This workaround should be removed when Audacity updates to wxWidgets 3.x which has a fix. // This workaround should be removed when Audacity updates to wxWidgets 3.x which has a fix.
wxRect r = p->GetRect(); auto &window = GetProjectFrame( *p );
p->SetSize(wxSize(1,1)); wxRect r = window.GetRect();
p->SetSize(r.GetSize()); window.SetSize(wxSize(1,1));
window.SetSize(r.GetSize());
#endif #endif
} }
} }

View File

@ -36,8 +36,9 @@ MissingAliasFileDialog::MissingAliasFileDialog(wxWindow *parent,
const wxString & dlogTitle, const wxString & dlogTitle,
const wxString & message, const wxString & message,
const wxString & helpURL, const wxString & helpURL,
const bool Close, const bool modal): const bool Close, const bool modal)
ErrorDialog(parent, dlogTitle, message, helpURL, Close, modal) : ErrorDialog( parent,
dlogTitle, message, helpURL, Close, modal )
{ {
sDialogs.push_back( this ); sDialogs.push_back( this );
} }
@ -62,12 +63,13 @@ namespace MissingAliasFilesDialog {
using Lock = std::unique_lock< std::mutex >; using Lock = std::unique_lock< std::mutex >;
void Show(AudacityProject *parent, void Show(AudacityProject *project,
const wxString &dlogTitle, const wxString &dlogTitle,
const wxString &message, const wxString &message,
const wxString &helpPage, const wxString &helpPage,
const bool Close) const bool Close)
{ {
auto parent = FindProjectFrame( project );
wxASSERT(parent); // to justify safenew wxASSERT(parent); // to justify safenew
ErrorDialog *dlog = safenew MissingAliasFileDialog(parent, dlogTitle, message, helpPage, Close, false); ErrorDialog *dlog = safenew MissingAliasFileDialog(parent, dlogTitle, message, helpPage, Close, false);
// Don't center because in many cases (effect, export, etc) there will be a progress bar in the center that blocks this. // Don't center because in many cases (effect, export, etc) there will be a progress bar in the center that blocks this.
@ -92,10 +94,11 @@ namespace MissingAliasFilesDialog {
wxDialog *Find( const AudacityProject &project ) wxDialog *Find( const AudacityProject &project )
{ {
auto &window = GetProjectFrame( project );
auto begin = sDialogs.begin(), end = sDialogs.end(), auto begin = sDialogs.begin(), end = sDialogs.end(),
iter = std::find_if( begin, end, iter = std::find_if( begin, end,
[&]( const wxDialogRef &ref ){ [&]( const wxDialogRef &ref ){
return ref && ref->GetParent() == &project; } ); return ref && ref->GetParent() == &window; } );
if (iter != end) if (iter != end)
return *iter; return *iter;
return nullptr; return nullptr;

View File

@ -748,9 +748,7 @@ void MixerTrackCluster::OnButton_Mute(wxCommandEvent& WXUNUSED(event))
// Update the TrackPanel correspondingly. // Update the TrackPanel correspondingly.
if (mProject->IsSoloSimple()) if (mProject->IsSoloSimple())
{ ProjectWindow::Get( *mProject ).RedrawProject();
mProject->RedrawProject();
}
else else
// Update only the changed track. // Update only the changed track.
TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get()); TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get());
@ -765,7 +763,7 @@ void MixerTrackCluster::OnButton_Solo(wxCommandEvent& WXUNUSED(event))
// Update the TrackPanel correspondingly. // Update the TrackPanel correspondingly.
// Bug 509: Must repaint all, as many tracks can change with one Solo change. // Bug 509: Must repaint all, as many tracks can change with one Solo change.
mProject->RedrawProject(); ProjectWindow::Get( *mProject ).RedrawProject();
} }
@ -1397,7 +1395,7 @@ const wxSize kDefaultSize =
wxSize(MIXER_BOARD_MIN_WIDTH, MIXER_BOARD_MIN_HEIGHT); wxSize(MIXER_BOARD_MIN_WIDTH, MIXER_BOARD_MIN_HEIGHT);
MixerBoardFrame::MixerBoardFrame(AudacityProject* parent) MixerBoardFrame::MixerBoardFrame(AudacityProject* parent)
: wxFrame(parent, -1, : wxFrame( &GetProjectFrame( *parent ), -1,
wxString::Format(_("Audacity Mixer Board%s"), wxString::Format(_("Audacity Mixer Board%s"),
((parent->GetProjectName().empty()) ? ((parent->GetProjectName().empty()) ?
wxT("") : wxT("") :

View File

@ -184,11 +184,11 @@ bool AllProjects::Close( bool force )
// of deletion from gAudacityProjects // of deletion from gAudacityProjects
if ( force ) if ( force )
{ {
gAudacityProjects[0]->Close(true); GetProjectFrame( *gAudacityProjects[0] ).Close(true);
} }
else else
{ {
if (!gAudacityProjects[0]->Close()) if (! GetProjectFrame( *gAudacityProjects[0] ).Close())
return false; return false;
} }
} }
@ -202,14 +202,15 @@ void AllProjects::SaveWindowSize()
return; return;
} }
bool validWindowForSaveWindowSize = FALSE; bool validWindowForSaveWindowSize = FALSE;
AudacityProject * validProject = NULL; ProjectWindow * validProject = nullptr;
bool foundIconizedProject = FALSE; bool foundIconizedProject = FALSE;
size_t numProjects = gAudacityProjects.size(); size_t numProjects = gAudacityProjects.size();
for (size_t i = 0; i < numProjects; i++) for (size_t i = 0; i < numProjects; i++)
{ {
if (!gAudacityProjects[i]->IsIconized()) { auto &window = ProjectWindow::Get( *gAudacityProjects[i] );
if (!window.IsIconized()) {
validWindowForSaveWindowSize = TRUE; validWindowForSaveWindowSize = TRUE;
validProject = gAudacityProjects[i].get(); validProject = &window;
i = numProjects; i = numProjects;
} }
else else
@ -235,7 +236,7 @@ void AllProjects::SaveWindowSize()
else else
{ {
if (foundIconizedProject) { if (foundIconizedProject) {
validProject = gAudacityProjects[0].get(); validProject = &ProjectWindow::Get( *gAudacityProjects[0] );
bool wndMaximized = validProject->IsMaximized(); bool wndMaximized = validProject->IsMaximized();
wxRect normalRect = validProject->GetNormalizedWindowState(); wxRect normalRect = validProject->GetNormalizedWindowState();
// store only the normal rectangle because the itemized rectangle // store only the normal rectangle because the itemized rectangle
@ -403,7 +404,7 @@ void SetActiveProject(AudacityProject * project)
gActiveProject = project; gActiveProject = project;
KeyboardCapture::Capture( nullptr ); KeyboardCapture::Capture( nullptr );
} }
wxTheApp->SetTopWindow(project); wxTheApp->SetTopWindow( FindProjectFrame( project ) );
} }
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
@ -552,7 +553,7 @@ public:
ODManager::Pauser pauser; ODManager::Pauser pauser;
auto cleanup = finally( [&] { auto cleanup = finally( [&] {
mProject->HandleResize(); // Adjust scrollers for NEW track sizes. ProjectWindow::Get( *mProject ).HandleResize(); // Adjust scrollers for NEW track sizes.
} ); } );
for (const auto &name : sortednames) { for (const auto &name : sortednames) {
@ -564,7 +565,8 @@ public:
mProject->Import(name); mProject->Import(name);
} }
mProject->ZoomAfterImport(nullptr); auto &window = ProjectWindow::Get( *mProject );
window.ZoomAfterImport(nullptr);
return true; return true;
} ); } );
@ -669,17 +671,19 @@ AudacityProject *CreateNewAudacityProject()
Destroyer< AudacityProject > {} Destroyer< AudacityProject > {}
} ); } );
const auto p = gAudacityProjects.back().get(); const auto p = gAudacityProjects.back().get();
auto &project = *p;
auto &window = GetProjectFrame( *p );
// wxGTK3 seems to need to require creating the window using default position // wxGTK3 seems to need to require creating the window using default position
// and then manually positioning it. // and then manually positioning it.
p->SetPosition(wndRect.GetPosition()); window.SetPosition(wndRect.GetPosition());
if(bMaximized) { if(bMaximized) {
p->Maximize(true); window.Maximize(true);
} }
else if (bIconized) { else if (bIconized) {
// if the user close down and iconized state we could start back up and iconized state // if the user close down and iconized state we could start back up and iconized state
// p->Iconize(TRUE); // window.Iconize(TRUE);
} }
//Initialise the Listener //Initialise the Listener
@ -694,7 +698,7 @@ AudacityProject *CreateNewAudacityProject()
ModuleManager::Get().Dispatch(ProjectInitialized); ModuleManager::Get().Dispatch(ProjectInitialized);
p->Show(true); window.Show(true);
return p; return p;
} }
@ -703,21 +707,21 @@ void RedrawAllProjects()
{ {
size_t len = gAudacityProjects.size(); size_t len = gAudacityProjects.size();
for (size_t i = 0; i < len; i++) for (size_t i = 0; i < len; i++)
gAudacityProjects[i]->RedrawProject(); ProjectWindow::Get( *gAudacityProjects[i] ).RedrawProject();
} }
void RefreshCursorForAllProjects() void RefreshCursorForAllProjects()
{ {
size_t len = gAudacityProjects.size(); size_t len = gAudacityProjects.size();
for (size_t i = 0; i < len; i++) for (size_t i = 0; i < len; i++)
gAudacityProjects[i]->RefreshCursor(); ProjectWindow::Get( *gAudacityProjects[i] ).RefreshCursor();
} }
AUDACITY_DLL_API void CloseAllProjects() AUDACITY_DLL_API void CloseAllProjects()
{ {
size_t len = gAudacityProjects.size(); size_t len = gAudacityProjects.size();
for (size_t i = 0; i < len; i++) for (size_t i = 0; i < len; i++)
gAudacityProjects[i]->Close(); GetProjectFrame( *gAudacityProjects[i] ).Close();
//Set the Offset and Position increments to 0 //Set the Offset and Position increments to 0
gAudacityOffsetInc = 0; gAudacityOffsetInc = 0;
@ -904,12 +908,12 @@ void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized)
} }
bool validWindowSize = false; bool validWindowSize = false;
AudacityProject * validProject = NULL; ProjectWindow * validProject = NULL;
size_t numProjects = gAudacityProjects.size(); size_t numProjects = gAudacityProjects.size();
for (int i = numProjects; i > 0 ; i--) { for (int i = numProjects; i > 0 ; i--) {
if (!gAudacityProjects[i-1]->IsIconized()) { if (!GetProjectFrame( *gAudacityProjects[i-1] ).IsIconized()) {
validWindowSize = true; validWindowSize = true;
validProject = gAudacityProjects[i-1].get(); validProject = &ProjectWindow::Get( *gAudacityProjects[i-1] );
break; break;
} }
} }
@ -1439,7 +1443,7 @@ void AudacityProject::OnThemeChange(wxCommandEvent& evt)
{ {
evt.Skip(); evt.Skip();
auto &project = *this; auto &project = *this;
ApplyUpdatedTheme(); ProjectWindow::Get( project ).ApplyUpdatedTheme();
auto &toolManager = ToolManager::Get( project ); auto &toolManager = ToolManager::Get( project );
for( int ii = 0; ii < ToolBarCount; ++ii ) for( int ii = 0; ii < ToolBarCount; ++ii )
{ {
@ -2144,7 +2148,7 @@ void AudacityProject::RefreshAllTitles(bool bShowProjectNumbers )
{ {
for ( size_t i = 0; i < gAudacityProjects.size(); i++) { for ( size_t i = 0; i < gAudacityProjects.size(); i++) {
if ( gAudacityProjects[i] ) { if ( gAudacityProjects[i] ) {
if ( !gAudacityProjects[i]->mIconized ) { if ( !GetProjectFrame( *gAudacityProjects[i] ).IsIconized() ) {
AudacityProject * p; AudacityProject * p;
p = gAudacityProjects[i].get(); p = gAudacityProjects[i].get();
p->SetProjectTitle( bShowProjectNumbers ? p->GetProjectNumber() : -1 ); p->SetProjectTitle( bShowProjectNumbers ? p->GetProjectNumber() : -1 );
@ -2169,7 +2173,7 @@ void AudacityProject::OnIconize(wxIconizeEvent &event)
// It's not used outside this function. // It's not used outside this function.
for(i=0;i<gAudacityProjects.size();i++){ for(i=0;i<gAudacityProjects.size();i++){
if(gAudacityProjects[i]){ if(gAudacityProjects[i]){
if( !gAudacityProjects[i]->mIconized ) if( !GetProjectFrame( *gAudacityProjects[i] ).IsIconized() )
VisibleProjectCount++; VisibleProjectCount++;
} }
} }
@ -2418,9 +2422,10 @@ void AudacityProject::OnMouseEvent(wxMouseEvent & event)
class TitleRestorer{ class TitleRestorer{
public: public:
TitleRestorer(AudacityProject * p ){ TitleRestorer(AudacityProject * p ){
if( p->IsIconized() ) auto &window = GetProjectFrame( *p );
p->Restore(); if( window.IsIconized() )
p->Raise(); // May help identifying the window on Mac window.Restore();
window.Raise(); // May help identifying the window on Mac
// Construct this projects name and number. // Construct this projects name and number.
sProjName = p->GetProjectName(); sProjName = p->GetProjectName();
@ -2881,11 +2886,15 @@ AudacityProject *AudacityProject::OpenProject(
AudacityProject *pNewProject = nullptr; AudacityProject *pNewProject = nullptr;
if ( ! pProject ) if ( ! pProject )
pProject = pNewProject = CreateNewAudacityProject(); pProject = pNewProject = CreateNewAudacityProject();
auto cleanup = finally( [&] { if( pNewProject ) pNewProject->Close(true); } ); auto cleanup = finally( [&] {
if( pNewProject )
GetProjectFrame( *pNewProject ).Close(true);
} );
pProject->OpenFile( fileNameArg, addtohistory ); pProject->OpenFile( fileNameArg, addtohistory );
pNewProject = nullptr; pNewProject = nullptr;
if( pProject && pProject->mIsRecovered ) if( pProject && pProject->mIsRecovered )
pProject->Zoom( ViewActions::GetZoomOfToFit( *pProject ) ); ProjectWindow::Get( *pProject ).Zoom(
ViewActions::GetZoomOfToFit( *pProject ) );
return pProject; return pProject;
} }
@ -3385,6 +3394,7 @@ void AudacityProject::EnqueueODTasks()
bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs) bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
{ {
auto &project = *this; auto &project = *this;
auto &window = ProjectWindow::Get( project );
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &dirManager = DirManager::Get( project ); auto &dirManager = DirManager::Get( project );
bool bFileVersionFound = false; bool bFileVersionFound = false;
@ -3527,7 +3537,7 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
if (longVpos != 0) { if (longVpos != 0) {
// PRL: It seems this must happen after SetSnapTo // PRL: It seems this must happen after SetSnapTo
viewInfo.vpos = longVpos; viewInfo.vpos = longVpos;
mbInitializingScrollbar = true; window.mbInitializingScrollbar = true;
} }
// Specifically detect newer versions of Audacity // Specifically detect newer versions of Audacity
@ -3786,7 +3796,7 @@ bool AudacityProject::DoSave (const bool fromSaveAs,
// See explanation above // See explanation above
// ProjectDisabler disabler(this); // ProjectDisabler disabler(this);
auto &proj = *this; auto &proj = *this;
auto &window = proj; auto &window = GetProjectFrame( proj );
auto &dirManager = DirManager::Get( proj ); auto &dirManager = DirManager::Get( proj );
wxASSERT_MSG(!bWantSaveCopy || fromSaveAs, "Copy Project SHOULD only be availabele from SaveAs"); wxASSERT_MSG(!bWantSaveCopy || fromSaveAs, "Copy Project SHOULD only be availabele from SaveAs");
@ -5089,7 +5099,7 @@ void AudacityProject::MayStartMonitoring()
void AudacityProject::OnAudioIORate(int rate) void AudacityProject::OnAudioIORate(int rate)
{ {
auto &project = *this; auto &project = *this;
auto &window = project; auto &window = GetProjectFrame( project );
wxString display; wxString display;
if (rate > 0) { if (rate > 0) {
display = wxString::Format(_("Actual Rate: %d"), rate); display = wxString::Format(_("Actual Rate: %d"), rate);
@ -5123,6 +5133,7 @@ void AudacityProject::OnAudioIOStopRecording()
{ {
auto &project = *this; auto &project = *this;
auto &dirManager = DirManager::Get( project ); auto &dirManager = DirManager::Get( project );
auto &window = ProjectWindow::Get( project );
// Only push state if we were capturing and not monitoring // Only push state if we were capturing and not monitoring
if (GetAudioIOToken() > 0) if (GetAudioIOToken() > 0)
@ -5147,7 +5158,7 @@ void AudacityProject::OnAudioIOStopRecording()
interval.first + interval.second }, interval.first + interval.second },
wxString::Format(wxT("%ld"), counter++), wxString::Format(wxT("%ld"), counter++),
-2 ); -2 );
ShowWarningDialog(this, wxT("DropoutDetected"), _("\ ShowWarningDialog(&window, wxT("DropoutDetected"), _("\
Recorded audio was lost at the labeled locations. Possible causes:\n\ Recorded audio was lost at the labeled locations. Possible causes:\n\
\n\ \n\
Other applications are competing with Audacity for processor time\n\ Other applications are competing with Audacity for processor time\n\
@ -5170,8 +5181,8 @@ You are saving directly to a slow external storage device\n\
} }
// Refresh the project window // Refresh the project window
FixScrollbars(); window.FixScrollbars();
RedrawProject(); window.RedrawProject();
} }
// Write all cached files to disk, if any // Write all cached files to disk, if any
@ -5421,7 +5432,7 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
} }
viewInfo.h = viewInfo.h =
viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true); viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true);
if (!mProject->MayScrollBeyondZero()) if (!ProjectWindow::Get( *mProject ).MayScrollBeyondZero())
// Can't scroll too far left // Can't scroll too far left
viewInfo.h = std::max(0.0, viewInfo.h); viewInfo.h = std::max(0.0, viewInfo.h);
trackPanel.Refresh(false); trackPanel.Refresh(false);

View File

@ -165,6 +165,7 @@ using AttachedWindows = ClientData::Site<
AudacityProject, wxWindow, ClientData::SkipCopying, wxWeakRef AudacityProject, wxWindow, ClientData::SkipCopying, wxWeakRef
>; >;
using ProjectWindow = AudacityProject;
class AUDACITY_DLL_API AudacityProject final : public wxFrame, class AUDACITY_DLL_API AudacityProject final : public wxFrame,
public TrackPanelListener, public TrackPanelListener,
public SelectionBarListener, public SelectionBarListener,
@ -176,6 +177,12 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
, public AttachedWindows , public AttachedWindows
{ {
public: public:
static ProjectWindow &Get( AudacityProject &project ) { return project; }
static const ProjectWindow &Get( const AudacityProject &project ) { return project; }
static ProjectWindow *Find( AudacityProject *pProject ) { return pProject; }
static const ProjectWindow *Find( const AudacityProject *pProject ) { return pProject; }
AudacityProject &GetProject() { return *this; }
using AttachedObjects = ::AttachedObjects; using AttachedObjects = ::AttachedObjects;
using AttachedWindows = ::AttachedWindows; using AttachedWindows = ::AttachedWindows;
@ -648,6 +655,17 @@ public:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
inline wxFrame &GetProjectFrame( AudacityProject &project ) { return project; }
inline const wxFrame &GetProjectFrame( const AudacityProject &project ) {
return project;
}
inline wxFrame *FindProjectFrame( AudacityProject *project ) {
return project ? &GetProjectFrame( *project ) : nullptr;
}
inline const wxFrame *FindProjectFrame( const AudacityProject *project ) {
return project ? &GetProjectFrame( *project ) : nullptr;
}
AudioIOStartStreamOptions DefaultPlayOptions( AudacityProject &project ); AudioIOStartStreamOptions DefaultPlayOptions( AudacityProject &project );
AudioIOStartStreamOptions DefaultSpeedPlayOptions( AudacityProject &project ); AudioIOStartStreamOptions DefaultSpeedPlayOptions( AudacityProject &project );

View File

@ -470,7 +470,7 @@ void ScreenFrame::PopulateOrExchange(ShuttleGui & S)
CentreOnParent(); CentreOnParent();
} }
SetIcon(mContext.project.GetIcon()); SetIcon( GetProjectFrame( mContext.project ).GetIcon() );
} }
bool ScreenFrame::ProcessEvent(wxEvent & e) bool ScreenFrame::ProcessEvent(wxEvent & e)
@ -565,8 +565,9 @@ void ScreenFrame::SizeMainWindow(int w, int h)
{ {
int top = 20; int top = 20;
mContext.project.Maximize(false); auto &window = GetProjectFrame( mContext.project );
mContext.project.SetSize(16, 16 + top, w, h); window.Maximize(false);
window.SetSize(16, 16 + top, w, h);
//Bug383 - Toolbar Resets not wanted. //Bug383 - Toolbar Resets not wanted.
//ToolManager::Get( mContext.project ).Reset(); //ToolManager::Get( mContext.project ).Reset();
} }
@ -670,10 +671,11 @@ void ScreenFrame::OnCaptureSomething(wxCommandEvent & event)
void ScreenFrame::TimeZoom(double seconds) void ScreenFrame::TimeZoom(double seconds)
{ {
auto &viewInfo = ViewInfo::Get( mContext.project ); auto &viewInfo = ViewInfo::Get( mContext.project );
auto &window = ProjectWindow::Get( mContext.project );
int width, height; int width, height;
mContext.project.GetClientSize(&width, &height); window.GetClientSize(&width, &height);
viewInfo.SetZoom((0.75 * width) / seconds); viewInfo.SetZoom((0.75 * width) / seconds);
mContext.project.RedrawProject(); window.RedrawProject();
} }
void ScreenFrame::OnOneSec(wxCommandEvent & WXUNUSED(event)) void ScreenFrame::OnOneSec(wxCommandEvent & WXUNUSED(event))
@ -718,7 +720,7 @@ void ScreenFrame::SizeTracks(int h)
for (auto channel : channels) for (auto channel : channels)
channel->SetHeight(height); channel->SetHeight(height);
} }
mContext.project.RedrawProject(); ProjectWindow::Get( mContext.project ).RedrawProject();
} }
void ScreenFrame::OnShortTracks(wxCommandEvent & WXUNUSED(event)) void ScreenFrame::OnShortTracks(wxCommandEvent & WXUNUSED(event))
@ -726,7 +728,7 @@ void ScreenFrame::OnShortTracks(wxCommandEvent & WXUNUSED(event))
for (auto t : TrackList::Get( mContext.project ).Any<WaveTrack>()) for (auto t : TrackList::Get( mContext.project ).Any<WaveTrack>())
t->SetHeight(t->GetMinimizedHeight()); t->SetHeight(t->GetMinimizedHeight());
mContext.project.RedrawProject(); ProjectWindow::Get( mContext.project ).RedrawProject();
} }
void ScreenFrame::OnMedTracks(wxCommandEvent & WXUNUSED(event)) void ScreenFrame::OnMedTracks(wxCommandEvent & WXUNUSED(event))

View File

@ -213,7 +213,7 @@ AudacityProject::AttachedWindows::RegisteredFactory sKey{
[]( AudacityProject &project ) -> wxWeakRef< wxWindow > { []( AudacityProject &project ) -> wxWeakRef< wxWindow > {
auto &ruler = AdornedRulerPanel::Get( project ); auto &ruler = AdornedRulerPanel::Get( project );
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &window = project; auto &window = ProjectWindow::Get( project );
auto mainPage = window.GetMainPage(); auto mainPage = window.GetMainPage();
wxASSERT( mainPage ); // to justify safenew wxASSERT( mainPage ); // to justify safenew
@ -263,7 +263,7 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
AdornedRulerPanel * ruler) AdornedRulerPanel * ruler)
: CellularPanel(parent, id, pos, size, viewInfo, : CellularPanel(parent, id, pos, size, viewInfo,
wxWANTS_CHARS | wxNO_BORDER), wxWANTS_CHARS | wxNO_BORDER),
mListener(project), mListener( &ProjectWindow::Get( *project ) ),
mTracks(tracks), mTracks(tracks),
mRuler(ruler), mRuler(ruler),
mTrackArtist(nullptr), mTrackArtist(nullptr),
@ -299,7 +299,8 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
mTimeCount = 0; mTimeCount = 0;
mTimer.parent = this; mTimer.parent = this;
// Timer is started after the window is visible // Timer is started after the window is visible
GetProject()->Bind(wxEVT_IDLE, &TrackPanel::OnIdle, this); ProjectWindow::Get( *GetProject() ).Bind(wxEVT_IDLE,
&TrackPanel::OnIdle, this);
// Register for tracklist updates // Register for tracklist updates
mTracks->Bind(EVT_TRACKLIST_RESIZING, mTracks->Bind(EVT_TRACKLIST_RESIZING,
@ -417,9 +418,9 @@ AudacityProject * TrackPanel::GetProject() const
#endif #endif
pWind = pWind->GetParent(); //MainPanel pWind = pWind->GetParent(); //MainPanel
wxASSERT( pWind ); wxASSERT( pWind );
pWind = pWind->GetParent(); //Project pWind = pWind->GetParent(); //ProjectWindow
wxASSERT( pWind ); wxASSERT( pWind );
return (AudacityProject*)pWind; return &static_cast<ProjectWindow*>( pWind )->GetProject();
} }
void TrackPanel::OnIdle(wxIdleEvent& event) void TrackPanel::OnIdle(wxIdleEvent& event)
@ -430,7 +431,8 @@ void TrackPanel::OnIdle(wxIdleEvent& event)
mTimer.Start(kTimerInterval, FALSE); mTimer.Start(kTimerInterval, FALSE);
// Timer is started, we don't need the event anymore // Timer is started, we don't need the event anymore
GetProject()->Unbind(wxEVT_IDLE, &TrackPanel::OnIdle, this); GetProjectFrame( *GetProject() ).Unbind(wxEVT_IDLE,
&TrackPanel::OnIdle, this);
} }
else else
{ {
@ -450,14 +452,16 @@ void TrackPanel::OnTimer(wxTimerEvent& )
// us a deactivate event for the application. // us a deactivate event for the application.
{ {
auto project = GetProject(); auto project = GetProject();
if (project->IsIconized()) auto &window = ProjectWindow::Get( *project );
project->MacShowUndockedToolbars(false); if (window.IsIconized())
window.MacShowUndockedToolbars(false);
} }
#endif #endif
mTimeCount++; mTimeCount++;
AudacityProject *const p = GetProject(); AudacityProject *const p = GetProject();
auto &window = ProjectWindow::Get( *p );
// Check whether we were playing or recording, but the stream has stopped. // Check whether we were playing or recording, but the stream has stopped.
if (p->GetAudioIOToken()>0 && !IsAudioActive()) if (p->GetAudioIOToken()>0 && !IsAudioActive())
@ -473,9 +477,9 @@ void TrackPanel::OnTimer(wxTimerEvent& )
if (p->GetAudioIOToken()>0 && if (p->GetAudioIOToken()>0 &&
!gAudioIO->IsAudioTokenActive(p->GetAudioIOToken())) !gAudioIO->IsAudioTokenActive(p->GetAudioIOToken()))
{ {
p->FixScrollbars(); window.FixScrollbars();
p->SetAudioIOToken(0); p->SetAudioIOToken(0);
p->RedrawProject(); window.RedrawProject();
mRedrawAfterStop = false; mRedrawAfterStop = false;
@ -2762,7 +2766,8 @@ LWSlider * TrackInfo::GainSlider
gGainCaptured->Set(gain); gGainCaptured->Set(gain);
auto slider = (captured ? gGainCaptured : gGain).get(); auto slider = (captured ? gGainCaptured : gGain).get();
slider->SetParent( pParent ? pParent : ::GetActiveProject() ); slider->SetParent( pParent ? pParent :
FindProjectFrame( ::GetActiveProject() ) );
return slider; return slider;
} }
@ -2778,7 +2783,8 @@ LWSlider * TrackInfo::PanSlider
gPanCaptured->Set(pan); gPanCaptured->Set(pan);
auto slider = (captured ? gPanCaptured : gPan).get(); auto slider = (captured ? gPanCaptured : gPan).get();
slider->SetParent( pParent ? pParent : ::GetActiveProject() ); slider->SetParent( pParent ? pParent :
FindProjectFrame( ::GetActiveProject() ) );
return slider; return slider;
} }
@ -2795,7 +2801,8 @@ LWSlider * TrackInfo::VelocitySlider
gVelocityCaptured->Set(velocity); gVelocityCaptured->Set(velocity);
auto slider = (captured ? gVelocityCaptured : gVelocity).get(); auto slider = (captured ? gVelocityCaptured : gVelocity).get();
slider->SetParent( pParent ? pParent : ::GetActiveProject() ); slider->SetParent( pParent ? pParent :
FindProjectFrame( ::GetActiveProject() ) );
return slider; return slider;
} }
#endif #endif

View File

@ -59,5 +59,5 @@ void CommandHandler::OnReceiveCommand(AppCommandEvent &event)
wxUnusedVar(result); wxUnusedVar(result);
// Redraw the project // Redraw the project
context.project.RedrawProject(); ProjectWindow::Get( context.project ).RedrawProject();
} }

View File

@ -1119,6 +1119,7 @@ wxString CommandManager::DescribeCommandsAndShortcuts
/// ///
bool CommandManager::FilterKeyEvent(AudacityProject *project, const wxKeyEvent & evt, bool permit) bool CommandManager::FilterKeyEvent(AudacityProject *project, const wxKeyEvent & evt, bool permit)
{ {
auto pWindow = FindProjectFrame( project );
CommandListEntry *entry = mCommandKeyHash[KeyEventToKeyString(evt)]; CommandListEntry *entry = mCommandKeyHash[KeyEventToKeyString(evt)];
if (entry == NULL) if (entry == NULL)
{ {
@ -1141,10 +1142,10 @@ bool CommandManager::FilterKeyEvent(AudacityProject *project, const wxKeyEvent &
wxWindow * pFocus = wxWindow::FindFocus(); wxWindow * pFocus = wxWindow::FindFocus();
wxWindow * pParent = wxGetTopLevelParent( pFocus ); wxWindow * pParent = wxGetTopLevelParent( pFocus );
bool validTarget = pParent == project; bool validTarget = pParent == pWindow;
// Bug 1557. MixerBoard should count as 'destined for project' // Bug 1557. MixerBoard should count as 'destined for project'
// MixerBoard IS a TopLevelWindow, and its parent is the project. // MixerBoard IS a TopLevelWindow, and its parent is the project.
if( pParent && pParent->GetParent() == project){ if( pParent && pParent->GetParent() == pWindow ){
if( dynamic_cast< TopLevelKeystrokeHandlingWindow* >( pParent ) != NULL ) if( dynamic_cast< TopLevelKeystrokeHandlingWindow* >( pParent ) != NULL )
validTarget = true; validTarget = true;
} }
@ -1280,7 +1281,8 @@ bool CommandManager::HandleMenuID(int id, CommandFlag flags, CommandMask mask)
// Only want one page of the preferences // Only want one page of the preferences
PrefsDialog::Factories factories; PrefsDialog::Factories factories;
factories.push_back(KeyConfigPrefsFactory( entry->name )); factories.push_back(KeyConfigPrefsFactory( entry->name ));
GlobalPrefsDialog dialog(GetActiveProject(), factories); auto pWindow = FindProjectFrame( GetActiveProject() );
GlobalPrefsDialog dialog( pWindow, factories );
dialog.ShowModal(); dialog.ShowModal();
MenuCreator::RebuildAllMenuBars(); MenuCreator::RebuildAllMenuBars();
return true; return true;
@ -1654,7 +1656,7 @@ static struct InstallHandlers
// We must have a project since we will be working with the // We must have a project since we will be working with the
// CommandManager, which is tied to individual projects. // CommandManager, which is tied to individual projects.
AudacityProject *project = GetActiveProject(); AudacityProject *project = GetActiveProject();
return project && project->IsEnabled(); return project && GetProjectFrame( *project ).IsEnabled();
} ); } );
KeyboardCapture::SetPostFilter( []( wxKeyEvent &key ) { KeyboardCapture::SetPostFilter( []( wxKeyEvent &key ) {
// Capture handler window didn't want it, so ask the CommandManager. // Capture handler window didn't want it, so ask the CommandManager.

View File

@ -90,7 +90,7 @@ bool DragCommand::Apply(const CommandContext & context)
if( !bHasToY ) if( !bHasToY )
mToY = 10; mToY = 10;
wxWindow * pWin = &context.project; wxWindow * pWin = &GetProjectFrame( context.project );
wxWindow * pWin1 = nullptr; wxWindow * pWin1 = nullptr;
wxMouseEvent Evt( wxEVT_MOTION ); wxMouseEvent Evt( wxEVT_MOTION );
Evt.m_x = mFromX; Evt.m_x = mFromX;

View File

@ -159,7 +159,7 @@ bool GetInfoCommand::ApplyInner(const CommandContext &context)
bool GetInfoCommand::SendMenus(const CommandContext &context) bool GetInfoCommand::SendMenus(const CommandContext &context)
{ {
wxMenuBar * pBar = context.project.GetMenuBar(); wxMenuBar * pBar = GetProjectFrame( context.project ).GetMenuBar();
if(!pBar ){ if(!pBar ){
wxLogDebug("No menus"); wxLogDebug("No menus");
return false; return false;
@ -418,12 +418,12 @@ wxSpinCtrl * ShuttleGuiGetDefinition::TieSpinCtrl(
bool GetInfoCommand::SendPreferences(const CommandContext &context) bool GetInfoCommand::SendPreferences(const CommandContext &context)
{ {
context.StartArray(); context.StartArray();
GlobalPrefsDialog dialog( &context.project ); auto pWin = &GetProjectFrame( context.project );
GlobalPrefsDialog dialog( pWin );
// wxCommandEvent Evt; // wxCommandEvent Evt;
//dialog.Show(); //dialog.Show();
wxWindow * pWin = &context.project;
ShuttleGuiGetDefinition S(pWin, *((context.pOutput)->mStatusTarget) ); ShuttleGuiGetDefinition S(pWin, *((context.pOutput)->mStatusTarget) );
dialog.ShuttleAll( S ); dialog.ShuttleAll( S );
context.EndArray(); context.EndArray();
return true; return true;
} }
@ -454,7 +454,7 @@ bool GetInfoCommand::SendCommands(const CommandContext &context, int flags )
bool GetInfoCommand::SendBoxes(const CommandContext &context) bool GetInfoCommand::SendBoxes(const CommandContext &context)
{ {
//context.Status("Boxes"); //context.Status("Boxes");
wxWindow * pWin = &context.project; auto pWin = &GetProjectFrame( context.project );
context.StartArray(); context.StartArray();
wxRect R = pWin->GetScreenRect(); wxRect R = pWin->GetScreenRect();

View File

@ -150,7 +150,7 @@ void IdleHandler(wxIdleEvent& event){
wxTopLevelWindow *ScreenshotCommand::GetFrontWindow(AudacityProject *project) wxTopLevelWindow *ScreenshotCommand::GetFrontWindow(AudacityProject *project)
{ {
wxWindow *front = NULL; wxWindow *front = NULL;
wxWindow *proj = wxGetTopLevelParent(project); wxWindow *proj = wxGetTopLevelParent( ProjectWindow::Find( project ) );
// JKC: The code below is no longer such a good idea. // JKC: The code below is no longer such a good idea.
@ -795,7 +795,7 @@ wxRect ScreenshotCommand::GetTrackRect( AudacityProject * pProj, TrackPanel * pa
} }
wxString ScreenshotCommand::WindowFileName(AudacityProject * proj, wxTopLevelWindow *w){ wxString ScreenshotCommand::WindowFileName(AudacityProject * proj, wxTopLevelWindow *w){
if (w != proj && !w->GetTitle().empty()) { if (w != ProjectWindow::Find( proj ) && !w->GetTitle().empty()) {
mFileName = MakeFileName(mFilePath, mFileName = MakeFileName(mFilePath,
kCaptureWhatStrings[ mCaptureMode ].Translation() + kCaptureWhatStrings[ mCaptureMode ].Translation() +
(wxT("-") + w->GetTitle() + wxT("-"))); (wxT("-") + w->GetTitle() + wxT("-")));

View File

@ -66,20 +66,21 @@ void SetProjectCommand::PopulateOrExchange(ShuttleGui & S)
bool SetProjectCommand::Apply(const CommandContext & context) bool SetProjectCommand::Apply(const CommandContext & context)
{ {
AudacityProject * pProj = &context.project; auto &project = context.project;
auto &window = GetProjectFrame( project );
if( bHasName ) if( bHasName )
pProj->SetLabel(mName); window.SetLabel(mName);
if( bHasRate && mRate >= 1 && mRate <= 1000000 ) if( bHasRate && mRate >= 1 && mRate <= 1000000 )
{ {
auto &bar = SelectionBar::Get( *pProj ); auto &bar = SelectionBar::Get( project );
bar.SetRate( mRate ); bar.SetRate( mRate );
} }
if( bHasSizing ) if( bHasSizing )
{ {
pProj->SetPosition( wxPoint( mPosX, mPosY)); window.SetPosition( wxPoint( mPosX, mPosY));
pProj->SetSize( wxSize( mWidth, mHeight )); window.SetSize( wxSize( mWidth, mHeight ));
} }
return true; return true;
} }

View File

@ -76,7 +76,7 @@ BEGIN_EVENT_TABLE(EffectRack, wxFrame)
END_EVENT_TABLE() END_EVENT_TABLE()
EffectRack::EffectRack() EffectRack::EffectRack()
: wxFrame(GetActiveProject(), : wxFrame( FindProjectFrame( GetActiveProject() ),
wxID_ANY, wxID_ANY,
_("Effects Rack"), _("Effects Rack"),
wxDefaultPosition, wxDefaultPosition,

View File

@ -334,7 +334,7 @@ void Exporter::OnExtensionChanged(wxCommandEvent &evt) {
void Exporter::OnHelp(wxCommandEvent& WXUNUSED(evt)) void Exporter::OnHelp(wxCommandEvent& WXUNUSED(evt))
{ {
wxWindow * pWin = GetActiveProject(); wxWindow * pWin = FindProjectFrame( GetActiveProject() );
HelpSystem::ShowHelp(pWin, wxT("File_Export_Dialog"), true); HelpSystem::ShowHelp(pWin, wxT("File_Export_Dialog"), true);
} }
@ -572,7 +572,7 @@ bool Exporter::GetFilename()
auto useFileName = mFilename; auto useFileName = mFilename;
if (!useFileName.HasExt()) if (!useFileName.HasExt())
useFileName.SetExt(defext); useFileName.SetExt(defext);
FileDialogWrapper fd(mProject, FileDialogWrapper fd( ProjectWindow::Find( mProject ),
mFileDialogTitle, mFileDialogTitle,
mFilename.GetPath(), mFilename.GetPath(),
useFileName.GetFullName(), useFileName.GetFullName(),
@ -813,22 +813,23 @@ bool Exporter::CheckMix()
if (exportFormat != wxT("CL") && exportFormat != wxT("FFMPEG") && exportedChannels == -1) if (exportFormat != wxT("CL") && exportFormat != wxT("FFMPEG") && exportedChannels == -1)
exportedChannels = mChannels; exportedChannels = mChannels;
auto pWindow = ProjectWindow::Find( mProject );
if (exportedChannels == 1) { if (exportedChannels == 1) {
if (ShowWarningDialog(mProject, if (ShowWarningDialog(pWindow,
wxT("MixMono"), wxT("MixMono"),
_("Your tracks will be mixed down and exported as one mono file."), _("Your tracks will be mixed down and exported as one mono file."),
true) == wxID_CANCEL) true) == wxID_CANCEL)
return false; return false;
} }
else if (exportedChannels == 2) { else if (exportedChannels == 2) {
if (ShowWarningDialog(mProject, if (ShowWarningDialog(pWindow,
wxT("MixStereo"), wxT("MixStereo"),
_("Your tracks will be mixed down and exported as one stereo file."), _("Your tracks will be mixed down and exported as one stereo file."),
true) == wxID_CANCEL) true) == wxID_CANCEL)
return false; return false;
} }
else { else {
if (ShowWarningDialog(mProject, if (ShowWarningDialog(pWindow,
wxT("MixUnknownChannels"), wxT("MixUnknownChannels"),
_("Your tracks will be mixed down to one exported file according to the encoder settings."), _("Your tracks will be mixed down to one exported file according to the encoder settings."),
true) == wxID_CANCEL) true) == wxID_CANCEL)

View File

@ -1755,7 +1755,7 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
{ {
int rate = lrint(project->GetRate()); int rate = lrint(project->GetRate());
#ifndef DISABLE_DYNAMIC_LOADING_LAME #ifndef DISABLE_DYNAMIC_LOADING_LAME
wxWindow *parent = project; wxWindow *parent = ProjectWindow::Find( project );
#endif // DISABLE_DYNAMIC_LOADING_LAME #endif // DISABLE_DYNAMIC_LOADING_LAME
const auto &tracks = TrackList::Get( *project ); const auto &tracks = TrackList::Get( *project );
MP3Exporter exporter; MP3Exporter exporter;

View File

@ -127,7 +127,8 @@ BEGIN_EVENT_TABLE(MouseEvtHandler, wxEvtHandler)
END_EVENT_TABLE() END_EVENT_TABLE()
ExportMultiple::ExportMultiple(AudacityProject *project) ExportMultiple::ExportMultiple(AudacityProject *project)
: wxDialogWrapper(project, wxID_ANY, wxString(_("Export Multiple"))) : wxDialogWrapper( &GetProjectFrame( *project ),
wxID_ANY, wxString(_("Export Multiple")) )
, mSelectionState{ SelectionState::Get( *project ) } , mSelectionState{ SelectionState::Get( *project ) }
{ {
SetName(GetTitle()); SetName(GetTitle());
@ -740,7 +741,9 @@ ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName,
// let the user have a crack at editing it, exit if cancelled // let the user have a crack at editing it, exit if cancelled
bool bShowTagsDialog = mProject->GetShowId3Dialog(); bool bShowTagsDialog = mProject->GetShowId3Dialog();
if( bShowTagsDialog ){ if( bShowTagsDialog ){
bool bCancelled = !setting.filetags.ShowEditDialog(mProject,_("Edit Metadata Tags"), bShowTagsDialog); bool bCancelled = !setting.filetags.ShowEditDialog(
ProjectWindow::Find( mProject ),
_("Edit Metadata Tags"), bShowTagsDialog);
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowTagsDialog, true); gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowTagsDialog, true);
mProject->SetShowId3Dialog( bShowTagsDialog ); mProject->SetShowId3Dialog( bShowTagsDialog );
if( bCancelled ) if( bCancelled )
@ -857,7 +860,9 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
// let the user have a crack at editing it, exit if cancelled // let the user have a crack at editing it, exit if cancelled
bool bShowTagsDialog = mProject->GetShowId3Dialog(); bool bShowTagsDialog = mProject->GetShowId3Dialog();
if( bShowTagsDialog ){ if( bShowTagsDialog ){
bool bCancelled = !setting.filetags.ShowEditDialog(mProject,_("Edit Metadata Tags"), bShowTagsDialog); bool bCancelled = !setting.filetags.ShowEditDialog(
ProjectWindow::Find( mProject ),
_("Edit Metadata Tags"), bShowTagsDialog);
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowTagsDialog, true); gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowTagsDialog, true);
mProject->SetShowId3Dialog( bShowTagsDialog ); mProject->SetShowId3Dialog( bShowTagsDialog );
if( bCancelled ) if( bCancelled )

View File

@ -472,13 +472,13 @@ void LOFImportFileHandle::doDurationAndScrollOffset()
if (callDurationFactor) if (callDurationFactor)
{ {
double longestDuration = TrackList::Get( *mProject ).GetEndTime(); double longestDuration = TrackList::Get( *mProject ).GetEndTime();
mProject->ZoomBy(longestDuration / durationFactor); ProjectWindow::Get( *mProject ).ZoomBy(longestDuration / durationFactor);
callDurationFactor = false; callDurationFactor = false;
} }
if (callScrollOffset && (scrollOffset != 0)) if (callScrollOffset && (scrollOffset != 0))
{ {
mProject->TP_ScrollWindow(scrollOffset); ProjectWindow::Get( *mProject ).TP_ScrollWindow(scrollOffset);
callScrollOffset = false; callScrollOffset = false;
} }

View File

@ -37,6 +37,7 @@ bool DoPasteText(AudacityProject &project)
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
for (auto pLabelTrack : tracks.Any<LabelTrack>()) for (auto pLabelTrack : tracks.Any<LabelTrack>())
{ {
@ -56,7 +57,7 @@ bool DoPasteText(AudacityProject &project)
} }
// Redraw everyting (is that necessary???) and bail // Redraw everyting (is that necessary???) and bail
project.RedrawProject(); window.RedrawProject();
return true; return true;
} }
} }
@ -73,6 +74,7 @@ bool DoPasteNothingSelected(AudacityProject &project)
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
// First check whether anything's selected. // First check whether anything's selected.
if (tracks.Selected()) if (tracks.Selected())
@ -147,7 +149,7 @@ bool DoPasteNothingSelected(AudacityProject &project)
project.PushState(_("Pasted from the clipboard"), _("Paste")); project.PushState(_("Pasted from the clipboard"), _("Paste"));
project.RedrawProject(); window.RedrawProject();
if (pFirstNewTrack) if (pFirstNewTrack)
trackPanel.EnsureVisible(pFirstNewTrack); trackPanel.EnsureVisible(pFirstNewTrack);
@ -168,7 +170,7 @@ void DoReloadPreferences( AudacityProject &project )
SpectrogramSettings::defaults().LoadPrefs(); SpectrogramSettings::defaults().LoadPrefs();
WaveformSettings::defaults().LoadPrefs(); WaveformSettings::defaults().LoadPrefs();
GlobalPrefsDialog dialog(&project /* parent */ ); GlobalPrefsDialog dialog(&GetProjectFrame( project ) /* parent */ );
wxCommandEvent Evt; wxCommandEvent Evt;
//dialog.Show(); //dialog.Show();
dialog.OnOK(Evt); dialog.OnOK(Evt);
@ -189,9 +191,10 @@ void DoReloadPreferences( AudacityProject &project )
// //
// This workaround should be removed when Audacity updates to wxWidgets // This workaround should be removed when Audacity updates to wxWidgets
// 3.x which has a fix. // 3.x which has a fix.
wxRect r = p->GetRect(); auto &window = GetProjectFrame( *p );
p->SetSize(wxSize(1,1)); wxRect r = window.GetRect();
p->SetSize(r.GetSize()); window.SetSize(wxSize(1,1));
window.SetSize(r.GetSize());
#endif #endif
} }
} }
@ -209,7 +212,7 @@ bool DoEditMetadata
// BEFORE doing any editing of it! // BEFORE doing any editing of it!
auto newTags = tags.Duplicate(); auto newTags = tags.Duplicate();
if (newTags->ShowEditDialog(&project, title, force)) { if (newTags->ShowEditDialog(&GetProjectFrame( project ), title, force)) {
if (tags != *newTags) { if (tags != *newTags) {
// Commit the change to project state only now. // Commit the change to project state only now.
Tags::Set( project, newTags ); Tags::Set( project, newTags );
@ -228,6 +231,7 @@ void DoUndo(AudacityProject &project)
{ {
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &undoManager = UndoManager::Get( project ); auto &undoManager = UndoManager::Get( project );
auto &window = ProjectWindow::Get( project );
if (!project.UndoAvailable()) { if (!project.UndoAvailable()) {
AudacityMessageBox(_("Nothing to undo")); AudacityMessageBox(_("Nothing to undo"));
@ -244,7 +248,7 @@ void DoUndo(AudacityProject &project)
trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack()); trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack());
project.RedrawProject(); window.RedrawProject();
MenuManager::ModifyUndoMenuItems(project); MenuManager::ModifyUndoMenuItems(project);
} }
@ -263,6 +267,7 @@ void OnRedo(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &undoManager = UndoManager::Get( project ); auto &undoManager = UndoManager::Get( project );
auto &window = ProjectWindow::Get( project );
if (!project.RedoAvailable()) { if (!project.RedoAvailable()) {
AudacityMessageBox(_("Nothing to redo")); AudacityMessageBox(_("Nothing to redo"));
@ -278,7 +283,7 @@ void OnRedo(const CommandContext &context)
trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack()); trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack());
project.RedrawProject(); window.RedrawProject();
MenuManager::ModifyUndoMenuItems(project); MenuManager::ModifyUndoMenuItems(project);
} }
@ -290,6 +295,7 @@ void OnCut(const CommandContext &context)
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &ruler = AdornedRulerPanel::Get( project ); auto &ruler = AdornedRulerPanel::Get( project );
auto &window = ProjectWindow::Get( project );
// This doesn't handle cutting labels, it handles // This doesn't handle cutting labels, it handles
// cutting the _text_ inside of labels, i.e. if you're // cutting the _text_ inside of labels, i.e. if you're
@ -366,7 +372,7 @@ void OnCut(const CommandContext &context)
//mRuler->ClearPlayRegion(); //mRuler->ClearPlayRegion();
ruler.DrawOverlays( true ); ruler.DrawOverlays( true );
project.RedrawProject(); window.RedrawProject();
} }
void OnDelete(const CommandContext &context) void OnDelete(const CommandContext &context)
@ -374,6 +380,7 @@ void OnDelete(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
for (auto n : tracks.Any()) { for (auto n : tracks.Any()) {
if (n->GetSelected() || n->IsSyncLockSelected()) { if (n->GetSelected() || n->IsSyncLockSelected()) {
@ -390,7 +397,7 @@ void OnDelete(const CommandContext &context)
selectedRegion.t0()), selectedRegion.t0()),
_("Delete")); _("Delete"));
project.RedrawProject(); window.RedrawProject();
} }
@ -435,6 +442,8 @@ void OnPaste(const CommandContext &context)
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
auto isSyncLocked = project.IsSyncLocked(); auto isSyncLocked = project.IsSyncLocked();
// Handle text paste (into active label) first. // Handle text paste (into active label) first.
@ -684,7 +693,7 @@ void OnPaste(const CommandContext &context)
project.PushState(_("Pasted from the clipboard"), _("Paste")); project.PushState(_("Pasted from the clipboard"), _("Paste"));
project.RedrawProject(); window.RedrawProject();
if (ff) if (ff)
trackPanel.EnsureVisible(ff); trackPanel.EnsureVisible(ff);
@ -696,6 +705,7 @@ void OnDuplicate(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
// This iteration is unusual because we add to the list inside the loop // This iteration is unusual because we add to the list inside the loop
auto range = tracks.Selected(); auto range = tracks.Selected();
@ -715,7 +725,7 @@ void OnDuplicate(const CommandContext &context)
project.PushState(_("Duplicated"), _("Duplicate")); project.PushState(_("Duplicated"), _("Duplicate"));
project.RedrawProject(); window.RedrawProject();
} }
void OnSplitCut(const CommandContext &context) void OnSplitCut(const CommandContext &context)
@ -723,6 +733,7 @@ void OnSplitCut(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
auto &clipboard = Clipboard::Get(); auto &clipboard = Clipboard::Get();
clipboard.Clear(); clipboard.Clear();
@ -756,7 +767,7 @@ void OnSplitCut(const CommandContext &context)
project.PushState(_("Split-cut to the clipboard"), _("Split Cut")); project.PushState(_("Split-cut to the clipboard"), _("Split Cut"));
project.RedrawProject(); window.RedrawProject();
} }
void OnSplitDelete(const CommandContext &context) void OnSplitDelete(const CommandContext &context)
@ -764,6 +775,7 @@ void OnSplitDelete(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
tracks.Selected().Visit( tracks.Selected().Visit(
[&](WaveTrack *wt) { [&](WaveTrack *wt) {
@ -782,7 +794,7 @@ void OnSplitDelete(const CommandContext &context)
selectedRegion.t0()), selectedRegion.t0()),
_("Split Delete")); _("Split Delete"));
project.RedrawProject(); window.RedrawProject();
} }
void OnSilence(const CommandContext &context) void OnSilence(const CommandContext &context)
@ -809,6 +821,7 @@ void OnTrim(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
if (selectedRegion.isPoint()) if (selectedRegion.isPoint())
return; return;
@ -833,7 +846,7 @@ void OnTrim(const CommandContext &context)
selectedRegion.t0(), selectedRegion.t1()), selectedRegion.t0(), selectedRegion.t1()),
_("Trim Audio")); _("Trim Audio"));
project.RedrawProject(); window.RedrawProject();
} }
void OnSplit(const CommandContext &context) void OnSplit(const CommandContext &context)
@ -907,6 +920,7 @@ void OnSplitNew(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
Track::Holder dest; Track::Holder dest;
@ -950,7 +964,7 @@ void OnSplitNew(const CommandContext &context)
project.PushState(_("Split to new track"), _("Split New")); project.PushState(_("Split to new track"), _("Split New"));
project.RedrawProject(); window.RedrawProject();
} }
void OnJoin(const CommandContext &context) void OnJoin(const CommandContext &context)
@ -958,6 +972,7 @@ void OnJoin(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
for (auto wt : tracks.Selected< WaveTrack >()) for (auto wt : tracks.Selected< WaveTrack >())
wt->Join(selectedRegion.t0(), wt->Join(selectedRegion.t0(),
@ -969,7 +984,7 @@ void OnJoin(const CommandContext &context)
selectedRegion.t0()), selectedRegion.t0()),
_("Join")); _("Join"));
project.RedrawProject(); window.RedrawProject();
} }
void OnDisjoin(const CommandContext &context) void OnDisjoin(const CommandContext &context)
@ -977,6 +992,7 @@ void OnDisjoin(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
for (auto wt : tracks.Selected< WaveTrack >()) for (auto wt : tracks.Selected< WaveTrack >())
wt->Disjoin(selectedRegion.t0(), wt->Disjoin(selectedRegion.t0(),
@ -988,7 +1004,7 @@ void OnDisjoin(const CommandContext &context)
selectedRegion.t0()), selectedRegion.t0()),
_("Detach")); _("Detach"));
project.RedrawProject(); window.RedrawProject();
} }
void OnEditMetadata(const CommandContext &context) void OnEditMetadata(const CommandContext &context)
@ -1002,7 +1018,7 @@ void OnPreferences(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
GlobalPrefsDialog dialog(&project /* parent */ ); GlobalPrefsDialog dialog(&GetProjectFrame( project ) /* parent */ );
if( ScreenshotCommand::MayCapture( &dialog ) ) if( ScreenshotCommand::MayCapture( &dialog ) )
return; return;
@ -1027,9 +1043,10 @@ void OnPreferences(const CommandContext &context)
// //
// This workaround should be removed when Audacity updates to wxWidgets // This workaround should be removed when Audacity updates to wxWidgets
// 3.x which has a fix. // 3.x which has a fix.
wxRect r = p->GetRect(); auto &window = GetProjectFrame( *p );
p->SetSize(wxSize(1,1)); wxRect r = window.GetRect();
p->SetSize(r.GetSize()); window.SetSize(wxSize(1,1));
window.SetSize(r.GetSize());
#endif #endif
} }
} }

View File

@ -110,10 +110,11 @@ void OnAudioHost(const CommandContext &context)
void OnFullScreen(const CommandContext &context) void OnFullScreen(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &window = GetProjectFrame( project );
auto &commandManager = CommandManager::Get( project ); auto &commandManager = CommandManager::Get( project );
bool bChecked = !project.wxTopLevelWindow::IsFullScreen(); bool bChecked = !window.wxTopLevelWindow::IsFullScreen();
project.wxTopLevelWindow::ShowFullScreen(bChecked); window.wxTopLevelWindow::ShowFullScreen(bChecked);
commandManager.Check(wxT("FullScreenOnOff"), bChecked); commandManager.Check(wxT("FullScreenOnOff"), bChecked);
} }
@ -243,8 +244,8 @@ MenuTable::BaseItemPtr ExtraMiscItems( AudacityProject &project )
Command( wxT("FullScreenOnOff"), XXO("&Full Screen (on/off)"), Command( wxT("FullScreenOnOff"), XXO("&Full Screen (on/off)"),
FN(OnFullScreen), FN(OnFullScreen),
AlwaysEnabledFlag, AlwaysEnabledFlag,
Options{ key } Options{ key }.CheckState(
.CheckState( project.wxTopLevelWindow::IsFullScreen() ) ), GetProjectFrame( project ).wxTopLevelWindow::IsFullScreen() ) ),
ExtraWindowItems ExtraWindowItems
); );

View File

@ -118,7 +118,7 @@ AudacityProject *DoImportMIDI(
if ( !pProject ) if ( !pProject )
pProject = pNewProject = CreateNewAudacityProject(); pProject = pNewProject = CreateNewAudacityProject();
auto cleanup = finally( [&] auto cleanup = finally( [&]
{ if ( pNewProject ) pNewProject->Close(true); } ); { if ( pNewProject ) GetProjectFrame( *pNewProject ).Close(true); } );
auto newTrack = TrackFactory::Get( *pProject ).NewNoteTrack(); auto newTrack = TrackFactory::Get( *pProject ).NewNoteTrack();
@ -131,7 +131,7 @@ AudacityProject *DoImportMIDI(
pProject->PushState(wxString::Format(_("Imported MIDI from '%s'"), pProject->PushState(wxString::Format(_("Imported MIDI from '%s'"),
fileName), _("Import MIDI")); fileName), _("Import MIDI"));
pProject->ZoomAfterImport(pTrack); ProjectWindow::Get( *pProject ).ZoomAfterImport(pTrack);
pNewProject = nullptr; pNewProject = nullptr;
FileHistory::Global().AddFileToHistory(fileName); FileHistory::Global().AddFileToHistory(fileName);
@ -174,8 +174,9 @@ void OnProjectReset(const CommandContext &context)
void OnClose(const CommandContext &context ) void OnClose(const CommandContext &context )
{ {
auto &project = context.project; auto &project = context.project;
auto &window = GetProjectFrame( project );
project.SetMenuClose(true); project.SetMenuClose(true);
project.Close(); window.Close();
} }
void OnSave(const CommandContext &context ) void OnSave(const CommandContext &context )
@ -244,6 +245,7 @@ void OnExportLabels(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = GetProjectFrame( project );
/* i18n-hint: filename containing exported text from label tracks */ /* i18n-hint: filename containing exported text from label tracks */
wxString fName = _("labels.txt"); wxString fName = _("labels.txt");
@ -264,7 +266,7 @@ void OnExportLabels(const CommandContext &context)
wxT("txt"), wxT("txt"),
wxT("*.txt"), wxT("*.txt"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project); &window);
if (fName.empty()) if (fName.empty())
return; return;
@ -315,6 +317,7 @@ void OnExportMIDI(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = GetProjectFrame( project );
// Make sure that there is // Make sure that there is
// exactly one NoteTrack selected. // exactly one NoteTrack selected.
@ -349,7 +352,7 @@ void OnExportMIDI(const CommandContext &context)
wxT(".mid|.gro"), wxT(".mid|.gro"),
_("MIDI file (*.mid)|*.mid|Allegro file (*.gro)|*.gro"), _("MIDI file (*.mid)|*.mid|Allegro file (*.gro)|*.gro"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project); &window);
if (fName.empty()) if (fName.empty())
return; return;
@ -396,6 +399,7 @@ void OnExportMIDI(const CommandContext &context)
void OnImport(const CommandContext &context) void OnImport(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &window = ProjectWindow::Get( project );
// An import trigger for the alias missing dialog might not be intuitive, but // An import trigger for the alias missing dialog might not be intuitive, but
// this serves to track the file if the users zooms in and such. // this serves to track the file if the users zooms in and such.
@ -423,7 +427,7 @@ void OnImport(const CommandContext &context)
gPrefs->Flush(); gPrefs->Flush();
project.HandleResize(); // Adjust scrollers for NEW track sizes. window.HandleResize(); // Adjust scrollers for NEW track sizes.
} ); } );
for (size_t ff = 0; ff < selectedFiles.size(); ff++) { for (size_t ff = 0; ff < selectedFiles.size(); ff++) {
@ -434,7 +438,7 @@ void OnImport(const CommandContext &context)
project.Import(fileName); project.Import(fileName);
} }
project.ZoomAfterImport(nullptr); window.ZoomAfterImport(nullptr);
} }
void OnImportLabels(const CommandContext &context) void OnImportLabels(const CommandContext &context)
@ -442,6 +446,7 @@ void OnImportLabels(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = ProjectWindow::Get( project );
wxString fileName = wxString fileName =
FileNames::SelectFile(FileNames::Operation::Open, FileNames::SelectFile(FileNames::Operation::Open,
@ -451,7 +456,7 @@ void OnImportLabels(const CommandContext &context)
wxT(".txt"), // Extension wxT(".txt"), // Extension
_("Text files (*.txt)|*.txt|All files|*"), _("Text files (*.txt)|*.txt|All files|*"),
wxRESIZE_BORDER, // Flags wxRESIZE_BORDER, // Flags
&project); // Parent &window); // Parent
if (!fileName.empty()) { if (!fileName.empty()) {
wxTextFile f; wxTextFile f;
@ -478,13 +483,14 @@ void OnImportLabels(const CommandContext &context)
Format(_("Imported labels from '%s'"), fileName), Format(_("Imported labels from '%s'"), fileName),
_("Import Labels")); _("Import Labels"));
project.ZoomAfterImport(nullptr); window.ZoomAfterImport(nullptr);
} }
} }
void OnImportMIDI(const CommandContext &context) void OnImportMIDI(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &window = GetProjectFrame( project );
wxString fileName = FileNames::SelectFile(FileNames::Operation::Open, wxString fileName = FileNames::SelectFile(FileNames::Operation::Open,
_("Select a MIDI file"), _("Select a MIDI file"),
@ -493,7 +499,7 @@ void OnImportMIDI(const CommandContext &context)
wxT(""), // Extension wxT(""), // Extension
_("MIDI and Allegro files (*.mid;*.midi;*.gro)|*.mid;*.midi;*.gro|MIDI files (*.mid;*.midi)|*.mid;*.midi|Allegro files (*.gro)|*.gro|All files|*"), _("MIDI and Allegro files (*.mid;*.midi;*.gro)|*.mid;*.midi;*.gro|MIDI files (*.mid;*.midi)|*.mid;*.midi|Allegro files (*.gro)|*.gro|All files|*"),
wxRESIZE_BORDER, // Flags wxRESIZE_BORDER, // Flags
&project); // Parent &window); // Parent
if (!fileName.empty()) if (!fileName.empty())
DoImportMIDI(&project, fileName); DoImportMIDI(&project, fileName);
@ -504,6 +510,7 @@ void OnImportRaw(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &window = ProjectWindow::Get( project );
wxString fileName = wxString fileName =
FileNames::SelectFile(FileNames::Operation::Open, FileNames::SelectFile(FileNames::Operation::Open,
@ -513,26 +520,27 @@ void OnImportRaw(const CommandContext &context)
wxT(""), // Extension wxT(""), // Extension
_("All files|*"), _("All files|*"),
wxRESIZE_BORDER, // Flags wxRESIZE_BORDER, // Flags
&project); // Parent &window); // Parent
if (fileName.empty()) if (fileName.empty())
return; return;
TrackHolders newTracks; TrackHolders newTracks;
::ImportRaw(&project, fileName, &trackFactory, newTracks); ::ImportRaw(&window, fileName, &trackFactory, newTracks);
if (newTracks.size() <= 0) if (newTracks.size() <= 0)
return; return;
project.AddImportedTracks(fileName, std::move(newTracks)); project.AddImportedTracks(fileName, std::move(newTracks));
project.HandleResize(); // Adjust scrollers for NEW track sizes. window.HandleResize(); // Adjust scrollers for NEW track sizes.
} }
void OnPageSetup(const CommandContext &context) void OnPageSetup(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
HandlePageSetup(&project); auto &window = GetProjectFrame( project );
HandlePageSetup(&window);
} }
void OnPrint(const CommandContext &context) void OnPrint(const CommandContext &context)
@ -540,7 +548,8 @@ void OnPrint(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto name = project.GetProjectName(); auto name = project.GetProjectName();
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
HandlePrint(&project, name, &tracks, TrackPanel::Get( project )); auto &window = GetProjectFrame( project );
HandlePrint(&window, name, &tracks, TrackPanel::Get( project ));
} }
void OnExit(const CommandContext &WXUNUSED(context) ) void OnExit(const CommandContext &WXUNUSED(context) )

View File

@ -35,7 +35,8 @@ void ShowDiagnostics(
AudacityProject &project, const wxString &info, AudacityProject &project, const wxString &info,
const wxString &description, const wxString &defaultPath) const wxString &description, const wxString &defaultPath)
{ {
wxDialogWrapper dlg(&project, wxID_ANY, description); auto &window = GetProjectFrame( project );
wxDialogWrapper dlg( &window, wxID_ANY, description);
dlg.SetName(dlg.GetTitle()); dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating); ShuttleGui S(&dlg, eIsCreating);
@ -62,7 +63,7 @@ void ShowDiagnostics(
wxT("txt"), wxT("txt"),
wxT("*.txt"), wxT("*.txt"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project); &window);
if (!fName.empty()) if (!fName.empty())
{ {
if (!text->SaveFile(fName)) if (!text->SaveFile(fName))
@ -280,7 +281,7 @@ namespace HelpActions {
void DoHelpWelcome( AudacityProject &project ) void DoHelpWelcome( AudacityProject &project )
{ {
SplashDialog::Show2( &project ); SplashDialog::Show2( &GetProjectFrame( project ) );
} }
// Menu handler functions // Menu handler functions
@ -290,7 +291,7 @@ struct Handler : CommandHandlerObject {
void OnQuickFix(const CommandContext &context) void OnQuickFix(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
QuickFixDialog dlg( &project ); QuickFixDialog dlg( &GetProjectFrame( project ) );
dlg.ShowModal(); dlg.ShowModal();
} }
@ -298,7 +299,7 @@ void OnQuickHelp(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
HelpSystem::ShowHelp( HelpSystem::ShowHelp(
&project, &GetProjectFrame( project ),
wxT("Quick_Help")); wxT("Quick_Help"));
} }
@ -306,7 +307,7 @@ void OnManual(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
HelpSystem::ShowHelp( HelpSystem::ShowHelp(
&project, &GetProjectFrame( project ),
wxT("Main_Page")); wxT("Main_Page"));
} }
@ -368,9 +369,10 @@ void OnAbout(const CommandContext &context)
wxTheApp->AddPendingEvent( evt ); wxTheApp->AddPendingEvent( evt );
#else #else
auto &project = context.project; auto &project = context.project;
auto &window = GetProjectFrame( project );
// Windows and Linux still modal. // Windows and Linux still modal.
AboutDialog dlog(&project); AboutDialog dlog( &window );
dlog.ShowModal(); dlog.ShowModal();
#endif #endif
} }

View File

@ -21,6 +21,7 @@ int DoAddLabel(
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &window = ProjectWindow::Get( project );
wxString title; // of label wxString title; // of label
@ -71,7 +72,7 @@ int DoAddLabel(
project.PushState(_("Added label"), _("Label")); project.PushState(_("Added label"), _("Label"));
project.RedrawProject(); window.RedrawProject();
if (!useDialog) { if (!useDialog) {
trackPanel.EnsureVisible(lt); trackPanel.EnsureVisible(lt);
} }
@ -284,6 +285,7 @@ void OnPasteNewLabel(const CommandContext &context)
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
bool bPastedSomething = false; bool bPastedSomething = false;
@ -337,7 +339,7 @@ void OnPasteNewLabel(const CommandContext &context)
_("Pasted from the clipboard"), _("Paste Text to New Label")); _("Pasted from the clipboard"), _("Paste Text to New Label"));
// Is this necessary? (carried over from former logic in OnPaste()) // Is this necessary? (carried over from former logic in OnPaste())
project.RedrawProject(); window.RedrawProject();
} }
} }
@ -355,6 +357,7 @@ void OnCutLabels(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
if( selectedRegion.isPoint() ) if( selectedRegion.isPoint() )
return; return;
@ -379,7 +382,7 @@ void OnCutLabels(const CommandContext &context)
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
_( "Cut Labeled Audio" ) ); _( "Cut Labeled Audio" ) );
project.RedrawProject(); window.RedrawProject();
} }
void OnDeleteLabels(const CommandContext &context) void OnDeleteLabels(const CommandContext &context)
@ -387,6 +390,7 @@ void OnDeleteLabels(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
if( selectedRegion.isPoint() ) if( selectedRegion.isPoint() )
return; return;
@ -401,7 +405,7 @@ void OnDeleteLabels(const CommandContext &context)
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
_( "Delete Labeled Audio" ) ); _( "Delete Labeled Audio" ) );
project.RedrawProject(); window.RedrawProject();
} }
void OnSplitCutLabels(const CommandContext &context) void OnSplitCutLabels(const CommandContext &context)
@ -409,6 +413,7 @@ void OnSplitCutLabels(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
if( selectedRegion.isPoint() ) if( selectedRegion.isPoint() )
return; return;
@ -423,7 +428,7 @@ void OnSplitCutLabels(const CommandContext &context)
/* i18n-hint: (verb) Do a special kind of cut on the labels*/ /* i18n-hint: (verb) Do a special kind of cut on the labels*/
_( "Split Cut Labeled Audio" ) ); _( "Split Cut Labeled Audio" ) );
project.RedrawProject(); window.RedrawProject();
} }
void OnSplitDeleteLabels(const CommandContext &context) void OnSplitDeleteLabels(const CommandContext &context)
@ -431,6 +436,7 @@ void OnSplitDeleteLabels(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
if( selectedRegion.isPoint() ) if( selectedRegion.isPoint() )
return; return;
@ -445,7 +451,7 @@ void OnSplitDeleteLabels(const CommandContext &context)
regions */ regions */
_( "Split Delete Labeled Audio" ) ); _( "Split Delete Labeled Audio" ) );
project.RedrawProject(); window.RedrawProject();
} }
void OnSilenceLabels(const CommandContext &context) void OnSilenceLabels(const CommandContext &context)
@ -494,6 +500,7 @@ void OnSplitLabels(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
EditByLabel( tracks, selectedRegion, &WaveTrack::Split, false ); EditByLabel( tracks, selectedRegion, &WaveTrack::Split, false );
@ -504,7 +511,7 @@ void OnSplitLabels(const CommandContext &context)
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
_( "Split Labeled Audio" ) ); _( "Split Labeled Audio" ) );
project.RedrawProject(); window.RedrawProject();
} }
void OnJoinLabels(const CommandContext &context) void OnJoinLabels(const CommandContext &context)
@ -512,6 +519,7 @@ void OnJoinLabels(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
if( selectedRegion.isPoint() ) if( selectedRegion.isPoint() )
return; return;
@ -525,7 +533,7 @@ void OnJoinLabels(const CommandContext &context)
/* i18n-hint: (verb) */ /* i18n-hint: (verb) */
_( "Join Labeled Audio" ) ); _( "Join Labeled Audio" ) );
project.RedrawProject(); window.RedrawProject();
} }
void OnDisjoinLabels(const CommandContext &context) void OnDisjoinLabels(const CommandContext &context)
@ -533,6 +541,7 @@ void OnDisjoinLabels(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
if( selectedRegion.isPoint() ) if( selectedRegion.isPoint() )
return; return;
@ -547,7 +556,7 @@ void OnDisjoinLabels(const CommandContext &context)
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
_( "Detach Labeled Audio" ) ); _( "Detach Labeled Audio" ) );
project.RedrawProject(); window.RedrawProject();
} }
}; // struct Handler }; // struct Handler

View File

@ -35,7 +35,7 @@ void NextOrPrevFrame(AudacityProject &project, bool forward)
static const unsigned rotationSize = 3u; static const unsigned rotationSize = 3u;
wxWindow *const begin [rotationSize] = { wxWindow *const begin [rotationSize] = {
project.GetTopPanel(), ProjectWindow::Get( project ).GetTopPanel(),
&TrackPanel::Get( project ), &TrackPanel::Get( project ),
botDock, botDock,
}; };
@ -310,15 +310,16 @@ struct Handler
void OnPrevWindow(const CommandContext &context) void OnPrevWindow(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto isEnabled = project.IsEnabled(); auto &window = GetProjectFrame( project );
auto isEnabled = window.IsEnabled();
wxWindow *w = wxGetTopLevelParent(wxWindow::FindFocus()); wxWindow *w = wxGetTopLevelParent(wxWindow::FindFocus());
const auto & list = project.GetChildren(); const auto & list = window.GetChildren();
auto iter = list.rbegin(), end = list.rend(); auto iter = list.rbegin(), end = list.rend();
// If the project window has the current focus, start the search with the // If the project window has the current focus, start the search with the
// last child // last child
if (w == &project) if (w == &window)
{ {
} }
// Otherwise start the search with the current window's previous sibling // Otherwise start the search with the current window's previous sibling
@ -345,7 +346,7 @@ void OnPrevWindow(const CommandContext &context)
// Ran out of siblings, so make the current project active // Ran out of siblings, so make the current project active
if ((iter == end) && isEnabled) if ((iter == end) && isEnabled)
{ {
w = &project; w = &window;
} }
// And make sure it's on top (only for floating windows...project window will // And make sure it's on top (only for floating windows...project window will
@ -368,15 +369,16 @@ void OnPrevWindow(const CommandContext &context)
void OnNextWindow(const CommandContext &context) void OnNextWindow(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto isEnabled = project.IsEnabled(); auto &window = GetProjectFrame( project );
auto isEnabled = window.IsEnabled();
wxWindow *w = wxGetTopLevelParent(wxWindow::FindFocus()); wxWindow *w = wxGetTopLevelParent(wxWindow::FindFocus());
const auto & list = project.GetChildren(); const auto & list = window.GetChildren();
auto iter = list.begin(), end = list.end(); auto iter = list.begin(), end = list.end();
// If the project window has the current focus, start the search with the // If the project window has the current focus, start the search with the
// first child // first child
if (w == &project) if (w == &window)
{ {
} }
// Otherwise start the search with the current window's next sibling // Otherwise start the search with the current window's next sibling
@ -407,7 +409,7 @@ void OnNextWindow(const CommandContext &context)
// Ran out of siblings, so make the current project active // Ran out of siblings, so make the current project active
if ((iter == end) && isEnabled) if ((iter == end) && isEnabled)
{ {
w = &project; w = &window;
} }
// And make sure it's on top (only for floating windows...project window will // And make sure it's on top (only for floating windows...project window will

View File

@ -25,8 +25,9 @@ namespace {
AudacityProject::AttachedWindows::RegisteredFactory sContrastDialogKey{ AudacityProject::AttachedWindows::RegisteredFactory sContrastDialogKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > { []( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
auto &window = ProjectWindow::Get( parent );
return safenew ContrastDialog( return safenew ContrastDialog(
&parent, -1, _("Contrast Analysis (WCAG 2 compliance)"), &window, -1, _("Contrast Analysis (WCAG 2 compliance)"),
wxPoint{ 150, 150 } wxPoint{ 150, 150 }
); );
} }
@ -34,8 +35,9 @@ AudacityProject::AttachedWindows::RegisteredFactory sContrastDialogKey{
AudacityProject::AttachedWindows::RegisteredFactory sFrequencyWindowKey{ AudacityProject::AttachedWindows::RegisteredFactory sFrequencyWindowKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > { []( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
auto &window = ProjectWindow::Get( parent );
return safenew FreqWindow( return safenew FreqWindow(
&parent, -1, _("Frequency Analysis"), &window, -1, _("Frequency Analysis"),
wxPoint{ 150, 150 } wxPoint{ 150, 150 }
); );
} }
@ -43,16 +45,17 @@ AudacityProject::AttachedWindows::RegisteredFactory sFrequencyWindowKey{
AudacityProject::AttachedWindows::RegisteredFactory sMacrosWindowKey{ AudacityProject::AttachedWindows::RegisteredFactory sMacrosWindowKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > { []( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
auto &window = ProjectWindow::Get( parent );
return safenew MacrosWindow( return safenew MacrosWindow(
&parent, true &window, true
); );
} }
}; };
void DoManagePluginsMenu void DoManagePluginsMenu(AudacityProject &project, EffectType type)
(AudacityProject &project, EffectType type)
{ {
if (PluginManager::Get().ShowManager(&project, type)) auto &window = GetProjectFrame( project );
if (PluginManager::Get().ShowManager(&window, type))
MenuCreator::RebuildAllMenuBars(); MenuCreator::RebuildAllMenuBars();
} }
@ -426,6 +429,7 @@ bool DoEffect(
auto rate = project.GetRate(); auto rate = project.GetRate();
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &commandManager = CommandManager::Get( project ); auto &commandManager = CommandManager::Get( project );
auto &window = ProjectWindow::Get( project );
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID); const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
if (!plug) if (!plug)
@ -473,7 +477,7 @@ bool DoEffect(
EffectManager & em = EffectManager::Get(); EffectManager & em = EffectManager::Get();
success = em.DoEffect(ID, &project, rate, success = em.DoEffect(ID, &window, rate,
&tracks, &trackFactory, &selectedRegion, &tracks, &trackFactory, &selectedRegion,
(flags & kConfigured) == 0); (flags & kConfigured) == 0);
@ -515,7 +519,7 @@ bool DoEffect(
ViewActions::DoZoomFit(project); ViewActions::DoZoomFit(project);
// trackPanel->Refresh(false); // trackPanel->Refresh(false);
} }
project.RedrawProject(); window.RedrawProject();
if (focus != nullptr && focus->GetParent()==parent) { if (focus != nullptr && focus->GetParent()==parent) {
focus->SetFocus(); focus->SetFocus();
} }
@ -543,6 +547,7 @@ bool DoAudacityCommand(
const PluginID & ID, const CommandContext & context, unsigned flags ) const PluginID & ID, const CommandContext & context, unsigned flags )
{ {
auto &project = context.project; auto &project = context.project;
auto &window = ProjectWindow::Get( project );
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID); const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
if (!plug) if (!plug)
return false; return false;
@ -556,7 +561,7 @@ bool DoAudacityCommand(
EffectManager & em = EffectManager::Get(); EffectManager & em = EffectManager::Get();
bool success = em.DoAudacityCommand(ID, bool success = em.DoAudacityCommand(ID,
context, context,
&project, &window,
(flags & kConfigured) == 0); (flags & kConfigured) == 0);
if (!success) if (!success)
@ -573,7 +578,7 @@ bool DoAudacityCommand(
PushState(longDesc, shortDesc); PushState(longDesc, shortDesc);
} }
*/ */
project.RedrawProject(); window.RedrawProject();
return true; return true;
} }
@ -677,7 +682,8 @@ void OnScreenshot(const CommandContext &WXUNUSED(context) )
void OnBenchmark(const CommandContext &context) void OnBenchmark(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
::RunBenchmark(&project); auto &window = GetProjectFrame( project );
::RunBenchmark(&window);
} }
void OnSimulateRecordingErrors(const CommandContext &context) void OnSimulateRecordingErrors(const CommandContext &context)
@ -703,9 +709,10 @@ void OnDetectUpstreamDropouts(const CommandContext &context)
void OnApplyMacroDirectly(const CommandContext &context ) void OnApplyMacroDirectly(const CommandContext &context )
{ {
auto &project = context.project; auto &project = context.project;
auto &window = ProjectWindow::Get( project );
//wxLogDebug( "Macro was: %s", context.parameter); //wxLogDebug( "Macro was: %s", context.parameter);
ApplyMacroDialog dlg( &project ); ApplyMacroDialog dlg( &window );
const auto &Name = context.parameter; const auto &Name = context.parameter;
// We used numbers previously, but macros could get renumbered, making // We used numbers previously, but macros could get renumbered, making

View File

@ -271,6 +271,7 @@ void MoveWhenAudioInactive
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &ruler = AdornedRulerPanel::Get( project ); auto &ruler = AdornedRulerPanel::Get( project );
auto &window = ProjectWindow::Get( project );
// If TIME_UNIT_SECONDS, snap-to will be off. // If TIME_UNIT_SECONDS, snap-to will be off.
int snapToTime = project.GetSnapTo(); int snapToTime = project.GetSnapTo();
@ -300,7 +301,7 @@ void MoveWhenAudioInactive
// This updates the selection shown on the selection bar, and the play // This updates the selection shown on the selection bar, and the play
// region // region
project.TP_DisplaySelection(); window.TP_DisplaySelection();
} else } else
{ {
// Transition to cursor mode. // Transition to cursor mode.
@ -513,15 +514,16 @@ void DoListSelection
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &selectionState = SelectionState::Get( project ); auto &selectionState = SelectionState::Get( project );
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto isSyncLocked = project.IsSyncLocked(); auto &window = GetProjectFrame( project );
auto isSyncLocked = project.IsSyncLocked();
selectionState.HandleListSelection( selectionState.HandleListSelection(
tracks, viewInfo, *t, tracks, viewInfo, *t,
shift, ctrl, isSyncLocked ); shift, ctrl, isSyncLocked );
if (! ctrl ) if (! ctrl )
trackPanel.SetFocusedTrack(t); trackPanel.SetFocusedTrack(t);
project.Refresh(false); window.Refresh(false);
if (modifyState) if (modifyState)
project.ModifyState(true); project.ModifyState(true);
} }
@ -610,6 +612,7 @@ void OnSetLeftSelection(const CommandContext &context)
auto token = project.GetAudioIOToken(); auto token = project.GetAudioIOToken();
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = GetProjectFrame( project );
bool bSelChanged = false; bool bSelChanged = false;
if ((token > 0) && gAudioIO->IsStreamActive(token)) if ((token > 0) && gAudioIO->IsStreamActive(token))
@ -623,7 +626,7 @@ void OnSetLeftSelection(const CommandContext &context)
auto fmt = project.GetSelectionFormat(); auto fmt = project.GetSelectionFormat();
auto rate = project.GetRate(); auto rate = project.GetRate();
TimeDialog dlg(&project, _("Set Left Selection Boundary"), TimeDialog dlg(&window, _("Set Left Selection Boundary"),
fmt, rate, selectedRegion.t0(), _("Position")); fmt, rate, selectedRegion.t0(), _("Position"));
if (wxID_OK == dlg.ShowModal()) if (wxID_OK == dlg.ShowModal())
@ -648,6 +651,7 @@ void OnSetRightSelection(const CommandContext &context)
auto token = project.GetAudioIOToken(); auto token = project.GetAudioIOToken();
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = GetProjectFrame( project );
bool bSelChanged = false; bool bSelChanged = false;
if ((token > 0) && gAudioIO->IsStreamActive(token)) if ((token > 0) && gAudioIO->IsStreamActive(token))
@ -661,7 +665,7 @@ void OnSetRightSelection(const CommandContext &context)
auto fmt = project.GetSelectionFormat(); auto fmt = project.GetSelectionFormat();
auto rate = project.GetRate(); auto rate = project.GetRate();
TimeDialog dlg(&project, _("Set Right Selection Boundary"), TimeDialog dlg(&window, _("Set Right Selection Boundary"),
fmt, rate, selectedRegion.t1(), _("Position")); fmt, rate, selectedRegion.t1(), _("Position"));
if (wxID_OK == dlg.ShowModal()) if (wxID_OK == dlg.ShowModal())
@ -901,14 +905,16 @@ void OnSnapToPrior(const CommandContext &context)
void OnSelToStart(const CommandContext &context) void OnSelToStart(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
project.Rewind(true); auto &window = ProjectWindow::Get( project );
window.Rewind(true);
project.ModifyState(false); project.ModifyState(false);
} }
void OnSelToEnd(const CommandContext &context) void OnSelToEnd(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
project.SkipEnd(true); auto &window = ProjectWindow::Get( project );
window.SkipEnd(true);
project.ModifyState(false); project.ModifyState(false);
} }

View File

@ -43,6 +43,7 @@ void DoMixAndRender
auto rate = project.GetRate(); auto rate = project.GetRate();
auto defaultFormat = project.GetDefaultFormat(); auto defaultFormat = project.GetDefaultFormat();
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
MissingAliasFilesDialog::SetShouldShow(true); MissingAliasFilesDialog::SetShouldShow(true);
@ -105,13 +106,14 @@ void DoMixAndRender
trackPanel.SetFocus(); trackPanel.SetFocus();
trackPanel.SetFocusedTrack(pNewLeft); trackPanel.SetFocusedTrack(pNewLeft);
trackPanel.EnsureVisible(pNewLeft); trackPanel.EnsureVisible(pNewLeft);
project.RedrawProject(); window.RedrawProject();
} }
} }
void DoPanTracks(AudacityProject &project, float PanValue) void DoPanTracks(AudacityProject &project, float PanValue)
{ {
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = ProjectWindow::Get( project );
// count selected wave tracks // count selected wave tracks
const auto range = tracks.Any< WaveTrack >(); const auto range = tracks.Any< WaveTrack >();
@ -122,7 +124,7 @@ void DoPanTracks(AudacityProject &project, float PanValue)
for (auto left : count == 0 ? range : selectedRange ) for (auto left : count == 0 ? range : selectedRange )
left->SetPan( PanValue ); left->SetPan( PanValue );
project.RedrawProject(); window.RedrawProject();
auto flags = UndoPush::AUTOSAVE; auto flags = UndoPush::AUTOSAVE;
/*i18n-hint: One or more audio tracks have been panned*/ /*i18n-hint: One or more audio tracks have been panned*/
@ -156,6 +158,7 @@ void DoAlign
{ {
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
wxString action; wxString action;
wxString shortAction; wxString shortAction;
@ -288,7 +291,7 @@ void DoAlign
project.PushState(action, shortAction); project.PushState(action, shortAction);
project.RedrawProject(); window.RedrawProject();
} }
#ifdef EXPERIMENTAL_SCOREALIGN #ifdef EXPERIMENTAL_SCOREALIGN
@ -700,6 +703,7 @@ void DoRemoveTrack(AudacityProject &project, Track * toRemove)
{ {
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
// If it was focused, then NEW focus is the next or, if // If it was focused, then NEW focus is the next or, if
// unavailable, the previous track. (The NEW focus is set // unavailable, the previous track. (The NEW focus is set
@ -730,8 +734,8 @@ void DoRemoveTrack(AudacityProject &project, Track * toRemove)
name), name),
_("Track Remove")); _("Track Remove"));
project.FixScrollbars(); window.FixScrollbars();
project.HandleResize(); window.HandleResize();
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -798,6 +802,8 @@ void OnNewWaveTrack(const CommandContext &context)
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
auto defaultFormat = project.GetDefaultFormat(); auto defaultFormat = project.GetDefaultFormat();
auto rate = project.GetRate(); auto rate = project.GetRate();
@ -808,7 +814,7 @@ void OnNewWaveTrack(const CommandContext &context)
project.PushState(_("Created new audio track"), _("New Track")); project.PushState(_("Created new audio track"), _("New Track"));
project.RedrawProject(); window.RedrawProject();
trackPanel.EnsureVisible(t); trackPanel.EnsureVisible(t);
} }
@ -818,6 +824,8 @@ void OnNewStereoTrack(const CommandContext &context)
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
auto defaultFormat = project.GetDefaultFormat(); auto defaultFormat = project.GetDefaultFormat();
auto rate = project.GetRate(); auto rate = project.GetRate();
@ -833,7 +841,7 @@ void OnNewStereoTrack(const CommandContext &context)
project.PushState(_("Created new stereo audio track"), _("New Track")); project.PushState(_("Created new stereo audio track"), _("New Track"));
project.RedrawProject(); window.RedrawProject();
trackPanel.EnsureVisible(left); trackPanel.EnsureVisible(left);
} }
@ -843,6 +851,7 @@ void OnNewLabelTrack(const CommandContext &context)
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
auto t = tracks.Add( trackFactory.NewLabelTrack() ); auto t = tracks.Add( trackFactory.NewLabelTrack() );
@ -852,7 +861,7 @@ void OnNewLabelTrack(const CommandContext &context)
project.PushState(_("Created new label track"), _("New Track")); project.PushState(_("Created new label track"), _("New Track"));
project.RedrawProject(); window.RedrawProject();
trackPanel.EnsureVisible(t); trackPanel.EnsureVisible(t);
} }
@ -862,6 +871,7 @@ void OnNewTimeTrack(const CommandContext &context)
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &trackFactory = TrackFactory::Get( project ); auto &trackFactory = TrackFactory::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
if (tracks.GetTimeTrack()) { if (tracks.GetTimeTrack()) {
AudacityMessageBox(_("This version of Audacity only allows one time track for each project window.")); AudacityMessageBox(_("This version of Audacity only allows one time track for each project window."));
@ -876,7 +886,7 @@ void OnNewTimeTrack(const CommandContext &context)
project.PushState(_("Created new time track"), _("New Track")); project.PushState(_("Created new time track"), _("New Track"));
project.RedrawProject(); window.RedrawProject();
trackPanel.EnsureVisible(t); trackPanel.EnsureVisible(t);
} }
@ -906,12 +916,13 @@ void OnResample(const CommandContext &context)
auto projectRate = project.GetRate(); auto projectRate = project.GetRate();
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &undoManager = UndoManager::Get( project ); auto &undoManager = UndoManager::Get( project );
auto &window = ProjectWindow::Get( project );
int newRate; int newRate;
while (true) while (true)
{ {
wxDialogWrapper dlg(&project, wxID_ANY, wxString(_("Resample"))); wxDialogWrapper dlg(&window, wxID_ANY, wxString(_("Resample")));
dlg.SetName(dlg.GetTitle()); dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating); ShuttleGui S(&dlg, eIsCreating);
wxString rate; wxString rate;
@ -970,7 +981,7 @@ void OnResample(const CommandContext &context)
} }
AudacityMessageBox(_("The entered value is invalid"), _("Error"), AudacityMessageBox(_("The entered value is invalid"), _("Error"),
wxICON_ERROR, &project); wxICON_ERROR, &window);
} }
int ndx = 0; int ndx = 0;
@ -1000,10 +1011,10 @@ void OnResample(const CommandContext &context)
} }
undoManager.StopConsolidating(); undoManager.StopConsolidating();
project.RedrawProject(); window.RedrawProject();
// Need to reset // Need to reset
project.FinishAutoScroll(); window.FinishAutoScroll();
} }
void OnRemoveTracks(const CommandContext &context) void OnRemoveTracks(const CommandContext &context)
@ -1015,6 +1026,8 @@ void OnMuteAllTracks(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = ProjectWindow::Get( project );
auto soloSimple = project.IsSoloSimple(); auto soloSimple = project.IsSoloSimple();
auto soloNone = project.IsSoloNone(); auto soloNone = project.IsSoloNone();
@ -1026,13 +1039,15 @@ void OnMuteAllTracks(const CommandContext &context)
} }
project.ModifyState(true); project.ModifyState(true);
project.RedrawProject(); window.RedrawProject();
} }
void OnUnmuteAllTracks(const CommandContext &context) void OnUnmuteAllTracks(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = ProjectWindow::Get( project );
auto soloSimple = project.IsSoloSimple(); auto soloSimple = project.IsSoloSimple();
auto soloNone = project.IsSoloNone(); auto soloNone = project.IsSoloNone();
@ -1044,7 +1059,7 @@ void OnUnmuteAllTracks(const CommandContext &context)
} }
project.ModifyState(true); project.ModifyState(true);
project.RedrawProject(); window.RedrawProject();
} }
void OnPanLeft(const CommandContext &context) void OnPanLeft(const CommandContext &context)

View File

@ -80,6 +80,7 @@ void DoPlayStop(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &toolbar = ControlToolBar::Get( project ); auto &toolbar = ControlToolBar::Get( project );
auto &window = ProjectWindow::Get( project );
auto token = project.GetAudioIOToken(); auto token = project.GetAudioIOToken();
//If this project is playing, stop playing, make sure everything is unpaused. //If this project is playing, stop playing, make sure everything is unpaused.
@ -112,7 +113,7 @@ void DoPlayStop(const CommandContext &context)
//play the front project //play the front project
if (!gAudioIO->IsBusy()) { if (!gAudioIO->IsBusy()) {
//update the playing area //update the playing area
project.TP_DisplaySelection(); window.TP_DisplaySelection();
//Otherwise, start playing (assuming audio I/O isn't busy) //Otherwise, start playing (assuming audio I/O isn't busy)
//toolbar->SetPlay(true); // Not needed as done in PlayPlayRegion. //toolbar->SetPlay(true); // Not needed as done in PlayPlayRegion.
toolbar.SetStop(false); toolbar.SetStop(false);
@ -135,6 +136,7 @@ void DoMoveToLabel(AudacityProject &project, bool next)
{ {
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
// Find the number of label tracks, and ptr to last track found // Find the number of label tracks, and ptr to last track found
auto trackRange = tracks.Any<LabelTrack>(); auto trackRange = tracks.Any<LabelTrack>();
@ -168,13 +170,13 @@ void DoMoveToLabel(AudacityProject &project, bool next)
if (project.IsAudioActive()) { if (project.IsAudioActive()) {
DoPlayStop(project); // stop DoPlayStop(project); // stop
selectedRegion = label->selectedRegion; selectedRegion = label->selectedRegion;
project.RedrawProject(); window.RedrawProject();
DoPlayStop(project); // play DoPlayStop(project); // play
} }
else { else {
selectedRegion = label->selectedRegion; selectedRegion = label->selectedRegion;
trackPanel.ScrollIntoView(selectedRegion.t0()); trackPanel.ScrollIntoView(selectedRegion.t0());
project.RedrawProject(); window.RedrawProject();
} }
wxString message; wxString message;
@ -400,6 +402,7 @@ void OnTimerRecord(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &undoManager = UndoManager::Get( project ); auto &undoManager = UndoManager::Get( project );
auto &window = ProjectWindow::Get( project );
// MY: Due to improvements in how Timer Recording saves and/or exports // MY: Due to improvements in how Timer Recording saves and/or exports
// it is now safer to disable Timer Recording when there is more than // it is now safer to disable Timer Recording when there is more than
@ -431,7 +434,7 @@ void OnTimerRecord(const CommandContext &context)
//and therefore remove the newly inserted track. //and therefore remove the newly inserted track.
TimerRecordDialog dialog( TimerRecordDialog dialog(
&project, bProjectSaved); /* parent, project saved? */ &window, bProjectSaved); /* parent, project saved? */
int modalResult = dialog.ShowModal(); int modalResult = dialog.ShowModal();
if (modalResult == wxID_CANCEL) if (modalResult == wxID_CANCEL)
{ {
@ -443,9 +446,9 @@ void OnTimerRecord(const CommandContext &context)
bool bPreferNewTrack; bool bPreferNewTrack;
gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false); gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
if (bPreferNewTrack) { if (bPreferNewTrack) {
project.Rewind(false); window.Rewind(false);
} else { } else {
project.SkipEnd(false); window.SkipEnd(false);
} }
int iTimerRecordingOutcome = dialog.RunWaitDialog(); int iTimerRecordingOutcome = dialog.RunWaitDialog();
@ -494,6 +497,7 @@ void OnPunchAndRoll(const CommandContext &context)
{ {
AudacityProject &project = context.project; AudacityProject &project = context.project;
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &window = GetProjectFrame( project );
static const auto url = static const auto url =
wxT("Punch_and_Roll_Record#Using_Punch_and_Roll_Record"); wxT("Punch_and_Roll_Record#Using_Punch_and_Roll_Record");
@ -518,7 +522,7 @@ void OnPunchAndRoll(const CommandContext &context)
? _("Please select in a stereo track.") ? _("Please select in a stereo track.")
: wxString::Format( : wxString::Format(
_("Please select at least %d channels."), recordingChannels); _("Please select at least %d channels."), recordingChannels);
ShowErrorDialog(&project, _("Error"), message, url); ShowErrorDialog(&window, _("Error"), message, url);
return; return;
} }
@ -560,7 +564,7 @@ void OnPunchAndRoll(const CommandContext &context)
if (error) { if (error) {
auto message = _("Please select a time within a clip."); auto message = _("Please select a time within a clip.");
ShowErrorDialog(&project, _("Error"), message, url); ShowErrorDialog( &window, _("Error"), message, url);
return; return;
} }
@ -639,7 +643,7 @@ void OnSoundActivated(const CommandContext &context)
{ {
AudacityProject &project = context.project; AudacityProject &project = context.project;
SoundActivatedRecord dialog(&project /* parent */ ); SoundActivatedRecord dialog( &GetProjectFrame( project ) /* parent */ );
dialog.ShowModal(); dialog.ShowModal();
} }

View File

@ -47,10 +47,11 @@ double GetZoomOfSelection( const AudacityProject &project )
{ {
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
const double lowerBound = const double lowerBound =
std::max(viewInfo.selectedRegion.t0(), std::max(viewInfo.selectedRegion.t0(),
project.ScrollingLowerBoundTime()); window.ScrollingLowerBoundTime());
const double denom = const double denom =
viewInfo.selectedRegion.t1() - lowerBound; viewInfo.selectedRegion.t1() - lowerBound;
if (denom <= 0.0) if (denom <= 0.0)
@ -165,13 +166,14 @@ void DoZoomFit(AudacityProject &project)
{ {
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = ProjectWindow::Get( project );
const double start = viewInfo.bScrollBeyondZero const double start = viewInfo.bScrollBeyondZero
? std::min(tracks.GetStartTime(), 0.0) ? std::min(tracks.GetStartTime(), 0.0)
: 0; : 0;
project.Zoom( GetZoomOfToFit( project ) ); window.Zoom( GetZoomOfToFit( project ) );
project.TP_ScrollWindow(start); window.TP_ScrollWindow(start);
} }
void DoZoomFitV(AudacityProject &project) void DoZoomFitV(AudacityProject &project)
@ -209,31 +211,35 @@ struct Handler : CommandHandlerObject {
void OnZoomIn(const CommandContext &context) void OnZoomIn(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
project.ZoomInByFactor( 2.0 ); auto &window = ProjectWindow::Get( project );
window.ZoomInByFactor( 2.0 );
} }
void OnZoomNormal(const CommandContext &context) void OnZoomNormal(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
project.Zoom(ZoomInfo::GetDefaultZoom()); window.Zoom(ZoomInfo::GetDefaultZoom());
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
void OnZoomOut(const CommandContext &context) void OnZoomOut(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
project.ZoomOutByFactor( 1 /2.0 ); auto &window = ProjectWindow::Get( project );
window.ZoomOutByFactor( 1 /2.0 );
} }
void OnZoomSel(const CommandContext &context) void OnZoomSel(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
auto &window = ProjectWindow::Get( project );
project.Zoom( GetZoomOfSelection( project ) ); window.Zoom( GetZoomOfSelection( project ) );
project.TP_ScrollWindow(selectedRegion.t0()); window.TP_ScrollWindow(selectedRegion.t0());
} }
void OnZoomToggle(const CommandContext &context) void OnZoomToggle(const CommandContext &context)
@ -241,6 +247,7 @@ void OnZoomToggle(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
// const double origLeft = viewInfo.h; // const double origLeft = viewInfo.h;
// const double origWidth = GetScreenEndTime() - origLeft; // const double origWidth = GetScreenEndTime() - origLeft;
@ -252,7 +259,7 @@ void OnZoomToggle(const CommandContext &context)
double ChosenZoom = double ChosenZoom =
fabs(log(Zoom1 / Z)) > fabs(log( Z / Zoom2)) ? Zoom1:Zoom2; fabs(log(Zoom1 / Z)) > fabs(log( Z / Zoom2)) ? Zoom1:Zoom2;
project.Zoom(ChosenZoom); window.Zoom(ChosenZoom);
trackPanel.Refresh(false); trackPanel.Refresh(false);
// const double newWidth = GetScreenEndTime() - viewInfo.h; // const double newWidth = GetScreenEndTime() - viewInfo.h;
// const double newh = origLeft + (origWidth - newWidth) / 2; // const double newh = origLeft + (origWidth - newWidth) / 2;
@ -267,11 +274,12 @@ void OnZoomFit(const CommandContext &context)
void OnZoomFitV(const CommandContext &context) void OnZoomFitV(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &window = ProjectWindow::Get( project );
DoZoomFitV(project); DoZoomFitV(project);
project.GetVerticalScrollBar().SetThumbPosition(0); window.GetVerticalScrollBar().SetThumbPosition(0);
project.RedrawProject(); window.RedrawProject();
project.ModifyState(true); project.ModifyState(true);
} }
@ -291,24 +299,26 @@ void OnCollapseAllTracks(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = ProjectWindow::Get( project );
for (auto t : tracks.Any()) for (auto t : tracks.Any())
t->SetMinimized(true); t->SetMinimized(true);
project.ModifyState(true); project.ModifyState(true);
project.RedrawProject(); window.RedrawProject();
} }
void OnExpandAllTracks(const CommandContext &context) void OnExpandAllTracks(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &window = ProjectWindow::Get( project );
for (auto t : tracks.Any()) for (auto t : tracks.Any())
t->SetMinimized(false); t->SetMinimized(false);
project.ModifyState(true); project.ModifyState(true);
project.RedrawProject(); window.RedrawProject();
} }
void OnGoSelStart(const CommandContext &context) void OnGoSelStart(const CommandContext &context)
@ -317,11 +327,12 @@ void OnGoSelStart(const CommandContext &context)
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &selectedRegion = viewInfo.selectedRegion; auto &selectedRegion = viewInfo.selectedRegion;
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
if (selectedRegion.isPoint()) if (selectedRegion.isPoint())
return; return;
project.TP_ScrollWindow( window.TP_ScrollWindow(
selectedRegion.t0() - ((trackPanel.GetScreenEndTime() - viewInfo.h) / 2)); selectedRegion.t0() - ((trackPanel.GetScreenEndTime() - viewInfo.h) / 2));
} }
@ -331,11 +342,12 @@ void OnGoSelEnd(const CommandContext &context)
auto &viewInfo = ViewInfo::Get( project ); auto &viewInfo = ViewInfo::Get( project );
auto &selectedRegion = viewInfo.selectedRegion; auto &selectedRegion = viewInfo.selectedRegion;
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &window = ProjectWindow::Get( project );
if (selectedRegion.isPoint()) if (selectedRegion.isPoint())
return; return;
project.TP_ScrollWindow( window.TP_ScrollWindow(
selectedRegion.t1() - ((trackPanel.GetScreenEndTime() - viewInfo.h) / 2)); selectedRegion.t1() - ((trackPanel.GetScreenEndTime() - viewInfo.h) / 2));
} }

View File

@ -28,8 +28,8 @@ namespace {
void DoMacMinimize(AudacityProject *project) void DoMacMinimize(AudacityProject *project)
{ {
auto window = project; if (project) {
if (window) { auto window = &GetProjectFrame( *project );
#ifdef USE_COCOA #ifdef USE_COCOA
// Adapted from mbarman.mm in wxWidgets 3.0.2 // Adapted from mbarman.mm in wxWidgets 3.0.2
auto peer = window->GetPeer(); auto peer = window->GetPeer();
@ -67,7 +67,7 @@ void OnMacMinimize(const CommandContext &context)
void OnMacZoom(const CommandContext &context) void OnMacZoom(const CommandContext &context)
{ {
auto window = &context.project; auto window = &GetProjectFrame( context.project );
auto topWindow = static_cast<wxTopLevelWindow*>(window); auto topWindow = static_cast<wxTopLevelWindow*>(window);
auto maximized = topWindow->IsMaximized(); auto maximized = topWindow->IsMaximized();
if (window) { if (window) {
@ -89,9 +89,8 @@ void OnMacBringAllToFront(const CommandContext &)
{ {
// Reall this de-miniaturizes all, which is not exactly the standard // Reall this de-miniaturizes all, which is not exactly the standard
// behavior. // behavior.
for (const auto project : gAudacityProjects) { for (const auto project : gAudacityProjects)
project->Raise(); GetProjectFrame( *project ).Raise();
}
} }
void OnMacMinimizeAll(const CommandContext &) void OnMacMinimizeAll(const CommandContext &)

View File

@ -424,7 +424,8 @@ void ODManager::Start()
ODLocker locker{ &AudacityProject::AllProjectDeleteMutex() }; ODLocker locker{ &AudacityProject::AllProjectDeleteMutex() };
AudacityProject* proj = GetActiveProject(); AudacityProject* proj = GetActiveProject();
if(proj) if(proj)
proj->GetEventHandler()->AddPendingEvent(event); GetProjectFrame( *proj )
.GetEventHandler()->AddPendingEvent(event);
} }
mTerminateMutex.Lock(); mTerminateMutex.Lock();
} }

View File

@ -159,7 +159,8 @@ void ODTask::DoSome(float amountWork)
if(IsTaskAssociatedWithProject(gAudacityProjects[i].get())) if(IsTaskAssociatedWithProject(gAudacityProjects[i].get()))
{ {
//this assumes tasks are only associated with one project. //this assumes tasks are only associated with one project.
gAudacityProjects[i]->GetEventHandler()->AddPendingEvent(event); GetProjectFrame( *gAudacityProjects[i] )
.GetEventHandler()->AddPendingEvent(event);
//mark the changes so that the project can be resaved. //mark the changes so that the project can be resaved.
UndoManager::Get( *gAudacityProjects[i] ).SetODChangesFlag(); UndoManager::Get( *gAudacityProjects[i] ).SetODChangesFlag();
break; break;

View File

@ -817,7 +817,8 @@ void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
StopPlaying(); StopPlaying();
if (p) p->TP_DisplaySelection(); if (p)
ProjectWindow::Get( *p ).TP_DisplaySelection();
auto cleanup = finally( [&]{ UpdateStatusBar(p); } ); auto cleanup = finally( [&]{ UpdateStatusBar(p); } );
PlayDefault(); PlayDefault();
@ -1337,7 +1338,7 @@ void ControlToolBar::OnRewind(wxCommandEvent & WXUNUSED(evt))
AudacityProject *p = GetActiveProject(); AudacityProject *p = GetActiveProject();
if (p) { if (p) {
TransportActions::StopIfPaused( *p ); TransportActions::StopIfPaused( *p );
p->Rewind(mRewind->WasShiftDown()); ProjectWindow::Get( *p ).Rewind(mRewind->WasShiftDown());
} }
} }
@ -1350,7 +1351,7 @@ void ControlToolBar::OnFF(wxCommandEvent & WXUNUSED(evt))
if (p) { if (p) {
TransportActions::StopIfPaused( *p ); TransportActions::StopIfPaused( *p );
p->SkipEnd(mFF->WasShiftDown()); ProjectWindow::Get( *p ).SkipEnd(mFF->WasShiftDown());
} }
} }
@ -1442,7 +1443,8 @@ wxString ControlToolBar::StateForStatusBar()
void ControlToolBar::UpdateStatusBar(AudacityProject *pProject) void ControlToolBar::UpdateStatusBar(AudacityProject *pProject)
{ {
pProject->GetStatusBar()->SetStatusText(StateForStatusBar(), stateStatusBarField); GetProjectFrame( *pProject )
.GetStatusBar()->SetStatusText(StateForStatusBar(), stateStatusBarField);
} }
bool ControlToolBar::IsTransportingPinned() bool ControlToolBar::IsTransportingPinned()
@ -1466,8 +1468,8 @@ void ControlToolBar::StartScrollingIfPreferred()
// doing this causes wheel rotation events (mapped from the double finger vertical // doing this causes wheel rotation events (mapped from the double finger vertical
// swipe) to be delivered more uniformly to the application, so that speed control // swipe) to be delivered more uniformly to the application, so that speed control
// works better. // works better.
::GetActiveProject()->GetPlaybackScroller().Activate ProjectWindow::Get( *::GetActiveProject() ).GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Refresh); (ProjectWindow::PlaybackScroller::Mode::Refresh);
} }
#endif #endif
else else
@ -1476,7 +1478,7 @@ void ControlToolBar::StartScrollingIfPreferred()
void ControlToolBar::StartScrolling() void ControlToolBar::StartScrolling()
{ {
using Mode = AudacityProject::PlaybackScroller::Mode; using Mode = ProjectWindow::PlaybackScroller::Mode;
const auto project = GetActiveProject(); const auto project = GetActiveProject();
if (project) { if (project) {
auto mode = Mode::Pinned; auto mode = Mode::Pinned;
@ -1508,7 +1510,7 @@ void ControlToolBar::StartScrolling()
} }
#endif #endif
project->GetPlaybackScroller().Activate(mode); ProjectWindow::Get( *project ).GetPlaybackScroller().Activate(mode);
} }
} }
@ -1516,8 +1518,8 @@ void ControlToolBar::StopScrolling()
{ {
const auto project = GetActiveProject(); const auto project = GetActiveProject();
if(project) if(project)
project->GetPlaybackScroller().Activate ProjectWindow::Get( *project ).GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Off); (ProjectWindow::PlaybackScroller::Mode::Off);
} }
void ControlToolBar::CommitRecording() void ControlToolBar::CommitRecording()

View File

@ -83,7 +83,7 @@
// //
ToolFrame::ToolFrame ToolFrame::ToolFrame
( AudacityProject *parent, ToolManager *manager, ToolBar *bar, wxPoint pos ) ( AudacityProject *parent, ToolManager *manager, ToolBar *bar, wxPoint pos )
: wxFrame( parent, : wxFrame( ProjectWindow::Find( parent ),
bar->GetId(), bar->GetId(),
wxEmptyString, wxEmptyString,
pos, pos,
@ -324,7 +324,8 @@ END_EVENT_TABLE()
static const AudacityProject::AttachedObjects::RegisteredFactory key{ static const AudacityProject::AttachedObjects::RegisteredFactory key{
[]( AudacityProject &parent ){ []( AudacityProject &parent ){
return std::make_shared< ToolManager >( &parent, parent.GetTopPanel() ); } auto &window = ProjectWindow::Get( parent );
return std::make_shared< ToolManager >( &parent, window.GetTopPanel() ); }
}; };
ToolManager &ToolManager::Get( AudacityProject &project ) ToolManager &ToolManager::Get( AudacityProject &project )
@ -343,6 +344,7 @@ const ToolManager &ToolManager::Get( const AudacityProject &project )
ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent ) ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
: wxEvtHandler() : wxEvtHandler()
{ {
auto &window = ProjectWindow::Get( *parent );
wxPoint pt[ 3 ]; wxPoint pt[ 3 ];
#if defined(__WXMAC__) #if defined(__WXMAC__)
@ -409,19 +411,19 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
// Hook the parents mouse events...using the parent helps greatly // Hook the parents mouse events...using the parent helps greatly
// under GTK // under GTK
mParent->Bind( wxEVT_LEFT_UP, window.Bind( wxEVT_LEFT_UP,
&ToolManager::OnMouse, &ToolManager::OnMouse,
this ); this );
mParent->Bind( wxEVT_MOTION, window.Bind( wxEVT_MOTION,
&ToolManager::OnMouse, &ToolManager::OnMouse,
this ); this );
mParent->Bind( wxEVT_MOUSE_CAPTURE_LOST, window.Bind( wxEVT_MOUSE_CAPTURE_LOST,
&ToolManager::OnCaptureLost, &ToolManager::OnCaptureLost,
this ); this );
// Create the top and bottom docks // Create the top and bottom docks
mTopDock = safenew ToolDock( this, topDockParent, TopDockID ); mTopDock = safenew ToolDock( this, topDockParent, TopDockID );
mBotDock = safenew ToolDock( this, mParent, BotDockID ); mBotDock = safenew ToolDock( this, &window, BotDockID );
// Create all of the toolbars // Create all of the toolbars
// All have the project as parent window // All have the project as parent window
@ -665,7 +667,7 @@ int ToolManager::FilterEvent(wxEvent &event)
if ( window && if ( window &&
!dynamic_cast<Grabber*>( window ) && !dynamic_cast<Grabber*>( window ) &&
!dynamic_cast<ToolFrame*>( window ) && !dynamic_cast<ToolFrame*>( window ) &&
top == mParent ) top == ProjectWindow::Find( mParent ) )
// Note this is a dangle-proof wxWindowRef: // Note this is a dangle-proof wxWindowRef:
mLastFocus = window; mLastFocus = window;
} }
@ -1050,7 +1052,7 @@ void ToolManager::Updated()
{ {
// Queue an update event // Queue an update event
wxCommandEvent e( EVT_TOOLBAR_UPDATED ); wxCommandEvent e( EVT_TOOLBAR_UPDATED );
mParent->GetEventHandler()->AddPendingEvent( e ); GetProjectFrame( *mParent ).GetEventHandler()->AddPendingEvent( e );
} }
// //
@ -1182,7 +1184,7 @@ void ToolManager::OnMouse( wxMouseEvent & event )
// Must set the bar afloat if it's currently docked // Must set the bar afloat if it's currently docked
mDidDrag = true; mDidDrag = true;
wxPoint mp = event.GetPosition(); wxPoint mp = event.GetPosition();
mp = mParent->ClientToScreen(mp); mp = GetProjectFrame( *mParent ).ClientToScreen(mp);
if (!mDragWindow) { if (!mDragWindow) {
// We no longer have control // We no longer have control
if (mPrevDock) if (mPrevDock)
@ -1457,8 +1459,9 @@ void ToolManager::OnGrabber( GrabberEvent & event )
} }
// We want all mouse events from this point on // We want all mouse events from this point on
if( !mParent->HasCapture() ) auto &window = GetProjectFrame( *mParent );
mParent->CaptureMouse(); if( !window.HasCapture() )
window.CaptureMouse();
// Start monitoring shift key changes // Start monitoring shift key changes
mLastState = wxGetKeyState( WXK_SHIFT ); mLastState = wxGetKeyState( WXK_SHIFT );
@ -1499,9 +1502,10 @@ void ToolManager::DoneDragging()
{ {
// Done dragging // Done dragging
// Release capture // Release capture
if( mParent->HasCapture() ) auto &window = GetProjectFrame( *mParent );
if( window.HasCapture() )
{ {
mParent->ReleaseMouse(); window.ReleaseMouse();
} }
// Hide the indicator // Hide the indicator

View File

@ -34,6 +34,7 @@ class wxTimerEvent;
class wxWindow; class wxWindow;
class AudacityProject; class AudacityProject;
using ProjectWindow = AudacityProject;
class ToolFrame; class ToolFrame;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -184,8 +185,6 @@ public:
void Resize( const wxSize &size ); void Resize( const wxSize &size );
AudacityProject *GetParent() const { return mParent; }
private: private:
AudacityProject *const mParent; AudacityProject *const mParent;

View File

@ -48,6 +48,7 @@ unsigned CommonTrackPanelCell::HandleWheelRotation
const wxMouseEvent &event = evt.event; const wxMouseEvent &event = evt.event;
auto &viewInfo = ViewInfo::Get( *pProject ); auto &viewInfo = ViewInfo::Get( *pProject );
Scrubber &scrubber = Scrubber::Get( *pProject ); Scrubber &scrubber = Scrubber::Get( *pProject );
auto &window = ProjectWindow::Get( *pProject );
const auto steps = evt.steps; const auto steps = evt.steps;
if (event.ShiftDown() if (event.ShiftDown()
@ -57,7 +58,7 @@ unsigned CommonTrackPanelCell::HandleWheelRotation
) )
{ {
// MM: Scroll left/right when used with Shift key down // MM: Scroll left/right when used with Shift key down
pProject->TP_ScrollWindow( window.TP_ScrollWindow(
viewInfo.OffsetTimeByPixels( viewInfo.OffsetTimeByPixels(
viewInfo.PositionToTime(0), 50.0 * -steps)); viewInfo.PositionToTime(0), 50.0 * -steps));
} }
@ -153,7 +154,7 @@ unsigned CommonTrackPanelCell::HandleWheelRotation
double lines = steps * 4 + mVertScrollRemainder; double lines = steps * 4 + mVertScrollRemainder;
mVertScrollRemainder = lines - floor(lines); mVertScrollRemainder = lines - floor(lines);
lines = floor(lines); lines = floor(lines);
auto didSomething = pProject->TP_ScrollUpDown((int)-lines); auto didSomething = window.TP_ScrollUpDown((int)-lines);
if (!didSomething) if (!didSomething)
result |= Cancelled; result |= Cancelled;
} }

View File

@ -126,7 +126,8 @@ static const AudacityProject::AttachedObjects::RegisteredFactory sOverlayKey{
PlayIndicatorOverlay::PlayIndicatorOverlay(AudacityProject *project) PlayIndicatorOverlay::PlayIndicatorOverlay(AudacityProject *project)
: PlayIndicatorOverlayBase(project, true) : PlayIndicatorOverlayBase(project, true)
{ {
mProject->GetPlaybackScroller().Bind(EVT_TRACK_PANEL_TIMER, ProjectWindow::Get( *mProject ).GetPlaybackScroller().Bind(
EVT_TRACK_PANEL_TIMER,
&PlayIndicatorOverlay::OnTimer, &PlayIndicatorOverlay::OnTimer,
this); this);
} }
@ -165,8 +166,10 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
// Calculate the horizontal position of the indicator // Calculate the horizontal position of the indicator
const double playPos = viewInfo.mRecentStreamTime; const double playPos = viewInfo.mRecentStreamTime;
using Mode = AudacityProject::PlaybackScroller::Mode; auto &window = ProjectWindow::Get( *mProject );
const Mode mode = mProject->GetPlaybackScroller().GetMode(); using Mode = ProjectWindow::PlaybackScroller::Mode;
const Mode mode =
window.GetPlaybackScroller().GetMode();
const bool pinned = ( mode == Mode::Pinned || mode == Mode::Right ); const bool pinned = ( mode == Mode::Pinned || mode == Mode::Right );
// Use a small tolerance to avoid flicker of play head pinned all the way // Use a small tolerance to avoid flicker of play head pinned all the way
@ -179,7 +182,7 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
trackPanel.GetScreenEndTime() + tolerance); trackPanel.GetScreenEndTime() + tolerance);
// This displays the audio time, too... // This displays the audio time, too...
mProject->TP_DisplaySelection(); window.TP_DisplaySelection();
// BG: Scroll screen if option is set // BG: Scroll screen if option is set
if( viewInfo.bUpdateTrackIndicator && if( viewInfo.bUpdateTrackIndicator &&
@ -199,9 +202,9 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
// just a little bit equal to the scrubbing poll interval // just a little bit equal to the scrubbing poll interval
// duration. // duration.
newPos = viewInfo.OffsetTimeByPixels( newPos, -width ); newPos = viewInfo.OffsetTimeByPixels( newPos, -width );
newPos = std::max( newPos, mProject->ScrollingLowerBoundTime() ); newPos = std::max( newPos, window.ScrollingLowerBoundTime() );
} }
mProject->TP_ScrollWindow(newPos); window.TP_ScrollWindow(newPos);
// Might yet be off screen, check it // Might yet be off screen, check it
onScreen = playPos >= 0.0 && onScreen = playPos >= 0.0 &&
between_incexc(viewInfo.h, between_incexc(viewInfo.h,
@ -213,7 +216,7 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
// Always update scrollbars even if not scrolling the window. This is // Always update scrollbars even if not scrolling the window. This is
// important when NEW audio is recorded, because this can change the // important when NEW audio is recorded, because this can change the
// length of the project and therefore the appearance of the scrollbar. // length of the project and therefore the appearance of the scrollbar.
mProject->TP_RedrawScrollbars(); window.TP_RedrawScrollbars();
if (onScreen) if (onScreen)
mNewIndicatorX = viewInfo.TimeToPosition(playPos, trackPanel.GetLeftOffset()); mNewIndicatorX = viewInfo.TimeToPosition(playPos, trackPanel.GetLeftOffset());

View File

@ -1067,13 +1067,14 @@ void SelectHandle::TimerHandler::OnTimer(wxCommandEvent &event)
const auto project = mConnectedProject; const auto project = mConnectedProject;
const auto &trackPanel = TrackPanel::Get( *project ); const auto &trackPanel = TrackPanel::Get( *project );
auto &window = ProjectWindow::Get( *project );
if (mParent->mMostRecentX >= mParent->mRect.x + mParent->mRect.width) { if (mParent->mMostRecentX >= mParent->mRect.x + mParent->mRect.width) {
mParent->mAutoScrolling = true; mParent->mAutoScrolling = true;
project->TP_ScrollRight(); window.TP_ScrollRight();
} }
else if (mParent->mMostRecentX < mParent->mRect.x) { else if (mParent->mMostRecentX < mParent->mRect.x) {
mParent->mAutoScrolling = true; mParent->mAutoScrolling = true;
project->TP_ScrollLeft(); window.TP_ScrollLeft();
} }
else { else {
// Bug1387: enable autoscroll during drag, if the pointer is at either // Bug1387: enable autoscroll during drag, if the pointer is at either
@ -1084,14 +1085,14 @@ void SelectHandle::TimerHandler::OnTimer(wxCommandEvent &event)
trackPanel.ClientToScreen(&xx, &yy); trackPanel.ClientToScreen(&xx, &yy);
if (xx == 0) { if (xx == 0) {
mParent->mAutoScrolling = true; mParent->mAutoScrolling = true;
project->TP_ScrollLeft(); window.TP_ScrollLeft();
} }
else { else {
int width, height; int width, height;
::wxDisplaySize(&width, &height); ::wxDisplaySize(&width, &height);
if (xx == width - 1) { if (xx == width - 1) {
mParent->mAutoScrolling = true; mParent->mAutoScrolling = true;
project->TP_ScrollRight(); window.TP_ScrollRight();
} }
} }
} }

View File

@ -214,7 +214,7 @@ void TrackMenuTable::OnSetName(wxCommandEvent &)
SetTrackNameCommand Command; SetTrackNameCommand Command;
Command.mName = oldName; Command.mName = oldName;
// Bug 1837 : We need an OK/Cancel result if we are to enter a blank string. // Bug 1837 : We need an OK/Cancel result if we are to enter a blank string.
bool bResult = Command.PromptUser( proj ); bool bResult = Command.PromptUser( &GetProjectFrame( *proj ) );
if (bResult) if (bResult)
{ {
wxString newName = Command.mName; wxString newName = Command.mName;

View File

@ -1987,7 +1987,8 @@ void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
// Dialog is a child of the project, rather than of the toolbar. // Dialog is a child of the project, rather than of the toolbar.
// This determines where it pops up. // This determines where it pops up.
wxDialogWrapper dlg(GetActiveProject(), wxID_ANY, title); wxDialogWrapper dlg( FindProjectFrame( GetActiveProject() ),
wxID_ANY, title );
dlg.SetName(dlg.GetTitle()); dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating); ShuttleGui S(&dlg, eIsCreating);
S.StartVerticalLay(); S.StartVerticalLay();