1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-21 08:27:13 +01:00

Decouple class AudacityProject from some attached frames...

... use registered factories instead, so class AudacityProject needn't know
the other classes.

This frees 9 .cpp files, related to various non-modal dialogs, to higher
levels out of the big strongly connected component, as determined by
scripts/graph.pl!

But in reality there is still link dependency on them that the script does not
detect.  The remaining dependency is via the declarations of ViewMenu,
EffectMenu, etc. in Menus.cpp.

That could be broken with a registration system for menus.
This commit is contained in:
Paul Licameli
2019-05-01 13:23:34 -04:00
parent f83a866276
commit 00117897bc
6 changed files with 80 additions and 113 deletions

View File

@@ -8,6 +8,7 @@
#include "../Prefs.h"
#include "../Project.h"
#include "../TrackPanel.h"
#include "../UndoManager.h"
#include "../ViewInfo.h"
#include "../commands/CommandContext.h"
#include "../commands/CommandManager.h"
@@ -23,6 +24,25 @@
// private helper classes and functions
namespace {
AudacityProject::AttachedWindows::RegisteredFactory sMixerBoardKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
return safenew MixerBoardFrame( &parent );
}
};
AudacityProject::AttachedWindows::RegisteredFactory sHistoryWindowKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
auto &undoManager = UndoManager::Get( parent );
return safenew HistoryWindow( &parent, &undoManager );
}
};
AudacityProject::AttachedWindows::RegisteredFactory sLyricsWindowKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
return safenew LyricsWindow( &parent );
}
};
double GetZoomOfSelection( const AudacityProject &project )
{
auto &viewInfo = ViewInfo::Get( project );
@@ -323,7 +343,7 @@ void OnHistory(const CommandContext &context)
{
auto &project = context.project;
auto historyWindow = project.GetHistoryWindow(true);
auto historyWindow = &project.AttachedWindows::Get( sHistoryWindowKey );
historyWindow->Show();
historyWindow->Raise();
}
@@ -332,7 +352,7 @@ void OnKaraoke(const CommandContext &context)
{
auto &project = context.project;
auto lyricsWindow = project.GetLyricsWindow(true);
auto lyricsWindow = &project.AttachedWindows::Get( sLyricsWindowKey );
lyricsWindow->Show();
lyricsWindow->Raise();
}
@@ -341,7 +361,7 @@ void OnMixerBoard(const CommandContext &context)
{
auto &project = context.project;
auto mixerBoardFrame = project.GetMixerBoardFrame(true);
auto mixerBoardFrame = &project.AttachedWindows::Get( sMixerBoardKey );
mixerBoardFrame->Show();
mixerBoardFrame->Raise();
mixerBoardFrame->SetFocus();