mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-05 14:18:53 +02:00
Split MenuCommandHandler into three classes.
Menus.cpp is over 10,000 lines. The main point of the split is to make possible a new .cpp file for MenuCreator, which is responsible for the creation of the menu bar, and which contains the near 2,000 line function MenuCreator::CreateMenusAndCommands() The menu handlers are also (better) separated from the menu management.
This commit is contained in:
parent
529e1e2afb
commit
26086a4142
106
src/Menus.cpp
106
src/Menus.cpp
@ -28,6 +28,22 @@ Implements AudacityProjectCommandFunctor.
|
|||||||
\brief AudacityProjectCommandFunctor, derived from CommandFunctor,
|
\brief AudacityProjectCommandFunctor, derived from CommandFunctor,
|
||||||
simplifies construction of menu items.
|
simplifies construction of menu items.
|
||||||
|
|
||||||
|
*//****************************************************************//**
|
||||||
|
|
||||||
|
\class MenuCommandHandler
|
||||||
|
\brief MenuCommandHandler contains many command handlers for individual
|
||||||
|
menu items.
|
||||||
|
|
||||||
|
*//****************************************************************//**
|
||||||
|
|
||||||
|
\class MenuCreator
|
||||||
|
\brief MenuCreator is responsible for creating the main menu bar.
|
||||||
|
|
||||||
|
*//****************************************************************//**
|
||||||
|
|
||||||
|
\class MenuManager
|
||||||
|
\brief MenuManager handles updates to menu state.
|
||||||
|
|
||||||
*//*******************************************************************/
|
*//*******************************************************************/
|
||||||
|
|
||||||
#include "Audacity.h"
|
#include "Audacity.h"
|
||||||
@ -142,7 +158,7 @@ simplifies construction of menu items.
|
|||||||
#include "./commands/AudacityCommand.h"
|
#include "./commands/AudacityCommand.h"
|
||||||
#include "commands/CommandContext.h"
|
#include "commands/CommandContext.h"
|
||||||
|
|
||||||
MenuCommandHandler &GetMenuCommandHandler(AudacityProject &project)
|
MenuManager &GetMenuCommandHandler(AudacityProject &project)
|
||||||
{ return *project.mMenuCommandHandler; }
|
{ return *project.mMenuCommandHandler; }
|
||||||
|
|
||||||
MenuCommandHandler::MenuCommandHandler()
|
MenuCommandHandler::MenuCommandHandler()
|
||||||
@ -152,6 +168,13 @@ MenuCommandHandler::MenuCommandHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuCommandHandler::~MenuCommandHandler()
|
MenuCommandHandler::~MenuCommandHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuCreator::MenuCreator(){
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuCreator::~MenuCreator()
|
||||||
{
|
{
|
||||||
if (wxGetApp().GetRecentFiles())
|
if (wxGetApp().GetRecentFiles())
|
||||||
{
|
{
|
||||||
@ -307,7 +330,7 @@ static bool SortEffectsByType(const PluginDescriptor *a, const PluginDescriptor
|
|||||||
return akey.CmpNoCase(bkey) < 0;
|
return akey.CmpNoCase(bkey) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::UpdatePrefs()
|
void MenuManager::UpdatePrefs()
|
||||||
{
|
{
|
||||||
bool bSelectAllIfNone;
|
bool bSelectAllIfNone;
|
||||||
gPrefs->Read(wxT("/GUI/SelectAllOnNone"), &bSelectAllIfNone, false);
|
gPrefs->Read(wxT("/GUI/SelectAllOnNone"), &bSelectAllIfNone, false);
|
||||||
@ -340,7 +363,7 @@ static CommandHandlerObject &findMenuCommandHandler(AudacityProject &project)
|
|||||||
static_cast<CommandFunctorPointer>(& MenuCommandHandler :: X)
|
static_cast<CommandFunctorPointer>(& MenuCommandHandler :: X)
|
||||||
#define XXO(X) _(X), wxString{X}.Contains("...")
|
#define XXO(X) _(X), wxString{X}.Contains("...")
|
||||||
|
|
||||||
void MenuCommandHandler::CreateMenusAndCommands(AudacityProject &project)
|
void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
|
||||||
{
|
{
|
||||||
CommandManager *c = project.GetCommandManager();
|
CommandManager *c = project.GetCommandManager();
|
||||||
wxArrayString names;
|
wxArrayString names;
|
||||||
@ -501,7 +524,7 @@ void MenuCommandHandler::CreateMenusAndCommands(AudacityProject &project)
|
|||||||
AudioIONotBusyFlag | RedoAvailableFlag,
|
AudioIONotBusyFlag | RedoAvailableFlag,
|
||||||
AudioIONotBusyFlag | RedoAvailableFlag);
|
AudioIONotBusyFlag | RedoAvailableFlag);
|
||||||
|
|
||||||
ModifyUndoMenuItems(project);
|
MenuManager::ModifyUndoMenuItems(project);
|
||||||
|
|
||||||
c->AddSeparator();
|
c->AddSeparator();
|
||||||
|
|
||||||
@ -1804,7 +1827,7 @@ void MenuCommandHandler::CreateMenusAndCommands(AudacityProject &project)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MenuCommandHandler::PopulateMacrosMenu( CommandManager* c, CommandFlag flags )
|
void MenuCreator::PopulateMacrosMenu( CommandManager* c, CommandFlag flags )
|
||||||
{
|
{
|
||||||
wxArrayString names = MacroCommands::GetNames();
|
wxArrayString names = MacroCommands::GetNames();
|
||||||
int i;
|
int i;
|
||||||
@ -1822,7 +1845,7 @@ void MenuCommandHandler::PopulateMacrosMenu( CommandManager* c, CommandFlag flag
|
|||||||
/// The effects come from a plug in list
|
/// The effects come from a plug in list
|
||||||
/// This code iterates through the list, adding effects into
|
/// This code iterates through the list, adding effects into
|
||||||
/// the menu.
|
/// the menu.
|
||||||
void MenuCommandHandler::PopulateEffectsMenu(CommandManager* c,
|
void MenuCreator::PopulateEffectsMenu(CommandManager* c,
|
||||||
EffectType type,
|
EffectType type,
|
||||||
CommandFlag batchflags,
|
CommandFlag batchflags,
|
||||||
CommandFlag realflags)
|
CommandFlag realflags)
|
||||||
@ -1884,7 +1907,7 @@ void MenuCommandHandler::PopulateEffectsMenu(CommandManager* c,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::AddEffectMenuItems(CommandManager *c,
|
void MenuCreator::AddEffectMenuItems(CommandManager *c,
|
||||||
std::vector<const PluginDescriptor*> & plugs,
|
std::vector<const PluginDescriptor*> & plugs,
|
||||||
CommandFlag batchflags,
|
CommandFlag batchflags,
|
||||||
CommandFlag realflags,
|
CommandFlag realflags,
|
||||||
@ -2025,7 +2048,7 @@ void MenuCommandHandler::AddEffectMenuItems(CommandManager *c,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::AddEffectMenuItemGroup(CommandManager *c,
|
void MenuCreator::AddEffectMenuItemGroup(CommandManager *c,
|
||||||
const wxArrayString & names,
|
const wxArrayString & names,
|
||||||
const std::vector<bool> &vHasDialog,
|
const std::vector<bool> &vHasDialog,
|
||||||
const PluginIDList & plugs,
|
const PluginIDList & plugs,
|
||||||
@ -2130,7 +2153,7 @@ void MenuCommandHandler::AddEffectMenuItemGroup(CommandManager *c,
|
|||||||
|
|
||||||
#undef FN
|
#undef FN
|
||||||
|
|
||||||
void MenuCommandHandler::CreateRecentFilesMenu(CommandManager *c)
|
void MenuCreator::CreateRecentFilesMenu(CommandManager *c)
|
||||||
{
|
{
|
||||||
// Recent Files and Recent Projects menus
|
// Recent Files and Recent Projects menus
|
||||||
|
|
||||||
@ -2149,7 +2172,8 @@ void MenuCommandHandler::CreateRecentFilesMenu(CommandManager *c)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::ModifyUndoMenuItems(AudacityProject &project)
|
// TODO: This surely belongs in CommandManager?
|
||||||
|
void MenuManager::ModifyUndoMenuItems(AudacityProject &project)
|
||||||
{
|
{
|
||||||
wxString desc;
|
wxString desc;
|
||||||
auto &undoManager = *project.GetUndoManager();
|
auto &undoManager = *project.GetUndoManager();
|
||||||
@ -2182,7 +2206,7 @@ void MenuCommandHandler::ModifyUndoMenuItems(AudacityProject &project)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::RebuildMenuBar(AudacityProject &project)
|
void MenuCreator::RebuildMenuBar(AudacityProject &project)
|
||||||
{
|
{
|
||||||
// On OSX, we can't rebuild the menus while a modal dialog is being shown
|
// On OSX, we can't rebuild the menus while a modal dialog is being shown
|
||||||
// since the enabled state for menus like Quit and Preference gets out of
|
// since the enabled state for menus like Quit and Preference gets out of
|
||||||
@ -2247,7 +2271,7 @@ CommandFlag MenuCommandHandler::GetFocusedFrame(AudacityProject &project)
|
|||||||
return AlwaysEnabledFlag;
|
return AlwaysEnabledFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandFlag MenuCommandHandler::GetUpdateFlags
|
CommandFlag MenuManager::GetUpdateFlags
|
||||||
(AudacityProject &project, bool checkActive)
|
(AudacityProject &project, bool checkActive)
|
||||||
{
|
{
|
||||||
// This method determines all of the flags that determine whether
|
// This method determines all of the flags that determine whether
|
||||||
@ -2431,7 +2455,7 @@ void AudacityProject::StopIfPaused()
|
|||||||
GetMenuCommandHandler(*this).OnStop(*this);
|
GetMenuCommandHandler(*this).OnStop(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::ModifyAllProjectToolbarMenus()
|
void MenuManager::ModifyAllProjectToolbarMenus()
|
||||||
{
|
{
|
||||||
AProjectArray::iterator i;
|
AProjectArray::iterator i;
|
||||||
for (i = gAudacityProjects.begin(); i != gAudacityProjects.end(); ++i) {
|
for (i = gAudacityProjects.begin(); i != gAudacityProjects.end(); ++i) {
|
||||||
@ -2440,7 +2464,7 @@ void MenuCommandHandler::ModifyAllProjectToolbarMenus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::ModifyToolbarMenus(AudacityProject &project)
|
void MenuManager::ModifyToolbarMenus(AudacityProject &project)
|
||||||
{
|
{
|
||||||
// Refreshes can occur during shutdown and the toolmanager may already
|
// Refreshes can occur during shutdown and the toolmanager may already
|
||||||
// be deleted, so protect against it.
|
// be deleted, so protect against it.
|
||||||
@ -2513,7 +2537,7 @@ void MenuCommandHandler::ModifyToolbarMenus(AudacityProject &project)
|
|||||||
|
|
||||||
// checkActive is a temporary hack that should be removed as soon as we
|
// checkActive is a temporary hack that should be removed as soon as we
|
||||||
// get multiple effect preview working
|
// get multiple effect preview working
|
||||||
void MenuCommandHandler::UpdateMenus(AudacityProject &project, bool checkActive)
|
void MenuManager::UpdateMenus(AudacityProject &project, bool checkActive)
|
||||||
{
|
{
|
||||||
//ANSWER-ME: Why UpdateMenus only does active project?
|
//ANSWER-ME: Why UpdateMenus only does active project?
|
||||||
//JKC: Is this test fixing a bug when multiple projects are open?
|
//JKC: Is this test fixing a bug when multiple projects are open?
|
||||||
@ -2521,7 +2545,7 @@ void MenuCommandHandler::UpdateMenus(AudacityProject &project, bool checkActive)
|
|||||||
if (&project != GetActiveProject())
|
if (&project != GetActiveProject())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto flags = GetUpdateFlags(project, checkActive);
|
auto flags = GetMenuCommandHandler(project).GetUpdateFlags(project, checkActive);
|
||||||
auto flags2 = flags;
|
auto flags2 = flags;
|
||||||
|
|
||||||
// We can enable some extra items if we have select-all-on-none.
|
// We can enable some extra items if we have select-all-on-none.
|
||||||
@ -2592,7 +2616,7 @@ void MenuCommandHandler::UpdateMenus(AudacityProject &project, bool checkActive)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -3158,7 +3182,7 @@ void MenuCommandHandler::OnToggleSoundActivated(const CommandContext &WXUNUSED(c
|
|||||||
gPrefs->Read(wxT("/AudioIO/SoundActivatedRecord"), &pause, false);
|
gPrefs->Read(wxT("/AudioIO/SoundActivatedRecord"), &pause, false);
|
||||||
gPrefs->Write(wxT("/AudioIO/SoundActivatedRecord"), !pause);
|
gPrefs->Write(wxT("/AudioIO/SoundActivatedRecord"), !pause);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
ModifyAllProjectToolbarMenus();
|
MenuManager::ModifyAllProjectToolbarMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnTogglePinnedHead(const CommandContext &context)
|
void MenuCommandHandler::OnTogglePinnedHead(const CommandContext &context)
|
||||||
@ -3167,7 +3191,7 @@ void MenuCommandHandler::OnTogglePinnedHead(const CommandContext &context)
|
|||||||
|
|
||||||
bool value = !TracksPrefs::GetPinnedHeadPreference();
|
bool value = !TracksPrefs::GetPinnedHeadPreference();
|
||||||
TracksPrefs::SetPinnedHeadPreference(value, true);
|
TracksPrefs::SetPinnedHeadPreference(value, true);
|
||||||
ModifyAllProjectToolbarMenus();
|
MenuManager::ModifyAllProjectToolbarMenus();
|
||||||
|
|
||||||
// Change what happens in case transport is in progress right now
|
// Change what happens in case transport is in progress right now
|
||||||
auto ctb = GetActiveProject()->GetControlToolBar();
|
auto ctb = GetActiveProject()->GetControlToolBar();
|
||||||
@ -3194,7 +3218,7 @@ void MenuCommandHandler::OnTogglePlayRecording(const CommandContext &WXUNUSED(co
|
|||||||
#endif
|
#endif
|
||||||
gPrefs->Write(wxT("/AudioIO/Duplex"), !Duplex);
|
gPrefs->Write(wxT("/AudioIO/Duplex"), !Duplex);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
ModifyAllProjectToolbarMenus();
|
MenuManager::ModifyAllProjectToolbarMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnToggleSWPlaythrough(const CommandContext &WXUNUSED(context) )
|
void MenuCommandHandler::OnToggleSWPlaythrough(const CommandContext &WXUNUSED(context) )
|
||||||
@ -3203,7 +3227,7 @@ void MenuCommandHandler::OnToggleSWPlaythrough(const CommandContext &WXUNUSED(co
|
|||||||
gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &SWPlaythrough, false);
|
gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &SWPlaythrough, false);
|
||||||
gPrefs->Write(wxT("/AudioIO/SWPlaythrough"), !SWPlaythrough);
|
gPrefs->Write(wxT("/AudioIO/SWPlaythrough"), !SWPlaythrough);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
ModifyAllProjectToolbarMenus();
|
MenuManager::ModifyAllProjectToolbarMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
|
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
|
||||||
@ -3214,7 +3238,7 @@ void AudacityProject::OnToggleAutomatedInputLevelAdjustment(
|
|||||||
gPrefs->Read(wxT("/AudioIO/AutomatedInputLevelAdjustment"), &AVEnabled, false);
|
gPrefs->Read(wxT("/AudioIO/AutomatedInputLevelAdjustment"), &AVEnabled, false);
|
||||||
gPrefs->Write(wxT("/AudioIO/AutomatedInputLevelAdjustment"), !AVEnabled);
|
gPrefs->Write(wxT("/AudioIO/AutomatedInputLevelAdjustment"), !AVEnabled);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
ModifyAllProjectToolbarMenus();
|
MenuManager::ModifyAllProjectToolbarMenus();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4830,7 +4854,7 @@ bool MenuCommandHandler::DoEffect(
|
|||||||
// For now, we're limiting realtime preview to a single effect, so
|
// For now, we're limiting realtime preview to a single effect, so
|
||||||
// make sure the menus reflect that fact that one may have just been
|
// make sure the menus reflect that fact that one may have just been
|
||||||
// opened.
|
// opened.
|
||||||
UpdateMenus(project, false);
|
GetMenuCommandHandler(project).UpdateMenus(project, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} );
|
} );
|
||||||
@ -5443,7 +5467,7 @@ void MenuCommandHandler::OnUndo(const CommandContext &context)
|
|||||||
// Mixer board may need to change for selection state and pan/gain
|
// Mixer board may need to change for selection state and pan/gain
|
||||||
mixerBoard->Refresh();
|
mixerBoard->Refresh();
|
||||||
|
|
||||||
ModifyUndoMenuItems(project);
|
MenuManager::ModifyUndoMenuItems(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnRedo(const CommandContext &context)
|
void MenuCommandHandler::OnRedo(const CommandContext &context)
|
||||||
@ -5478,7 +5502,7 @@ void MenuCommandHandler::OnRedo(const CommandContext &context)
|
|||||||
// Mixer board may need to change for selection state and pan/gain
|
// Mixer board may need to change for selection state and pan/gain
|
||||||
mixerBoard->Refresh();
|
mixerBoard->Refresh();
|
||||||
|
|
||||||
ModifyUndoMenuItems(project);
|
MenuManager::ModifyUndoMenuItems(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::FinishCopy
|
void MenuCommandHandler::FinishCopy
|
||||||
@ -7408,7 +7432,7 @@ void MenuCommandHandler::OnApplyMacroDirectly(const CommandContext &context )
|
|||||||
#else
|
#else
|
||||||
dlg.ApplyMacroToProject( Name, false );
|
dlg.ApplyMacroToProject( Name, false );
|
||||||
#endif
|
#endif
|
||||||
ModifyUndoMenuItems( project );
|
MenuManager::ModifyUndoMenuItems( project );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnApplyMacrosPalette(const CommandContext &context )
|
void MenuCommandHandler::OnApplyMacrosPalette(const CommandContext &context )
|
||||||
@ -7485,7 +7509,7 @@ void MenuCommandHandler::OnShowTransportToolBar(const CommandContext &context)
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide(TransportBarID);
|
toolManager->ShowHide(TransportBarID);
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowDeviceToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowDeviceToolBar(const CommandContext &context)
|
||||||
@ -7494,7 +7518,7 @@ void MenuCommandHandler::OnShowDeviceToolBar(const CommandContext &context)
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide( DeviceBarID );
|
toolManager->ShowHide( DeviceBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowEditToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowEditToolBar(const CommandContext &context)
|
||||||
@ -7503,7 +7527,7 @@ void MenuCommandHandler::OnShowEditToolBar(const CommandContext &context)
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide( EditBarID );
|
toolManager->ShowHide( EditBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowMeterToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowMeterToolBar(const CommandContext &context)
|
||||||
@ -7517,7 +7541,7 @@ void MenuCommandHandler::OnShowMeterToolBar(const CommandContext &context)
|
|||||||
toolManager->Expose( RecordMeterBarID, false );
|
toolManager->Expose( RecordMeterBarID, false );
|
||||||
}
|
}
|
||||||
toolManager->ShowHide( MeterBarID );
|
toolManager->ShowHide( MeterBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowRecordMeterToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowRecordMeterToolBar(const CommandContext &context)
|
||||||
@ -7530,7 +7554,7 @@ void MenuCommandHandler::OnShowRecordMeterToolBar(const CommandContext &context)
|
|||||||
toolManager->Expose( MeterBarID, false );
|
toolManager->Expose( MeterBarID, false );
|
||||||
}
|
}
|
||||||
toolManager->ShowHide( RecordMeterBarID );
|
toolManager->ShowHide( RecordMeterBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowPlayMeterToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowPlayMeterToolBar(const CommandContext &context)
|
||||||
@ -7544,7 +7568,7 @@ void MenuCommandHandler::OnShowPlayMeterToolBar(const CommandContext &context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
toolManager->ShowHide( PlayMeterBarID );
|
toolManager->ShowHide( PlayMeterBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowMixerToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowMixerToolBar(const CommandContext &context)
|
||||||
@ -7553,7 +7577,7 @@ void MenuCommandHandler::OnShowMixerToolBar(const CommandContext &context)
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide( MixerBarID );
|
toolManager->ShowHide( MixerBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowScrubbingToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowScrubbingToolBar(const CommandContext &context)
|
||||||
@ -7562,7 +7586,7 @@ void MenuCommandHandler::OnShowScrubbingToolBar(const CommandContext &context)
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide( ScrubbingBarID );
|
toolManager->ShowHide( ScrubbingBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowSelectionToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowSelectionToolBar(const CommandContext &context)
|
||||||
@ -7571,7 +7595,7 @@ void MenuCommandHandler::OnShowSelectionToolBar(const CommandContext &context)
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide( SelectionBarID );
|
toolManager->ShowHide( SelectionBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||||
@ -7581,7 +7605,7 @@ void MenuCommandHandler::OnShowSpectralSelectionToolBar(const CommandContext &co
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide( SpectralSelectionBarID );
|
toolManager->ShowHide( SpectralSelectionBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -7591,7 +7615,7 @@ void MenuCommandHandler::OnShowToolsToolBar(const CommandContext &context)
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide( ToolsBarID );
|
toolManager->ShowHide( ToolsBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnShowTranscriptionToolBar(const CommandContext &context)
|
void MenuCommandHandler::OnShowTranscriptionToolBar(const CommandContext &context)
|
||||||
@ -7600,7 +7624,7 @@ void MenuCommandHandler::OnShowTranscriptionToolBar(const CommandContext &contex
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->ShowHide( TranscriptionBarID );
|
toolManager->ShowHide( TranscriptionBarID );
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnResetToolBars(const CommandContext &context)
|
void MenuCommandHandler::OnResetToolBars(const CommandContext &context)
|
||||||
@ -7609,7 +7633,7 @@ void MenuCommandHandler::OnResetToolBars(const CommandContext &context)
|
|||||||
auto toolManager = project.GetToolManager();
|
auto toolManager = project.GetToolManager();
|
||||||
|
|
||||||
toolManager->Reset();
|
toolManager->Reset();
|
||||||
ModifyToolbarMenus(project);
|
MenuManager::ModifyToolbarMenus(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||||
@ -9198,7 +9222,7 @@ void MenuCommandHandler::OnSyncLock(const CommandContext &context)
|
|||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
|
|
||||||
// Toolbar, project sync-lock handled within
|
// Toolbar, project sync-lock handled within
|
||||||
ModifyAllProjectToolbarMenus();
|
MenuManager::ModifyAllProjectToolbarMenus();
|
||||||
|
|
||||||
trackPanel->Refresh(false);
|
trackPanel->Refresh(false);
|
||||||
}
|
}
|
||||||
@ -9258,7 +9282,7 @@ void MenuCommandHandler::OnToggleTypeToCreateLabel(const CommandContext &WXUNUSE
|
|||||||
gPrefs->Read(wxT("/GUI/TypeToCreateLabel"), &typeToCreateLabel, true);
|
gPrefs->Read(wxT("/GUI/TypeToCreateLabel"), &typeToCreateLabel, true);
|
||||||
gPrefs->Write(wxT("/GUI/TypeToCreateLabel"), !typeToCreateLabel);
|
gPrefs->Write(wxT("/GUI/TypeToCreateLabel"), !typeToCreateLabel);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
ModifyAllProjectToolbarMenus();
|
MenuManager::ModifyAllProjectToolbarMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCommandHandler::OnRemoveTracks(const CommandContext &context)
|
void MenuCommandHandler::OnRemoveTracks(const CommandContext &context)
|
||||||
|
112
src/Menus.h
112
src/Menus.h
@ -14,51 +14,13 @@
|
|||||||
#include "Experimental.h"
|
#include "Experimental.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct MenuCommandHandler : public wxEvtHandler {
|
struct MenuCommandHandler : public wxEvtHandler {
|
||||||
MenuCommandHandler();
|
MenuCommandHandler();
|
||||||
~MenuCommandHandler();
|
~MenuCommandHandler();
|
||||||
|
|
||||||
// Formerly members of AudacityProject, now members of MenuCommandHandler
|
|
||||||
|
|
||||||
|
|
||||||
// Command Handling
|
|
||||||
bool ReportIfActionNotAllowed
|
|
||||||
( AudacityProject &project,
|
|
||||||
const wxString & Name, CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask );
|
|
||||||
bool TryToMakeActionAllowed
|
|
||||||
( AudacityProject &project,
|
|
||||||
CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask );
|
|
||||||
|
|
||||||
void UpdatePrefs();
|
|
||||||
|
|
||||||
void CreateMenusAndCommands(AudacityProject &project);
|
|
||||||
void PopulateMacrosMenu( CommandManager* c, CommandFlag flags );
|
|
||||||
|
|
||||||
void PopulateEffectsMenu(CommandManager *c, EffectType type,
|
|
||||||
CommandFlag batchflags, CommandFlag realflags);
|
|
||||||
void AddEffectMenuItems(CommandManager *c,
|
|
||||||
std::vector<const PluginDescriptor*> & plugs,
|
|
||||||
CommandFlag batchflags, CommandFlag realflags, bool isDefault);
|
|
||||||
void AddEffectMenuItemGroup(CommandManager *c, const wxArrayString & names,
|
|
||||||
const std::vector<bool> &vHasDialog,
|
|
||||||
const PluginIDList & plugs,
|
|
||||||
const std::vector<CommandFlag> & flags, bool isDefault);
|
|
||||||
void CreateRecentFilesMenu(CommandManager *c);
|
|
||||||
void ModifyUndoMenuItems(AudacityProject &project);
|
|
||||||
void ModifyToolbarMenus(AudacityProject &project);
|
|
||||||
void RebuildMenuBar(AudacityProject &project);
|
|
||||||
// Calls ModifyToolbarMenus() on all projects
|
|
||||||
void ModifyAllProjectToolbarMenus();
|
|
||||||
|
|
||||||
// checkActive is a temporary hack that should be removed as soon as we
|
|
||||||
// get multiple effect preview working
|
|
||||||
void UpdateMenus(AudacityProject &project, bool checkActive = true);
|
|
||||||
|
|
||||||
CommandFlag GetFocusedFrame(AudacityProject &project);
|
CommandFlag GetFocusedFrame(AudacityProject &project);
|
||||||
|
|
||||||
// If checkActive, do not do complete flags testing on an
|
|
||||||
// inactive project as it is needlessly expensive.
|
|
||||||
CommandFlag GetUpdateFlags(AudacityProject &project, bool checkActive = false);
|
|
||||||
|
|
||||||
|
|
||||||
//Adds label and returns index of label in labeltrack.
|
//Adds label and returns index of label in labeltrack.
|
||||||
@ -619,30 +581,80 @@ double OffsetTime(const CommandContext &context,
|
|||||||
// Helper for moving by keyboard with snap-to-grid enabled
|
// Helper for moving by keyboard with snap-to-grid enabled
|
||||||
double GridMove(AudacityProject &project, double t, int minPix);
|
double GridMove(AudacityProject &project, double t, int minPix);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
// Last effect applied to this project
|
// Last effect applied to this project
|
||||||
PluginID mLastEffect{};
|
PluginID mLastEffect{};
|
||||||
|
|
||||||
// Recent files
|
|
||||||
wxMenu *mRecentFilesMenu;
|
|
||||||
|
|
||||||
CommandFlag mLastFlags;
|
CommandFlag mLastFlags;
|
||||||
|
|
||||||
// 0 is grey out, 1 is Autoselect, 2 is Give warnings.
|
// 0 is grey out, 1 is Autoselect, 2 is Give warnings.
|
||||||
int mWhatIfNoSelection;
|
int mWhatIfNoSelection;
|
||||||
|
|
||||||
bool mStopIfWasPaused;
|
bool mStopIfWasPaused;
|
||||||
|
|
||||||
bool mCircularTrackNavigation{};
|
|
||||||
|
|
||||||
double mSeekShort;
|
double mSeekShort;
|
||||||
double mSeekLong;
|
double mSeekLong;
|
||||||
|
bool mCircularTrackNavigation{};
|
||||||
wxLongLong mLastSelectionAdjustment;
|
wxLongLong mLastSelectionAdjustment;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MenuCreator : public MenuCommandHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MenuCreator();
|
||||||
|
~MenuCreator();
|
||||||
|
void CreateMenusAndCommands(AudacityProject &project);
|
||||||
|
void RebuildMenuBar(AudacityProject &project);
|
||||||
|
|
||||||
MenuCommandHandler &GetMenuCommandHandler(AudacityProject &project);
|
void PopulateMacrosMenu( CommandManager* c, CommandFlag flags );
|
||||||
|
|
||||||
|
void PopulateEffectsMenu(CommandManager *c, EffectType type,
|
||||||
|
CommandFlag batchflags, CommandFlag realflags);
|
||||||
|
void AddEffectMenuItems(CommandManager *c,
|
||||||
|
std::vector<const PluginDescriptor*> & plugs,
|
||||||
|
CommandFlag batchflags, CommandFlag realflags, bool isDefault);
|
||||||
|
void AddEffectMenuItemGroup(CommandManager *c, const wxArrayString & names,
|
||||||
|
const std::vector<bool> &vHasDialog,
|
||||||
|
const PluginIDList & plugs,
|
||||||
|
const std::vector<CommandFlag> & flags, bool isDefault);
|
||||||
|
void CreateRecentFilesMenu(CommandManager *c);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Recent files
|
||||||
|
wxMenu *mRecentFilesMenu;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class MenuManager : public MenuCreator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void ModifyUndoMenuItems(AudacityProject &project);
|
||||||
|
static void ModifyToolbarMenus(AudacityProject &project);
|
||||||
|
// Calls ModifyToolbarMenus() on all projects
|
||||||
|
static void ModifyAllProjectToolbarMenus();
|
||||||
|
|
||||||
|
// checkActive is a temporary hack that should be removed as soon as we
|
||||||
|
// get multiple effect preview working
|
||||||
|
void UpdateMenus(AudacityProject &project, bool checkActive = true);
|
||||||
|
|
||||||
|
// If checkActive, do not do complete flags testing on an
|
||||||
|
// inactive project as it is needlessly expensive.
|
||||||
|
CommandFlag GetUpdateFlags(AudacityProject &project, bool checkActive = false);
|
||||||
|
void UpdatePrefs();
|
||||||
|
|
||||||
|
// Command Handling
|
||||||
|
bool ReportIfActionNotAllowed
|
||||||
|
( AudacityProject &project,
|
||||||
|
const wxString & Name, CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask );
|
||||||
|
bool TryToMakeActionAllowed
|
||||||
|
( AudacityProject &project,
|
||||||
|
CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MenuManager &GetMenuCommandHandler(AudacityProject &project);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -979,7 +979,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
|||||||
// Initialize view info (shared with TrackPanel)
|
// Initialize view info (shared with TrackPanel)
|
||||||
//
|
//
|
||||||
|
|
||||||
mMenuCommandHandler = std::make_unique<MenuCommandHandler>();
|
mMenuCommandHandler = std::make_unique<MenuManager>();
|
||||||
|
|
||||||
UpdatePrefs();
|
UpdatePrefs();
|
||||||
|
|
||||||
@ -2268,7 +2268,7 @@ void AudacityProject::DoScroll()
|
|||||||
GetTrackPanel()->HandleCursorForPresentMouseState(); } );
|
GetTrackPanel()->HandleCursorForPresentMouseState(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuCommandHandler::ReportIfActionNotAllowed
|
bool MenuManager::ReportIfActionNotAllowed
|
||||||
( AudacityProject &project,
|
( AudacityProject &project,
|
||||||
const wxString & Name, CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask )
|
const wxString & Name, CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask )
|
||||||
{
|
{
|
||||||
@ -2285,14 +2285,14 @@ bool MenuCommandHandler::ReportIfActionNotAllowed
|
|||||||
/// Determines if flags for command are compatible with current state.
|
/// Determines if flags for command are compatible with current state.
|
||||||
/// If not, then try some recovery action to make it so.
|
/// If not, then try some recovery action to make it so.
|
||||||
/// @return whether compatible or not after any actions taken.
|
/// @return whether compatible or not after any actions taken.
|
||||||
bool MenuCommandHandler::TryToMakeActionAllowed
|
bool MenuManager::TryToMakeActionAllowed
|
||||||
( AudacityProject &project,
|
( AudacityProject &project,
|
||||||
CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask )
|
CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask )
|
||||||
{
|
{
|
||||||
bool bAllowed;
|
bool bAllowed;
|
||||||
|
|
||||||
if( !flags )
|
if( !flags )
|
||||||
flags = GetUpdateFlags(project);
|
flags = GetMenuCommandHandler(project).GetUpdateFlags(project);
|
||||||
|
|
||||||
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
||||||
if( bAllowed )
|
if( bAllowed )
|
||||||
@ -2305,7 +2305,7 @@ bool MenuCommandHandler::TryToMakeActionAllowed
|
|||||||
if( mStopIfWasPaused && (MissingFlags & AudioIONotBusyFlag ) ){
|
if( mStopIfWasPaused && (MissingFlags & AudioIONotBusyFlag ) ){
|
||||||
project.StopIfPaused();
|
project.StopIfPaused();
|
||||||
// Hope this will now reflect stopped audio.
|
// Hope this will now reflect stopped audio.
|
||||||
flags = GetUpdateFlags(project);
|
flags = GetMenuCommandHandler(project).GetUpdateFlags(project);
|
||||||
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
||||||
if( bAllowed )
|
if( bAllowed )
|
||||||
return true;
|
return true;
|
||||||
@ -2335,7 +2335,7 @@ bool MenuCommandHandler::TryToMakeActionAllowed
|
|||||||
// This was 'OnSelectAll'. Changing it to OnSelectSomething means if
|
// This was 'OnSelectAll'. Changing it to OnSelectSomething means if
|
||||||
// selecting all tracks is enough, we just do that.
|
// selecting all tracks is enough, we just do that.
|
||||||
GetMenuCommandHandler(project).OnSelectSomething(project);
|
GetMenuCommandHandler(project).OnSelectSomething(project);
|
||||||
flags = GetUpdateFlags(project);
|
flags = GetMenuCommandHandler(project).GetUpdateFlags(project);
|
||||||
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
||||||
return bAllowed;
|
return bAllowed;
|
||||||
}
|
}
|
||||||
|
@ -811,10 +811,10 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<MenuCommandHandler> mMenuCommandHandler;
|
std::unique_ptr<MenuManager> mMenuCommandHandler;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend MenuCommandHandler &GetMenuCommandHandler(AudacityProject &project);
|
friend MenuManager &GetMenuCommandHandler(AudacityProject &project);
|
||||||
|
|
||||||
class PlaybackScroller final : public wxEvtHandler
|
class PlaybackScroller final : public wxEvtHandler
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user