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

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

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

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

623{
625 NewIdentifier(name, label_in, NULL, finder, callback,
626 {}, 0, 0, options);
627
628 entry->enabled = false;
629 entry->isGlobal = true;
630 entry->flags = AlwaysEnabledFlag;
631}
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 532 of file CommandManager.cpp.

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

599{
600 for (size_t i = 0, cnt = nItems; i < cnt; i++) {
603 items[i].Msgid(),
604 CurrentMenu(),
605 finder,
606 callback,
607 items[i].Internal(),
608 i,
609 cnt,
610 Options{}
611 .IsEffect(bIsEffect));
612 entry->flags = flags;
613 CurrentMenu()->Append(entry->id, FormatLabelForMenu(entry));
614 mbSeparatorAllowed = true;
615 }
616}
@ 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 351 of file CommandManager.cpp.

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

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

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

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

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

1592{
1593 // To do: perhaps allow occult item switching at lower levels of the
1594 // menu tree.
1595 wxASSERT( !CurrentMenu() );
1596
1597 // Make a temporary menu bar collecting items added after.
1598 // This bar will be discarded but other side effects on the command
1599 // manager persist.
1600 mTempMenuBar = AddMenuBar(wxT("ext-menu"));
1601 bMakingOccultCommands = true;
1602}
std::unique_ptr< wxMenuBar > mTempMenuBar
std::unique_ptr< wxMenuBar > AddMenuBar(const wxString &sMenu)

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

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

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

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

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

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

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

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

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

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

Here is the call graph for this function:

◆ DoRepeatProcess()

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

Definition at line 1299 of file CommandManager.cpp.

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

References entry, 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 904 of file CommandManager.cpp.

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

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

Here is the call graph for this function:

◆ Enable() [2/2]

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

Definition at line 949 of file CommandManager.cpp.

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

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

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

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

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

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

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

Here is the call graph for this function:

◆ EndOccultCommands()

void CommandManager::EndOccultCommands ( )

Definition at line 1604 of file CommandManager.cpp.

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

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

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

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

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

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

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

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

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

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

Here is the call graph for this function:

◆ FormatLabelWithDisabledAccel()

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

Definition at line 850 of file CommandManager.cpp.

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

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

208{
209 return project.AttachedObjects::Get< CommandManager >( key );
210}
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 212 of file CommandManager.cpp.

213{
214 return Get( const_cast< AudacityProject & >( project ) );
215}
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 1430 of file CommandManager.cpp.

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

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

References entry, mCommandList, and names.

◆ GetAllCommandNames()

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

Definition at line 1398 of file CommandManager.cpp.

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

References entry, mCommandList, and names.

◆ GetCategories()

TranslatableStrings CommandManager::GetCategories ( AudacityProject )

Definition at line 1366 of file CommandManager.cpp.

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

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

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

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

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

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

References entry, mCommandNameHash, and name.

Referenced by EditToolBar::ForAllButtons().

Here is the caller graph for this function:

◆ GetKeyFromName()

NormalizedKeyString CommandManager::GetKeyFromName ( const CommandID name) const

Definition at line 1500 of file CommandManager.cpp.

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

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

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

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

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

References entry, and mMenuBarList.

Referenced by AddMenuBar().

Here is the caller graph for this function:

◆ GetNameFromNumericID()

CommandID CommandManager::GetNameFromNumericID ( int  id)

Definition at line 1460 of file CommandManager.cpp.

1461{
1463 if (!entry)
1464 return {};
1465 return entry->name;
1466}

References entry, id, and mCommandNumericIDHash.

◆ GetNumberOfKeysRead()

int CommandManager::GetNumberOfKeysRead ( ) const

Definition at line 997 of file CommandManager.cpp.

998{
999 return mXMLKeysRead;
1000}

References mXMLKeysRead.

Referenced by KeyConfigPrefs::OnImport().

Here is the caller graph for this function:

◆ GetPrefixedLabelFromName()

TranslatableString CommandManager::GetPrefixedLabelFromName ( const CommandID name)

Definition at line 1477 of file CommandManager.cpp.

1478{
1480 if (!entry)
1481 return {};
1482
1483 if (!entry->labelPrefix.empty())
1484 return Verbatim( wxT("%s - %s") )
1485 .Format(entry->labelPrefix, entry->label)
1486 .Stripped();
1487 else
1488 return entry->label.Stripped();
1489}
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object

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

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

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

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

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

1570{
1571 return this;
1572}

◆ HandleXMLEndTag()

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

Definition at line 1556 of file CommandManager.cpp.

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

◆ HandleXMLTag()

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

Implements XMLTagHandler.

Definition at line 1520 of file CommandManager.cpp.

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

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

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

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

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

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

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

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

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

References mMenuBarList.

Referenced by EndOccultCommands().

Here is the caller graph for this function:

◆ PurgeData()

void CommandManager::PurgeData ( )

Definition at line 328 of file CommandManager.cpp.

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

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

1274 {
1275 if (mLastProcessId != 0) {
1276 auto& menuManager = MenuManager::Get(context.project);
1277 menuManager.mLastAnalyzerRegistration = MenuCreator::repeattypeunique;
1278 menuManager.mLastAnalyzerRegisteredId = mLastProcessId;
1279 auto lastEffectDesc = XO("Repeat %s").Format(mNiceName);
1280 Modify(wxT("RepeatLastAnalyzer"), lastEffectDesc);
1281 }
1282 return;
1283}
#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, 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 1287 of file CommandManager.cpp.

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

References MenuManager::Get(), mLastProcessId, mNiceName, Modify(), CommandContext::project, MenuCreator::repeattypeunique, 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 1665 of file CommandManager.cpp.

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

1613{
1615 if (entry)
1616 entry->flags = flags;
1617}

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

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

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

1023{
1025 if (entry) {
1026 entry->key = key;
1027 }
1028}

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

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

References ExcludedList(), gPrefs, and mMaxListOnly.

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

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

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

1576{
1577 xmlFile.StartTag(wxT("audacitykeyboard"));
1578 xmlFile.WriteAttr(wxT("audacityversion"), AUDACITY_VERSION_STRING);
1579
1580 for(const auto &entry : mCommandList) {
1581
1582 xmlFile.StartTag(wxT("command"));
1583 xmlFile.WriteAttr(wxT("name"), entry->name);
1584 xmlFile.WriteAttr(wxT("key"), entry->key);
1585 xmlFile.EndTag(wxT("command"));
1586 }
1587
1588 xmlFile.EndTag(wxT("audacitykeyboard"));
1589}
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.

Referenced by KeyConfigPrefs::OnExport().

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: