Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CommandManager Class Referencefinal

CommandManager implements a system for organizing all user-callable commands. More...

#include <CommandManager.h>

Inheritance diagram for CommandManager:
[legend]
Collaboration diagram for CommandManager:
[legend]

Classes

struct  GlobalMenuHook
 
struct  Options
 

Public Types

enum  TextualCommandResult { CommandFailure , CommandSuccess , CommandNotFound }
 
using CheckFn = std::function< bool(AudacityProject &) >
 

Public Member Functions

 CommandManager ()
 
virtual ~CommandManager ()
 
 CommandManager (const CommandManager &) PROHIBITED
 
CommandManageroperator= (const CommandManager &) PROHIBITED
 
void SetMaxList ()
 
void PurgeData ()
 
std::unique_ptr< wxMenuBar > AddMenuBar (const wxString &sMenu)
 
wxMenu * BeginMenu (const TranslatableString &tName)
 
void EndMenu ()
 This attaches a menu, if it's main, to the menubar. More...
 
void AddItemList (const CommandID &name, const ComponentInterfaceSymbol items[], size_t nItems, CommandHandlerFinder finder, CommandFunctorPointer callback, CommandFlag flags, bool bIsEffect=false)
 
void AddItem (AudacityProject &project, const CommandID &name, const TranslatableString &label_in, CommandHandlerFinder finder, CommandFunctorPointer callback, CommandFlag flags, const Options &options={})
 
void AddSeparator ()
 
void PopMenuBar ()
 
void BeginOccultCommands ()
 
void EndOccultCommands ()
 
void SetCommandFlags (const CommandID &name, CommandFlag flags)
 
void EnableUsingFlags (CommandFlag flags, CommandFlag strictFlags)
 
void Enable (const wxString &name, bool enabled)
 
void Check (const CommandID &name, bool checked)
 
void Modify (const wxString &name, const TranslatableString &newLabel)
 Changes the label text of a menu item. More...
 
void SetKeyFromName (const CommandID &name, const NormalizedKeyString &key)
 
void SetKeyFromIndex (int i, const NormalizedKeyString &key)
 
bool FilterKeyEvent (AudacityProject *project, const wxKeyEvent &evt, bool permit=false)
 
bool HandleMenuID (AudacityProject &project, int id, CommandFlag flags, bool alwaysEnabled)
 
void RegisterLastAnalyzer (const CommandContext &context)
 
void RegisterLastTool (const CommandContext &context)
 
void DoRepeatProcess (const CommandContext &context, int)
 
TextualCommandResult HandleTextualCommand (const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
 
TranslatableStrings GetCategories (AudacityProject &)
 
void GetAllCommandNames (CommandIDs &names, bool includeMultis) const
 
void GetAllCommandLabels (TranslatableStrings &labels, std::vector< bool > &vExcludeFromMacros, bool includeMultis) const
 
void GetAllCommandData (CommandIDs &names, std::vector< NormalizedKeyString > &keys, std::vector< NormalizedKeyString > &default_keys, TranslatableStrings &labels, TranslatableStrings &categories, bool includeMultis)
 
CommandID GetNameFromNumericID (int id)
 
TranslatableString GetLabelFromName (const CommandID &name)
 
TranslatableString GetPrefixedLabelFromName (const CommandID &name)
 
TranslatableString GetCategoryFromName (const CommandID &name)
 
NormalizedKeyString GetKeyFromName (const CommandID &name) const
 
NormalizedKeyString GetDefaultKeyFromName (const CommandID &name)
 
bool GetEnabled (const CommandID &name)
 
int GetNumberOfKeysRead () const
 
void RemoveDuplicateShortcuts ()
 
void WriteXML (XMLWriter &xmlFile) const
 
TranslatableString DescribeCommandsAndShortcuts (const ComponentInterfaceSymbol commands[], size_t nCommands) const
 
wxMenu * CurrentMenu () const
 
void UpdateCheckmarks (AudacityProject &project)
 
wxString FormatLabelForMenu (const CommandID &id, const TranslatableString *pLabel) const
 Format a string appropriate for insertion in a menu. More...
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs)=0
 
virtual void HandleXMLEndTag (const std::string_view &WXUNUSED(tag))
 
virtual void HandleXMLContent (const std::string_view &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const std::string_view &tag)=0
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static CommandManagerGet (AudacityProject &project)
 
static const CommandManagerGet (const AudacityProject &project)
 
static const std::vector< NormalizedKeyString > & ExcludedList ()
 

Private Member Functions

int NextIdentifier (int ID)
 
CommandListEntryNewIdentifier (const CommandID &name, const TranslatableString &label, wxMenu *menu, CommandHandlerFinder finder, CommandFunctorPointer callback, const CommandID &nameSuffix, int index, int count, const Options &options)
 
void AddGlobalCommand (const CommandID &name, const TranslatableString &label, CommandHandlerFinder finder, CommandFunctorPointer callback, const Options &options={})
 
bool HandleCommandEntry (AudacityProject &project, const CommandListEntry *entry, CommandFlag flags, bool alwaysEnabled, const wxEvent *evt=nullptr, const CommandContext *pGivenContext=nullptr)
 
void Enable (CommandListEntry *entry, bool enabled)
 
wxMenu * BeginMainMenu (const TranslatableString &tName)
 
void EndMainMenu ()
 
wxMenu * BeginSubMenu (const TranslatableString &tName)
 
void EndSubMenu ()
 
wxMenuBar * CurrentMenuBar () const
 
wxMenuBar * GetMenuBar (const wxString &sMenu) const
 
wxMenu * CurrentSubMenu () const
 
wxString FormatLabelForMenu (const CommandListEntry *entry) const
 
wxString FormatLabelForMenu (const TranslatableString &translatableLabel, const NormalizedKeyString &keyStr) const
 
wxString FormatLabelWithDisabledAccel (const CommandListEntry *entry) const
 
bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs) override
 
void HandleXMLEndTag (const std::string_view &tag) override
 
XMLTagHandlerHandleXMLChild (const std::string_view &tag) override
 

Private Attributes

std::vector< NormalizedKeyStringmMaxListOnly
 
MenuBarList mMenuBarList
 
SubMenuList mSubMenuList
 
CommandList mCommandList
 
CommandNameHash mCommandNameHash
 
CommandKeyHash mCommandKeyHash
 
CommandNumericIDHash mCommandNumericIDHash
 
int mCurrentID
 
int mXMLKeysRead
 
bool mbSeparatorAllowed
 
TranslatableString mCurrentMenuName
 
TranslatableString mNiceName
 
int mLastProcessId
 
std::unique_ptr< wxMenu > uCurrentMenu
 
wxMenu * mCurrentMenu {}
 
bool bMakingOccultCommands
 
std::unique_ptr< wxMenuBar > mTempMenuBar
 

Detailed Description

CommandManager implements a system for organizing all user-callable commands.

It creates and manages a menu bar with a command associated with each item, and managing other commands callable by keyboard shortcuts.

Commands are implemented by overriding an abstract functor class. See Menus.cpp for an example use.

Menus or submenus containing lists of items can be added at once, with a single function (functor) to be called when any of the items is selected, with the index number of the selection as the parameter. This is useful for dynamic menus (effects) and submenus containing a list of choices (selection formats).

Menu items can be enabled or disabled individually, groups of "multi-items" can be enabled or disabled all at once, or entire sets of commands can be enabled or disabled all at once using flags. The flags should be a bitfield stored in a 32-bit integer but can be whatever you want. You specify both the desired values of the flags, and the set of flags relevant to a particular command, by using a combination of a flags parameter and a mask parameter. Any flag set to 0 in the mask parameter is the same as "don't care". Any command whose mask is set to zero will not be affected by enabling/disabling by flags.

Definition at line 58 of file CommandManager.h.

Member Typedef Documentation

◆ CheckFn

using CommandManager::CheckFn = std::function< bool(AudacityProject&) >

Definition at line 95 of file CommandManager.h.

Member Enumeration Documentation

◆ TextualCommandResult

Enumerator
CommandFailure 
CommandSuccess 
CommandNotFound 

Definition at line 222 of file CommandManager.h.

Constructor & Destructor Documentation

◆ CommandManager() [1/2]

CommandManager::CommandManager ( )

Standard Constructor

Definition at line 219 of file CommandManager.cpp.

219 :
220 mCurrentID(17000),
222 bMakingOccultCommands( false )
223{
224 mbSeparatorAllowed = false;
225 SetMaxList();
226 mLastProcessId = 0;
227}
#define COMMAND
TranslatableString mCurrentMenuName
bool bMakingOccultCommands

References mbSeparatorAllowed, mLastProcessId, and SetMaxList().

Here is the call graph for this function:

◆ ~CommandManager()

CommandManager::~CommandManager ( )
virtual

Class Destructor. Includes PurgeData, which removes menubars

Definition at line 232 of file CommandManager.cpp.

233{
234 //WARNING: This removes menubars that could still be assigned to windows!
235 PurgeData();
236}

References PurgeData().

Here is the call graph for this function:

◆ CommandManager() [2/2]

CommandManager::CommandManager ( const CommandManager )

Member Function Documentation

◆ AddGlobalCommand()

void CommandManager::AddGlobalCommand ( const CommandID name,
const TranslatableString label,
CommandHandlerFinder  finder,
CommandFunctorPointer  callback,
const Options options = {} 
)
private

Definition at line 617 of file CommandManager.cpp.

622{
624 NewIdentifier(name, label_in, NULL, finder, callback,
625 {}, 0, 0, options);
626
627 entry->enabled = false;
628 entry->isGlobal = true;
629 entry->flags = AlwaysEnabledFlag;
630}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const TranslatableString name
Definition: Distortion.cpp:74
static ProjectFileIORegistry::AttributeWriterEntry entry
CommandListEntry * NewIdentifier(const CommandID &name, const TranslatableString &label, wxMenu *menu, CommandHandlerFinder finder, CommandFunctorPointer callback, const CommandID &nameSuffix, int index, int count, const Options &options)
CommandListEntry is a structure used by CommandManager.

References AlwaysEnabledFlag, entry, name, and NewIdentifier().

Referenced by AddItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddItem()

void CommandManager::AddItem ( AudacityProject project,
const CommandID name,
const TranslatableString label_in,
CommandHandlerFinder  finder,
CommandFunctorPointer  callback,
CommandFlag  flags,
const Options options = {} 
)

Definition at line 531 of file CommandManager.cpp.

538{
539 if (options.global) {
540 //wxASSERT( flags == AlwaysEnabledFlag );
542 name, label_in, finder, callback, options );
543 return;
544 }
545
546 wxASSERT( flags != NoFlagsSpecified );
547
550 label_in,
551 CurrentMenu(), finder, callback,
552 {}, 0, 0,
553 options);
554 entry->useStrictFlags = options.useStrictFlags;
555 int ID = entry->id;
557
558 SetCommandFlags(name, flags);
559
560
561 auto &checker = options.checker;
562 if (checker) {
563 CurrentMenu()->AppendCheckItem(ID, label);
564 CurrentMenu()->Check(ID, checker( project ));
565 }
566 else {
567 CurrentMenu()->Append(ID, label);
568 }
569
570 mbSeparatorAllowed = true;
571}
constexpr CommandFlag NoFlagsSpecified
Definition: CommandFlag.h:35
TranslatableString label
Definition: TagsEditor.cpp:164
void AddGlobalCommand(const CommandID &name, const TranslatableString &label, CommandHandlerFinder finder, CommandFunctorPointer callback, const Options &options={})
wxString FormatLabelWithDisabledAccel(const CommandListEntry *entry) const
wxMenu * CurrentMenu() const
void SetCommandFlags(const CommandID &name, CommandFlag flags)

References AddGlobalCommand(), CommandManager::Options::checker, CurrentMenu(), entry, FormatLabelWithDisabledAccel(), CommandManager::Options::global, label, mbSeparatorAllowed, name, NewIdentifier(), NoFlagsSpecified, SetCommandFlags(), and CommandManager::Options::useStrictFlags.

Here is the call graph for this function:

◆ AddItemList()

void CommandManager::AddItemList ( const CommandID name,
const ComponentInterfaceSymbol  items[],
size_t  nItems,
CommandHandlerFinder  finder,
CommandFunctorPointer  callback,
CommandFlag  flags,
bool  bIsEffect = false 
)

Add a list of menu items to the current menu. When the user selects any one of these, the given functor will be called with its position in the list as the index number. When you call Enable on this command name, it will enable or disable all of the items at once.

Definition at line 591 of file CommandManager.cpp.

598{
599 for (size_t i = 0, cnt = nItems; i < cnt; i++) {
602 items[i].Msgid(),
603 CurrentMenu(),
604 finder,
605 callback,
606 items[i].Internal(),
607 i,
608 cnt,
609 Options{}
610 .IsEffect(bIsEffect));
611 entry->flags = flags;
612 CurrentMenu()->Append(entry->id, FormatLabelForMenu(entry));
613 mbSeparatorAllowed = true;
614 }
615}
@ Internal
Indicates internal failure from Audacity.
wxString FormatLabelForMenu(const CommandID &id, const TranslatableString *pLabel) const
Format a string appropriate for insertion in a menu.
Options && IsEffect(bool value=true) &&

References CurrentMenu(), entry, FormatLabelForMenu(), Internal, CommandManager::Options::IsEffect(), mbSeparatorAllowed, name, and NewIdentifier().

Here is the call graph for this function:

◆ AddMenuBar()

std::unique_ptr< wxMenuBar > CommandManager::AddMenuBar ( const wxString &  sMenu)

Makes a NEW menubar for placement on the top of a project Names it according to the passed-in string argument.

If the menubar already exists, that's unexpected.

Definition at line 350 of file CommandManager.cpp.

351{
352 wxMenuBar *menuBar = GetMenuBar(sMenu);
353 if (menuBar) {
354 wxASSERT(false);
355 return {};
356 }
357
358 auto result = std::make_unique<wxMenuBar>();
359 mMenuBarList.emplace_back(sMenu, result.get());
360
361 return result;
362}
MenuBarList mMenuBarList
wxMenuBar * GetMenuBar(const wxString &sMenu) const

References GetMenuBar(), and mMenuBarList.

Referenced by BeginOccultCommands().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddSeparator()

void CommandManager::AddSeparator ( )

Definition at line 632 of file CommandManager.cpp.

633{
635 CurrentMenu()->AppendSeparator();
636 mbSeparatorAllowed = false; // boolean to prevent too many separators.
637}

References CurrentMenu(), and mbSeparatorAllowed.

Here is the call graph for this function:

◆ BeginMainMenu()

wxMenu * CommandManager::BeginMainMenu ( const TranslatableString tName)
private

This starts a NEW menu

Definition at line 434 of file CommandManager.cpp.

435{
436 uCurrentMenu = std::make_unique<wxMenu>();
438 mCurrentMenuName = tName;
439 return mCurrentMenu;
440}
std::unique_ptr< wxMenu > uCurrentMenu
wxMenu * mCurrentMenu

References mCurrentMenu, mCurrentMenuName, and uCurrentMenu.

Referenced by BeginMenu().

Here is the caller graph for this function:

◆ BeginMenu()

wxMenu * CommandManager::BeginMenu ( const TranslatableString tName)

This starts a NEW menu

Definition at line 409 of file CommandManager.cpp.

410{
411 if ( mCurrentMenu )
412 return BeginSubMenu( tName );
413 else
414 return BeginMainMenu( tName );
415}
wxMenu * BeginSubMenu(const TranslatableString &tName)
wxMenu * BeginMainMenu(const TranslatableString &tName)

References BeginMainMenu(), BeginSubMenu(), and mCurrentMenu.

Here is the call graph for this function:

◆ BeginOccultCommands()

void CommandManager::BeginOccultCommands ( )

Definition at line 1600 of file CommandManager.cpp.

1601{
1602 // To do: perhaps allow occult item switching at lower levels of the
1603 // menu tree.
1604 wxASSERT( !CurrentMenu() );
1605
1606 // Make a temporary menu bar collecting items added after.
1607 // This bar will be discarded but other side effects on the command
1608 // manager persist.
1609 mTempMenuBar = AddMenuBar(wxT("ext-menu"));
1610 bMakingOccultCommands = true;
1611}
wxT("CloseDown"))
std::unique_ptr< wxMenuBar > mTempMenuBar
std::unique_ptr< wxMenuBar > AddMenuBar(const wxString &sMenu)

References AddMenuBar(), bMakingOccultCommands, CurrentMenu(), mTempMenuBar, and wxT().

Here is the call graph for this function:

◆ BeginSubMenu()

wxMenu * CommandManager::BeginSubMenu ( const TranslatableString tName)
private

This starts a NEW submenu, and names it according to the function's argument.

Definition at line 462 of file CommandManager.cpp.

463{
464 mSubMenuList.emplace_back( tName );
465 mbSeparatorAllowed = false;
466 return mSubMenuList.back().menu.get();
467}
SubMenuList mSubMenuList

References mbSeparatorAllowed, and mSubMenuList.

Referenced by BeginMenu().

Here is the caller graph for this function:

◆ Check()

void CommandManager::Check ( const CommandID name,
bool  checked 
)

Definition at line 1001 of file CommandManager.cpp.

1002{
1004 if (!entry || !entry->menu || entry->isOccult) {
1005 return;
1006 }
1007 entry->menu->Check(entry->id, checked);
1008}
CommandNameHash mCommandNameHash

References entry, mCommandNameHash, and name.

◆ CurrentMenu()

wxMenu * CommandManager::CurrentMenu ( ) const

This returns the current menu that we're appending to - note that it could be a submenu if BeginSubMenu was called and we haven't reached EndSubMenu yet.

Definition at line 505 of file CommandManager.cpp.

506{
507 if(!mCurrentMenu)
508 return NULL;
509
510 wxMenu * tmpCurrentSubMenu = CurrentSubMenu();
511
512 if(!tmpCurrentSubMenu)
513 {
514 return mCurrentMenu;
515 }
516
517 return tmpCurrentSubMenu;
518}
wxMenu * CurrentSubMenu() const

References CurrentSubMenu(), and mCurrentMenu.

Referenced by AddItem(), AddItemList(), AddSeparator(), BeginOccultCommands(), and EndSubMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CurrentMenuBar()

wxMenuBar * CommandManager::CurrentMenuBar ( ) const
private

Retrieve the 'current' menubar; either NULL or the last on in the mMenuBarList.

Definition at line 383 of file CommandManager.cpp.

384{
385 if(mMenuBarList.empty())
386 return NULL;
387
388 return mMenuBarList.back().menubar;
389}

References mMenuBarList.

Referenced by EndMainMenu().

Here is the caller graph for this function:

◆ CurrentSubMenu()

wxMenu * CommandManager::CurrentSubMenu ( ) const
private

This returns the 'Current' Submenu, which is the one at the end of the mSubMenuList (or NULL, if it doesn't exist).

Definition at line 493 of file CommandManager.cpp.

494{
495 if(mSubMenuList.empty())
496 return NULL;
497
498 return mSubMenuList.back().menu.get();
499}

References mSubMenuList.

Referenced by CurrentMenu().

Here is the caller graph for this function:

◆ DescribeCommandsAndShortcuts()

TranslatableString CommandManager::DescribeCommandsAndShortcuts ( const ComponentInterfaceSymbol  commands[],
size_t  nCommands 
) const

Formatting summaries that include shortcut keys

Definition at line 1035 of file CommandManager.cpp.

1037{
1038 wxString mark;
1039 // This depends on the language setting and may change in-session after
1040 // change of preferences:
1041 bool rtl = (wxLayout_RightToLeft == wxTheApp->GetLayoutDirection());
1042 if (rtl)
1043 mark = wxT("\u200f");
1044
1045 static const wxString &separatorFormat = wxT("%s / %s");
1046 TranslatableString result;
1047 for (size_t ii = 0; ii < nCommands; ++ii) {
1048 const auto &pair = commands[ii];
1049 // If RTL, then the control character forces right-to-left sequencing of
1050 // "/" -separated command names, and puts any "(...)" shortcuts to the
1051 // left, consistently with accelerators in menus (assuming matching
1052 // operating system preferences for language), even if the command name
1053 // was missing from the translation file and defaulted to the English.
1054
1055 // Note: not putting this and other short format strings in the
1056 // translation catalogs
1057 auto piece = Verbatim( wxT("%s%s") )
1058 .Format( mark, pair.Msgid().Stripped() );
1059
1060 auto name = pair.Internal();
1061 if (!name.empty()) {
1062 auto keyStr = GetKeyFromName(name);
1063 if (!keyStr.empty()){
1064 auto keyString = keyStr.Display(true);
1065 auto format = wxT("%s %s(%s)");
1066#ifdef __WXMAC__
1067 // The unicode controls push and pop left-to-right embedding.
1068 // This keeps the directionally weak characters, such as uparrow
1069 // for Shift, left of the key name,
1070 // consistently with how menu accelerators appear, even when the
1071 // system language is RTL.
1072 format = wxT("%s %s(\u202a%s\u202c)");
1073#endif
1074 // The mark makes correctly placed parentheses for RTL, even
1075 // in the case that the piece is untranslated.
1076 piece = Verbatim( format ).Format( piece, mark, keyString );
1077 }
1078 }
1079
1080 if (result.empty())
1081 result = piece;
1082 else
1083 result = Verbatim( separatorFormat ).Format( result, piece );
1084 }
1085 return result;
1086}
int format
Definition: ExportPCM.cpp:53
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
NormalizedKeyString GetKeyFromName(const CommandID &name) const
Holds a msgid for the translation catalog; may also bind format arguments.
TranslatableString & Format(Args &&...args) &
Capture variadic format arguments (by copy) when there is no plural.

References TranslatableString::empty(), TranslatableString::Format(), format, GetKeyFromName(), name, Verbatim(), and wxT().

Here is the call graph for this function:

◆ DoRepeatProcess()

void CommandManager::DoRepeatProcess ( const CommandContext context,
int  id 
)

Definition at line 1303 of file CommandManager.cpp.

1303 {
1304 mLastProcessId = 0; //Don't Process this as repeat
1306 // Discriminate the union entry->callback by entry->finder
1307 if (auto &finder = entry->finder) {
1308 auto &handler = finder(context.project);
1309 (handler.*(entry->callback.memberFn))(context);
1310 }
1311 else
1312 (entry->callback.nonMemberFn)(context);
1313}
int id
AudacityProject & project
CommandNumericIDHash mCommandNumericIDHash

References entry, cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, id, mCommandNumericIDHash, mLastProcessId, and CommandContext::project.

Referenced by anonymous_namespace{PluginMenus.cpp}::OnRepeatLastAnalyzer(), and anonymous_namespace{BatchProcessDialog.cpp}::OnRepeatLastTool().

Here is the caller graph for this function:

◆ Enable() [1/2]

void CommandManager::Enable ( CommandListEntry entry,
bool  enabled 
)
private

Enables or disables a menu item based on its name (not the label in the menu bar, but the name of the command.) If you give it the name of a multi-item (one that was added using AddItemList(), it will enable or disable all of them at once

Definition at line 903 of file CommandManager.cpp.

904{
905 if (!entry->menu) {
906 entry->enabled = enabled;
907 return;
908 }
909
910 // LL: Refresh from real state as we can get out of sync on the
911 // Mac due to its reluctance to enable menus when in a modal
912 // state.
913 entry->enabled = entry->menu->IsEnabled(entry->id);
914
915 // Only enabled if needed
916 if (entry->enabled != enabled) {
917 entry->menu->Enable(entry->id, enabled);
918 entry->enabled = entry->menu->IsEnabled(entry->id);
919 }
920
921 if (entry->multi) {
922 int i;
923 int ID = entry->id;
924
925 for(i=1; i<entry->count; i++) {
926 ID = NextIdentifier(ID);
927
928 // This menu item is not necessarily in the same menu, because
929 // multi-items can be spread across multiple sub menus
930 CommandListEntry *multiEntry = mCommandNumericIDHash[ID];
931 if (multiEntry) {
932 wxMenuItem *item = multiEntry->menu->FindItem(ID);
933
934 if (item) {
935 item->Enable(enabled);
936 } else {
937 // using GET in a log message for devs' eyes only
938 wxLogDebug(wxT("Warning: Menu entry with id %i in %s not found"),
939 ID, entry->name.GET());
940 }
941 } else {
942 wxLogDebug(wxT("Warning: Menu entry with id %i not in hash"), ID);
943 }
944 }
945 }
946}
int NextIdentifier(int ID)
wxMenu * menu

References entry, mCommandNumericIDHash, CommandListEntry::menu, NextIdentifier(), and wxT().

Here is the call graph for this function:

◆ Enable() [2/2]

void CommandManager::Enable ( const wxString &  name,
bool  enabled 
)

Definition at line 948 of file CommandManager.cpp.

949{
951 if (!entry || !entry->menu) {
952 wxLogDebug(wxT("Warning: Unknown command enabled: '%s'"),
953 (const wxChar*)name);
954 return;
955 }
956
957 Enable(entry, enabled);
958}
void Enable(const wxString &name, bool enabled)

References Enable(), entry, mCommandNameHash, name, and wxT().

Referenced by Enable(), and EnableUsingFlags().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnableUsingFlags()

void CommandManager::EnableUsingFlags ( CommandFlag  flags,
CommandFlag  strictFlags 
)

Definition at line 960 of file CommandManager.cpp.

962{
963 // strictFlags are a subset of flags. strictFlags represent the real
964 // conditions now, but flags are the conditions that could be made true.
965 // Some commands use strict flags only, refusing the chance to fix
966 // conditions
967 wxASSERT( (strictFlags & ~flags).none() );
968
969 for(const auto &entry : mCommandList) {
970 if (entry->multi && entry->index != 0)
971 continue;
972 if( entry->isOccult )
973 continue;
974
975 auto useFlags = entry->useStrictFlags ? strictFlags : flags;
976
977 if (entry->flags.any()) {
978 bool enable = ((useFlags & entry->flags) == entry->flags);
979 Enable(entry.get(), enable);
980 }
981 }
982}
@ none
Definition: Dither.h:20
CommandList mCommandList

References Enable(), entry, mCommandList, and none.

Here is the call graph for this function:

◆ EndMainMenu()

void CommandManager::EndMainMenu ( )
private

This attaches a menu to the menubar and ends the menu

Definition at line 446 of file CommandManager.cpp.

447{
448 // Add the menu to the menubar after all menu items have been
449 // added to the menu to allow OSX to rearrange special menu
450 // items like Preferences, About, and Quit.
451 wxASSERT(uCurrentMenu);
452 CurrentMenuBar()->Append(
454 mCurrentMenu = nullptr;
456}
wxMenuBar * CurrentMenuBar() const
wxString Translation() const

References COMMAND, CurrentMenuBar(), mCurrentMenu, mCurrentMenuName, TranslatableString::Translation(), and uCurrentMenu.

Referenced by EndMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EndMenu()

void CommandManager::EndMenu ( )

This attaches a menu, if it's main, to the menubar.

Definition at line 422 of file CommandManager.cpp.

423{
424 if ( mSubMenuList.empty() )
425 EndMainMenu();
426 else
427 EndSubMenu();
428}

References EndMainMenu(), EndSubMenu(), and mSubMenuList.

Here is the call graph for this function:

◆ EndOccultCommands()

void CommandManager::EndOccultCommands ( )

Definition at line 1613 of file CommandManager.cpp.

1614{
1615 PopMenuBar();
1616 bMakingOccultCommands = false;
1617 mTempMenuBar.reset();
1618}

References bMakingOccultCommands, mTempMenuBar, and PopMenuBar().

Here is the call graph for this function:

◆ EndSubMenu()

void CommandManager::EndSubMenu ( )
private

This function is called after the final item of a SUBmenu is added. Submenu items are added just like regular menu items; they just happen after BeginSubMenu() is called but before EndSubMenu() is called.

Definition at line 474 of file CommandManager.cpp.

475{
476 //Save the submenu's information
477 SubMenuListEntry tmpSubMenu{ std::move( mSubMenuList.back() ) };
478
479 //Pop off the NEW submenu so CurrentMenu returns the parent of the submenu
480 mSubMenuList.pop_back();
481
482 //Add the submenu to the current menu
483 auto name = tmpSubMenu.name.Translation();
484 CurrentMenu()->Append(0, name, tmpSubMenu.menu.release(),
485 name /* help string */ );
486 mbSeparatorAllowed = true;
487}
SubMenuListEntry is a structure used by CommandManager.

References CurrentMenu(), mbSeparatorAllowed, mSubMenuList, name, and TranslatableString::Translation().

Referenced by EndMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExcludedList()

const std::vector< NormalizedKeyString > & CommandManager::ExcludedList ( )
static

Definition at line 238 of file CommandManager.cpp.

239{
240 static const auto list = [] {
241 // These short cuts are for the max list only....
242 const char *const strings[] = {
243 // "Ctrl+I",
244 "Ctrl+Alt+I",
245 "Ctrl+J",
246 "Ctrl+Alt+J",
247 "Ctrl+Alt+V",
248 "Alt+X",
249 "Alt+K",
250 "Shift+Alt+X",
251 "Shift+Alt+K",
252 "Alt+L",
253 "Shift+Alt+C",
254 "Alt+I",
255 "Alt+J",
256 "Shift+Alt+J",
257 "Ctrl+Shift+A",
258 //"Q",
259 //"Shift+J",
260 //"Shift+K",
261 //"Shift+Home",
262 //"Shift+End",
263 "Ctrl+[",
264 "Ctrl+]",
265 "1",
266 "Shift+F5",
267 "Shift+F6",
268 "Shift+F7",
269 "Shift+F8",
270 "Ctrl+Shift+F5",
271 "Ctrl+Shift+F7",
272 "Ctrl+Shift+N",
273 "Ctrl+Shift+M",
274 "Ctrl+Home",
275 "Ctrl+End",
276 "Shift+C",
277 "Alt+Shift+Up",
278 "Alt+Shift+Down",
279 "Shift+P",
280 "Alt+Shift+Left",
281 "Alt+Shift+Right",
282 "Ctrl+Shift+T",
283 //"Command+M",
284 //"Option+Command+M",
285 "Shift+H",
286 "Shift+O",
287 "Shift+I",
288 "Shift+N",
289 "D",
290 "A",
291 "Alt+Shift+F6",
292 "Alt+F6",
293 };
294
295 std::vector<NormalizedKeyString> result(
296 std::begin(strings), std::end(strings)
297 );
298 std::sort( result.begin(), result.end() );
299 return result;
300 }();
301 return list;
302}
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References PackedArray::begin(), and PackedArray::end().

Referenced by KeyConfigPrefs::FilterKeys(), and SetMaxList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FilterKeyEvent()

bool CommandManager::FilterKeyEvent ( AudacityProject project,
const wxKeyEvent &  evt,
bool  permit = false 
)

Definition at line 1091 of file CommandManager.cpp.

1092{
1093 if (!project)
1094 return false;
1095
1096 auto pWindow = FindProjectFrame( project );
1098 if (entry == NULL)
1099 {
1100 return false;
1101 }
1102
1103 int type = evt.GetEventType();
1104
1105 // Global commands aren't tied to any specific project
1106 if (entry->isGlobal && type == wxEVT_KEY_DOWN)
1107 {
1108 // Global commands are always disabled so they do not interfere with the
1109 // rest of the command handling. But, to use the common handler, we
1110 // enable them temporarily and then disable them again after handling.
1111 // LL: Why do they need to be disabled???
1112 entry->enabled = false;
1113 auto cleanup = valueRestorer( entry->enabled, true );
1114 return HandleCommandEntry(*project, entry, NoFlagsSpecified, false, &evt);
1115 }
1116
1117 wxWindow * pFocus = wxWindow::FindFocus();
1118 wxWindow * pParent = wxGetTopLevelParent( pFocus );
1119 bool validTarget = pParent == pWindow;
1120 // Bug 1557. MixerBoard should count as 'destined for project'
1121 // MixerBoard IS a TopLevelWindow, and its parent is the project.
1122 if( pParent && pParent->GetParent() == pWindow ){
1123 if(auto keystrokeHandlingWindow = dynamic_cast< TopLevelKeystrokeHandlingWindow* >( pParent ))
1124 validTarget = keystrokeHandlingWindow->HandleCommandKeystrokes();
1125 }
1126 validTarget = validTarget && wxEventLoop::GetActive()->IsMain();
1127
1128 // Any other keypresses must be destined for this project window
1129 if (!permit && !validTarget )
1130 {
1131 return false;
1132 }
1133
1134 auto flags = MenuManager::Get(*project).GetUpdateFlags();
1135
1136 wxKeyEvent temp = evt;
1137
1138 // Possibly let wxWidgets do its normal key handling IF it is one of
1139 // the standard navigation keys.
1140 if((type == wxEVT_KEY_DOWN) || (type == wxEVT_KEY_UP ))
1141 {
1142 wxWindow * pWnd = wxWindow::FindFocus();
1143 bool bIntercept =
1144 pWnd && !dynamic_cast< NonKeystrokeInterceptingWindow * >( pWnd );
1145
1146 //wxLogDebug("Focus: %p TrackPanel: %p", pWnd, pTrackPanel );
1147 // We allow the keystrokes below to be handled by wxWidgets controls IF we are
1148 // in some sub window rather than in the TrackPanel itself.
1149 // Otherwise they will go to our command handler and if it handles them
1150 // they will NOT be available to wxWidgets.
1151 if( bIntercept ){
1152 switch( evt.GetKeyCode() ){
1153 case WXK_LEFT:
1154 case WXK_RIGHT:
1155 case WXK_UP:
1156 case WXK_DOWN:
1157 // Don't trap WXK_SPACE (Bug 1727 - SPACE not starting/stopping playback
1158 // when cursor is in a time control)
1159 // case WXK_SPACE:
1160 case WXK_TAB:
1161 case WXK_BACK:
1162 case WXK_HOME:
1163 case WXK_END:
1164 case WXK_RETURN:
1165 case WXK_NUMPAD_ENTER:
1166 case WXK_DELETE:
1167 case '0':
1168 case '1':
1169 case '2':
1170 case '3':
1171 case '4':
1172 case '5':
1173 case '6':
1174 case '7':
1175 case '8':
1176 case '9':
1177 return false;
1178 }
1179 }
1180 }
1181
1182 if (type == wxEVT_KEY_DOWN)
1183 {
1184 if (entry->skipKeydown)
1185 {
1186 return true;
1187 }
1188 return HandleCommandEntry(*project, entry, flags, false, &temp);
1189 }
1190
1191 if (type == wxEVT_KEY_UP && entry->wantKeyup)
1192 {
1193 return HandleCommandEntry(*project, entry, flags, false, &temp);
1194 }
1195
1196 return false;
1197}
NormalizedKeyString KeyEventToKeyString(const wxKeyEvent &event)
Definition: Keyboard.cpp:83
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:234
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
CommandKeyHash mCommandKeyHash
bool HandleCommandEntry(AudacityProject &project, const CommandListEntry *entry, CommandFlag flags, bool alwaysEnabled, const wxEvent *evt=nullptr, const CommandContext *pGivenContext=nullptr)
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:69
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:533

References entry, FindProjectFrame(), MenuManager::Get(), MenuManager::GetUpdateFlags(), HandleCommandEntry(), KeyEventToKeyString(), mCommandKeyHash, NoFlagsSpecified, and valueRestorer().

Here is the call graph for this function:

◆ FormatLabelForMenu() [1/3]

wxString CommandManager::FormatLabelForMenu ( const CommandID id,
const TranslatableString pLabel 
) const

Format a string appropriate for insertion in a menu.

Parameters
pLabelif not null, use this instead of the manager's stored label

Definition at line 808 of file CommandManager.cpp.

810{
811 NormalizedKeyString keyStr;
812 if (auto iter = mCommandNameHash.find(id); iter != mCommandNameHash.end()) {
813 if (auto pEntry = iter->second) {
814 keyStr = pEntry->key;
815 if (!pLabel)
816 pLabel = &pEntry->label;
817 }
818 }
819 if (pLabel)
820 return FormatLabelForMenu(*pLabel, keyStr);
821 return {};
822}

References FormatLabelForMenu(), and mCommandNameHash.

Referenced by AddItemList(), FormatLabelForMenu(), and Modify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FormatLabelForMenu() [2/3]

wxString CommandManager::FormatLabelForMenu ( const CommandListEntry entry) const
private

Definition at line 824 of file CommandManager.cpp.

825{
826 return FormatLabelForMenu( entry->label, entry->key );
827}

References entry, and FormatLabelForMenu().

Here is the call graph for this function:

◆ FormatLabelForMenu() [3/3]

wxString CommandManager::FormatLabelForMenu ( const TranslatableString translatableLabel,
const NormalizedKeyString keyStr 
) const
private

Definition at line 829 of file CommandManager.cpp.

832{
833 auto label = translatableLabel.Translation();
834 auto key = keyStr.GET();
835 if (!key.empty())
836 {
837 // using GET to compose menu item name for wxWidgets
838 label += wxT("\t") + key;
839 }
840
841 return label;
842}
static const AudacityProject::AttachedObjects::RegisteredFactory key
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66

References Identifier::GET(), key, label, TranslatableString::Translation(), and wxT().

Here is the call graph for this function:

◆ FormatLabelWithDisabledAccel()

wxString CommandManager::FormatLabelWithDisabledAccel ( const CommandListEntry entry) const
private

Definition at line 849 of file CommandManager.cpp.

850{
851 auto label = entry->label.Translation();
852#if 1
853 wxString Accel;
854 do{
855 if (!entry->key.empty())
856 {
857 // Dummy accelerator that looks Ok in menus but is non functional.
858 // Note the space before the key.
859#ifdef __WXMSW__
860 // using GET to compose menu item name for wxWidgets
861 auto key = entry->key.GET();
862 Accel = wxString("\t ") + key;
863 if( key.StartsWith("Left" )) break;
864 if( key.StartsWith("Right")) break;
865 if( key.StartsWith("Up" )) break;
866 if( key.StartsWith("Down")) break;
867 if( key.StartsWith("Return")) break;
868 if( key.StartsWith("Tab")) break;
869 if( key.StartsWith("Shift+Tab")) break;
870 if( key.StartsWith("0")) break;
871 if( key.StartsWith("1")) break;
872 if( key.StartsWith("2")) break;
873 if( key.StartsWith("3")) break;
874 if( key.StartsWith("4")) break;
875 if( key.StartsWith("5")) break;
876 if( key.StartsWith("6")) break;
877 if( key.StartsWith("7")) break;
878 if( key.StartsWith("8")) break;
879 if( key.StartsWith("9")) break;
880 // Uncomment the below so as not to add the illegal accelerators.
881 // Accel = "";
882 //if( entry->key.StartsWith("Space" )) break;
883 // These ones appear to be illegal already and mess up accelerator processing.
884 if( key.StartsWith("NUMPAD_ENTER" )) break;
885 if( key.StartsWith("Backspace" )) break;
886 if( key.StartsWith("Delete" )) break;
887#endif
888 //wxLogDebug("Added Accel:[%s][%s]", entry->label, entry->key );
889 // Normal accelerator.
890 // using GET to compose menu item name for wxWidgets
891 Accel = wxString("\t") + entry->key.GET();
892 }
893 } while (false );
894 label += Accel;
895#endif
896 return label;
897}

References entry, key, and label.

Referenced by AddItem().

Here is the caller graph for this function:

◆ Get() [1/2]

CommandManager & CommandManager::Get ( AudacityProject project)
static

Definition at line 206 of file CommandManager.cpp.

207{
208 return project.AttachedObjects::Get< CommandManager >( key );
209}
CommandManager implements a system for organizing all user-callable commands.

References key.

Referenced by SelectUtilities::ActivatePlayRegion(), MacroCommands::ApplyCommand(), ScreenshotCommand::CaptureCommands(), ScreenshotCommand::CapturePreferences(), MenuCreator::CreateMenusAndCommands(), CommonTrackPanelCell::DoContextMenu(), EffectUI::DoEffect(), GetInfoCommand::ExploreMenu(), ToolBarButtons::ForAllButtons(), Get(), SelectUtilities::InactivatePlayRegion(), AudacityApp::InitPart2(), MacroCommandsCatalog::MacroCommandsCatalog(), ToolManager::ModifyToolbarMenus(), MenuManager::ModifyUndoMenuItems(), ViewActions::Handler::OnAdvancedVZoom(), anonymous_namespace{BatchProcessDialog.cpp}::OnApplyMacroDirectlyByName(), anonymous_namespace{BatchProcessDialog.cpp}::OnApplyMacrosPalette(), anonymous_namespace{PluginMenus.cpp}::OnBenchmark(), ToolBarButtons::OnButton(), anonymous_namespace{Contrast.cpp}::anonymous_namespace{Contrast.cpp}::OnContrast(), anonymous_namespace{PluginMenus.cpp}::OnDetectUpstreamDropouts(), LyricsPanel::OnKeyEvent(), MixerBoardFrame::OnKeyEvent(), anonymous_namespace{BatchProcessDialog.cpp}::OnManageMacros(), ProjectWindow::OnMenu(), anonymous_namespace{FreqWindow.cpp}::OnPlotSpectrum(), anonymous_namespace{PluginMenus.cpp}::OnRepeatLastAnalyzer(), anonymous_namespace{BatchProcessDialog.cpp}::OnRepeatLastTool(), anonymous_namespace{Screenshot.cpp}::OnScreenshot(), ViewActions::Handler::OnShowClipping(), ViewActions::Handler::OnShowExtraMenus(), ViewActions::Handler::OnShowNameOverlay(), anonymous_namespace{PluginMenus.cpp}::OnSimulateRecordingErrors(), KeyConfigPrefs::Populate(), SelectHandle::Preview(), MenuCreator::RebuildMenuBar(), MenuManager::ReportIfActionNotAllowed(), ToolBar::SetButtonToolTip(), MuteButtonHandle::Tip(), SoloButtonHandle::Tip(), MenuButtonHandle::Tip(), CloseButtonHandle::Tip(), and MenuManager::UpdateMenus().

Here is the caller graph for this function:

◆ Get() [2/2]

const CommandManager & CommandManager::Get ( const AudacityProject project)
static

Definition at line 211 of file CommandManager.cpp.

212{
213 return Get( const_cast< AudacityProject & >( project ) );
214}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static CommandManager & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ GetAllCommandData()

void CommandManager::GetAllCommandData ( CommandIDs names,
std::vector< NormalizedKeyString > &  keys,
std::vector< NormalizedKeyString > &  default_keys,
TranslatableStrings labels,
TranslatableStrings categories,
bool  includeMultis 
)

Definition at line 1439 of file CommandManager.cpp.

1449{
1450 for(const auto &entry : mCommandList) {
1451 // GetAllCommandData is used by KeyConfigPrefs.
1452 // It does need the effects.
1453 //if ( entry->isEffect )
1454 // continue;
1455 if ( !entry->multi || includeMultis )
1456 {
1457 names.push_back(entry->name);
1458 keys.push_back(entry->key);
1459 default_keys.push_back(entry->defaultKey);
1460 labels.push_back(entry->label);
1461 categories.push_back(entry->labelTop);
1462#if defined(EXPERIMENTAL_KEY_VIEW)
1463 prefixes.push_back(entry->labelPrefix);
1464#endif
1465 }
1466 }
1467}
static TranslatableStrings names
Definition: TagsEditor.cpp:152

References entry, mCommandList, and names.

Referenced by KeyConfigPrefs::RefreshBindings().

Here is the caller graph for this function:

◆ GetAllCommandLabels()

void CommandManager::GetAllCommandLabels ( TranslatableStrings labels,
std::vector< bool > &  vExcludeFromMacros,
bool  includeMultis 
) const

Definition at line 1420 of file CommandManager.cpp.

1423{
1424 vExcludeFromMacros.clear();
1425 for(const auto &entry : mCommandList) {
1426 // This is fetching commands from the menus, for use as batch commands.
1427 // Until we have properly merged EffectManager and CommandManager
1428 // we explicitly exclude effects, as they are already handled by the
1429 // effects Manager.
1430 if ( entry->isEffect )
1431 continue;
1432 if (!entry->multi)
1433 names.push_back(entry->longLabel), vExcludeFromMacros.push_back(entry->excludeFromMacros);
1434 else if( includeMultis )
1435 names.push_back(entry->longLabel), vExcludeFromMacros.push_back(entry->excludeFromMacros);
1436 }
1437}

References entry, mCommandList, and names.

◆ GetAllCommandNames()

void CommandManager::GetAllCommandNames ( CommandIDs names,
bool  includeMultis 
) const

Definition at line 1407 of file CommandManager.cpp.

1409{
1410 for(const auto &entry : mCommandList) {
1411 if ( entry->isEffect )
1412 continue;
1413 if (!entry->multi)
1414 names.push_back(entry->name);
1415 else if( includeMultis )
1416 names.push_back(entry->name );// + wxT(":")/*+ mCommandList[i]->label*/);
1417 }
1418}

References entry, mCommandList, and names.

◆ GetCategories()

TranslatableStrings CommandManager::GetCategories ( AudacityProject )

Definition at line 1375 of file CommandManager.cpp.

1376{
1378
1379 for (const auto &entry : mCommandList) {
1380 auto &cat = entry->labelTop;
1381 if ( ! make_iterator_range( cats ).contains(cat) ) {
1382 cats.push_back(cat);
1383 }
1384 }
1385#if 0
1386 mCommandList.size(); i++) {
1387 if (includeMultis || !mCommandList[i]->multi)
1388 names.push_back(mCommandList[i]->name);
1389 }
1390
1391 if (p == NULL) {
1392 return;
1393 }
1394
1395 wxMenuBar *bar = p->GetMenuBar();
1396 size_t cnt = bar->GetMenuCount();
1397 for (size_t i = 0; i < cnt; i++) {
1398 cats.push_back(bar->GetMenuLabelText(i));
1399 }
1400
1401 cats.push_back(COMMAND);
1402#endif
1403
1404 return cats;
1405}
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:431
std::vector< TranslatableString > TranslatableStrings

References COMMAND, entry, make_iterator_range(), mCommandList, name, and names.

Here is the call graph for this function:

◆ GetCategoryFromName()

TranslatableString CommandManager::GetCategoryFromName ( const CommandID name)

Definition at line 1500 of file CommandManager.cpp.

1501{
1503 if (!entry)
1504 return {};
1505
1506 return entry->labelTop;
1507}

References entry, mCommandNameHash, and name.

Referenced by KeyConfigPrefs::OnSet().

Here is the caller graph for this function:

◆ GetDefaultKeyFromName()

NormalizedKeyString CommandManager::GetDefaultKeyFromName ( const CommandID name)

Definition at line 1520 of file CommandManager.cpp.

1521{
1523 if (!entry)
1524 return {};
1525
1526 return entry->defaultKey;
1527}

References entry, mCommandNameHash, and name.

Referenced by KeyConfigPrefs::OnSet().

Here is the caller graph for this function:

◆ GetEnabled()

bool CommandManager::GetEnabled ( const CommandID name)

Definition at line 984 of file CommandManager.cpp.

985{
987 if (!entry || !entry->menu) {
988 // using GET in a log message for devs' eyes only
989 wxLogDebug(wxT("Warning: command doesn't exist: '%s'"),
990 name.GET());
991 return false;
992 }
993 return entry->enabled;
994}

References entry, mCommandNameHash, name, and wxT().

Referenced by ToolBarButtons::ForAllButtons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetKeyFromName()

NormalizedKeyString CommandManager::GetKeyFromName ( const CommandID name) const

Definition at line 1509 of file CommandManager.cpp.

1510{
1512 // May create a NULL entry
1513 const_cast<CommandManager*>(this)->mCommandNameHash[name];
1514 if (!entry)
1515 return {};
1516
1517 return entry->key;
1518}

References entry, mCommandNameHash, and name.

Referenced by DescribeCommandsAndShortcuts(), KeyConfigPrefs::MergeWithExistingKeys(), SelectHandle::Preview(), and KeyConfigPrefs::RefreshKeyInfo().

Here is the caller graph for this function:

◆ GetLabelFromName()

TranslatableString CommandManager::GetLabelFromName ( const CommandID name)

Definition at line 1477 of file CommandManager.cpp.

1478{
1480 if (!entry)
1481 return {};
1482
1483 return entry->longLabel;
1484}

References entry, mCommandNameHash, and name.

◆ GetMenuBar()

wxMenuBar * CommandManager::GetMenuBar ( const wxString &  sMenu) const
private

Retrieves the menubar based on the name given in AddMenuBar(name)

Definition at line 368 of file CommandManager.cpp.

369{
370 for (const auto &entry : mMenuBarList)
371 {
372 if(entry.name == sMenu)
373 return entry.menubar;
374 }
375
376 return NULL;
377}

References entry, and mMenuBarList.

Referenced by AddMenuBar().

Here is the caller graph for this function:

◆ GetNameFromNumericID()

CommandID CommandManager::GetNameFromNumericID ( int  id)

Definition at line 1469 of file CommandManager.cpp.

1470{
1472 if (!entry)
1473 return {};
1474 return entry->name;
1475}

References entry, id, and mCommandNumericIDHash.

◆ GetNumberOfKeysRead()

int CommandManager::GetNumberOfKeysRead ( ) const

Definition at line 996 of file CommandManager.cpp.

997{
998 return mXMLKeysRead;
999}

References mXMLKeysRead.

Referenced by KeyConfigPrefs::OnImport().

Here is the caller graph for this function:

◆ GetPrefixedLabelFromName()

TranslatableString CommandManager::GetPrefixedLabelFromName ( const CommandID name)

Definition at line 1486 of file CommandManager.cpp.

1487{
1489 if (!entry)
1490 return {};
1491
1492 if (!entry->labelPrefix.empty())
1493 return Verbatim( wxT("%s - %s") )
1494 .Format(entry->labelPrefix, entry->label)
1495 .Stripped();
1496 else
1497 return entry->label.Stripped();
1498}
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object

References entry, TranslatableString::Format(), mCommandNameHash, name, TranslatableString::Stripped(), Verbatim(), and wxT().

Referenced by KeyConfigPrefs::ContainsIllegalDups(), KeyConfigPrefs::MergeWithExistingKeys(), and KeyConfigPrefs::OnSet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleCommandEntry()

bool CommandManager::HandleCommandEntry ( AudacityProject project,
const CommandListEntry entry,
CommandFlag  flags,
bool  alwaysEnabled,
const wxEvent *  evt = nullptr,
const CommandContext pGivenContext = nullptr 
)
private

HandleCommandEntry() takes a CommandListEntry and executes it returning true iff successful. If you pass any flags, the command won't be executed unless the flags are compatible with the command's flags.

Definition at line 1230 of file CommandManager.cpp.

1234{
1235 if (!entry )
1236 return false;
1237
1238 if (flags != AlwaysEnabledFlag && !entry->enabled)
1239 return false;
1240
1241 if (!alwaysEnabled && entry->flags.any()) {
1242
1243 const auto NiceName = entry->label.Stripped(
1245 // NB: The call may have the side effect of changing flags.
1246 bool allowed =
1248 NiceName, flags, entry->flags );
1249 // If the function was disallowed, it STILL should count as having been
1250 // handled (by doing nothing or by telling the user of the problem).
1251 // Otherwise we may get other handlers having a go at obeying the command.
1252 if (!allowed)
1253 return true;
1254 mNiceName = NiceName;
1255 }
1256 else {
1257 mNiceName = {};
1258 }
1259
1260 Journal::Output({ JournalCode, entry->name.GET() });
1261
1262 CommandContext context{ project, evt, entry->index, entry->parameter };
1263 if (pGivenContext)
1264 context.temporarySelection = pGivenContext->temporarySelection;
1265 // Discriminate the union entry->callback by entry->finder
1266 if (auto &finder = entry->finder) {
1267 auto &handler = finder(project);
1268 (handler.*(entry->callback.memberFn))(context);
1269 }
1270 else
1271 (entry->callback.nonMemberFn)(context);
1272 mLastProcessId = 0;
1273 return true;
1274}
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
TemporarySelection temporarySelection
TranslatableString mNiceName
bool ReportIfActionNotAllowed(const TranslatableString &Name, CommandFlag &flags, CommandFlag flagsRqd)
Definition: Menus.cpp:637
void Output(const wxString &string)

References AlwaysEnabledFlag, TranslatableString::Ellipses, entry, MenuManager::Get(), cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, anonymous_namespace{CommandManager.cpp}::JournalCode, TranslatableString::MenuCodes, mLastProcessId, mNiceName, Journal::Output(), MenuManager::ReportIfActionNotAllowed(), and CommandContext::temporarySelection.

Referenced by FilterKeyEvent(), HandleMenuID(), and HandleTextualCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleMenuID()

bool CommandManager::HandleMenuID ( AudacityProject project,
int  id,
CommandFlag  flags,
bool  alwaysEnabled 
)

Call this when a menu event is received. If it matches a command, it will call the appropriate CommandManagerListener function. If you pass any flags, the command won't be executed unless the flags are compatible with the command's flags.

Definition at line 1321 of file CommandManager.cpp.

1323{
1326
1327 if (GlobalMenuHook::Call(entry->name))
1328 return true;
1329
1330 return HandleCommandEntry( project, entry, flags, alwaysEnabled );
1331}
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.

References GlobalHook< GlobalMenuHook, bool(const CommandID &) >::Call(), entry, HandleCommandEntry(), id, mCommandNumericIDHash, and mLastProcessId.

Here is the call graph for this function:

◆ HandleTextualCommand()

CommandManager::TextualCommandResult CommandManager::HandleTextualCommand ( const CommandID Str,
const CommandContext context,
CommandFlag  flags,
bool  alwaysEnabled 
)

HandleTextualCommand() allows us a limited version of script/batch behavior, since we can get from a string command name to the actual code to run.

Definition at line 1337 of file CommandManager.cpp.

1339{
1340 if( Str.empty() )
1341 return CommandFailure;
1342 // Linear search for now...
1343 for (const auto &entry : mCommandList)
1344 {
1345 if (!entry->multi)
1346 {
1347 // Testing against labelPrefix too allows us to call Nyquist functions by name.
1348 if( Str == entry->name ||
1349 // PRL: uh oh, mixing internal string (Str) with user-visible
1350 // (labelPrefix, which was initialized from a user-visible
1351 // sub-menu name)
1352 Str == entry->labelPrefix.Translation() )
1353 {
1354 return HandleCommandEntry(
1355 context.project, entry.get(), flags, alwaysEnabled,
1356 nullptr, &context)
1358 }
1359 }
1360 else
1361 {
1362 // Handle multis too...
1363 if( Str == entry->name )
1364 {
1365 return HandleCommandEntry(
1366 context.project, entry.get(), flags, alwaysEnabled,
1367 nullptr, &context)
1369 }
1370 }
1371 }
1372 return CommandNotFound;
1373}
bool empty() const
Definition: Identifier.h:61

References CommandFailure, CommandNotFound, CommandSuccess, Identifier::empty(), entry, HandleCommandEntry(), mCommandList, and CommandContext::project.

Referenced by CommandDispatch::HandleTextualCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleXMLChild()

XMLTagHandler * CommandManager::HandleXMLChild ( const std::string_view &  tag)
overrideprivatevirtual

Implements XMLTagHandler.

Definition at line 1578 of file CommandManager.cpp.

1579{
1580 return this;
1581}

◆ HandleXMLEndTag()

void CommandManager::HandleXMLEndTag ( const std::string_view &  tag)
overrideprivate

Definition at line 1565 of file CommandManager.cpp.

1566{
1567 /*
1568 if (tag == "audacitykeyboard") {
1569 AudacityMessageBox(
1570 XO("Loaded %d keyboard shortcuts\n")
1571 .Format( mXMLKeysRead ),
1572 XO("Loading Keyboard Shortcuts"),
1573 wxOK | wxCENTRE);
1574 }
1575 */
1576}

◆ HandleXMLTag()

bool CommandManager::HandleXMLTag ( const std::string_view &  tag,
const AttributesList attrs 
)
overrideprivatevirtual

Implements XMLTagHandler.

Definition at line 1529 of file CommandManager.cpp.

1530{
1531 if (tag == "audacitykeyboard") {
1532 mXMLKeysRead = 0;
1533 }
1534
1535 if (tag == "command") {
1536 wxString name;
1538
1539 for (auto pair : attrs)
1540 {
1541 auto attr = pair.first;
1542 auto value = pair.second;
1543
1544 if (value.IsStringView())
1545 {
1546 const wxString strValue = value.ToWString();
1547
1548 if (attr == "name")
1549 name = strValue;
1550 else if (attr == "key")
1551 key = NormalizedKeyString{ strValue };
1552 }
1553 }
1554
1555 if (mCommandNameHash[name]) {
1556 mCommandNameHash[name]->key = key;
1557 mXMLKeysRead++;
1558 }
1559 }
1560
1561 return true;
1562}

References key, mCommandNameHash, mXMLKeysRead, and name.

◆ Modify()

void CommandManager::Modify ( const wxString &  name,
const TranslatableString newLabel 
)

Changes the label text of a menu item.

Definition at line 1011 of file CommandManager.cpp.

1012{
1014 if (entry && entry->menu) {
1015 entry->label = newLabel;
1016 entry->menu->SetLabel(entry->id, FormatLabelForMenu(entry));
1017 }
1018}

References entry, FormatLabelForMenu(), mCommandNameHash, and name.

Referenced by RegisterLastAnalyzer(), and RegisterLastTool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NewIdentifier()

CommandListEntry * CommandManager::NewIdentifier ( const CommandID nameIn,
const TranslatableString label,
wxMenu *  menu,
CommandHandlerFinder  finder,
CommandFunctorPointer  callback,
const CommandID nameSuffix,
int  index,
int  count,
const Options options 
)
private

Given all of the information for a command, comes up with a NEW unique ID, adds it to a list, and returns the ID. WARNING: Does this conflict with the identifiers set for controls/windows? If it does, a workaround may be to keep controls below wxID_LOWEST and keep menus above wxID_HIGHEST

Definition at line 655 of file CommandManager.cpp.

664{
665 bool excludeFromMacros =
666 (options.allowInMacros == 0) ||
667 ((options.allowInMacros == -1) && label.MSGID().GET().Contains("..."));
668
669 const wxString & accel = options.accel;
670 bool bIsEffect = options.bIsEffect;
671 CommandID parameter = options.parameter == "" ? nameIn : options.parameter;
672
673 // if empty, new identifier's long label will be same as label, below:
674 const auto &longLabel = options.longName;
675
676 const bool multi = !nameSuffix.empty();
677 auto name = nameIn;
678
679 // If we have the identifier already, reuse it.
681 if (!prev);
682 else if( prev->label != label );
683 else if( multi );
684 else
685 return prev;
686
687 {
688 auto entry = std::make_unique<CommandListEntry>();
689
690 TranslatableString labelPrefix;
691 if (!mSubMenuList.empty())
692 labelPrefix = mSubMenuList.back().name.Stripped();
693
694 // For key bindings for commands with a list, such as align,
695 // the name in prefs is the category name plus the effect name.
696 // This feature is not used for built-in effects.
697 if (multi)
698 name = CommandID{ { name, nameSuffix }, wxT('_') };
699
700 // wxMac 2.5 and higher will do special things with the
701 // Preferences, Exit (Quit), and About menu items,
702 // if we give them the right IDs.
703 // Otherwise we just pick increasing ID numbers for each NEW
704 // command. Note that the name string we are comparing
705 // ("About", "Preferences") is the internal command name
706 // (untranslated), not the label that actually appears in the
707 // menu (which might be translated).
708
710 entry->id = mCurrentID;
711 entry->parameter = parameter;
712
713#if defined(__WXMAC__)
714 // See bug #2642 for some history as to why these items
715 // on Mac have their IDs set explicitly and not others.
716 if (name == wxT("Preferences"))
717 entry->id = wxID_PREFERENCES;
718 else if (name == wxT("Exit"))
719 entry->id = wxID_EXIT;
720 else if (name == wxT("About"))
721 entry->id = wxID_ABOUT;
722#endif
723
724 entry->name = name;
725 entry->label = label;
726
727 // long label is the same as label unless options specified otherwise:
728 entry->longLabel = longLabel.empty() ? label : longLabel;
729
730 entry->excludeFromMacros = excludeFromMacros;
731 entry->key = NormalizedKeyString{ accel.BeforeFirst(wxT('\t')) };
732 entry->defaultKey = entry->key;
733 entry->labelPrefix = labelPrefix;
734 entry->labelTop = mCurrentMenuName.Stripped();
735 entry->menu = menu;
736 entry->finder = finder;
737 entry->callback = callback;
738 entry->isEffect = bIsEffect;
739 entry->multi = multi;
740 entry->index = index;
741 entry->count = count;
742 entry->flags = AlwaysEnabledFlag;
743 entry->enabled = true;
744 entry->skipKeydown = options.skipKeyDown;
745 entry->wantKeyup = options.wantKeyUp || entry->skipKeydown;
746 entry->allowDup = options.allowDup;
747 entry->isGlobal = false;
748 entry->isOccult = bMakingOccultCommands;
749 entry->checkmarkFn = options.checker;
750
751 // Exclude accelerators that are in the MaxList.
752 // Note that the default is unaffected, intentionally so.
753 // There are effectively two levels of default, the full (max) list
754 // and the normal reduced list.
755 if( std::binary_search( mMaxListOnly.begin(), mMaxListOnly.end(),
756 entry->key ) )
757 entry->key = {};
758
759 // Key from preferences overrides the default key given
760 gPrefs->SetPath(wxT("/NewKeys"));
761 // using GET to interpret CommandID as a config path component
762 const auto &path = entry->name.GET();
763 if (gPrefs->HasEntry(path)) {
764 entry->key =
765 NormalizedKeyString{ gPrefs->ReadObject(path, entry->key) };
766 }
767 gPrefs->SetPath(wxT("/"));
768
769 mCommandList.push_back(std::move(entry));
770 // Don't use the variable entry eny more!
771 }
772
773 // New variable
776
777#if defined(_DEBUG)
778 prev = mCommandNameHash[entry->name];
779 if (prev) {
780 // Under Linux it looks as if we may ask for a newID for the same command
781 // more than once. So it's only an error if two different commands
782 // have the exact same name.
783 if( prev->label != entry->label )
784 {
785 wxLogDebug(wxT("Command '%s' defined by '%s' and '%s'"),
786 // using GET in a log message for devs' eyes only
787 entry->name.GET(),
788 prev->label.Debug(),
789 entry->label.Debug());
790 wxFAIL_MSG(wxString::Format(wxT("Command '%s' defined by '%s' and '%s'"),
791 // using GET in an assertion violation message for devs'
792 // eyes only
793 entry->name.GET(),
794 prev->label.Debug(),
795 entry->label.Debug()));
796 }
797 }
798#endif
800
801 if (!entry->key.empty()) {
803 }
804
805 return entry;
806}
FileConfig * gPrefs
Definition: Prefs.cpp:70
std::vector< NormalizedKeyString > mMaxListOnly
virtual bool HasEntry(const wxString &strName) const wxOVERRIDE
Definition: FileConfig.cpp:138
virtual void SetPath(const wxString &strPath) wxOVERRIDE
Definition: FileConfig.cpp:93
Identifier MSGID() const
MSGID is the English lookup key in the catalog, not necessarily for user's eyes if locale is some oth...
wxString Debug() const
Format as an English string for debugging logs and developers' eyes, not for end users.
TranslatableString label

References CommandManager::Options::accel, CommandManager::Options::allowDup, CommandManager::Options::allowInMacros, AlwaysEnabledFlag, CommandManager::Options::bIsEffect, bMakingOccultCommands, CommandManager::Options::checker, TranslatableString::Debug(), Identifier::empty(), entry, Identifier::GET(), gPrefs, FileConfig::HasEntry(), CommandListEntry::label, label, CommandManager::Options::longName, mCommandKeyHash, mCommandList, mCommandNameHash, mCommandNumericIDHash, mCurrentID, mCurrentMenuName, mMaxListOnly, TranslatableString::MSGID(), mSubMenuList, name, NextIdentifier(), CommandManager::Options::parameter, FileConfig::SetPath(), CommandManager::Options::skipKeyDown, TranslatableString::Stripped(), CommandManager::Options::wantKeyUp, and wxT().

Referenced by AddGlobalCommand(), AddItem(), and AddItemList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextIdentifier()

int CommandManager::NextIdentifier ( int  ID)
private

Definition at line 639 of file CommandManager.cpp.

640{
641 ID++;
642
643 //Skip the reserved identifiers used by wxWidgets
644 if((ID >= wxID_LOWEST) && (ID <= wxID_HIGHEST))
645 ID = wxID_HIGHEST+1;
646
647 return ID;
648}

Referenced by Enable(), and NewIdentifier().

Here is the caller graph for this function:

◆ operator=()

CommandManager & CommandManager::operator= ( const CommandManager )

◆ PopMenuBar()

void CommandManager::PopMenuBar ( )

Typically used to switch back and forth between adding to a hidden menu bar and adding to one that is visible

Definition at line 396 of file CommandManager.cpp.

397{
398 auto iter = mMenuBarList.end();
399 if ( iter != mMenuBarList.begin() )
400 mMenuBarList.erase( --iter );
401 else
402 wxASSERT( false );
403}

References mMenuBarList.

Referenced by EndOccultCommands().

Here is the caller graph for this function:

◆ PurgeData()

void CommandManager::PurgeData ( )

Definition at line 327 of file CommandManager.cpp.

328{
329 // mCommandList contains pointers to CommandListEntrys
330 // mMenuBarList contains MenuBarListEntrys.
331 // mSubMenuList contains SubMenuListEntrys
332 mCommandList.clear();
333 mMenuBarList.clear();
334 mSubMenuList.clear();
335
336 mCommandNameHash.clear();
337 mCommandKeyHash.clear();
338 mCommandNumericIDHash.clear();
339
341 mCurrentID = 17000;
342}

References COMMAND, mCommandKeyHash, mCommandList, mCommandNameHash, mCommandNumericIDHash, mCurrentID, mCurrentMenuName, mMenuBarList, and mSubMenuList.

Referenced by MenuCreator::RebuildMenuBar(), and ~CommandManager().

Here is the caller graph for this function:

◆ RegisterLastAnalyzer()

void CommandManager::RegisterLastAnalyzer ( const CommandContext context)

Definition at line 1278 of file CommandManager.cpp.

1278 {
1279 if (mLastProcessId != 0) {
1280 auto& menuManager = MenuManager::Get(context.project);
1281 menuManager.mLastAnalyzerRegistration = MenuCreator::repeattypeunique;
1282 menuManager.mLastAnalyzerRegisteredId = mLastProcessId;
1283 auto lastEffectDesc = XO("Repeat %s").Format(mNiceName);
1284 Modify(wxT("RepeatLastAnalyzer"), lastEffectDesc);
1285 }
1286 return;
1287}
XO("Cut/Copy/Paste")
void Modify(const wxString &name, const TranslatableString &newLabel)
Changes the label text of a menu item.
@ repeattypeunique
Definition: Menus.h:62

References MenuManager::Get(), mLastProcessId, mNiceName, Modify(), CommandContext::project, MenuCreator::repeattypeunique, wxT(), and XO().

Referenced by anonymous_namespace{Contrast.cpp}::anonymous_namespace{Contrast.cpp}::OnContrast(), and anonymous_namespace{FreqWindow.cpp}::OnPlotSpectrum().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterLastTool()

void CommandManager::RegisterLastTool ( const CommandContext context)

Definition at line 1291 of file CommandManager.cpp.

1291 {
1292 if (mLastProcessId != 0) {
1293 auto& menuManager = MenuManager::Get(context.project);
1294 menuManager.mLastToolRegistration = MenuCreator::repeattypeunique;
1295 menuManager.mLastToolRegisteredId = mLastProcessId;
1296 auto lastEffectDesc = XO("Repeat %s").Format(mNiceName);
1297 Modify(wxT("RepeatLastTool"), lastEffectDesc);
1298 }
1299 return;
1300}

References MenuManager::Get(), mLastProcessId, mNiceName, Modify(), CommandContext::project, MenuCreator::repeattypeunique, wxT(), and XO().

Referenced by anonymous_namespace{BatchProcessDialog.cpp}::OnApplyMacrosPalette(), anonymous_namespace{PluginMenus.cpp}::OnBenchmark(), anonymous_namespace{BatchProcessDialog.cpp}::OnManageMacros(), and anonymous_namespace{Screenshot.cpp}::OnScreenshot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveDuplicateShortcuts()

void CommandManager::RemoveDuplicateShortcuts ( )

Definition at line 1674 of file CommandManager.cpp.

1675{
1676 TranslatableString disabledShortcuts;
1677
1678 for (auto& entry : mCommandList) {
1679 if (!entry->key.empty() && entry->key != entry->defaultKey) { // user assigned
1680 for (auto& entry2 : mCommandList) {
1681 if (!entry2->key.empty() && entry2->key == entry2->defaultKey) { // default
1682 if (entry2->key == entry->key) {
1683 auto name = wxT("/NewKeys/") + entry2->name.GET();
1684 gPrefs->Write(name, NormalizedKeyString{});
1685
1686 disabledShortcuts +=
1687 XO("\n* %s, because you have assigned the shortcut %s to %s")
1688 .Format(entry2->label.Strip(), entry->key.GET(), entry->label.Strip());
1689 }
1690 }
1691 }
1692 }
1693 }
1694
1695 if (!disabledShortcuts.Translation().empty()) {
1696 TranslatableString message = XO("The following commands have had their shortcuts removed,"
1697 " because their default shortcut is new or changed, and is the same shortcut"
1698 " that you have assigned to another command.")
1699 + disabledShortcuts;
1700 AudacityMessageBox(message, XO("Shortcuts have been removed"), wxOK | wxCENTRE);
1701
1702 gPrefs->Flush();
1704 }
1705}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
static void RebuildAllMenuBars()
Definition: Menus.cpp:619

References AudacityMessageBox(), entry, FileConfig::Flush(), gPrefs, mCommandList, name, MenuCreator::RebuildAllMenuBars(), TranslatableString::Translation(), wxT(), and XO().

Referenced by AudacityApp::InitPart2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCommandFlags()

void CommandManager::SetCommandFlags ( const CommandID name,
CommandFlag  flags 
)

Definition at line 1620 of file CommandManager.cpp.

1622{
1624 if (entry)
1625 entry->flags = flags;
1626}

References entry, mCommandNameHash, and name.

Referenced by AddItem().

Here is the caller graph for this function:

◆ SetKeyFromIndex()

void CommandManager::SetKeyFromIndex ( int  i,
const NormalizedKeyString key 
)

Definition at line 1029 of file CommandManager.cpp.

1030{
1031 const auto &entry = mCommandList[i];
1032 entry->key = key;
1033}

References entry, key, and mCommandList.

Referenced by KeyConfigPrefs::Cancel(), KeyConfigPrefs::MergeWithExistingKeys(), and KeyConfigPrefs::OnImportDefaults().

Here is the caller graph for this function:

◆ SetKeyFromName()

void CommandManager::SetKeyFromName ( const CommandID name,
const NormalizedKeyString key 
)

Definition at line 1020 of file CommandManager.cpp.

1022{
1024 if (entry) {
1025 entry->key = key;
1026 }
1027}

References entry, key, mCommandNameHash, and name.

Referenced by KeyConfigPrefs::ClearAllKeys(), KeyConfigPrefs::OnImport(), KeyConfigPrefs::OnSet(), and KeyConfigPrefs::SetKeyForSelected().

Here is the caller graph for this function:

◆ SetMaxList()

void CommandManager::SetMaxList ( )

Definition at line 306 of file CommandManager.cpp.

307{
308
309 // This list is a DUPLICATE of the list in
310 // KeyConfigPrefs::OnImportDefaults(wxCommandEvent & event)
311
312 // TODO: At a later date get rid of the maxList entirely and
313 // instead use flags in the menu entries to indicate whether the default
314 // shortcut is standard or full.
315
316 mMaxListOnly.clear();
317
318 // if the full list, don't exclude any.
319 bool bFull = gPrefs->ReadBool(wxT("/GUI/Shortcuts/FullDefaults"),false);
320 if( bFull )
321 return;
322
324}
static const std::vector< NormalizedKeyString > & ExcludedList()

References ExcludedList(), gPrefs, mMaxListOnly, and wxT().

Referenced by CommandManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateCheckmarks()

void CommandManager::UpdateCheckmarks ( AudacityProject project)

Definition at line 520 of file CommandManager.cpp.

521{
522 for ( const auto &entry : mCommandList ) {
523 if ( entry->menu && entry->checkmarkFn && !entry->isOccult) {
524 entry->menu->Check( entry->id, entry->checkmarkFn( project ) );
525 }
526 }
527}

References entry, and mCommandList.

Referenced by SelectUtilities::ActivatePlayRegion(), SelectUtilities::InactivatePlayRegion(), and ToolManager::ModifyToolbarMenus().

Here is the caller graph for this function:

◆ WriteXML()

void CommandManager::WriteXML ( XMLWriter xmlFile) const

Definition at line 1583 of file CommandManager.cpp.

1585{
1586 xmlFile.StartTag(wxT("audacitykeyboard"));
1587 xmlFile.WriteAttr(wxT("audacityversion"), AUDACITY_VERSION_STRING);
1588
1589 for(const auto &entry : mCommandList) {
1590
1591 xmlFile.StartTag(wxT("command"));
1592 xmlFile.WriteAttr(wxT("name"), entry->name);
1593 xmlFile.WriteAttr(wxT("key"), entry->key);
1594 xmlFile.EndTag(wxT("command"));
1595 }
1596
1597 xmlFile.EndTag(wxT("audacitykeyboard"));
1598}
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:79
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:37
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:102

References entry, and wxT().

Referenced by KeyConfigPrefs::OnExport().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bMakingOccultCommands

bool CommandManager::bMakingOccultCommands
private

Definition at line 386 of file CommandManager.h.

Referenced by BeginOccultCommands(), EndOccultCommands(), and NewIdentifier().

◆ mbSeparatorAllowed

bool CommandManager::mbSeparatorAllowed
private

◆ mCommandKeyHash

CommandKeyHash CommandManager::mCommandKeyHash
private

Definition at line 373 of file CommandManager.h.

Referenced by FilterKeyEvent(), NewIdentifier(), and PurgeData().

◆ mCommandList

CommandList CommandManager::mCommandList
private

◆ mCommandNameHash

CommandNameHash CommandManager::mCommandNameHash
private

◆ mCommandNumericIDHash

CommandNumericIDHash CommandManager::mCommandNumericIDHash
private

◆ mCurrentID

int CommandManager::mCurrentID
private

Definition at line 375 of file CommandManager.h.

Referenced by NewIdentifier(), and PurgeData().

◆ mCurrentMenu

wxMenu* CommandManager::mCurrentMenu {}
private

Definition at line 384 of file CommandManager.h.

Referenced by BeginMainMenu(), BeginMenu(), CurrentMenu(), and EndMainMenu().

◆ mCurrentMenuName

TranslatableString CommandManager::mCurrentMenuName
private

Definition at line 380 of file CommandManager.h.

Referenced by BeginMainMenu(), EndMainMenu(), NewIdentifier(), and PurgeData().

◆ mLastProcessId

int CommandManager::mLastProcessId
private

◆ mMaxListOnly

std::vector<NormalizedKeyString> CommandManager::mMaxListOnly
private

Definition at line 367 of file CommandManager.h.

Referenced by NewIdentifier(), and SetMaxList().

◆ mMenuBarList

MenuBarList CommandManager::mMenuBarList
private

Definition at line 369 of file CommandManager.h.

Referenced by AddMenuBar(), CurrentMenuBar(), GetMenuBar(), PopMenuBar(), and PurgeData().

◆ mNiceName

TranslatableString CommandManager::mNiceName
private

Definition at line 381 of file CommandManager.h.

Referenced by HandleCommandEntry(), RegisterLastAnalyzer(), and RegisterLastTool().

◆ mSubMenuList

SubMenuList CommandManager::mSubMenuList
private

◆ mTempMenuBar

std::unique_ptr< wxMenuBar > CommandManager::mTempMenuBar
private

Definition at line 387 of file CommandManager.h.

Referenced by BeginOccultCommands(), and EndOccultCommands().

◆ mXMLKeysRead

int CommandManager::mXMLKeysRead
private

Definition at line 376 of file CommandManager.h.

Referenced by GetNumberOfKeysRead(), and HandleXMLTag().

◆ uCurrentMenu

std::unique_ptr<wxMenu> CommandManager::uCurrentMenu
private

Definition at line 383 of file CommandManager.h.

Referenced by BeginMainMenu(), and EndMainMenu().


The documentation for this class was generated from the following files: