1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-18 17:10:55 +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 commits cbfde23 and 68e4bf6 which added the #include directives
This commit is contained in:
Paul Licameli 2018-12-28 11:49:35 -05:00
parent 1bcb7c20a5
commit 3dba70120c
13 changed files with 75 additions and 25 deletions

View File

@ -266,6 +266,7 @@ src/commands/CommandHandler.cpp
src/commands/CommandHandler.h
src/commands/CommandManager.cpp
src/commands/CommandManager.h
src/commands/CommandManagerWindowClasses.h
src/commands/CommandMisc.h
src/commands/CommandSignature.cpp
src/commands/CommandSignature.h

View File

@ -3205,6 +3205,7 @@
5ED1D0AC1CDE55BD00471E3C /* OverlayPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlayPanel.h; sourceTree = "<group>"; };
5ED1D0AF1CDE560C00471E3C /* BackedPanel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackedPanel.cpp; sourceTree = "<group>"; };
5ED1D0B01CDE560C00471E3C /* BackedPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackedPanel.h; sourceTree = "<group>"; };
5EE8984821D68D88006DE939 /* CommandManagerWindowClasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandManagerWindowClasses.h; sourceTree = "<group>"; };
5EF17C211D1F0A690090A642 /* ScrubbingToolBar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrubbingToolBar.cpp; sourceTree = "<group>"; };
5EF17C221D1F0A690090A642 /* ScrubbingToolBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrubbingToolBar.h; sourceTree = "<group>"; };
5EF3E643203FBAFB006C6882 /* AudacityCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudacityCommand.cpp; sourceTree = "<group>"; };
@ -3871,6 +3872,7 @@
5E4685F81CCA9D84008741F2 /* CommandFunctors.h */,
28D540010FD1912A00FA7C75 /* CommandHandler.h */,
174D9027098C78AF00D5909F /* CommandManager.h */,
5EE8984821D68D88006DE939 /* CommandManagerWindowClasses.h */,
1818558F0FFE916C0026D190 /* CommandMisc.h */,
28851F9E1027F16400152EE1 /* CommandSignature.h */,
181855900FFE916C0026D190 /* CommandTargets.h */,

View File

@ -16,6 +16,7 @@
#include <vector>
#include <wx/textctrl.h>
#include "commands/CommandManagerWindowClasses.h"
#include "widgets/wxPanelWrapper.h"
class AudacityProject;
@ -71,7 +72,9 @@ private:
\brief LyricsPanel is a panel that paints the bouncing
ball and the lyrics text.
*******************************************************************/
class LyricsPanel final : public wxPanelWrapper
class LyricsPanel final
: public wxPanelWrapper
, public NonKeystrokeInterceptingWindow
{
DECLARE_DYNAMIC_CLASS(LyricsPanel)

View File

@ -297,6 +297,7 @@ audacity_SOURCES = \
commands/CommandHandler.h \
commands/CommandManager.cpp \
commands/CommandManager.h \
commands/CommandManagerWindowClasses.h \
commands/CommandMisc.h \
commands/CommandSignature.cpp \
commands/CommandSignature.h \

View File

@ -349,7 +349,8 @@ am__audacity_SOURCES_DIST = BlockFile.cpp BlockFile.h DirManager.cpp \
commands/CommandDirectory.h commands/CommandFlag.h \
commands/CommandFunctors.h commands/CommandHandler.cpp \
commands/CommandHandler.h commands/CommandManager.cpp \
commands/CommandManager.h commands/CommandMisc.h \
commands/CommandManager.h \
commands/CommandManagerWindowClasses.h commands/CommandMisc.h \
commands/CommandSignature.cpp commands/CommandSignature.h \
commands/CommandTargets.h commands/CommandType.cpp \
commands/CommandType.h commands/CompareAudioCommand.cpp \
@ -1398,7 +1399,8 @@ audacity_SOURCES = $(libaudacity_la_SOURCES) AboutDialog.cpp \
commands/CommandDirectory.h commands/CommandFlag.h \
commands/CommandFunctors.h commands/CommandHandler.cpp \
commands/CommandHandler.h commands/CommandManager.cpp \
commands/CommandManager.h commands/CommandMisc.h \
commands/CommandManager.h \
commands/CommandManagerWindowClasses.h commands/CommandMisc.h \
commands/CommandSignature.cpp commands/CommandSignature.h \
commands/CommandTargets.h commands/CommandType.cpp \
commands/CommandType.h commands/CompareAudioCommand.cpp \

View File

@ -32,7 +32,6 @@
#include "AudacityApp.h"
#include "AudioIO.h"
#include "LabelTrack.h"
#include "LyricsWindow.h"
#include "ModuleManager.h"
#ifdef USE_MIDI
#include "NoteTrack.h"
@ -372,12 +371,7 @@ CommandFlag MenuManager::GetFocusedFrame(AudacityProject &project)
if (w == project.GetRulerPanel())
return RulerHasFocus;
if (w == project.GetTrackPanel()) {
return TrackPanelHasFocus;
}
// LIE if Lyrics window has focus.
// we want to act as if TrackPanel has focus.
if (w == project.GetLyricsWindow()) {
if (dynamic_cast<NonKeystrokeInterceptingWindow*>(w)) {
return TrackPanelHasFocus;
}
if (w == project.GetToolManager()->GetBotDock()) {

View File

@ -24,6 +24,7 @@
#include "widgets/AButton.h"
#include "widgets/ASlider.h"
#include "widgets/wxPanelWrapper.h"
#include "commands/CommandManagerWindowClasses.h"
struct TrackListEvent;
@ -260,7 +261,9 @@ public:
};
class MixerBoardFrame final : public wxFrame
class MixerBoardFrame final
: public wxFrame
, public TopLevelKeystrokeHandlingWindow
{
public:
MixerBoardFrame(AudacityProject* parent);

View File

@ -24,6 +24,8 @@
#include "Track.h"
#include "SelectionState.h"
#include "ViewInfo.h"
#include "commands/CommandManagerWindowClasses.h"
#include "TrackPanelListener.h"
#include "AudioIOListener.h"
#include "xml/XMLTagHandler.h"

View File

@ -24,6 +24,8 @@
#include "CellularPanel.h"
#include "commands/CommandManagerWindowClasses.h"
class wxMenu;
class wxRect;
@ -245,8 +247,10 @@ enum : int {
};
#endif
class AUDACITY_DLL_API TrackPanel final : public CellularPanel {
class AUDACITY_DLL_API TrackPanel final
: public CellularPanel
, public NonKeystrokeInterceptingWindow
{
public:
TrackPanel(wxWindow * parent,
wxWindowID id,

View File

@ -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.

View 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

View File

@ -778,6 +778,7 @@
<ClInclude Include="..\..\..\src\commands\CommandDirectory.h" />
<ClInclude Include="..\..\..\src\commands\CommandHandler.h" />
<ClInclude Include="..\..\..\src\commands\CommandManager.h" />
<ClInclude Include="..\..\..\src\commands\CommandManagerWindowClasses.h" />
<ClInclude Include="..\..\..\src\commands\CommandMisc.h" />
<ClInclude Include="..\..\..\src\commands\CommandSignature.h" />
<ClInclude Include="..\..\..\src\commands\CommandTargets.h" />

View File

@ -1723,6 +1723,9 @@
<ClInclude Include="..\..\..\src\commands\CommandManager.h">
<Filter>src\commands</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\commands\CommandManagerWindowClasses.h">
<Filter>src\commands</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\commands\CommandMisc.h">
<Filter>src\commands</Filter>
</ClInclude>