mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-30 15:18:42 +02:00
static CommandManager::Get()...
... not member functions of AudacityProject
This commit is contained in:
parent
805af452a4
commit
4ba4d0978b
lib-src
src
BatchCommands.cppLyrics.cppMenus.cppMixerBoard.cppProject.cppProject.h
commands
menus
prefs
toolbars
tracks
@ -154,7 +154,7 @@ int ModuleDispatch(ModuleDispatchTypes type)
|
|||||||
|
|
||||||
wxMenuBar * pBar = p->GetMenuBar();
|
wxMenuBar * pBar = p->GetMenuBar();
|
||||||
wxMenu * pMenu = pBar->GetMenu( 8 ); // Menu 8 is the Analyze Menu.
|
wxMenu * pMenu = pBar->GetMenu( 8 ); // Menu 8 is the Analyze Menu.
|
||||||
CommandManager * c = p->GetCommandManager();
|
CommandManager * c = &CommandManager::Get( *p );
|
||||||
|
|
||||||
c->SetCurrentMenu( pMenu );
|
c->SetCurrentMenu( pMenu );
|
||||||
c->AddSeparator();
|
c->AddSeparator();
|
||||||
|
@ -184,7 +184,7 @@ extern "C"
|
|||||||
case MenusRebuilt: {
|
case MenusRebuilt: {
|
||||||
AudacityProject *p = GetActiveProject();
|
AudacityProject *p = GetActiveProject();
|
||||||
wxASSERT(p != NULL);
|
wxASSERT(p != NULL);
|
||||||
CommandManager *c = p->GetCommandManager();
|
CommandManager *c = &CommandManager::Get( *p );
|
||||||
wxASSERT(c != NULL);
|
wxASSERT(c != NULL);
|
||||||
|
|
||||||
wxMenuBar * pBar = p->GetMenuBar();
|
wxMenuBar * pBar = p->GetMenuBar();
|
||||||
|
@ -314,14 +314,14 @@ MacroCommandsCatalog::MacroCommandsCatalog( const AudacityProject *project )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mManager = project->GetCommandManager();
|
auto &manager = CommandManager::Get( *project );
|
||||||
wxArrayString mLabels;
|
wxArrayString mLabels;
|
||||||
CommandIDs mNames;
|
CommandIDs mNames;
|
||||||
std::vector<bool> vHasDialog;
|
std::vector<bool> vHasDialog;
|
||||||
mLabels.clear();
|
mLabels.clear();
|
||||||
mNames.clear();
|
mNames.clear();
|
||||||
mManager->GetAllCommandLabels(mLabels, vHasDialog, true);
|
manager.GetAllCommandLabels(mLabels, vHasDialog, true);
|
||||||
mManager->GetAllCommandNames(mNames, true);
|
manager.GetAllCommandNames(mNames, true);
|
||||||
|
|
||||||
const bool english = wxGetLocale()->GetCanonicalName().StartsWith(wxT("en"));
|
const bool english = wxGetLocale()->GetCanonicalName().StartsWith(wxT("en"));
|
||||||
|
|
||||||
@ -774,9 +774,9 @@ bool MacroCommands::ApplyCommand( const wxString &friendlyCommand,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
CommandManager * pManager = project->GetCommandManager();
|
auto &manager = CommandManager::Get( *project );
|
||||||
if( pContext ){
|
if( pContext ){
|
||||||
if( pManager->HandleTextualCommand( command, *pContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
if( manager.HandleTextualCommand( command, *pContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
||||||
return true;
|
return true;
|
||||||
pContext->Status( wxString::Format(
|
pContext->Status( wxString::Format(
|
||||||
_("Your batch command of %s was not recognized."), friendlyCommand ));
|
_("Your batch command of %s was not recognized."), friendlyCommand ));
|
||||||
@ -785,7 +785,7 @@ bool MacroCommands::ApplyCommand( const wxString &friendlyCommand,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const CommandContext context( *GetActiveProject() );
|
const CommandContext context( *GetActiveProject() );
|
||||||
if( pManager->HandleTextualCommand( command, context, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
if( manager.HandleTextualCommand( command, context, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,7 +528,8 @@ void LyricsPanel::OnShow(wxShowEvent &e)
|
|||||||
void LyricsPanel::OnKeyEvent(wxKeyEvent & event)
|
void LyricsPanel::OnKeyEvent(wxKeyEvent & event)
|
||||||
{
|
{
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
project->GetCommandManager()->FilterKeyEvent(project, event, true);
|
auto &commandManager = CommandManager::Get( *project );
|
||||||
|
commandManager.FilterKeyEvent(project, event, true);
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ void VisitItem( AudacityProject &project, MenuTable::BaseItem *pItem )
|
|||||||
if (!pItem)
|
if (!pItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto &manager = *project.GetCommandManager();
|
auto &manager = CommandManager::Get( project );
|
||||||
|
|
||||||
using namespace MenuTable;
|
using namespace MenuTable;
|
||||||
if (const auto pComputed =
|
if (const auto pComputed =
|
||||||
@ -279,13 +279,13 @@ static const auto menuTree = MenuTable::Items(
|
|||||||
|
|
||||||
void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
|
void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
|
||||||
{
|
{
|
||||||
CommandManager *c = project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
// The list of defaults to exclude depends on
|
// The list of defaults to exclude depends on
|
||||||
// preference wxT("/GUI/Shortcuts/FullDefaults"), which may have changed.
|
// preference wxT("/GUI/Shortcuts/FullDefaults"), which may have changed.
|
||||||
c->SetMaxList();
|
commandManager.SetMaxList();
|
||||||
|
|
||||||
auto menubar = c->AddMenuBar(wxT("appmenu"));
|
auto menubar = commandManager.AddMenuBar(wxT("appmenu"));
|
||||||
wxASSERT(menubar);
|
wxASSERT(menubar);
|
||||||
|
|
||||||
VisitItem( project, menuTree.get() );
|
VisitItem( project, menuTree.get() );
|
||||||
@ -304,7 +304,7 @@ void MenuManager::ModifyUndoMenuItems(AudacityProject &project)
|
|||||||
{
|
{
|
||||||
wxString desc;
|
wxString desc;
|
||||||
auto &undoManager = UndoManager::Get( project );
|
auto &undoManager = UndoManager::Get( project );
|
||||||
auto &commandManager = *project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
int cur = undoManager.GetCurrentState();
|
int cur = undoManager.GetCurrentState();
|
||||||
|
|
||||||
if (undoManager.UndoAvailable()) {
|
if (undoManager.UndoAvailable()) {
|
||||||
@ -354,7 +354,7 @@ void MenuCreator::RebuildMenuBar(AudacityProject &project)
|
|||||||
// menuBar gets deleted here
|
// menuBar gets deleted here
|
||||||
}
|
}
|
||||||
|
|
||||||
project.GetCommandManager()->PurgeData();
|
CommandManager::Get( project ).PurgeData();
|
||||||
|
|
||||||
CreateMenusAndCommands(project);
|
CreateMenusAndCommands(project);
|
||||||
|
|
||||||
@ -576,7 +576,7 @@ void MenuManager::ModifyToolbarMenus(AudacityProject &project)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &commandManager = *project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
commandManager.Check(wxT("ShowScrubbingTB"),
|
commandManager.Check(wxT("ShowScrubbingTB"),
|
||||||
toolManager->IsVisible(ScrubbingBarID));
|
toolManager->IsVisible(ScrubbingBarID));
|
||||||
@ -683,7 +683,7 @@ void MenuManager::UpdateMenus(AudacityProject &project, bool checkActive)
|
|||||||
return;
|
return;
|
||||||
mLastFlags = flags;
|
mLastFlags = flags;
|
||||||
|
|
||||||
auto &commandManager = *project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
commandManager.EnableUsingFlags(flags2 , NoFlagsSpecified);
|
commandManager.EnableUsingFlags(flags2 , NoFlagsSpecified);
|
||||||
|
|
||||||
@ -752,9 +752,8 @@ bool MenuManager::ReportIfActionNotAllowed
|
|||||||
bool bAllowed = TryToMakeActionAllowed( project, flags, flagsRqd, mask );
|
bool bAllowed = TryToMakeActionAllowed( project, flags, flagsRqd, mask );
|
||||||
if( bAllowed )
|
if( bAllowed )
|
||||||
return true;
|
return true;
|
||||||
CommandManager* cm = project.GetCommandManager();
|
auto &cm = CommandManager::Get( project );
|
||||||
if (!cm) return false;
|
cm.TellUserWhyDisallowed( Name, flags & mask, flagsRqd & mask);
|
||||||
cm->TellUserWhyDisallowed( Name, flags & mask, flagsRqd & mask);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1457,7 +1457,8 @@ void MixerBoardFrame::OnSize(wxSizeEvent & WXUNUSED(event))
|
|||||||
void MixerBoardFrame::OnKeyEvent(wxKeyEvent & event)
|
void MixerBoardFrame::OnKeyEvent(wxKeyEvent & event)
|
||||||
{
|
{
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
project->GetCommandManager()->FilterKeyEvent(project, event, true);
|
auto &commandManager = CommandManager::Get( *project );
|
||||||
|
commandManager.FilterKeyEvent(project, event, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixerBoardFrame::Recreate( AudacityProject *pProject )
|
void MixerBoardFrame::Recreate( AudacityProject *pProject )
|
||||||
|
@ -1060,7 +1060,6 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
|||||||
mBandwidthSelectionFormatName( NumericTextCtrl::LookupFormat(
|
mBandwidthSelectionFormatName( NumericTextCtrl::LookupFormat(
|
||||||
NumericConverter::BANDWIDTH,
|
NumericConverter::BANDWIDTH,
|
||||||
gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT("")) ) )
|
gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT("")) ) )
|
||||||
, mCommandManager( std::make_unique<CommandManager>() )
|
|
||||||
{
|
{
|
||||||
auto &project = *this;
|
auto &project = *this;
|
||||||
auto &window = project;
|
auto &window = project;
|
||||||
@ -2373,7 +2372,9 @@ void AudacityProject::OnMenu(wxCommandEvent & event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
bool handled = GetCommandManager()->HandleMenuID(
|
auto &project = *this;
|
||||||
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
bool handled = commandManager.HandleMenuID(
|
||||||
event.GetId(), GetMenuManager(*this).GetUpdateFlags(*this),
|
event.GetId(), GetMenuManager(*this).GetUpdateFlags(*this),
|
||||||
NoFlagsSpecified);
|
NoFlagsSpecified);
|
||||||
|
|
||||||
|
@ -161,7 +161,6 @@ private:
|
|||||||
|
|
||||||
class EffectPlugs;
|
class EffectPlugs;
|
||||||
class CommandContext;
|
class CommandContext;
|
||||||
class CommandManager;
|
|
||||||
class Track;
|
class Track;
|
||||||
class TrackHolder;
|
class TrackHolder;
|
||||||
class TrackList;
|
class TrackList;
|
||||||
@ -333,11 +332,6 @@ public:
|
|||||||
// Converts number of minutes to human readable format
|
// Converts number of minutes to human readable format
|
||||||
wxString GetHoursMinsString(int iMinutes);
|
wxString GetHoursMinsString(int iMinutes);
|
||||||
|
|
||||||
CommandManager *GetCommandManager()
|
|
||||||
{ return mCommandManager.get(); }
|
|
||||||
const CommandManager *GetCommandManager() const
|
|
||||||
{ return mCommandManager.get(); }
|
|
||||||
|
|
||||||
void MayStartMonitoring();
|
void MayStartMonitoring();
|
||||||
|
|
||||||
|
|
||||||
@ -563,10 +557,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool mDirty{ false };
|
bool mDirty{ false };
|
||||||
|
|
||||||
// Commands
|
|
||||||
|
|
||||||
std::unique_ptr<CommandManager> mCommandManager;
|
|
||||||
|
|
||||||
// Window elements
|
// Window elements
|
||||||
|
|
||||||
wxString mLastMainStatusMessage;
|
wxString mLastMainStatusMessage;
|
||||||
|
@ -151,6 +151,23 @@ SubMenuListEntry::~SubMenuListEntry()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
static const AudacityProject::AttachedObjects::RegisteredFactory key{
|
||||||
|
[](AudacityProject&) {
|
||||||
|
return std::make_unique<CommandManager>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
CommandManager &CommandManager::Get( AudacityProject &project )
|
||||||
|
{
|
||||||
|
return project.AttachedObjects::Get< CommandManager >( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
const CommandManager &CommandManager::Get( const AudacityProject &project )
|
||||||
|
{
|
||||||
|
return Get( const_cast< AudacityProject & >( project ) );
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Standard Constructor
|
/// Standard Constructor
|
||||||
///
|
///
|
||||||
@ -1642,8 +1659,8 @@ static struct InstallHandlers
|
|||||||
KeyboardCapture::SetPostFilter( []( wxKeyEvent &key ) {
|
KeyboardCapture::SetPostFilter( []( wxKeyEvent &key ) {
|
||||||
// Capture handler window didn't want it, so ask the CommandManager.
|
// Capture handler window didn't want it, so ask the CommandManager.
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
CommandManager *manager = project->GetCommandManager();
|
auto &manager = CommandManager::Get( *project );
|
||||||
return manager && manager->FilterKeyEvent(project, key);
|
return manager.FilterKeyEvent(project, key);
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
} installHandlers;
|
} installHandlers;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "audacity/Types.h"
|
#include "audacity/Types.h"
|
||||||
|
|
||||||
|
#include "../ClientData.h"
|
||||||
#include "CommandFunctors.h"
|
#include "CommandFunctors.h"
|
||||||
#include "CommandFlag.h"
|
#include "CommandFlag.h"
|
||||||
|
|
||||||
@ -99,9 +100,13 @@ using CommandNumericIDHash = std::unordered_map<int, CommandListEntry*>;
|
|||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
class CommandContext;
|
class CommandContext;
|
||||||
|
|
||||||
class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
|
class AUDACITY_DLL_API CommandManager final
|
||||||
|
: public XMLTagHandler
|
||||||
|
, public ClientData::Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static CommandManager &Get( AudacityProject &project );
|
||||||
|
static const CommandManager &Get( const AudacityProject &project );
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor / Destructor
|
// Constructor / Destructor
|
||||||
|
@ -640,7 +640,7 @@ void GetInfoCommand::ExploreMenu( const CommandContext &context, wxMenu * pMenu,
|
|||||||
if( !pMenu )
|
if( !pMenu )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CommandManager * pMan = context.project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( context.project );
|
||||||
|
|
||||||
wxMenuItemList list = pMenu->GetMenuItems();
|
wxMenuItemList list = pMenu->GetMenuItems();
|
||||||
size_t lcnt = list.size();
|
size_t lcnt = list.size();
|
||||||
@ -652,7 +652,7 @@ void GetInfoCommand::ExploreMenu( const CommandContext &context, wxMenu * pMenu,
|
|||||||
for (size_t lndx = 0; lndx < lcnt; lndx++) {
|
for (size_t lndx = 0; lndx < lcnt; lndx++) {
|
||||||
item = list.Item(lndx)->GetData();
|
item = list.Item(lndx)->GetData();
|
||||||
Label = item->GetItemLabelText();
|
Label = item->GetItemLabelText();
|
||||||
Name = pMan->GetNameFromNumericID( item->GetId() );
|
Name = commandManager.GetNameFromNumericID( item->GetId() );
|
||||||
Accel = item->GetItemLabel();
|
Accel = item->GetItemLabel();
|
||||||
if( Accel.Contains("\t") )
|
if( Accel.Contains("\t") )
|
||||||
Accel = Accel.AfterLast('\t');
|
Accel = Accel.AfterLast('\t');
|
||||||
|
@ -433,7 +433,7 @@ void ScreenshotCommand::CapturePreferences(
|
|||||||
AudacityProject * pProject, const wxString &FileName ){
|
AudacityProject * pProject, const wxString &FileName ){
|
||||||
(void)&FileName;//compiler food.
|
(void)&FileName;//compiler food.
|
||||||
(void)&context;
|
(void)&context;
|
||||||
CommandManager * pMan = pProject->GetCommandManager();
|
CommandManager &commandManager = CommandManager::Get( *pProject );
|
||||||
|
|
||||||
// Yucky static variables. Is there a better way? The problem is that we need the
|
// Yucky static variables. Is there a better way? The problem is that we need the
|
||||||
// idle callback to know more about what to do.
|
// idle callback to know more about what to do.
|
||||||
@ -452,7 +452,7 @@ void ScreenshotCommand::CapturePreferences(
|
|||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
CommandID Command{ wxT("Preferences") };
|
CommandID Command{ wxT("Preferences") };
|
||||||
const CommandContext projectContext( *pProject );
|
const CommandContext projectContext( *pProject );
|
||||||
if( !pMan->HandleTextualCommand( Command, projectContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
if( !commandManager.HandleTextualCommand( Command, projectContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
||||||
{
|
{
|
||||||
// using GET in a log message for devs' eyes only
|
// using GET in a log message for devs' eyes only
|
||||||
wxLogDebug("Command %s not found", Command.GET() );
|
wxLogDebug("Command %s not found", Command.GET() );
|
||||||
@ -596,7 +596,7 @@ void ScreenshotCommand::CaptureScriptables(
|
|||||||
void ScreenshotCommand::CaptureCommands(
|
void ScreenshotCommand::CaptureCommands(
|
||||||
const CommandContext & context, const wxArrayStringEx & Commands ){
|
const CommandContext & context, const wxArrayStringEx & Commands ){
|
||||||
AudacityProject * pProject = &context.project;
|
AudacityProject * pProject = &context.project;
|
||||||
CommandManager * pMan = pProject->GetCommandManager();
|
CommandManager &manager = CommandManager::Get( *pProject );
|
||||||
wxString Str;
|
wxString Str;
|
||||||
// Yucky static variables. Is there a better way? The problem is that we need the
|
// Yucky static variables. Is there a better way? The problem is that we need the
|
||||||
// idle callback to know more about what to do.
|
// idle callback to know more about what to do.
|
||||||
@ -612,7 +612,7 @@ void ScreenshotCommand::CaptureCommands(
|
|||||||
SetIdleHandler( IdleHandler );
|
SetIdleHandler( IdleHandler );
|
||||||
Str = Commands[i];
|
Str = Commands[i];
|
||||||
const CommandContext projectContext( *pProject );
|
const CommandContext projectContext( *pProject );
|
||||||
if( !pMan->HandleTextualCommand( Str, projectContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
if( !manager.HandleTextualCommand( Str, projectContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
||||||
{
|
{
|
||||||
wxLogDebug("Command %s not found", Str);
|
wxLogDebug("Command %s not found", Str);
|
||||||
}
|
}
|
||||||
|
@ -122,11 +122,11 @@ void OnAudioHost(const CommandContext &context)
|
|||||||
void OnFullScreen(const CommandContext &context)
|
void OnFullScreen(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
auto commandManager = project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
bool bChecked = !project.wxTopLevelWindow::IsFullScreen();
|
bool bChecked = !project.wxTopLevelWindow::IsFullScreen();
|
||||||
project.wxTopLevelWindow::ShowFullScreen(bChecked);
|
project.wxTopLevelWindow::ShowFullScreen(bChecked);
|
||||||
commandManager->Check(wxT("FullScreenOnOff"), bChecked);
|
commandManager.Check(wxT("FullScreenOnOff"), bChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // struct Handler
|
}; // struct Handler
|
||||||
|
@ -399,7 +399,7 @@ bool DoEffect(
|
|||||||
auto trackFactory = project.GetTrackFactory();
|
auto trackFactory = project.GetTrackFactory();
|
||||||
auto rate = project.GetRate();
|
auto rate = project.GetRate();
|
||||||
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||||
auto commandManager = project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
|
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
|
||||||
if (!plug)
|
if (!plug)
|
||||||
@ -475,7 +475,7 @@ bool DoEffect(
|
|||||||
/* i18n-hint: %s will be the name of the effect which will be
|
/* i18n-hint: %s will be the name of the effect which will be
|
||||||
* repeated if this menu item is chosen */
|
* repeated if this menu item is chosen */
|
||||||
lastEffectDesc.Printf(_("Repeat %s"), shortDesc);
|
lastEffectDesc.Printf(_("Repeat %s"), shortDesc);
|
||||||
commandManager->Modify(wxT("RepeatLastEffect"), lastEffectDesc);
|
commandManager.Modify(wxT("RepeatLastEffect"), lastEffectDesc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,20 +645,20 @@ void OnBenchmark(const CommandContext &context)
|
|||||||
void OnSimulateRecordingErrors(const CommandContext &context)
|
void OnSimulateRecordingErrors(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
auto commandManager = project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
bool &setting = gAudioIO->mSimulateRecordingErrors;
|
bool &setting = gAudioIO->mSimulateRecordingErrors;
|
||||||
commandManager->Check(wxT("SimulateRecordingErrors"), !setting);
|
commandManager.Check(wxT("SimulateRecordingErrors"), !setting);
|
||||||
setting = !setting;
|
setting = !setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDetectUpstreamDropouts(const CommandContext &context)
|
void OnDetectUpstreamDropouts(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
auto commandManager = project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
bool &setting = gAudioIO->mDetectUpstreamDropouts;
|
bool &setting = gAudioIO->mDetectUpstreamDropouts;
|
||||||
commandManager->Check(wxT("DetectUpstreamDropouts"), !setting);
|
commandManager.Check(wxT("DetectUpstreamDropouts"), !setting);
|
||||||
setting = !setting;
|
setting = !setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,12 +258,12 @@ void OnZoomFitV(const CommandContext &context)
|
|||||||
void OnAdvancedVZoom(const CommandContext &context)
|
void OnAdvancedVZoom(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
auto commandManager = project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
bool checked = !gPrefs->Read(wxT("/GUI/VerticalZooming"), 0L);
|
bool checked = !gPrefs->Read(wxT("/GUI/VerticalZooming"), 0L);
|
||||||
gPrefs->Write(wxT("/GUI/VerticalZooming"), checked);
|
gPrefs->Write(wxT("/GUI/VerticalZooming"), checked);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
commandManager->Check(wxT("AdvancedVZoom"), checked);
|
commandManager.Check(wxT("AdvancedVZoom"), checked);
|
||||||
MenuCreator::RebuildAllMenuBars();
|
MenuCreator::RebuildAllMenuBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,25 +350,25 @@ void OnMixerBoard(const CommandContext &context)
|
|||||||
void OnShowExtraMenus(const CommandContext &context)
|
void OnShowExtraMenus(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
auto commandManager = project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
|
|
||||||
bool checked = !gPrefs->Read(wxT("/GUI/ShowExtraMenus"), 0L);
|
bool checked = !gPrefs->Read(wxT("/GUI/ShowExtraMenus"), 0L);
|
||||||
gPrefs->Write(wxT("/GUI/ShowExtraMenus"), checked);
|
gPrefs->Write(wxT("/GUI/ShowExtraMenus"), checked);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
commandManager->Check(wxT("ShowExtraMenus"), checked);
|
commandManager.Check(wxT("ShowExtraMenus"), checked);
|
||||||
MenuCreator::RebuildAllMenuBars();
|
MenuCreator::RebuildAllMenuBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnShowClipping(const CommandContext &context)
|
void OnShowClipping(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
auto commandManager = project.GetCommandManager();
|
auto &commandManager = CommandManager::Get( project );
|
||||||
auto trackPanel = project.GetTrackPanel();
|
auto trackPanel = project.GetTrackPanel();
|
||||||
|
|
||||||
bool checked = !gPrefs->Read(wxT("/GUI/ShowClipping"), 0L);
|
bool checked = !gPrefs->Read(wxT("/GUI/ShowClipping"), 0L);
|
||||||
gPrefs->Write(wxT("/GUI/ShowClipping"), checked);
|
gPrefs->Write(wxT("/GUI/ShowClipping"), checked);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
commandManager->Check(wxT("ShowClipping"), checked);
|
commandManager.Check(wxT("ShowClipping"), checked);
|
||||||
|
|
||||||
wxTheApp->AddPendingEvent(wxCommandEvent{
|
wxTheApp->AddPendingEvent(wxCommandEvent{
|
||||||
EVT_PREFS_UPDATE, ShowClippingPrefsID() });
|
EVT_PREFS_UPDATE, ShowClippingPrefsID() });
|
||||||
|
@ -136,7 +136,7 @@ void KeyConfigPrefs::Populate()
|
|||||||
|
|
||||||
mCommandSelected = wxNOT_FOUND;
|
mCommandSelected = wxNOT_FOUND;
|
||||||
|
|
||||||
mManager = project->GetCommandManager();
|
mManager = &CommandManager::Get( *project );
|
||||||
|
|
||||||
// For speed, don't sort here. We're just creating.
|
// For speed, don't sort here. We're just creating.
|
||||||
// Instead sort when we do SetView later in this function.
|
// Instead sort when we do SetView later in this function.
|
||||||
|
@ -262,8 +262,7 @@ void EditToolBar::ForAllButtons(int Action)
|
|||||||
if( Action & ETBActEnableDisable ){
|
if( Action & ETBActEnableDisable ){
|
||||||
p = GetActiveProject();
|
p = GetActiveProject();
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
cm = p->GetCommandManager();
|
cm = &CommandManager::Get( *p );
|
||||||
if (!cm) return;
|
|
||||||
#ifdef OPTION_SYNC_LOCK_BUTTON
|
#ifdef OPTION_SYNC_LOCK_BUTTON
|
||||||
bool bSyncLockTracks;
|
bool bSyncLockTracks;
|
||||||
gPrefs->Read(wxT("/GUI/SyncLockTracks"), &bSyncLockTracks, false);
|
gPrefs->Read(wxT("/GUI/SyncLockTracks"), &bSyncLockTracks, false);
|
||||||
@ -298,12 +297,11 @@ void EditToolBar::OnButton(wxCommandEvent &event)
|
|||||||
|
|
||||||
AudacityProject *p = GetActiveProject();
|
AudacityProject *p = GetActiveProject();
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
CommandManager* cm = p->GetCommandManager();
|
auto &cm = CommandManager::Get( *p );
|
||||||
if (!cm) return;
|
|
||||||
|
|
||||||
auto flags = GetMenuManager(*p).GetUpdateFlags(*p);
|
auto flags = GetMenuManager(*p).GetUpdateFlags(*p);
|
||||||
const CommandContext context( *GetActiveProject() );
|
const CommandContext context( *GetActiveProject() );
|
||||||
cm->HandleTextualCommand(EditToolbarButtonList[id].commandName, context, flags, NoFlagsSpecified);
|
cm.HandleTextualCommand(EditToolbarButtonList[id].commandName, context, flags, NoFlagsSpecified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ void ToolBar::SetButtonToolTip
|
|||||||
wxString result;
|
wxString result;
|
||||||
const auto project = GetActiveProject();
|
const auto project = GetActiveProject();
|
||||||
const auto commandManager =
|
const auto commandManager =
|
||||||
project ? project->GetCommandManager() : nullptr;
|
project ? &CommandManager::Get( *project ) : nullptr;
|
||||||
if (commandManager)
|
if (commandManager)
|
||||||
result =
|
result =
|
||||||
commandManager->DescribeCommandsAndShortcuts(commands, nCommands);
|
commandManager->DescribeCommandsAndShortcuts(commands, nCommands);
|
||||||
|
@ -47,9 +47,9 @@ wxString MuteButtonHandle::Tip(const wxMouseState &) const
|
|||||||
if (!focused)
|
if (!focused)
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
auto commandManager = project->GetCommandManager();
|
auto &commandManager = CommandManager::Get( *project );
|
||||||
TranslatedInternalString command{ wxT("TrackMute"), name };
|
TranslatedInternalString command{ wxT("TrackMute"), name };
|
||||||
return commandManager->DescribeCommandsAndShortcuts(&command, 1u);
|
return commandManager.DescribeCommandsAndShortcuts(&command, 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
UIHandlePtr MuteButtonHandle::HitTest
|
UIHandlePtr MuteButtonHandle::HitTest
|
||||||
@ -103,9 +103,9 @@ wxString SoloButtonHandle::Tip(const wxMouseState &) const
|
|||||||
if (!focused)
|
if (!focused)
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
auto commandManager = project->GetCommandManager();
|
auto &commandManager = CommandManager::Get( *project );
|
||||||
TranslatedInternalString command{ wxT("TrackSolo"), name };
|
TranslatedInternalString command{ wxT("TrackSolo"), name };
|
||||||
return commandManager->DescribeCommandsAndShortcuts( &command, 1u );
|
return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
|
||||||
}
|
}
|
||||||
|
|
||||||
UIHandlePtr SoloButtonHandle::HitTest
|
UIHandlePtr SoloButtonHandle::HitTest
|
||||||
|
@ -1145,8 +1145,8 @@ std::vector<wxString> Scrubber::GetAllUntranslatedStatusStrings()
|
|||||||
bool Scrubber::CanScrub() const
|
bool Scrubber::CanScrub() const
|
||||||
{
|
{
|
||||||
// Return the enabled state for the menu item that really launches the scrub or seek.
|
// Return the enabled state for the menu item that really launches the scrub or seek.
|
||||||
auto cm = mProject->GetCommandManager();
|
auto &cm = CommandManager::Get( *mProject );
|
||||||
return cm->GetEnabled(menuItems[ 0 ].name);
|
return cm.GetEnabled(menuItems[ 0 ].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// To supply the "finder" argument
|
// To supply the "finder" argument
|
||||||
@ -1178,9 +1178,9 @@ MenuTable::BaseItemPtr Scrubber::Menu()
|
|||||||
void Scrubber::PopulatePopupMenu(wxMenu &menu)
|
void Scrubber::PopulatePopupMenu(wxMenu &menu)
|
||||||
{
|
{
|
||||||
int id = CMD_ID;
|
int id = CMD_ID;
|
||||||
auto cm = mProject->GetCommandManager();
|
auto &cm = CommandManager::Get( *mProject );
|
||||||
for (const auto &item : menuItems) {
|
for (const auto &item : menuItems) {
|
||||||
if (cm->GetEnabled(item.name)) {
|
if (cm.GetEnabled(item.name)) {
|
||||||
auto test = item.StatusTest;
|
auto test = item.StatusTest;
|
||||||
menu.Append(id, wxGetTranslation(item.label), wxString{},
|
menu.Append(id, wxGetTranslation(item.label), wxString{},
|
||||||
test ? wxITEM_CHECK : wxITEM_NORMAL);
|
test ? wxITEM_CHECK : wxITEM_NORMAL);
|
||||||
@ -1193,11 +1193,11 @@ void Scrubber::PopulatePopupMenu(wxMenu &menu)
|
|||||||
|
|
||||||
void Scrubber::CheckMenuItems()
|
void Scrubber::CheckMenuItems()
|
||||||
{
|
{
|
||||||
auto cm = mProject->GetCommandManager();
|
auto &cm = CommandManager::Get( *mProject );
|
||||||
for (const auto &item : menuItems) {
|
for (const auto &item : menuItems) {
|
||||||
auto test = item.StatusTest;
|
auto test = item.StatusTest;
|
||||||
if (test)
|
if (test)
|
||||||
cm->Check(item.name, (this->*test)());
|
cm.Check(item.name, (this->*test)());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,7 +906,7 @@ HitTestPreview SelectHandle::Preview
|
|||||||
// Look up the current key binding for Preferences.
|
// Look up the current key binding for Preferences.
|
||||||
// (Don't assume it's the default!)
|
// (Don't assume it's the default!)
|
||||||
auto keyStr =
|
auto keyStr =
|
||||||
pProject->GetCommandManager()->GetKeyFromName(wxT("Preferences"))
|
CommandManager::Get( *pProject ).GetKeyFromName(wxT("Preferences"))
|
||||||
.Display( true );
|
.Display( true );
|
||||||
if (keyStr.empty())
|
if (keyStr.empty())
|
||||||
// No keyboard preference defined for opening Preferences dialog
|
// No keyboard preference defined for opening Preferences dialog
|
||||||
|
@ -169,9 +169,9 @@ wxString CloseButtonHandle::Tip(const wxMouseState &) const
|
|||||||
if (!focused)
|
if (!focused)
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
auto commandManager = project->GetCommandManager();
|
auto &commandManager = CommandManager::Get( *project );
|
||||||
TranslatedInternalString command{ wxT("TrackClose"), name };
|
TranslatedInternalString command{ wxT("TrackClose"), name };
|
||||||
return commandManager->DescribeCommandsAndShortcuts( &command, 1u );
|
return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
|
||||||
}
|
}
|
||||||
|
|
||||||
UIHandlePtr CloseButtonHandle::HitTest
|
UIHandlePtr CloseButtonHandle::HitTest
|
||||||
@ -228,9 +228,9 @@ wxString MenuButtonHandle::Tip(const wxMouseState &) const
|
|||||||
if (!focused)
|
if (!focused)
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
auto commandManager = project->GetCommandManager();
|
auto &commandManager = CommandManager::Get( *project );
|
||||||
TranslatedInternalString command{ wxT("TrackMenu"), name };
|
TranslatedInternalString command{ wxT("TrackMenu"), name };
|
||||||
return commandManager->DescribeCommandsAndShortcuts( &command, 1u );
|
return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
|
||||||
}
|
}
|
||||||
|
|
||||||
UIHandlePtr MenuButtonHandle::HitTest
|
UIHandlePtr MenuButtonHandle::HitTest
|
||||||
|
@ -139,28 +139,28 @@ BEGIN_POPUP_MENU(TrackMenuTable)
|
|||||||
// functions.
|
// functions.
|
||||||
OnMoveUpID,
|
OnMoveUpID,
|
||||||
_("Move Track &Up") + wxT("\t") +
|
_("Move Track &Up") + wxT("\t") +
|
||||||
(GetActiveProject()->GetCommandManager()->
|
(CommandManager::Get( *GetActiveProject() ).
|
||||||
// using GET to compose menu item name for wxWidgets
|
// using GET to compose menu item name for wxWidgets
|
||||||
GetKeyFromName(wxT("TrackMoveUp")).GET()),
|
GetKeyFromName(wxT("TrackMoveUp")).GET()),
|
||||||
OnMoveTrack)
|
OnMoveTrack)
|
||||||
POPUP_MENU_ITEM(
|
POPUP_MENU_ITEM(
|
||||||
OnMoveDownID,
|
OnMoveDownID,
|
||||||
_("Move Track &Down") + wxT("\t") +
|
_("Move Track &Down") + wxT("\t") +
|
||||||
(GetActiveProject()->GetCommandManager()->
|
(CommandManager::Get( *GetActiveProject() ).
|
||||||
// using GET to compose menu item name for wxWidgets
|
// using GET to compose menu item name for wxWidgets
|
||||||
GetKeyFromName(wxT("TrackMoveDown")).GET()),
|
GetKeyFromName(wxT("TrackMoveDown")).GET()),
|
||||||
OnMoveTrack)
|
OnMoveTrack)
|
||||||
POPUP_MENU_ITEM(
|
POPUP_MENU_ITEM(
|
||||||
OnMoveTopID,
|
OnMoveTopID,
|
||||||
_("Move Track to &Top") + wxT("\t") +
|
_("Move Track to &Top") + wxT("\t") +
|
||||||
(GetActiveProject()->GetCommandManager()->
|
(CommandManager::Get( *GetActiveProject() ).
|
||||||
// using GET to compose menu item name for wxWidgets
|
// using GET to compose menu item name for wxWidgets
|
||||||
GetKeyFromName(wxT("TrackMoveTop")).GET()),
|
GetKeyFromName(wxT("TrackMoveTop")).GET()),
|
||||||
OnMoveTrack)
|
OnMoveTrack)
|
||||||
POPUP_MENU_ITEM(
|
POPUP_MENU_ITEM(
|
||||||
OnMoveBottomID,
|
OnMoveBottomID,
|
||||||
_("Move Track to &Bottom") + wxT("\t") +
|
_("Move Track to &Bottom") + wxT("\t") +
|
||||||
(GetActiveProject()->GetCommandManager()->
|
(CommandManager::Get( *GetActiveProject() ).
|
||||||
// using GET to compose menu item name for wxWidgets
|
// using GET to compose menu item name for wxWidgets
|
||||||
GetKeyFromName(wxT("TrackMoveBottom")).GET()),
|
GetKeyFromName(wxT("TrackMoveBottom")).GET()),
|
||||||
OnMoveTrack)
|
OnMoveTrack)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user