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