Audacity 3.2.0
CommandManager.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 CommandManager.h
6
7 Brian Gunlogson
8 Dominic Mazzoni
9
10**********************************************************************/
11
12#ifndef __AUDACITY_COMMAND_MANAGER__
13#define __AUDACITY_COMMAND_MANAGER__
14
15#include "Identifier.h"
16
17#include "ClientData.h"
18#include "CommandFunctors.h"
19#include "CommandFlag.h"
20#include "GlobalVariable.h"
21
22#include "Keyboard.h"
23
24#include "Prefs.h"
25#include "Registry.h"
26
27#include <vector>
28
29#include "XMLTagHandler.h"
30
31#include <unordered_map>
32
33class wxEvent;
34class wxMenu;
35class wxMenuBar;
37
38class BoolSetting;
39
40struct MenuBarListEntry;
41struct SubMenuListEntry;
42struct CommandListEntry;
43
44using MenuBarList = std::vector < MenuBarListEntry >;
45using SubMenuList = std::vector < SubMenuListEntry >;
46
47// This is an array of pointers, not structures, because the hash maps also point to them,
48// so we don't want the structures to relocate with vector operations.
49using CommandList = std::vector<std::unique_ptr<CommandListEntry>>;
50
51using CommandKeyHash = std::unordered_map<NormalizedKeyString, CommandListEntry*>;
52using CommandNameHash = std::unordered_map<CommandID, CommandListEntry*>;
53using CommandNumericIDHash = std::unordered_map<int, CommandListEntry*>;
54
55class AudacityProject;
56class CommandContext;
57
58class AUDACITY_DLL_API CommandManager final
59 : public XMLTagHandler
60 , public ClientData::Base
61{
62 public:
63 static CommandManager &Get( AudacityProject &project );
64 static const CommandManager &Get( const AudacityProject &project );
65
66 // Interception of menu item handling.
67 // If it returns true, bypass the usual dispatch of commands.
68 struct AUDACITY_DLL_API GlobalMenuHook : GlobalHook<GlobalMenuHook,
69 bool(const CommandID&)
70 >{};
71
72 //
73 // Constructor / Destructor
74 //
75
77 virtual ~CommandManager();
78
79 CommandManager(const CommandManager&) PROHIBITED;
80 CommandManager &operator= (const CommandManager&) PROHIBITED;
81
82 void SetMaxList();
83 void PurgeData();
84
85 //
86 // Creating menus and adding commands
87 //
88
89 std::unique_ptr<wxMenuBar> AddMenuBar(const wxString & sMenu);
90
91 wxMenu *BeginMenu(const TranslatableString & tName);
92 void EndMenu();
93
94 // type of a function that determines checkmark state
95 using CheckFn = std::function< bool(AudacityProject&) >;
96
97 // For specifying unusual arguments in AddItem
98 struct AUDACITY_DLL_API Options
99 {
101 // Allow implicit construction from an accelerator string, which is
102 // a very common case
103 Options( const wxChar *accel_ ) : accel{ accel_ } {}
104 // A two-argument constructor for another common case
106 const wxChar *accel_,
107 const TranslatableString &longName_ )
108 : accel{ accel_ }, longName{ longName_ } {}
109
110 Options &&Accel (const wxChar *value) &&
111 { accel = value; return std::move(*this); }
112 Options &&IsEffect (bool value = true) &&
113 { bIsEffect = value; return std::move(*this); }
115 { parameter = value; return std::move(*this); }
117 { longName = value; return std::move(*this); }
119 { global = true; return std::move(*this); }
121 { useStrictFlags = true; return std::move(*this); }
123 { wantKeyUp = true; return std::move(*this); }
125 { skipKeyDown = true; return std::move(*this); }
126
127 // This option affects debugging only:
129 { allowDup = true; return std::move(*this); }
130
131 Options &&AllowInMacros ( int value = 1 ) &&
132 { allowInMacros = value; return std::move(*this); }
133
134 // CheckTest is overloaded
135 // Take arbitrary predicate
137 { checker = fn; return std::move(*this); }
138 // Take a preference path
139 Options &&CheckTest (const wxChar *key, bool defaultValue) && {
140 checker = MakeCheckFn( key, defaultValue );
141 return std::move(*this);
142 }
143 // Take a BoolSetting
144 Options &&CheckTest ( const BoolSetting &setting ) && {
145 checker = MakeCheckFn( setting );
146 return std::move(*this);
147 }
148
149 const wxChar *accel{ wxT("") };
150 CheckFn checker; // default value means it's not a check item
151 bool bIsEffect{ false };
152 CommandParameter parameter{};
154 bool global{ false };
155 bool useStrictFlags{ false };
156 bool wantKeyUp{ false };
157 bool skipKeyDown{ false };
158 bool allowDup{ false };
159 int allowInMacros{ -1 }; // 0 = never, 1 = always, -1 = deduce from label
160
161 private:
162 static CheckFn
163 MakeCheckFn( const wxString key, bool defaultValue );
164 static CheckFn
165 MakeCheckFn( const BoolSetting &setting );
166 };
167
168 void AddItemList(const CommandID & name,
169 const ComponentInterfaceSymbol items[],
170 size_t nItems,
172 CommandFunctorPointer callback,
173 CommandFlag flags,
174 bool bIsEffect = false);
175
176 void AddItem(AudacityProject &project,
177 const CommandID & name,
178 const TranslatableString &label_in,
180 CommandFunctorPointer callback,
181 CommandFlag flags,
182 const Options &options = {});
183
184 void AddSeparator();
185
186 void PopMenuBar();
187 void BeginOccultCommands();
188 void EndOccultCommands();
189
190
191 void SetCommandFlags(const CommandID &name, CommandFlag flags);
192
193 //
194 // Modifying menus
195 //
196
197 void EnableUsingFlags(
198 CommandFlag flags, CommandFlag strictFlags);
199 void Enable(const wxString &name, bool enabled);
200 void Check(const CommandID &name, bool checked);
201 void Modify(const wxString &name, const TranslatableString &newLabel);
202
203 //
204 // Modifying accelerators
205 //
206
207 void SetKeyFromName(const CommandID &name, const NormalizedKeyString &key);
208 void SetKeyFromIndex(int i, const NormalizedKeyString &key);
209
210 //
211 // Executing commands
212 //
213
214 // "permit" allows filtering even if the active window isn't a child of the project.
215 // Lyrics and MixerTrackCluster classes use it.
216 bool FilterKeyEvent(AudacityProject *project, const wxKeyEvent & evt, bool permit = false);
217 bool HandleMenuID(AudacityProject &project, int id, CommandFlag flags, bool alwaysEnabled);
218 void RegisterLastAnalyzer(const CommandContext& context);
219 void RegisterLastTool(const CommandContext& context);
220 void DoRepeatProcess(const CommandContext& context, int);
221
225 CommandNotFound
226 };
227
228 TextualCommandResult
230 const CommandContext & context, CommandFlag flags, bool alwaysEnabled);
231
232 //
233 // Accessing
234 //
235
236 TranslatableStrings GetCategories( AudacityProject& );
237 void GetAllCommandNames(CommandIDs &names, bool includeMultis) const;
238 void GetAllCommandLabels(
239 TranslatableStrings &labels, std::vector<bool> &vExcludeFromMacros,
240 bool includeMultis) const;
241 void GetAllCommandData(
243 std::vector<NormalizedKeyString> &keys,
244 std::vector<NormalizedKeyString> &default_keys,
245 TranslatableStrings &labels, TranslatableStrings &categories,
246#if defined(EXPERIMENTAL_KEY_VIEW)
247 TranslatableStrings &prefixes,
248#endif
249 bool includeMultis);
250
251 // Each command is assigned a numerical ID for use in wxMenu and wxEvent,
252 // which need not be the same across platforms or sessions
253 CommandID GetNameFromNumericID( int id );
254
255 TranslatableString GetLabelFromName(const CommandID &name);
256 TranslatableString GetPrefixedLabelFromName(const CommandID &name);
257 TranslatableString GetCategoryFromName(const CommandID &name);
258 NormalizedKeyString GetKeyFromName(const CommandID &name) const;
259 NormalizedKeyString GetDefaultKeyFromName(const CommandID &name);
260
261 bool GetEnabled(const CommandID &name);
262 int GetNumberOfKeysRead() const;
263
264#if defined(_DEBUG)
265 void CheckDups();
266#endif
267 void RemoveDuplicateShortcuts();
268
269 //
270 // Loading/Saving
271 //
272
273 void WriteXML(XMLWriter &xmlFile) const /* not override */;
274
278 TranslatableString DescribeCommandsAndShortcuts
279 (
280 // If a shortcut key is defined for the command, then it is appended,
281 // parenthesized, after the translated name.
282 const ComponentInterfaceSymbol commands[], size_t nCommands) const;
283
284 // Sorted list of the shortcut keys to be excluded from the standard defaults
285 static const std::vector<NormalizedKeyString> &ExcludedList();
286
287private:
288
289 //
290 // Creating menus and adding commands
291 //
292
293 int NextIdentifier(int ID);
294 CommandListEntry *NewIdentifier(const CommandID & name,
296 wxMenu *menu,
298 CommandFunctorPointer callback,
299 const CommandID &nameSuffix,
300 int index,
301 int count,
302 const Options &options);
303
304 void AddGlobalCommand(const CommandID &name,
307 CommandFunctorPointer callback,
308 const Options &options = {});
309
310 //
311 // Executing commands
312 //
313
314 bool HandleCommandEntry(AudacityProject &project,
315 const CommandListEntry * entry, CommandFlag flags,
316 bool alwaysEnabled, const wxEvent * evt = nullptr,
317 const CommandContext *pGivenContext = nullptr );
318
319 //
320 // Modifying
321 //
322
323 void Enable(CommandListEntry *entry, bool enabled);
324 wxMenu *BeginMainMenu(const TranslatableString & tName);
325 void EndMainMenu();
326 wxMenu* BeginSubMenu(const TranslatableString & tName);
327 void EndSubMenu();
328
329 //
330 // Accessing
331 //
332
333 wxMenuBar * CurrentMenuBar() const;
334 wxMenuBar * GetMenuBar(const wxString & sMenu) const;
335 wxMenu * CurrentSubMenu() const;
336public:
337 wxMenu * CurrentMenu() const;
338
339 void UpdateCheckmarks( AudacityProject &project );
340
342
346 wxString FormatLabelForMenu(
347 const CommandID &id, const TranslatableString *pLabel) const;
348
349private:
350 wxString FormatLabelForMenu(const CommandListEntry *entry) const;
351 wxString FormatLabelForMenu(
352 const TranslatableString &translatableLabel,
353 const NormalizedKeyString &keyStr) const;
354 wxString FormatLabelWithDisabledAccel(const CommandListEntry *entry) const;
355
356 //
357 // Loading/Saving
358 //
359
360 bool HandleXMLTag(const std::string_view& tag, const AttributesList &attrs) override;
361 void HandleXMLEndTag(const std::string_view& tag) override;
362 XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
363
364private:
365 // mMaxList only holds shortcuts that should not be added (by default)
366 // and is sorted.
367 std::vector<NormalizedKeyString> mMaxListOnly;
368
377
378 bool mbSeparatorAllowed; // false at the start of a menu and immediately after a separator.
379
383 std::unique_ptr<wxMenu> uCurrentMenu;
384 wxMenu *mCurrentMenu {};
385
387 std::unique_ptr< wxMenuBar > mTempMenuBar;
388};
389
390struct AUDACITY_DLL_API MenuVisitor : Registry::Visitor
391{
392 // final overrides
393 void BeginGroup( Registry::GroupItem &item, const Path &path ) final;
394 void EndGroup( Registry::GroupItem &item, const Path& ) final;
395 void Visit( Registry::SingleItem &item, const Path &path ) final;
396
397 // added virtuals
398 virtual void DoBeginGroup( Registry::GroupItem &item, const Path &path );
399 virtual void DoEndGroup( Registry::GroupItem &item, const Path &path );
400 virtual void DoVisit( Registry::SingleItem &item, const Path &path );
401 virtual void DoSeparator();
402
403private:
404 void MaybeDoSeparator();
405 std::vector<bool> firstItem;
406 std::vector<bool> needSeparator;
407};
408
410{
412 operator AudacityProject & () const { return project; }
414};
415
416// Define items that populate tables that specifically describe menu trees
417namespace MenuTable {
418 using namespace Registry;
419
420 // These are found by dynamic_cast
421 struct AUDACITY_DLL_API MenuSection {
422 virtual ~MenuSection();
423 };
424 struct AUDACITY_DLL_API WholeMenu {
425 WholeMenu( bool extend = false ) : extension{ extend } {}
426 virtual ~WholeMenu();
428 };
429
430 // Describes a main menu in the toolbar, or a sub-menu
431 struct AUDACITY_DLL_API MenuItem final
432 : ConcreteGroupItem< false, ToolbarMenuVisitor >
433 , WholeMenu {
434 // Construction from an internal name and a previously built-up
435 // vector of pointers
436 MenuItem( const Identifier &internalName,
437 const TranslatableString &title_, BaseItemPtrs &&items_ );
438 // In-line, variadic constructor that doesn't require building a vector
439 template< typename... Args >
440 MenuItem( const Identifier &internalName,
441 const TranslatableString &title_, Args&&... args )
443 internalName, std::forward<Args>(args)... }
444 , title{ title_ }
445 {}
446 ~MenuItem() override;
447
449 };
450
451 // Collects other items that are conditionally shown or hidden, but are
452 // always available to macro programming
454 : ConcreteGroupItem< false, ToolbarMenuVisitor > {
455 using Condition = std::function< bool() >;
456
457 // Construction from an internal name and a previously built-up
458 // vector of pointers
459 ConditionalGroupItem( const Identifier &internalName,
460 Condition condition_, BaseItemPtrs &&items_ );
461 // In-line, variadic constructor that doesn't require building a vector
462 template< typename... Args >
463 ConditionalGroupItem( const Identifier &internalName,
464 Condition condition_, Args&&... args )
466 internalName, std::forward<Args>(args)... }
467 , condition{ condition_ }
468 {}
469 ~ConditionalGroupItem() override;
470
472 };
473
474 // usage:
475 // auto scope = FinderScope( findCommandHandler );
476 // return Items( ... );
477 //
478 // or:
479 // return ( FinderScope( findCommandHandler ), Items( ... ) );
480 //
481 // where findCommandHandler names a function.
482 // This is used before a sequence of many calls to Command() and
483 // CommandGroup(), so that the finder argument need not be specified
484 // in each call.
485 class AUDACITY_DLL_API FinderScope : ValueRestorer< CommandHandlerFinder >
486 {
488
489 public:
490 static CommandHandlerFinder DefaultFinder() { return sFinder; }
491
492 explicit
494 : ValueRestorer( sFinder, finder )
495 {}
496 };
497
498 // Describes one command in a menu
499 struct AUDACITY_DLL_API CommandItem final : SingleItem {
500 CommandItem(const CommandID &name_,
501 const TranslatableString &label_in_,
502 CommandFunctorPointer callback_,
503 CommandFlag flags_,
504 const CommandManager::Options &options_,
505 CommandHandlerFinder finder_);
506
507 // Takes a pointer to member function directly, and delegates to the
508 // previous constructor; useful within the lifetime of a FinderScope
509 template< typename Handler >
510 CommandItem(const CommandID &name_,
511 const TranslatableString &label_in_,
512 void (Handler::*pmf)(const CommandContext&),
513 CommandFlag flags_,
514 const CommandManager::Options &options_,
516 : CommandItem(name_, label_in_,
517 static_cast<CommandFunctorPointer>(pmf),
518 flags_, options_, finder)
519 {}
520
521 ~CommandItem() override;
522
528 };
529
530 // Describes several successive commands in a menu that are closely related
531 // and dispatch to one common callback, which will be passed a number
532 // in the CommandContext identifying the command
533 struct AUDACITY_DLL_API CommandGroupItem final : SingleItem {
534 CommandGroupItem(const Identifier &name_,
535 std::vector< ComponentInterfaceSymbol > items_,
536 CommandFunctorPointer callback_,
537 CommandFlag flags_,
538 bool isEffect_,
539 CommandHandlerFinder finder_);
540
541 // Takes a pointer to member function directly, and delegates to the
542 // previous constructor; useful within the lifetime of a FinderScope
543 template< typename Handler >
545 std::vector< ComponentInterfaceSymbol > items_,
546 void (Handler::*pmf)(const CommandContext&),
547 CommandFlag flags_,
548 bool isEffect_,
550 : CommandGroupItem(name_, std::move(items_),
551 static_cast<CommandFunctorPointer>(pmf),
552 flags_, isEffect_, finder)
553 {}
554
555 ~CommandGroupItem() override;
556
557 const std::vector<ComponentInterfaceSymbol> items;
562 };
563
564 // For manipulating the enclosing menu or sub-menu directly,
565 // adding any number of items, not using the CommandManager
566 struct SpecialItem final : SingleItem
567 {
568 using Appender = std::function< void( AudacityProject&, wxMenu& ) >;
569
570 explicit SpecialItem( const Identifier &internalName, const Appender &fn_ )
571 : SingleItem{ internalName }
572 , fn{ fn_ }
573 {}
574 ~SpecialItem() override;
575
577 };
578
579 struct MenuPart : ConcreteGroupItem< false, ToolbarMenuVisitor >, MenuSection
580 {
581 template< typename... Args >
582 explicit
583 MenuPart( const Identifier &internalName, Args&&... args )
585 internalName, std::forward< Args >( args )... }
586 {}
587 };
589
590 // The following, and Shared(), are the functions to use directly
591 // in writing table definitions.
592
593 // Group items can be constructed two ways.
594 // Pointers to subordinate items are moved into the result.
595 // Null pointers are permitted, and ignored when building the menu.
596 // Items are spliced into the enclosing menu.
597 // The name is untranslated and may be empty, to make the group transparent
598 // in identification of items by path. Otherwise try to keep the name
599 // stable across Audacity versions.
600 template< typename... Args >
601 inline std::unique_ptr< MenuItems > Items(
602 const Identifier &internalName, Args&&... args )
603 { return std::make_unique< MenuItems >(
604 internalName, std::forward<Args>(args)... ); }
605
606 // Like Items, but insert a menu separator between the menu section and
607 // any other items or sections before or after it in the same (innermost,
608 // enclosing) menu.
609 // It's not necessary that the sisters of sections be other sections, but it
610 // might clarify the logical groupings.
611 template< typename... Args >
612 inline std::unique_ptr< MenuPart > Section(
613 const Identifier &internalName, Args&&... args )
614 { return std::make_unique< MenuPart >(
615 internalName, std::forward<Args>(args)... ); }
616
617 // Menu items can be constructed two ways, as for group items
618 // Items will appear in a main toolbar menu or in a sub-menu.
619 // The name is untranslated. Try to keep the name stable across Audacity
620 // versions.
621 // If the name of a menu is empty, then subordinate items cannot be located
622 // by path.
623 template< typename... Args >
624 inline std::unique_ptr<MenuItem> Menu(
625 const Identifier &internalName, const TranslatableString &title, Args&&... args )
626 { return std::make_unique<MenuItem>(
627 internalName, title, std::forward<Args>(args)... ); }
628 inline std::unique_ptr<MenuItem> Menu(
629 const Identifier &internalName, const TranslatableString &title, BaseItemPtrs &&items )
630 { return std::make_unique<MenuItem>(
631 internalName, title, std::move( items ) ); }
632
633 // Conditional group items can be constructed two ways, as for group items
634 // These items register in the CommandManager but are not shown in menus
635 // if the condition evaluates false.
636 // The name is untranslated. Try to keep the name stable across Audacity
637 // versions.
638 // Name for conditional group must be non-empty.
639 template< typename... Args >
640 inline std::unique_ptr<ConditionalGroupItem> ConditionalItems(
641 const Identifier &internalName,
642 ConditionalGroupItem::Condition condition, Args&&... args )
643 { return std::make_unique<ConditionalGroupItem>(
644 internalName, condition, std::forward<Args>(args)... ); }
645 inline std::unique_ptr<ConditionalGroupItem> ConditionalItems(
646 const Identifier &internalName, ConditionalGroupItem::Condition condition,
647 BaseItemPtrs &&items )
648 { return std::make_unique<ConditionalGroupItem>(
649 internalName, condition, std::move( items ) ); }
650
651 // Make either a menu item or just a group, depending on the nonemptiness
652 // of the title.
653 // The name is untranslated and may be empty, to make the group transparent
654 // in identification of items by path. Otherwise try to keep the name
655 // stable across Audacity versions.
656 // If the name of a menu is empty, then subordinate items cannot be located
657 // by path.
658 template< typename... Args >
660 const Identifier &internalName, const TranslatableString &title, Args&&... args )
661 { if ( title.empty() )
662 return Items( internalName, std::forward<Args>(args)... );
663 else
664 return std::make_unique<MenuItem>(
665 internalName, title, std::forward<Args>(args)... ); }
667 const Identifier &internalName,
668 const TranslatableString &title, BaseItemPtrs &&items )
669 { if ( title.empty() )
670 return Items( internalName, std::move( items ) );
671 else
672 return std::make_unique<MenuItem>(
673 internalName, title, std::move( items ) ); }
674
675 template< typename Handler >
676 inline std::unique_ptr<CommandItem> Command(
677 const CommandID &name,
678 const TranslatableString &label_in,
679 void (Handler::*pmf)(const CommandContext&),
680 CommandFlag flags, const CommandManager::Options &options = {},
682 {
683 return std::make_unique<CommandItem>(
684 name, label_in, pmf, flags, options, finder
685 );
686 }
687
688 template< typename Handler >
689 inline std::unique_ptr<CommandGroupItem> CommandGroup(
690 const Identifier &name,
691 std::vector< ComponentInterfaceSymbol > items,
692 void (Handler::*pmf)(const CommandContext&),
693 CommandFlag flags, bool isEffect = false,
695 {
696 return std::make_unique<CommandGroupItem>(
697 name, std::move(items), pmf, flags, isEffect, finder
698 );
699 }
700
701 inline std::unique_ptr<SpecialItem> Special(
702 const Identifier &name, const SpecialItem::Appender &fn )
703 { return std::make_unique<SpecialItem>( name, fn ); }
704
705 // Typically you make a static object of this type in the .cpp file that
706 // also defines the added menu actions.
707 // pItem can be specified by an expression using the inline functions above.
708 struct AUDACITY_DLL_API AttachedItem final
709 {
710 AttachedItem( const Placement &placement, BaseItemPtr pItem );
711
712 AttachedItem( const wxString &path, BaseItemPtr pItem )
713 // Delegating constructor
714 : AttachedItem( Placement{ path }, std::move( pItem ) )
715 {}
716 };
717
718 void DestroyRegistry();
719
720}
721
722#endif
wxT("CloseDown"))
Utility ClientData::Site to register hooks into a host class that attach client data.
bool HandleTextualCommand(CommandManager &commandManager, const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
void(CommandHandlerObject::*)(const CommandContext &context) CommandFunctorPointer
std::function< CommandHandlerObject &(AudacityProject &) > CommandHandlerFinder
static const AudacityProject::AttachedObjects::RegisteredFactory key
std::unordered_map< CommandID, CommandListEntry * > CommandNameHash
std::unordered_map< int, CommandListEntry * > CommandNumericIDHash
std::unordered_map< NormalizedKeyString, CommandListEntry * > CommandKeyHash
const TranslatableString name
Definition: Distortion.cpp:82
std::vector< CommandID > CommandIDs
Definition: Identifier.h:233
TaggedIdentifier< CommandIdTag, false > CommandID
Identifies a menu command or macro. Case-insensitive comparison.
Definition: Identifier.h:232
auto Visit(Visitor &&vis, Variant &&var)
Mimic some of std::visit, for the case of one visitor only.
Definition: MemoryX.h:611
static const auto title
static ProjectFileIORegistry::AttributeWriterEntry entry
TranslatableString label
Definition: TagsEditor.cpp:163
static TranslatableStrings names
Definition: TagsEditor.cpp:151
std::vector< TranslatableString > TranslatableStrings
static const auto fn
std::vector< Attribute > AttributesList
Definition: XMLTagHandler.h:40
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
This specialization of Setting for bool adds a Toggle method to negate the saved value.
Definition: Prefs.h:339
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
List of CommandListEntry.
CommandManager implements a system for organizing all user-callable commands.
CommandList mCommandList
CommandNameHash mCommandNameHash
std::unique_ptr< wxMenuBar > mTempMenuBar
TranslatableString mCurrentMenuName
MenuBarList mMenuBarList
SubMenuList mSubMenuList
std::vector< NormalizedKeyString > mMaxListOnly
std::unique_ptr< wxMenu > uCurrentMenu
bool bMakingOccultCommands
CommandKeyHash mCommandKeyHash
std::function< bool(AudacityProject &) > CheckFn
CommandManager(const CommandManager &) PROHIBITED
TranslatableString mNiceName
CommandNumericIDHash mCommandNumericIDHash
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Global function-valued variable, adding a convenient Call()
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
List of MenuBarListEntry.
static CommandHandlerFinder DefaultFinder()
FinderScope(CommandHandlerFinder finder)
static CommandHandlerFinder sFinder
std::vector< Identifier > Path
Definition: Registry.h:245
List of SubMenuListEntry.
Holds a msgid for the translation catalog; may also bind format arguments.
Set a variable temporarily in a scope.
Definition: MemoryX.h:212
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
virtual XMLTagHandler * HandleXMLChild(const std::string_view &tag)=0
virtual void HandleXMLEndTag(const std::string_view &WXUNUSED(tag))
Definition: XMLTagHandler.h:59
virtual bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs)=0
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:26
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:194
std::unique_ptr< MenuItem > Menu(const Identifier &internalName, const TranslatableString &title, Args &&... args)
std::unique_ptr< MenuPart > Section(const Identifier &internalName, Args &&... args)
void DestroyRegistry()
Definition: Menus.cpp:267
std::unique_ptr< CommandGroupItem > CommandGroup(const Identifier &name, std::vector< ComponentInterfaceSymbol > items, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, bool isEffect=false, CommandHandlerFinder finder=FinderScope::DefaultFinder())
std::unique_ptr< ConditionalGroupItem > ConditionalItems(const Identifier &internalName, ConditionalGroupItem::Condition condition, Args &&... args)
std::unique_ptr< MenuItems > Items(const Identifier &internalName, Args &&... args)
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
std::unique_ptr< SpecialItem > Special(const Identifier &name, const SpecialItem::Appender &fn)
BaseItemPtr MenuOrItems(const Identifier &internalName, const TranslatableString &title, Args &&... args)
Definition: Menus.h:36
std::unique_ptr< BaseItem > BaseItemPtr
Definition: Registry.h:71
std::vector< BaseItemPtr > BaseItemPtrs
Definition: Registry.h:73
std::vector< CommandFlagOptions > & Options()
Definition: Menus.cpp:535
STL namespace.
A convenient default parameter for class template Site.
Definition: ClientData.h:28
CommandListEntry is a structure used by CommandManager.
Options && CheckTest(const BoolSetting &setting) &&
Options && CheckTest(const wxChar *key, bool defaultValue) &&
Options && UseStrictFlags() &&
Options && CheckTest(const CheckFn &fn) &&
Options(const wxChar *accel_)
Options && AllowDup() &&
Options(const wxChar *accel_, const TranslatableString &longName_)
Options && WantKeyUp() &&
Options && IsGlobal() &&
Options && Accel(const wxChar *value) &&
Options && IsEffect(bool value=true) &&
Options && SkipKeyDown() &&
Options && Parameter(const CommandParameter &value) &&
Options && LongName(const TranslatableString &value) &&
Options && AllowInMacros(int value=1) &&
MenuBarListEntry is a structure used by CommandManager.
AttachedItem(const wxString &path, BaseItemPtr pItem)
const std::vector< ComponentInterfaceSymbol > items
CommandHandlerFinder finder
CommandFunctorPointer callback
CommandGroupItem(const Identifier &name_, std::vector< ComponentInterfaceSymbol > items_, void(Handler::*pmf)(const CommandContext &), CommandFlag flags_, bool isEffect_, CommandHandlerFinder finder=FinderScope::DefaultFinder())
const TranslatableString label_in
CommandHandlerFinder finder
CommandFunctorPointer callback
CommandItem(const CommandID &name_, const TranslatableString &label_in_, void(Handler::*pmf)(const CommandContext &), CommandFlag flags_, const CommandManager::Options &options_, CommandHandlerFinder finder=FinderScope::DefaultFinder())
CommandManager::Options options
std::function< bool() > Condition
ConditionalGroupItem(const Identifier &internalName, Condition condition_, BaseItemPtrs &&items_)
Definition: Menus.cpp:196
ConditionalGroupItem(const Identifier &internalName, Condition condition_, Args &&... args)
MenuItem(const Identifier &internalName, const TranslatableString &title_, Args &&... args)
TranslatableString title
MenuPart(const Identifier &internalName, Args &&... args)
~SpecialItem() override
Definition: Menus.cpp:228
SpecialItem(const Identifier &internalName, const Appender &fn_)
std::function< void(AudacityProject &, wxMenu &) > Appender
WholeMenu(bool extend=false)
std::vector< bool > firstItem
std::vector< bool > needSeparator
SubMenuListEntry is a structure used by CommandManager.
AudacityProject & project
ToolbarMenuVisitor(AudacityProject &p)