Audacity  3.0.3
Menus.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Menus.cpp
6 
7  Dominic Mazzoni
8  Brian Gunlogson
9  et al.
10 
11 *******************************************************************//****************************************************************//****************************************************************//*******************************************************************/
27 
28 
29 #include "Menus.h"
30 
31 
32 
33 #include <wx/frame.h>
34 
35 #include "Project.h"
36 #include "ProjectHistory.h"
37 #include "ProjectSettings.h"
38 #include "ProjectWindows.h"
39 #include "UndoManager.h"
41 #include "toolbars/ToolManager.h"
43 #include "BasicUI.h"
44 
45 #include <unordered_set>
46 
47 #include <wx/menu.h>
48 #include <wx/windowptr.h>
49 
51 {
54 
58  mRepeatToolFlags = 0;
59 }
60 
62 {
63 }
64 
66  []( AudacityProject &project ){
67  return std::make_shared< MenuManager >( project ); }
68 };
69 
71 {
72  return project.AttachedObjects::Get< MenuManager >( key );
73 }
74 
76 {
77  return Get( const_cast< AudacityProject & >( project ) );
78 }
79 
81  : mProject{ project }
82 {
83  UpdatePrefs();
84  mProject.Bind( EVT_UNDO_OR_REDO, &MenuManager::OnUndoRedo, this );
85  mProject.Bind( EVT_UNDO_RESET, &MenuManager::OnUndoRedo, this );
86  mProject.Bind( EVT_UNDO_PUSHED, &MenuManager::OnUndoRedo, this );
87  mProject.Bind( EVT_UNDO_RENAMED, &MenuManager::OnUndoRedo, this );
88 }
89 
91 {
92  mProject.Unbind( EVT_UNDO_OR_REDO, &MenuManager::OnUndoRedo, this );
93  mProject.Unbind( EVT_UNDO_RESET, &MenuManager::OnUndoRedo, this );
94  mProject.Unbind( EVT_UNDO_PUSHED, &MenuManager::OnUndoRedo, this );
95 }
96 
98 {
99  bool bSelectAllIfNone;
100  gPrefs->Read(wxT("/GUI/SelectAllOnNone"), &bSelectAllIfNone, false);
101  // 0 is grey out, 1 is Autoselect, 2 is Give warnings.
102 #ifdef EXPERIMENTAL_DA
103  // DA warns or greys out.
104  mWhatIfNoSelection = bSelectAllIfNone ? 2 : 0;
105 #else
106  // Audacity autoselects or warns.
107  mWhatIfNoSelection = bSelectAllIfNone ? 1 : 2;
108 #endif
109  mStopIfWasPaused = true; // not configurable for now, but could be later.
110 }
111 
113 {
114  bool isMenu = false;
115  bool isExtension = false;
116  auto pItem = &item;
117  if ( pItem->Transparent() ) {
118  }
119  else if ( dynamic_cast<MenuTable::MenuSection*>( pItem ) ) {
120  if ( !needSeparator.empty() )
121  needSeparator.back() = true;
122  }
123  else if ( auto pWhole = dynamic_cast<MenuTable::WholeMenu*>( pItem ) ) {
124  isMenu = true;
125  isExtension = pWhole->extension;
127  }
128 
129  DoBeginGroup( item, path );
130 
131  if ( isMenu ) {
132  needSeparator.push_back( false );
133  firstItem.push_back( !isExtension );
134  }
135 }
136 
138 {
139  auto pItem = &item;
140  if ( pItem->Transparent() ) {
141  }
142  else if ( dynamic_cast<MenuTable::MenuSection*>( pItem ) ) {
143  if ( !needSeparator.empty() )
144  needSeparator.back() = true;
145  }
146  else if ( dynamic_cast<MenuTable::WholeMenu*>( pItem ) ) {
147  firstItem.pop_back();
148  needSeparator.pop_back();
149  }
150 
151  DoEndGroup( item, path );
152 }
153 
154 void MenuVisitor::Visit( Registry::SingleItem &item, const Path &path )
155 {
157  DoVisit( item, path );
158 }
159 
161 {
162  bool separate = false;
163  if ( !needSeparator.empty() ) {
164  separate = needSeparator.back() && !firstItem.back();
165  needSeparator.back() = false;
166  firstItem.back() = false;
167  }
168 
169  if ( separate )
170  DoSeparator();
171 }
172 
174 {
175 }
176 
178 {
179 }
180 
182 {
183 }
184 
186 {
187 }
188 
189 namespace MenuTable {
190 
191 MenuItem::MenuItem( const Identifier &internalName,
192  const TranslatableString &title_, BaseItemPtrs &&items_ )
194  internalName, std::move( items_ ) }, title{ title_ }
195 {
196  wxASSERT( !title.empty() );
197 }
199 
201  const Identifier &internalName, Condition condition_, BaseItemPtrs &&items_ )
203  internalName, std::move( items_ ) }, condition{ condition_ }
204 {
205 }
207 
209  const TranslatableString &label_in_,
210  CommandFunctorPointer callback_,
211  CommandFlag flags_,
212  const CommandManager::Options &options_,
213  CommandHandlerFinder finder_)
214 : SingleItem{ name_ }, label_in{ label_in_ }
215 , finder{ finder_ }, callback{ callback_ }
216 , flags{ flags_ }, options{ options_ }
217 {}
219 
221  std::vector< ComponentInterfaceSymbol > items_,
222  CommandFunctorPointer callback_,
223  CommandFlag flags_,
224  bool isEffect_,
225  CommandHandlerFinder finder_)
226 : SingleItem{ name_ }, items{ std::move(items_) }
227 , finder{ finder_ }, callback{ callback_ }
228 , flags{ flags_ }, isEffect{ isEffect_ }
229 {}
231 
233 
236 
238  [](AudacityProject &project) -> CommandHandlerObject & {
239  // If this default finder function is reached, then FinderScope should
240  // have been used somewhere, or an explicit CommandHandlerFinder passed
241  // to menu item constructors
242  wxASSERT( false );
243  return project;
244  };
245 
246 }
247 
251 
252 namespace {
253 
254 using namespace Registry;
255 
256 const auto MenuPathStart = wxT("MenuBar");
257 
259 {
261  return registry;
262 }
263 }
264 
266  const Placement &placement, BaseItemPtr pItem )
267 {
268  Registry::RegisterItem( sRegistry(), placement, std::move( pItem ) );
269 }
270 
272 {
273  sRegistry().items.clear();
274 }
275 
276 namespace {
277 
278 using namespace MenuTable;
279 
281 {
283  : ToolbarMenuVisitor(proj), manager( man ) {}
284 
285  void DoBeginGroup( GroupItem &item, const Path& ) override
286  {
287  auto pItem = &item;
288  if (const auto pMenu =
289  dynamic_cast<MenuItem*>( pItem )) {
290  manager.BeginMenu( pMenu->title );
291  }
292  else
293  if (const auto pConditionalGroup =
294  dynamic_cast<ConditionalGroupItem*>( pItem )) {
295  const auto flag = pConditionalGroup->condition();
296  if (!flag)
297  manager.BeginOccultCommands();
298  // to avoid repeated call of condition predicate in EndGroup():
299  flags.push_back(flag);
300  }
301  else
302  if ( pItem->Transparent() ) {
303  }
304  else
305  if ( const auto pGroup = dynamic_cast<MenuSection*>( pItem ) ) {
306  }
307  else
308  wxASSERT( false );
309  }
310 
311  void DoEndGroup( GroupItem &item, const Path& ) override
312  {
313  auto pItem = &item;
314  if (const auto pMenu =
315  dynamic_cast<MenuItem*>( pItem )) {
316  manager.EndMenu();
317  }
318  else
319  if (const auto pConditionalGroup =
320  dynamic_cast<ConditionalGroupItem*>( pItem )) {
321  const bool flag = flags.back();
322  if (!flag)
323  manager.EndOccultCommands();
324  flags.pop_back();
325  }
326  else
327  if ( pItem->Transparent() ) {
328  }
329  else
330  if ( const auto pGroup = dynamic_cast<MenuSection*>( pItem ) ) {
331  }
332  else
333  wxASSERT( false );
334  }
335 
336  void DoVisit( SingleItem &item, const Path& ) override
337  {
338  const auto pCurrentMenu = manager.CurrentMenu();
339  if ( !pCurrentMenu ) {
340  // There may have been a mistake in the placement hint that registered
341  // this single item. It's not within any menu.
342  wxASSERT( false );
343  return;
344  }
345  auto pItem = &item;
346  if (const auto pCommand =
347  dynamic_cast<CommandItem*>( pItem )) {
348  manager.AddItem( project,
349  pCommand->name, pCommand->label_in,
350  pCommand->finder, pCommand->callback,
351  pCommand->flags, pCommand->options
352  );
353  }
354  else
355  if (const auto pCommandList =
356  dynamic_cast<CommandGroupItem*>( pItem ) ) {
357  manager.AddItemList(pCommandList->name,
358  pCommandList->items.data(), pCommandList->items.size(),
359  pCommandList->finder, pCommandList->callback,
360  pCommandList->flags, pCommandList->isEffect);
361  }
362  else
363  if (const auto pSpecial =
364  dynamic_cast<SpecialItem*>( pItem )) {
365  wxASSERT( pCurrentMenu );
366  pSpecial->fn( project, *pCurrentMenu );
367  }
368  else
369  wxASSERT( false );
370  }
371 
372  void DoSeparator() override
373  {
374  manager.AddSeparator();
375  }
376 
378  std::vector<bool> flags;
379 };
380 }
381 
383 {
384  // Once only, cause initial population of preferences for the ordering
385  // of some menu items that used to be given in tables but are now separately
386  // registered in several .cpp files; the sequence of registration depends
387  // on unspecified accidents of static initialization order across
388  // compilation units, so we need something specific here to preserve old
389  // default appearance of menus.
390  // But this needs only to mention some strings -- there is no compilation or
391  // link dependency of this source file on those other implementation files.
394  {
395  {wxT(""), wxT(
396  "File,Edit,Select,View,Transport,Tracks,Generate,Effect,Analyze,Tools,Window,Optional,Help"
397  )},
398  {wxT("/Optional/Extra/Part1"), wxT(
399  "Transport,Tools,Mixer,Edit,PlayAtSpeed,Seek,Device,Select"
400  )},
401  {wxT("/Optional/Extra/Part2"), wxT(
402  "Navigation,Focus,Cursor,Track,Scriptables1,Scriptables2"
403  )},
404  {wxT("/View/Windows"), wxT("UndoHistory,Karaoke,MixerBoard")},
405  {wxT("/Analyze/Analyzers/Windows"), wxT("ContrastAnalyser,PlotSpectrum")},
406  {wxT("/Transport/Basic"), wxT("Play,Record,Scrubbing,Cursor")},
407  {wxT("/View/Other/Toolbars/Toolbars/Other"), wxT(
408 "ShowTransportTB,ShowToolsTB,ShowRecordMeterTB,ShowPlayMeterTB,"
409 //"ShowMeterTB,"
410 "ShowMixerTB,"
411 "ShowEditTB,ShowTranscriptionTB,ShowScrubbingTB,ShowDeviceTB,ShowSelectionTB,"
412 "ShowSpectralSelectionTB") }
413  }
414  };
415 
416  auto &commandManager = CommandManager::Get( project );
417 
418  // The list of defaults to exclude depends on
419  // preference wxT("/GUI/Shortcuts/FullDefaults"), which may have changed.
420  commandManager.SetMaxList();
421 
422  auto menubar = commandManager.AddMenuBar(wxT("appmenu"));
423  wxASSERT(menubar);
424 
425  MenuItemVisitor visitor{ project, commandManager };
426  MenuManager::Visit( visitor );
427 
428  GetProjectFrame( project ).SetMenuBar(menubar.release());
429 
430  mLastFlags = AlwaysEnabledFlag;
431 
432 #if defined(_DEBUG)
433 // c->CheckDups();
434 #endif
435 }
436 
438 {
439  static const auto menuTree = MenuTable::Items( MenuPathStart );
440  Registry::Visit( visitor, menuTree.get(), &sRegistry() );
441 }
442 
443 // TODO: This surely belongs in CommandManager?
445 {
447  auto &undoManager = UndoManager::Get( project );
448  auto &commandManager = CommandManager::Get( project );
449  int cur = undoManager.GetCurrentState();
450 
451  if (undoManager.UndoAvailable()) {
452  undoManager.GetShortDescription(cur, &desc);
453  commandManager.Modify(wxT("Undo"),
454  XXO("&Undo %s")
455  .Format( desc ));
456  commandManager.Enable(wxT("Undo"),
457  ProjectHistory::Get( project ).UndoAvailable());
458  }
459  else {
460  commandManager.Modify(wxT("Undo"),
461  XXO("&Undo"));
462  }
463 
464  if (undoManager.RedoAvailable()) {
465  undoManager.GetShortDescription(cur+1, &desc);
466  commandManager.Modify(wxT("Redo"),
467  XXO("&Redo %s")
468  .Format( desc ));
469  commandManager.Enable(wxT("Redo"),
470  ProjectHistory::Get( project ).RedoAvailable());
471  }
472  else {
473  commandManager.Modify(wxT("Redo"),
474  XXO("&Redo"));
475  commandManager.Enable(wxT("Redo"), false);
476  }
477 }
478 
479 // Get hackcess to a protected method
480 class wxFrameEx : public wxFrame
481 {
482 public:
483  using wxFrame::DetachMenuBar;
484 };
485 
487 {
488  // On OSX, we can't rebuild the menus while a modal dialog is being shown
489  // since the enabled state for menus like Quit and Preference gets out of
490  // sync with wxWidgets idea of what it should be.
491 #if defined(__WXMAC__) && defined(_DEBUG)
492  {
493  wxDialog *dlg =
494  wxDynamicCast(wxGetTopLevelParent(wxWindow::FindFocus()), wxDialog);
495  wxASSERT((!dlg || !dlg->IsModal()));
496  }
497 #endif
498 
499  // Delete the menus, since we will soon recreate them.
500  // Rather oddly, the menus don't vanish as a result of doing this.
501  {
502  auto &window = static_cast<wxFrameEx&>( GetProjectFrame( project ) );
503  wxWindowPtr<wxMenuBar> menuBar{ window.GetMenuBar() };
504  window.DetachMenuBar();
505  // menuBar gets deleted here
506  }
507 
508  CommandManager::Get( project ).PurgeData();
509 
510  CreateMenusAndCommands(project);
511 }
512 
513 void MenuManager::OnUndoRedo( wxCommandEvent &evt )
514 {
515  evt.Skip();
516  ModifyUndoMenuItems( mProject );
517  UpdateMenus();
518 }
519 
520 namespace{
521  using Predicates = std::vector< ReservedCommandFlag::Predicate >;
523  {
524  static Predicates thePredicates;
525  return thePredicates;
526  }
527  std::vector< CommandFlagOptions > &Options()
528  {
529  static std::vector< CommandFlagOptions > options;
530  return options;
531  }
532 }
533 
535  const Predicate &predicate, const CommandFlagOptions &options )
536 {
537  static size_t sNextReservedFlag = 0;
538  // This will throw std::out_of_range if the constant NCommandFlags is too
539  // small
540  set( sNextReservedFlag++ );
541  RegisteredPredicates().emplace_back( predicate );
542  Options().emplace_back( options );
543 }
544 
545 CommandFlag MenuManager::GetUpdateFlags( bool checkActive ) const
546 {
547  // This method determines all of the flags that determine whether
548  // certain menu items and commands should be enabled or disabled,
549  // and returns them in a bitfield. Note that if none of the flags
550  // have changed, it's not necessary to even check for updates.
551 
552  // static variable, used to remember flags for next time.
553  static CommandFlag lastFlags;
554 
555  CommandFlag flags, quickFlags;
556 
557  const auto &options = Options();
558  size_t ii = 0;
559  for ( const auto &predicate : RegisteredPredicates() ) {
560  if ( options[ii].quickTest ) {
561  quickFlags[ii] = true;
562  if( predicate( mProject ) )
563  flags[ii] = true;
564  }
565  ++ii;
566  }
567 
568  if ( checkActive && !GetProjectFrame( mProject ).IsActive() )
569  // quick 'short-circuit' return.
570  flags = (lastFlags & ~quickFlags) | flags;
571  else {
572  ii = 0;
573  for ( const auto &predicate : RegisteredPredicates() ) {
574  if ( !options[ii].quickTest && predicate( mProject ) )
575  flags[ii] = true;
576  ++ii;
577  }
578  }
579 
580  lastFlags = flags;
581  return flags;
582 }
583 
585 {
586  for (auto pProject : AllProjects{}) {
587  auto &project = *pProject;
588  MenuManager::Get(project).ModifyToolbarMenus(project);
589  }
590 }
591 
593 {
594  // Refreshes can occur during shutdown and the toolmanager may already
595  // be deleted, so protect against it.
596  auto &toolManager = ToolManager::Get( project );
597 
598  auto &settings = ProjectSettings::Get( project );
599 
600  // Now, go through each toolbar, and call EnableDisableButtons()
601  for (int i = 0; i < ToolBarCount; i++) {
602  auto bar = toolManager.GetToolBar(i);
603  if (bar)
604  bar->EnableDisableButtons();
605  }
606 
607  // These don't really belong here, but it's easier and especially so for
608  // the Edit toolbar and the sync-lock menu item.
609  bool active;
610 
611  gPrefs->Read(wxT("/GUI/SyncLockTracks"), &active, false);
612  settings.SetSyncLock(active);
613 
614  CommandManager::Get( project ).UpdateCheckmarks( project );
615 }
616 
617 namespace
618 {
619  using MenuItemEnablers = std::vector<MenuItemEnabler>;
621  {
622  static MenuItemEnablers enablers;
623  return enablers;
624  }
625 }
626 
628  const MenuItemEnabler &enabler )
629 {
630  Enablers().emplace_back( enabler );
631 }
632 
633 // checkActive is a temporary hack that should be removed as soon as we
634 // get multiple effect preview working
635 void MenuManager::UpdateMenus( bool checkActive )
636 {
637  auto &project = mProject;
638 
639  auto flags = GetUpdateFlags(checkActive);
640  // Return from this function if nothing's changed since
641  // the last time we were here.
642  if (flags == mLastFlags)
643  return;
644  mLastFlags = flags;
645 
646  auto flags2 = flags;
647 
648  // We can enable some extra items if we have select-all-on-none.
649  //EXPLAIN-ME: Why is this here rather than in GetUpdateFlags()?
650  //ANSWER: Because flags2 is used in the menu enable/disable.
651  //The effect still needs flags to determine whether it will need
652  //to actually do the 'select all' to make the command valid.
653 
654  for ( const auto &enabler : Enablers() ) {
655  auto actual = enabler.actualFlags();
656  if (
657  enabler.applicable( project ) && (flags & actual) == actual
658  )
659  flags2 |= enabler.possibleFlags();
660  }
661 
662  auto &commandManager = CommandManager::Get( project );
663 
664  // With select-all-on-none, some items that we don't want enabled may have
665  // been enabled, since we changed the flags. Here we manually disable them.
666  // 0 is grey out, 1 is Autoselect, 2 is Give warnings.
667  commandManager.EnableUsingFlags(
668  flags2, // the "lax" flags
669  (mWhatIfNoSelection == 0 ? flags2 : flags) // the "strict" flags
670  );
671 
673 }
674 
678 
680 {
681  for( auto p : AllProjects{} ) {
683 #if defined(__WXGTK__)
684  // Workaround for:
685  //
686  // http://bugzilla.audacityteam.org/show_bug.cgi?id=458
687  //
688  // This workaround should be removed when Audacity updates to wxWidgets 3.x which has a fix.
689  auto &window = GetProjectFrame( *p );
690  wxRect r = window.GetRect();
691  window.SetSize(wxSize(1,1));
692  window.SetSize(r.GetSize());
693 #endif
694  }
695 }
696 
698  const TranslatableString & Name, CommandFlag & flags, CommandFlag flagsRqd )
699 {
700  auto &project = mProject;
701  bool bAllowed = TryToMakeActionAllowed( flags, flagsRqd );
702  if( bAllowed )
703  return true;
704  auto &cm = CommandManager::Get( project );
705  TellUserWhyDisallowed( Name, flags & flagsRqd, flagsRqd);
706  return false;
707 }
708 
713  CommandFlag & flags, CommandFlag flagsRqd )
714 {
715  auto &project = mProject;
716 
717  if( flags.none() )
718  flags = GetUpdateFlags();
719 
720  // Visit the table of recovery actions
721  auto &enablers = Enablers();
722  auto iter = enablers.begin(), end = enablers.end();
723  while ((flags & flagsRqd) != flagsRqd && iter != end) {
724  const auto &enabler = *iter;
725  auto actual = enabler.actualFlags();
726  auto MissingFlags = (~flags & flagsRqd);
727  if (
728  // Do we have the right precondition?
729  (flags & actual) == actual
730  &&
731  // Can we get the condition we need?
732  (MissingFlags & enabler.possibleFlags()).any()
733  ) {
734  // Then try the function
735  enabler.tryEnable( project, flagsRqd );
736  flags = GetUpdateFlags();
737  }
738  ++iter;
739  }
740  return (flags & flagsRqd) == flagsRqd;
741 }
742 
744  const TranslatableString & Name, CommandFlag flagsGot, CommandFlag flagsRequired )
745 {
746  // The default string for 'reason' is a catch all. I hope it won't ever be seen
747  // and that we will get something more specific.
748  auto reason = XO("There was a problem with your last action. If you think\nthis is a bug, please tell us exactly where it occurred.");
749  // The default title string is 'Disallowed'.
750  auto untranslatedTitle = XO("Disallowed");
751  wxString helpPage;
752 
753  bool enableDefaultMessage = true;
754  bool defaultMessage = true;
755 
756  auto doOption = [&](const CommandFlagOptions &options) {
757  if ( options.message ) {
758  reason = options.message( Name );
759  defaultMessage = false;
760  if ( !options.title.empty() )
761  untranslatedTitle = options.title;
762  helpPage = options.helpPage;
763  return true;
764  }
765  else {
766  enableDefaultMessage =
767  enableDefaultMessage && options.enableDefaultMessage;
768  return false;
769  }
770  };
771 
772  const auto &alloptions = Options();
773  auto missingFlags = flagsRequired & ~flagsGot;
774 
775  // Find greatest priority
776  unsigned priority = 0;
777  for ( const auto &options : alloptions )
778  priority = std::max( priority, options.priority );
779 
780  // Visit all unsatisfied conditions' options, by descending priority,
781  // stopping when we find a message
782  ++priority;
783  while( priority-- ) {
784  size_t ii = 0;
785  for ( const auto &options : alloptions ) {
786  if (
787  priority == options.priority
788  &&
789  missingFlags[ii]
790  &&
791  doOption( options ) )
792  goto done;
793 
794  ++ii;
795  }
796  }
797  done:
798 
799  if (
800  // didn't find a message
801  defaultMessage
802  &&
803  // did find a condition that suppresses the default message
804  !enableDefaultMessage
805  )
806  return;
807 
808  // Does not have the warning icon...
810  untranslatedTitle,
811  reason,
812  helpPage);
813 }
anonymous_namespace{Menus.cpp}::MenuItemVisitor::DoBeginGroup
void DoBeginGroup(GroupItem &item, const Path &) override
Definition: Menus.cpp:285
Registry::TransparentGroupItem
Definition: Registry.h:210
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
Registry::RegisterItem
void RegisterItem(GroupItem &registry, const Placement &placement, BaseItemPtr pItem)
Definition: Registry.cpp:750
ReservedCommandFlag::ReservedCommandFlag
ReservedCommandFlag(const Predicate &predicate, const CommandFlagOptions &options={})
Definition: Menus.cpp:534
Registry::SingleItem
Definition: Registry.h:120
MenuTable::CommandItem::~CommandItem
~CommandItem() override
Definition: Menus.cpp:218
Registry
Definition: Menus.h:35
ToolManager.h
ToolBarCount
@ ToolBarCount
Definition: ToolBar.h:87
MenuManager
MenuManager handles updates to menu state.
Definition: Menus.h:77
MenuTable::MenuItem::~MenuItem
~MenuItem() override
Definition: Menus.cpp:198
MenuVisitor::firstItem
std::vector< bool > firstItem
Definition: CommandManager.h:404
anonymous_namespace{Menus.cpp}::MenuItemVisitor::DoEndGroup
void DoEndGroup(GroupItem &item, const Path &) override
Definition: Menus.cpp:311
MenuTable::ConditionalGroupItem::ConditionalGroupItem
ConditionalGroupItem(const Identifier &internalName, Condition condition_, BaseItemPtrs &&items_)
Definition: Menus.cpp:200
flag
static std::once_flag flag
Definition: WaveformView.cpp:1124
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
MenuTable::WholeMenu::~WholeMenu
virtual ~WholeMenu()
Definition: Menus.cpp:235
MenuManager::UpdatePrefs
void UpdatePrefs() override
Definition: Menus.cpp:97
BasicUI::ShowErrorDialog
void ShowErrorDialog(const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options={})
Show an error dialog with a link to the manual for further help.
Definition: BasicUI.h:233
Project.h
MenuTable::ConditionalGroupItem::Condition
std::function< bool() > Condition
Definition: CommandManager.h:454
anonymous_namespace{Menus.cpp}::MenuItemVisitor::MenuItemVisitor
MenuItemVisitor(AudacityProject &proj, CommandManager &man)
Definition: Menus.cpp:282
CommandManager::Options
Definition: CommandManager.h:98
anonymous_namespace{Menus.cpp}::MenuItemVisitor::manager
CommandManager & manager
Definition: Menus.cpp:377
Format
Abstract base class used in importing a file.
MenuCreator::mRepeatEffectFlags
unsigned mRepeatEffectFlags
Definition: Menus.h:66
ToolManager::Get
static ToolManager & Get(AudacityProject &project)
Definition: ToolManager.cpp:356
anonymous_namespace{Menus.cpp}::MenuItemVisitor
Definition: Menus.cpp:281
MenuItemEnabler
Definition: CommandFlag.h:107
MenuManager::TellUserWhyDisallowed
void TellUserWhyDisallowed(const TranslatableString &Name, CommandFlag flagsGot, CommandFlag flagsRequired)
Definition: Menus.cpp:743
CommandManager.h
MenuTable::ConditionalGroupItem::~ConditionalGroupItem
~ConditionalGroupItem() override
Definition: Menus.cpp:206
XO
#define XO(s)
Definition: Internat.h:31
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:41
MenuCreator::mRepeatAnalyzerFlags
unsigned mRepeatAnalyzerFlags
Definition: Menus.h:67
anonymous_namespace{Menus.cpp}::Enablers
MenuItemEnablers & Enablers()
Definition: Menus.cpp:620
TrackInfo::UpdatePrefs
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
ProjectSettings.h
AlwaysEnabledFlag
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:35
CommandFlag
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
MenuManager::ModifyAllProjectToolbarMenus
static void ModifyAllProjectToolbarMenus()
Definition: Menus.cpp:584
MenuTable::SpecialItem
Definition: CommandManager.h:566
set
#define set(f, v)
MenuCreator::MenuCreator
MenuCreator()
Definition: Menus.cpp:50
Registry::Placement
Definition: Registry.h:219
ClientData::Site::RegisteredFactory
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:266
desc
const TranslatableString desc
Definition: ExportPCM.cpp:58
MenuTable::ConditionalGroupItem
Definition: CommandManager.h:453
MenuCreator::RebuildAllMenuBars
static void RebuildAllMenuBars()
Definition: Menus.cpp:679
CommandHandlerFinder
std::function< CommandHandlerObject &(AudacityProject &) > CommandHandlerFinder
Definition: CommandFunctors.h:33
MenuManager::MenuManager
MenuManager(AudacityProject &project)
Definition: Menus.cpp:80
MenuVisitor::DoBeginGroup
virtual void DoBeginGroup(Registry::GroupItem &item, const Path &path)
Definition: Menus.cpp:173
Identifier
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
MenuVisitor::needSeparator
std::vector< bool > needSeparator
Definition: CommandManager.h:405
XXO
#define XXO(s)
Definition: Internat.h:44
Registry::BaseItemPtr
std::unique_ptr< BaseItem > BaseItemPtr
Definition: Registry.h:71
MenuVisitor::EndGroup
void EndGroup(Registry::GroupItem &item, const Path &) final
Definition: Menus.cpp:137
MenuManager::UpdateMenus
void UpdateMenus(bool checkActive=true)
Definition: Menus.cpp:635
Registry::Visitor::Path
std::vector< Identifier > Path
Definition: Registry.h:245
anonymous_namespace{Menus.cpp}::MenuItemVisitor::DoVisit
void DoVisit(SingleItem &item, const Path &) override
Definition: Menus.cpp:336
MenuCreator::mLastAnalyzerRegistration
int mLastAnalyzerRegistration
Definition: Menus.h:54
anonymous_namespace{Menus.cpp}::MenuItemVisitor::flags
std::vector< bool > flags
Definition: Menus.cpp:378
MenuTable::CommandItem::CommandItem
CommandItem(const CommandID &name_, const TranslatableString &label_in_, CommandFunctorPointer callback_, CommandFlag flags_, const CommandManager::Options &options_, CommandHandlerFinder finder_)
Definition: Menus.cpp:208
MenuCreator::RebuildMenuBar
void RebuildMenuBar(AudacityProject &project)
Definition: Menus.cpp:486
MenuTable::AttachedItem::AttachedItem
AttachedItem(const Placement &placement, BaseItemPtr pItem)
Definition: Menus.cpp:265
MenuManager::mWhatIfNoSelection
int mWhatIfNoSelection
Definition: Menus.h:122
MenuCreator::CreateMenusAndCommands
void CreateMenusAndCommands(AudacityProject &project)
Definition: Menus.cpp:382
ToolbarMenuVisitor
Definition: CommandManager.h:409
MenuVisitor::MaybeDoSeparator
void MaybeDoSeparator()
Definition: Menus.cpp:160
UndoManager.h
MenuTable::Items
std::unique_ptr< MenuItems > Items(const Identifier &internalName, Args &&... args)
Definition: CommandManager.h:600
MenuManager::mProject
AudacityProject & mProject
Definition: Menus.h:118
MenuVisitor::Visit
void Visit(Registry::SingleItem &item, const Path &path) final
Definition: Menus.cpp:154
MenuVisitor::DoVisit
virtual void DoVisit(Registry::SingleItem &item, const Path &path)
Definition: Menus.cpp:181
MenuCreator::mRepeatGeneratorFlags
unsigned mRepeatGeneratorFlags
Definition: Menus.h:65
CommandManager::UpdateCheckmarks
void UpdateCheckmarks(AudacityProject &project)
Definition: CommandManager.cpp:535
anonymous_namespace{Menus.cpp}::RegisteredPredicates
Predicates & RegisteredPredicates()
Definition: Menus.cpp:522
MenuCreator::mRepeatToolFlags
unsigned mRepeatToolFlags
Definition: Menus.h:68
MenuVisitor::BeginGroup
void BeginGroup(Registry::GroupItem &item, const Path &path) final
Definition: Menus.cpp:112
CommandFlagOptions
Definition: CommandFlag.h:38
title
static const auto title
Definition: UpdateNoticeDialog.cpp:23
MenuManager::TryToMakeActionAllowed
bool TryToMakeActionAllowed(CommandFlag &flags, CommandFlag flagsRqd)
Definition: Menus.cpp:712
Menus.h
MenuTable::MenuItem
Definition: CommandManager.h:432
ProjectWindows.h
accessors for certain important windows associated with each project
BasicUI.h
Toolkit-neutral facade for basic user interface services.
MenuTable::CommandGroupItem
Definition: CommandManager.h:532
MenuTable::CommandItem
Definition: CommandManager.h:498
anonymous_namespace{Menus.cpp}::MenuItemVisitor::DoSeparator
void DoSeparator() override
Definition: Menus.cpp:372
Registry::BaseItemPtrs
std::vector< BaseItemPtr > BaseItemPtrs
Definition: Registry.h:73
MenuManager::ReportIfActionNotAllowed
bool ReportIfActionNotAllowed(const TranslatableString &Name, CommandFlag &flags, CommandFlag flagsRqd)
Definition: Menus.cpp:697
Registry::Visit
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry)
Definition: Registry.cpp:713
TaggedIdentifier< CommandIdTag, false >
MenuManager::OnUndoRedo
void OnUndoRedo(wxCommandEvent &evt)
Definition: Menus.cpp:513
wxFrameEx
Definition: Menus.cpp:481
UndoManager::Get
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:57
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
Registry::ConcreteGroupItem
Definition: Registry.h:198
AudacityMessageBox.h
GetProjectFrame
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
Definition: ProjectWindows.cpp:72
MenuManager::Get
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:70
AllProjects
Definition: Project.h:35
CommandManager
CommandManager implements a system for organizing all user-callable commands.
Definition: CommandManager.h:59
CommandHandlerObject
wxEvtHandler CommandHandlerObject
Definition: CommandFunctors.h:28
ProjectHistory.h
MenuCreator::~MenuCreator
~MenuCreator()
Definition: Menus.cpp:61
MenuTable::FinderScope::sFinder
static CommandHandlerFinder sFinder
Definition: CommandManager.h:486
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: Menus.cpp:65
Registry::GroupItem
Definition: Registry.h:126
RegisteredMenuItemEnabler::RegisteredMenuItemEnabler
RegisteredMenuItemEnabler(const MenuItemEnabler &enabler)
Definition: Menus.cpp:627
anonymous_namespace{Menus.cpp}::sRegistry
static Registry::GroupItem & sRegistry()
Definition: Menus.cpp:258
MenuTable::CommandGroupItem::CommandGroupItem
CommandGroupItem(const Identifier &name_, std::vector< ComponentInterfaceSymbol > items_, CommandFunctorPointer callback_, CommandFlag flags_, bool isEffect_, CommandHandlerFinder finder_)
Definition: Menus.cpp:220
MenuCreator::mLastToolRegistration
int mLastToolRegistration
Definition: Menus.h:57
MenuTable
Definition: CommandManager.h:416
MenuTable::CommandGroupItem::~CommandGroupItem
~CommandGroupItem() override
Definition: Menus.cpp:230
MenuPathStart
static const auto MenuPathStart
Definition: WaveTrackControls.cpp:492
MenuManager::~MenuManager
~MenuManager()
Definition: Menus.cpp:90
CommandManager::Get
static CommandManager & Get(AudacityProject &project)
Definition: CommandManager.cpp:207
MenuManager::ModifyUndoMenuItems
static void ModifyUndoMenuItems(AudacityProject &project)
Definition: Menus.cpp:444
MenuTable::DestroyRegistry
void DestroyRegistry()
Definition: Menus.cpp:271
Registry::GroupItem::items
BaseItemPtrs items
Definition: Registry.h:141
MenuTable::MenuSection
Definition: CommandManager.h:420
anonymous_namespace{Menus.cpp}::Predicates
std::vector< ReservedCommandFlag::Predicate > Predicates
Definition: Menus.cpp:521
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
CommandManager::PurgeData
void PurgeData()
Definition: CommandManager.cpp:342
MenuTable::MenuSection::~MenuSection
virtual ~MenuSection()
Definition: Menus.cpp:234
anonymous_namespace{Menus.cpp}::Options
std::vector< CommandFlagOptions > & Options()
Definition: Menus.cpp:527
MenuCreator::repeattypenone
@ repeattypenone
Definition: Menus.h:60
MenuTable::SpecialItem::~SpecialItem
~SpecialItem() override
Definition: Menus.cpp:232
MenuManager::mStopIfWasPaused
bool mStopIfWasPaused
Definition: Menus.h:123
anonymous_namespace{Menus.cpp}::MenuItemEnablers
std::vector< MenuItemEnabler > MenuItemEnablers
Definition: Menus.cpp:619
CommandFunctorPointer
void(CommandHandlerObject::*)(const CommandContext &context) CommandFunctorPointer
Definition: CommandFunctors.h:38
MenuManager::ModifyToolbarMenus
static void ModifyToolbarMenus(AudacityProject &project)
Definition: Menus.cpp:592
MenuManager::GetUpdateFlags
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:545
MenuVisitor::DoSeparator
virtual void DoSeparator()
Definition: Menus.cpp:185
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
ReservedCommandFlag::Predicate
std::function< bool(const AudacityProject &) > Predicate
Definition: CommandFlag.h:91
Registry::OrderingPreferenceInitializer
Definition: Registry.h:273
MenuTable::MenuItem::MenuItem
MenuItem(const Identifier &internalName, const TranslatableString &title_, BaseItemPtrs &&items_)
Definition: Menus.cpp:191
MenuManager::Visit
static void Visit(ToolbarMenuVisitor &visitor)
Definition: Menus.cpp:437
MenuVisitor::DoEndGroup
virtual void DoEndGroup(Registry::GroupItem &item, const Path &path)
Definition: Menus.cpp:177
MenuTable::WholeMenu
Definition: CommandManager.h:423