1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00
This commit is contained in:
Paul Licameli
2020-01-31 23:44:00 -05:00
parent 229e2673c7
commit 4d43967add
22 changed files with 794 additions and 546 deletions

View File

@@ -12,6 +12,7 @@
#include "LyricsWindow.h"
#include "Lyrics.h"
#include "AudioIOBase.h"
#include "CommonCommandFlags.h"
#include "Prefs.h" // for RTL_WORKAROUND
#include "Project.h"
#include "ProjectAudioIO.h"
@@ -167,3 +168,46 @@ void LyricsWindow::OnTimer(wxCommandEvent &event)
// Let other listeners get the notification
event.Skip();
}
// Remaining code hooks this add-on into the application
#include "commands/CommandContext.h"
#include "commands/CommandManager.h"
namespace {
// Lyrics window attached to each project is built on demand by:
AudacityProject::AttachedWindows::RegisteredFactory sLyricsWindowKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
return safenew LyricsWindow( &parent );
}
};
// Define our extra menu item that invokes that factory
struct Handler : CommandHandlerObject {
void OnKaraoke(const CommandContext &context)
{
auto &project = context.project;
auto lyricsWindow = &project.AttachedWindows::Get( sLyricsWindowKey );
lyricsWindow->Show();
lyricsWindow->Raise();
}
};
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("View/Windows"),
( FinderScope{ findCommandHandler },
Command( wxT("Karaoke"), XXO("&Karaoke..."), &Handler::OnKaraoke,
LabelTracksExistFlag() ) )
};
}