mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-21 14:02:57 +02:00
CommandManager, MenuManager don't use Lyrics.h, MixerBoard.h ...
... instead define new base classes in src/commands that those other windows can inherit. The classes have nothing but a virtual destructor. This lets CommandManager use dynamic_cast to detect the special windows. See commitscbfde23
and68e4bf6
which added the #include directives
This commit is contained in:
@@ -78,6 +78,7 @@ CommandManager. It holds the callback for one command.
|
||||
#include "../AudacityHeaders.h"
|
||||
#include "../Audacity.h"
|
||||
#include "CommandManager.h"
|
||||
#include "CommandManagerWindowClasses.h"
|
||||
#include "CommandContext.h"
|
||||
|
||||
#include <wx/defs.h>
|
||||
@@ -92,11 +93,6 @@ CommandManager. It holds the callback for one command.
|
||||
#include "../Prefs.h"
|
||||
#include "../Project.h"
|
||||
|
||||
// LyricsPanel and MixerBoard both intercept keys, as if they were the TrackPanel.
|
||||
// The mechanism of checking for the type of window here is klunky.
|
||||
#include "../Lyrics.h"
|
||||
#include "../MixerBoard.h"
|
||||
|
||||
#include "Keyboard.h"
|
||||
#include "../PluginManager.h"
|
||||
#include "../effects/EffectManager.h"
|
||||
@@ -128,6 +124,14 @@ CommandManager. It holds the callback for one command.
|
||||
|
||||
#include "../Experimental.h"
|
||||
|
||||
NonKeystrokeInterceptingWindow::~NonKeystrokeInterceptingWindow()
|
||||
{
|
||||
}
|
||||
|
||||
TopLevelKeystrokeHandlingWindow::~TopLevelKeystrokeHandlingWindow()
|
||||
{
|
||||
}
|
||||
|
||||
// Shared by all projects
|
||||
static class CommandManagerEventMonitor final : public wxEventFilter
|
||||
{
|
||||
@@ -1389,7 +1393,7 @@ bool CommandManager::FilterKeyEvent(AudacityProject *project, const wxKeyEvent &
|
||||
// Bug 1557. MixerBoard should count as 'destined for project'
|
||||
// MixerBoard IS a TopLevelWindow, and its parent is the project.
|
||||
if( pParent && pParent->GetParent() == project){
|
||||
if( dynamic_cast<MixerBoardFrame*>( pParent) != NULL )
|
||||
if( dynamic_cast< TopLevelKeystrokeHandlingWindow* >( pParent ) != NULL )
|
||||
validTarget = true;
|
||||
}
|
||||
validTarget = validTarget && wxEventLoop::GetActive()->IsMain();
|
||||
@@ -1409,12 +1413,9 @@ bool CommandManager::FilterKeyEvent(AudacityProject *project, const wxKeyEvent &
|
||||
if((type == wxEVT_KEY_DOWN) || (type == wxEVT_KEY_UP ))
|
||||
{
|
||||
wxWindow * pWnd = wxWindow::FindFocus();
|
||||
wxWindow * pTrackPanel = (wxWindow*)GetActiveProject()->GetTrackPanel();
|
||||
bool bIntercept = pWnd != pTrackPanel;
|
||||
// Intercept keys from windows that are NOT the Lyrics panel
|
||||
if( bIntercept ){
|
||||
bIntercept = pWnd && ( dynamic_cast<LyricsPanel*>(pWnd) == NULL );
|
||||
}
|
||||
bool bIntercept =
|
||||
pWnd && !dynamic_cast< NonKeystrokeInterceptingWindow * >( pWnd );
|
||||
|
||||
//wxLogDebug("Focus: %p TrackPanel: %p", pWnd, pTrackPanel );
|
||||
// We allow the keystrokes below to be handled by wxWidgets controls IF we are
|
||||
// in some sub window rather than in the TrackPanel itself.
|
||||
|
33
src/commands/CommandManagerWindowClasses.h
Normal file
33
src/commands/CommandManagerWindowClasses.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
CommandManagerWindowClasses.h
|
||||
|
||||
Paul Licameli
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_COMMAND_MANAGER_WINDOW_CLASSES__
|
||||
#define __AUDACITY_COMMAND_MANAGER_WINDOW_CLASSES__
|
||||
|
||||
/*
|
||||
\brief By default, windows when focused override the association of the digits
|
||||
and certain navigation keys with commands, but certain windows do not, and
|
||||
those inherit this class.
|
||||
*/
|
||||
struct NonKeystrokeInterceptingWindow
|
||||
{
|
||||
virtual ~NonKeystrokeInterceptingWindow();
|
||||
};
|
||||
|
||||
/*
|
||||
\brief Top-level windows that do redirect keystrokes to the associated
|
||||
project's CommandManager inherit this class.
|
||||
*/
|
||||
struct TopLevelKeystrokeHandlingWindow
|
||||
{
|
||||
virtual ~TopLevelKeystrokeHandlingWindow();
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user