1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-15 15:11:12 +02:00

Several nonmodal top level window tools register their menu items...

... removing link dependencies on them from src/menus, so they are now suitable
for moving out into modules.

They are:
Mixer Board
Karaoke (also called Lyrics)
History
Contrast
Plot Spectrum

Their header files are now no longer included anywhere but in their own
implementation files!
This commit is contained in:
Paul Licameli
2019-01-05 16:26:09 -05:00
parent a465ce0046
commit d9d3f95570
8 changed files with 315 additions and 150 deletions

View File

@@ -12,11 +12,12 @@
#include "../Audacity.h"
#include "Contrast.h"
#include "../CommonCommandFlags.h"
#include "../WaveTrack.h"
#include "../Prefs.h"
#include "../Project.h"
#include "../ProjectSettings.h"
#include "../ProjectWindowBase.h"
#include "../ProjectWindow.h"
#include "../ShuttleGui.h"
#include "../FileNames.h"
#include "../ViewInfo.h"
@@ -648,3 +649,56 @@ void ContrastDialog::OnReset(wxCommandEvent & /*event*/)
mPassFailText->ChangeValue(wxT(""));
mDiffText->ChangeValue(wxT(""));
}
// Remaining code hooks this add-on into the application
#include "commands/CommandContext.h"
#include "commands/CommandManager.h"
#include "../commands/ScreenshotCommand.h"
namespace {
// Contrast window attached to each project is built on demand by:
AudacityProject::AttachedWindows::RegisteredFactory sContrastDialogKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
auto &window = ProjectWindow::Get( parent );
return safenew ContrastDialog(
&window, -1, XO("Contrast Analysis (WCAG 2 compliance)"),
wxPoint{ 150, 150 }
);
}
};
// Define our extra menu item that invokes that factory
struct Handler : CommandHandlerObject {
void OnContrast(const CommandContext &context)
{
auto &project = context.project;
auto contrastDialog =
&project.AttachedWindows::Get< ContrastDialog >( sContrastDialogKey );
contrastDialog->CentreOnParent();
if( ScreenshotCommand::MayCapture( contrastDialog ) )
return;
contrastDialog->Show();
}
};
CommandHandlerObject &findCommandHandler(AudacityProject &) {
// Handler is not stateful. Doesn't need a factory registered with
// AudacityProject.
static Handler instance;
return instance;
}
// Register that menu item
using namespace MenuTable;
AttachedItem sAttachment{ wxT("Analyze/Analyzers/Windows"),
( FinderScope{ findCommandHandler },
Command( wxT("ContrastAnalyser"), XXO("Contrast..."),
&Handler::OnContrast,
AudioIONotBusyFlag() | WaveTracksSelectedFlag() | TimeSelectedFlag(),
wxT("Ctrl+Shift+T") ) )
};
}