1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Global keyboard capture handling into new files, better comments...

... and break its compile dependency on CommandManager.h by letting it install
callbacks.

This also removes Objective-C mixed code from CommmandManager.

This also eliminates four inclusions of Project.h!

Capture handler state is also global, not per project, though the
CommandManager's callbacks still do depend on the active project.
This commit is contained in:
Paul Licameli
2019-05-14 13:59:24 -04:00
parent 78a1263163
commit db8c4c5e5a
14 changed files with 501 additions and 433 deletions

View File

@@ -108,6 +108,7 @@ scroll information. It also has some status flags.
#include "InconsistencyException.h"
#include "MixerBoard.h"
#include "import/Import.h"
#include "KeyboardCapture.h"
#include "LabelTrack.h"
#include "Legacy.h"
#include "LyricsWindow.h"
@@ -303,11 +304,6 @@ const int sbarHjump = 30; //STM: This is how far the thumb jumps when the
int AudacityProject::mProjectCounter=0;// global counter.
////////////////////////////////////////////////////////////
/// Custom events
////////////////////////////////////////////////////////////
DEFINE_EVENT_TYPE(EVT_CAPTURE_KEY);
//
// This small template class resembles a try-finally block
//
@@ -407,7 +403,10 @@ AUDACITY_DLL_API AudacityProject *GetActiveProject()
void SetActiveProject(AudacityProject * project)
{
gActiveProject = project;
if ( gActiveProject != project ) {
gActiveProject = project;
KeyboardCapture::Capture( nullptr );
}
wxTheApp->SetTopWindow(project);
}
@@ -5338,50 +5337,6 @@ void AudacityProject::SetSyncLock(bool flag)
}
}
// Keyboard capture
// static
bool AudacityProject::HasKeyboardCapture(const wxWindow *handler)
{
return GetKeyboardCaptureHandler() == handler;
}
// static
wxWindow *AudacityProject::GetKeyboardCaptureHandler()
{
AudacityProject *project = GetActiveProject();
if (project)
{
return project->mKeyboardCaptureHandler;
}
return NULL;
}
// static
void AudacityProject::CaptureKeyboard(wxWindow *handler)
{
AudacityProject *project = GetActiveProject();
if (project)
{
// wxASSERT(project->mKeyboardCaptureHandler == NULL);
project->mKeyboardCaptureHandler = handler;
}
}
// static
void AudacityProject::ReleaseKeyboard(wxWindow * /* handler */)
{
AudacityProject *project = GetActiveProject();
if (project)
{
// wxASSERT(project->mKeyboardCaptureHandler == handler);
project->mKeyboardCaptureHandler = NULL;
}
return;
}
bool AudacityProject::ExportFromTimerRecording(wxFileName fnFile, int iFormat, int iSubFormat, int iFilterIndex)
{
Exporter e;