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 221 of file CommandManager.cpp.

221 :
222 mCurrentID(17000),
224 bMakingOccultCommands( false )
225{
226 mbSeparatorAllowed = false;
227 SetMaxList();
228 mLastProcessId = 0;
229}
#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 234 of file CommandManager.cpp.

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

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 619 of file CommandManager.cpp.

624{
626 NewIdentifier(name, label_in, NULL, finder, callback,
627 {}, 0, 0, options);
628
629 entry->enabled = false;
630 entry->isGlobal = true;
631 entry->flags = AlwaysEnabledFlag;
632}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:35
const TranslatableString name
Definition: Distortion.cpp:82
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 533 of file CommandManager.cpp.

540{
541 if (options.global) {
542 //wxASSERT( flags == AlwaysEnabledFlag );
544 name, label_in, finder, callback, options );
545 return;
546 }
547
548 wxASSERT( flags != NoFlagsSpecified );
549
552 label_in,
553 CurrentMenu(), finder, callback,
554 {}, 0, 0,
555 options);
556 entry->useStrictFlags = options.useStrictFlags;
557 int ID = entry->id;
559
560 SetCommandFlags(name, flags);
561
562
563 auto &checker = options.checker;
564 if (checker) {
565 CurrentMenu()->AppendCheckItem(ID, label);
566 CurrentMenu()->Check(ID, checker( project ));
567 }
568 else {
569 CurrentMenu()->Append(ID, label);
570 }
571
572 mbSeparatorAllowed = true;
573}
constexpr CommandFlag NoFlagsSpecified
Definition: CommandFlag.h:36
TranslatableString label
Definition: TagsEditor.cpp:163
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 593 of file CommandManager.cpp.

600{
601 for (size_t i = 0, cnt = nItems; i < cnt; i++) {
604 items[i].Msgid(),
605 CurrentMenu(),
606 finder,
607 callback,
608 items[i].Internal(),
609 i,
610 cnt,
611 Options{}
612 .IsEffect(bIsEffect));
613 entry->flags = flags;
614 CurrentMenu()->Append(entry->id, FormatLabelForMenu(entry));
615 mbSeparatorAllowed = true;
616 }
617}
@ Internal
Indicates internal failure from Audacity.
wxString FormatLabelForMenu(const CommandID &id, const TranslatableString *pLabel) const
Format a string appropriate for insertion in a menu.
std::vector< CommandFlagOptions > & Options()
Definition: Menus.cpp:535

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 352 of file CommandManager.cpp.

353{
354 wxMenuBar *menuBar = GetMenuBar(sMenu);
355 if (menuBar) {
356 wxASSERT(false);
357 return {};
358 }
359
360 auto result = std::make_unique<wxMenuBar>();
361 mMenuBarList.emplace_back(sMenu, result.get());
362
363 return result;
364}
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 634 of file CommandManager.cpp.

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

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 436 of file CommandManager.cpp.

437{
438 uCurrentMenu = std::make_unique<wxMenu>();
440 mCurrentMenuName = tName;
441 return mCurrentMenu;
442}
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 411 of file CommandManager.cpp.

412{
413 if ( mCurrentMenu )
414 return BeginSubMenu( tName );
415 else
416 return BeginMainMenu( tName );
417}
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 1592 of file CommandManager.cpp.

1593{
1594 // To do: perhaps allow occult item switching at lower levels of the
1595 // menu tree.
1596 wxASSERT( !CurrentMenu() );
1597
1598 // Make a temporary menu bar collecting items added after.
1599 // This bar will be discarded but other side effects on the command
1600 // manager persist.
1601 mTempMenuBar = AddMenuBar(wxT("ext-menu"));
1602 bMakingOccultCommands = true;
1603}
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 464 of file CommandManager.cpp.

465{
466 mSubMenuList.emplace_back( tName );
467 mbSeparatorAllowed = false;
468 return mSubMenuList.back().menu.get();
469}
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 1003 of file CommandManager.cpp.

1004{
1006 if (!entry || !entry->menu || entry->isOccult) {
1007 return;
1008 }
1009 entry->menu->Check(entry->id, checked);
1010}
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 507 of file CommandManager.cpp.

508{
509 if(!mCurrentMenu)
510 return NULL;
511
512 wxMenu * tmpCurrentSubMenu = CurrentSubMenu();
513
514 if(!tmpCurrentSubMenu)
515 {
516 return mCurrentMenu;
517 }
518
519 return tmpCurrentSubMenu;
520}
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 385 of file CommandManager.cpp.

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

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 495 of file CommandManager.cpp.

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

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 1037 of file CommandManager.cpp.

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

1300 {
1301 mLastProcessId = 0; //Don't Process this as repeat
1303 auto& handler = entry->finder(context.project);
1304 (handler.*(entry->callback))(context);
1305}
int id
AudacityProject & project
CommandNumericIDHash mCommandNumericIDHash

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

Referenced by PluginActions::Handler::OnRepeatLastAnalyzer(), and PluginActions::Handler::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 905 of file CommandManager.cpp.

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

951{
953 if (!entry || !entry->menu) {
954 wxLogDebug(wxT("Warning: Unknown command enabled: '%s'"),
955 (const wxChar*)name);
956 return;
957 }
958
959 Enable(entry, enabled);
960}
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 962 of file CommandManager.cpp.

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

449{
450 // Add the menu to the menubar after all menu items have been
451 // added to the menu to allow OSX to rearrange special menu
452 // items like Preferences, About, and Quit.
453 wxASSERT(uCurrentMenu);
454 CurrentMenuBar()->Append(
456 mCurrentMenu = nullptr;
458}
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 424 of file CommandManager.cpp.

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

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

Here is the call graph for this function:

◆ EndOccultCommands()

void CommandManager::EndOccultCommands ( )

Definition at line 1605 of file CommandManager.cpp.

1606{
1607 PopMenuBar();
1608 bMakingOccultCommands = false;
1609 mTempMenuBar.reset();
1610}

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 476 of file CommandManager.cpp.

477{
478 //Save the submenu's information
479 SubMenuListEntry tmpSubMenu{ std::move( mSubMenuList.back() ) };
480
481 //Pop off the NEW submenu so CurrentMenu returns the parent of the submenu
482 mSubMenuList.pop_back();
483
484 //Add the submenu to the current menu
485 auto name = tmpSubMenu.name.Translation();
486 CurrentMenu()->Append(0, name, tmpSubMenu.menu.release(),
487 name /* help string */ );
488 mbSeparatorAllowed = true;
489}
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 240 of file CommandManager.cpp.

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

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

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 810 of file CommandManager.cpp.

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

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 826 of file CommandManager.cpp.

827{
828 return FormatLabelForMenu( entry->label, entry->key );
829}

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 831 of file CommandManager.cpp.

834{
835 auto label = translatableLabel.Translation();
836 auto key = keyStr.GET();
837 if (!key.empty())
838 {
839 // using GET to compose menu item name for wxWidgets
840 label += wxT("\t") + key;
841 }
842
843 return label;
844}
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 851 of file CommandManager.cpp.

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

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 208 of file CommandManager.cpp.

209{
210 return project.AttachedObjects::Get< CommandManager >( key );
211}
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(), EditToolBar::ForAllButtons(), Get(), SelectUtilities::InactivatePlayRegion(), AudacityApp::InitPart2(), MacroCommandsCatalog::MacroCommandsCatalog(), MenuManager::ModifyToolbarMenus(), MenuManager::ModifyUndoMenuItems(), ViewActions::Handler::OnAdvancedVZoom(), PluginActions::Handler::OnApplyMacroDirectlyByName(), PluginActions::Handler::OnApplyMacrosPalette(), PluginActions::Handler::OnBenchmark(), EditToolBar::OnButton(), anonymous_namespace{Contrast.cpp}::Handler::OnContrast(), PluginActions::Handler::OnDetectUpstreamDropouts(), LyricsPanel::OnKeyEvent(), MixerBoardFrame::OnKeyEvent(), PluginActions::Handler::OnManageMacros(), ProjectWindow::OnMenu(), anonymous_namespace{FreqWindow.cpp}::Handler::OnPlotSpectrum(), PluginActions::Handler::OnRepeatLastAnalyzer(), PluginActions::Handler::OnRepeatLastTool(), PluginActions::Handler::OnScreenshot(), ViewActions::Handler::OnShowClipping(), ViewActions::Handler::OnShowExtraMenus(), ViewActions::Handler::OnShowNameOverlay(), PluginActions::Handler::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 213 of file CommandManager.cpp.

214{
215 return Get( const_cast< AudacityProject & >( project ) );
216}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
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 1431 of file CommandManager.cpp.

1441{
1442 for(const auto &entry : mCommandList) {
1443 // GetAllCommandData is used by KeyConfigPrefs.
1444 // It does need the effects.
1445 //if ( entry->isEffect )
1446 // continue;
1447 if ( !entry->multi || includeMultis )
1448 {
1449 names.push_back(entry->name);
1450 keys.push_back(entry->key);
1451 default_keys.push_back(entry->defaultKey);
1452 labels.push_back(entry->label);
1453 categories.push_back(entry->labelTop);
1454#if defined(EXPERIMENTAL_KEY_VIEW)
1455 prefixes.push_back(entry->labelPrefix);
1456#endif
1457 }
1458 }
1459}
static TranslatableStrings names
Definition: TagsEditor.cpp:151

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 1412 of file CommandManager.cpp.

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

References entry, mCommandList, and names.

◆ GetAllCommandNames()

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

Definition at line 1399 of file CommandManager.cpp.

1401{
1402 for(const auto &entry : mCommandList) {
1403 if ( entry->isEffect )
1404 continue;
1405 if (!entry->multi)
1406 names.push_back(entry->name);
1407 else if( includeMultis )
1408 names.push_back(entry->name );// + wxT(":")/*+ mCommandList[i]->label*/);
1409 }
1410}

References entry, mCommandList, and names.

◆ GetCategories()

TranslatableStrings CommandManager::GetCategories ( AudacityProject )

Definition at line 1367 of file CommandManager.cpp.

1368{
1370
1371 for (const auto &entry : mCommandList) {
1372 auto &cat = entry->labelTop;
1373 if ( ! make_iterator_range( cats ).contains(cat) ) {
1374 cats.push_back(cat);
1375 }
1376 }
1377#if 0
1378 mCommandList.size(); i++) {
1379 if (includeMultis || !mCommandList[i]->multi)
1380 names.push_back(mCommandList[i]->name);
1381 }
1382
1383 if (p == NULL) {
1384 return;
1385 }
1386
1387 wxMenuBar *bar = p->GetMenuBar();
1388 size_t cnt = bar->GetMenuCount();
1389 for (size_t i = 0; i < cnt; i++) {
1390 cats.push_back(bar->GetMenuLabelText(i));
1391 }
1392
1393 cats.push_back(COMMAND);
1394#endif
1395
1396 return cats;
1397}
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 1492 of file CommandManager.cpp.

1493{
1495 if (!entry)
1496 return {};
1497
1498 return entry->labelTop;
1499}

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 1512 of file CommandManager.cpp.

1513{
1515 if (!entry)
1516 return {};
1517
1518 return entry->defaultKey;
1519}

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 986 of file CommandManager.cpp.

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

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

Referenced by EditToolBar::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 1501 of file CommandManager.cpp.

1502{
1504 // May create a NULL entry
1505 const_cast<CommandManager*>(this)->mCommandNameHash[name];
1506 if (!entry)
1507 return {};
1508
1509 return entry->key;
1510}

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 1469 of file CommandManager.cpp.

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

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 370 of file CommandManager.cpp.

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

References entry, and mMenuBarList.

Referenced by AddMenuBar().

Here is the caller graph for this function:

◆ GetNameFromNumericID()

CommandID CommandManager::GetNameFromNumericID ( int  id)

Definition at line 1461 of file CommandManager.cpp.

1462{
1464 if (!entry)
1465 return {};
1466 return entry->name;
1467}

References entry, id, and mCommandNumericIDHash.

◆ GetNumberOfKeysRead()

int CommandManager::GetNumberOfKeysRead ( ) const

Definition at line 998 of file CommandManager.cpp.

999{
1000 return mXMLKeysRead;
1001}

References mXMLKeysRead.

Referenced by KeyConfigPrefs::OnImport().

Here is the caller graph for this function:

◆ GetPrefixedLabelFromName()

TranslatableString CommandManager::GetPrefixedLabelFromName ( const CommandID name)

Definition at line 1478 of file CommandManager.cpp.

1479{
1481 if (!entry)
1482 return {};
1483
1484 if (!entry->labelPrefix.empty())
1485 return Verbatim( wxT("%s - %s") )
1486 .Format(entry->labelPrefix, entry->label)
1487 .Stripped();
1488 else
1489 return entry->label.Stripped();
1490}
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 1232 of file CommandManager.cpp.

1236{
1237 if (!entry )
1238 return false;
1239
1240 if (flags != AlwaysEnabledFlag && !entry->enabled)
1241 return false;
1242
1243 if (!alwaysEnabled && entry->flags.any()) {
1244
1245 const auto NiceName = entry->label.Stripped(
1247 // NB: The call may have the side effect of changing flags.
1248 bool allowed =
1250 NiceName, flags, entry->flags );
1251 // If the function was disallowed, it STILL should count as having been
1252 // handled (by doing nothing or by telling the user of the problem).
1253 // Otherwise we may get other handlers having a go at obeying the command.
1254 if (!allowed)
1255 return true;
1256 mNiceName = NiceName;
1257 }
1258 else {
1259 mNiceName = {};
1260 }
1261
1262 Journal::Output({ JournalCode, entry->name.GET() });
1263
1264 CommandContext context{ project, evt, entry->index, entry->parameter };
1265 if (pGivenContext)
1266 context.temporarySelection = pGivenContext->temporarySelection;
1267 auto &handler = entry->finder(project);
1268 (handler.*(entry->callback))(context);
1269 mLastProcessId = 0;
1270 return true;
1271}
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:705
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 1313 of file CommandManager.cpp.

1315{
1318
1319 if (GlobalMenuHook::Call(entry->name))
1320 return true;
1321
1322 return HandleCommandEntry( project, entry, flags, alwaysEnabled );
1323}
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 1329 of file CommandManager.cpp.

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

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

Referenced by 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 1570 of file CommandManager.cpp.

1571{
1572 return this;
1573}

◆ HandleXMLEndTag()

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

Definition at line 1557 of file CommandManager.cpp.

1558{
1559 /*
1560 if (tag == "audacitykeyboard") {
1561 AudacityMessageBox(
1562 XO("Loaded %d keyboard shortcuts\n")
1563 .Format( mXMLKeysRead ),
1564 XO("Loading Keyboard Shortcuts"),
1565 wxOK | wxCENTRE);
1566 }
1567 */
1568}

◆ HandleXMLTag()

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

Implements XMLTagHandler.

Definition at line 1521 of file CommandManager.cpp.

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

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 1013 of file CommandManager.cpp.

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

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 657 of file CommandManager.cpp.

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

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

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 398 of file CommandManager.cpp.

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

References mMenuBarList.

Referenced by EndOccultCommands().

Here is the caller graph for this function:

◆ PurgeData()

void CommandManager::PurgeData ( )

Definition at line 329 of file CommandManager.cpp.

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

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 1275 of file CommandManager.cpp.

1275 {
1276 if (mLastProcessId != 0) {
1277 auto& menuManager = MenuManager::Get(context.project);
1278 menuManager.mLastAnalyzerRegistration = MenuCreator::repeattypeunique;
1279 menuManager.mLastAnalyzerRegisteredId = mLastProcessId;
1280 auto lastEffectDesc = XO("Repeat %s").Format(mNiceName);
1281 Modify(wxT("RepeatLastAnalyzer"), lastEffectDesc);
1282 }
1283 return;
1284}
#define XO(s)
Definition: Internat.h:31
void Modify(const wxString &name, const TranslatableString &newLabel)
Changes the label text of a menu item.
@ repeattypeunique
Definition: Menus.h:63

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

Referenced by anonymous_namespace{Contrast.cpp}::Handler::OnContrast(), and anonymous_namespace{FreqWindow.cpp}::Handler::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 1288 of file CommandManager.cpp.

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

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

Referenced by PluginActions::Handler::OnApplyMacrosPalette(), PluginActions::Handler::OnBenchmark(), PluginActions::Handler::OnManageMacros(), and PluginActions::Handler::OnScreenshot().

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

◆ RemoveDuplicateShortcuts()

void CommandManager::RemoveDuplicateShortcuts ( )

Definition at line 1666 of file CommandManager.cpp.

1667{
1668 TranslatableString disabledShortcuts;
1669
1670 for (auto& entry : mCommandList) {
1671 if (!entry->key.empty() && entry->key != entry->defaultKey) { // user assigned
1672 for (auto& entry2 : mCommandList) {
1673 if (!entry2->key.empty() && entry2->key == entry2->defaultKey) { // default
1674 if (entry2->key == entry->key) {
1675 auto name = wxT("/NewKeys/") + entry2->name.GET();
1676 gPrefs->Write(name, NormalizedKeyString{});
1677
1678 disabledShortcuts +=
1679 XO("\n* %s, because you have assigned the shortcut %s to %s")
1680 .Format(entry2->label.Strip(), entry->key.GET(), entry->label.Strip());
1681 }
1682 }
1683 }
1684 }
1685 }
1686
1687 if (!disabledShortcuts.Translation().empty()) {
1688 TranslatableString message = XO("The following commands have had their shortcuts removed,"
1689 " because their default shortcut is new or changed, and is the same shortcut"
1690 " that you have assigned to another command.")
1691 + disabledShortcuts;
1692 AudacityMessageBox(message, XO("Shortcuts have been removed"), wxOK | wxCENTRE);
1693
1694 gPrefs->Flush();
1696 }
1697}
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:687

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 1612 of file CommandManager.cpp.

1614{
1616 if (entry)
1617 entry->flags = flags;
1618}

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 1031 of file CommandManager.cpp.

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

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 1022 of file CommandManager.cpp.

1024{
1026 if (entry) {
1027 entry->key = key;
1028 }
1029}

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 308 of file CommandManager.cpp.

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

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

References entry, and mCommandList.

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

Here is the caller graph for this function:

◆ WriteXML()

void CommandManager::WriteXML ( XMLWriter xmlFile) const

Definition at line 1575 of file CommandManager.cpp.

1577{
1578 xmlFile.StartTag(wxT("audacitykeyboard"));
1579 xmlFile.WriteAttr(wxT("audacityversion"), AUDACITY_VERSION_STRING);
1580
1581 for(const auto &entry : mCommandList) {
1582
1583 xmlFile.StartTag(wxT("command"));
1584 xmlFile.WriteAttr(wxT("name"), entry->name);
1585 xmlFile.WriteAttr(wxT("key"), entry->key);
1586 xmlFile.EndTag(wxT("command"));
1587 }
1588
1589 xmlFile.EndTag(wxT("audacitykeyboard"));
1590}
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:80
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:37
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:103

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: