1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-15 15:11:12 +02:00
This commit is contained in:
Paul Licameli
2020-01-31 22:33:16 -05:00
parent c1d129ec98
commit 2c25a37994
22 changed files with 546 additions and 794 deletions

View File

@@ -12,12 +12,11 @@
#include "../Audacity.h"
#include "Contrast.h"
#include "../CommonCommandFlags.h"
#include "../WaveTrack.h"
#include "../Prefs.h"
#include "../Project.h"
#include "../ProjectSettings.h"
#include "../ProjectWindow.h"
#include "../ProjectWindowBase.h"
#include "../ShuttleGui.h"
#include "../FileNames.h"
#include "../ViewInfo.h"
@@ -649,56 +648,3 @@ 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") ) )
};
}