Audacity  3.0.3
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
MenuCreator Class Reference

MenuCreator is responsible for creating the main menu bar. More...

#include <Menus.h>

Inheritance diagram for MenuCreator:
[legend]
Collaboration diagram for MenuCreator:
[legend]

Public Types

enum  { repeattypenone = 0, repeattypeplugin = 1, repeattypeunique = 2, repeattypeapplymacro = 3 }
 

Public Member Functions

 MenuCreator ()
 
 ~MenuCreator ()
 
void CreateMenusAndCommands (AudacityProject &project)
 
void RebuildMenuBar (AudacityProject &project)
 

Static Public Member Functions

static void RebuildAllMenuBars ()
 

Public Attributes

CommandFlag mLastFlags
 
PluginID mLastGenerator {}
 
PluginID mLastEffect {}
 
PluginID mLastAnalyzer {}
 
int mLastAnalyzerRegistration
 
int mLastAnalyzerRegisteredId
 
PluginID mLastTool {}
 
int mLastToolRegistration
 
int mLastToolRegisteredId
 
unsigned mRepeatGeneratorFlags
 
unsigned mRepeatEffectFlags
 
unsigned mRepeatAnalyzerFlags
 
unsigned mRepeatToolFlags
 

Detailed Description

MenuCreator is responsible for creating the main menu bar.

Definition at line 37 of file Menus.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
repeattypenone 
repeattypeplugin 
repeattypeunique 
repeattypeapplymacro 

Definition at line 59 of file Menus.h.

59  {
60  repeattypenone = 0,
61  repeattypeplugin = 1,
62  repeattypeunique = 2,
64  };

Constructor & Destructor Documentation

◆ MenuCreator()

MenuCreator::MenuCreator ( )

◆ ~MenuCreator()

MenuCreator::~MenuCreator ( )

Definition at line 61 of file Menus.cpp.

62 {
63 }

Member Function Documentation

◆ CreateMenusAndCommands()

void MenuCreator::CreateMenusAndCommands ( AudacityProject project)

Definition at line 382 of file Menus.cpp.

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 
431 
432 #if defined(_DEBUG)
433 // c->CheckDups();
434 #endif
435 }

References AlwaysEnabledFlag, CommandManager::Get(), GetProjectFrame(), MenuPathStart, and MenuManager::Visit().

Referenced by ProjectManager::New().

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

◆ RebuildAllMenuBars()

void MenuCreator::RebuildAllMenuBars ( )
static

The following method moves to the previous track selecting and unselecting depending if you are on the start of a block or not.

Definition at line 679 of file Menus.cpp.

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 }

References MenuManager::Get(), GetProjectFrame(), and RebuildMenuBar().

Referenced by anonymous_namespace{PluginMenus.cpp}::DoManagePluginsMenu(), AudacityApp::InitPart2(), ViewActions::Handler::OnAdvancedVZoom(), ViewActions::Handler::OnShowExtraMenus(), anonymous_namespace{SpectrumView.cpp}::SpectrogramSettingsHandler::OnSpectrogramSettings(), ProjectFileManager::OpenFile(), and CommandManager::RemoveDuplicateShortcuts().

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

◆ RebuildMenuBar()

void MenuCreator::RebuildMenuBar ( AudacityProject project)

Definition at line 486 of file Menus.cpp.

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 }

References CommandManager::Get(), GetProjectFrame(), and CommandManager::PurgeData().

Referenced by DoReloadPreferences(), EditActions::Handler::OnPreferences(), RebuildAllMenuBars(), and MacrosWindow::UpdateMenus().

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

Member Data Documentation

◆ mLastAnalyzer

PluginID MenuCreator::mLastAnalyzer {}

◆ mLastAnalyzerRegisteredId

int MenuCreator::mLastAnalyzerRegisteredId

Definition at line 55 of file Menus.h.

◆ mLastAnalyzerRegistration

int MenuCreator::mLastAnalyzerRegistration

◆ mLastEffect

PluginID MenuCreator::mLastEffect {}

◆ mLastFlags

CommandFlag MenuCreator::mLastFlags

Definition at line 48 of file Menus.h.

◆ mLastGenerator

PluginID MenuCreator::mLastGenerator {}

◆ mLastTool

PluginID MenuCreator::mLastTool {}

Definition at line 56 of file Menus.h.

Referenced by anonymous_namespace{PluginMenus.cpp}::ToolsMenu().

◆ mLastToolRegisteredId

int MenuCreator::mLastToolRegisteredId

Definition at line 58 of file Menus.h.

◆ mLastToolRegistration

int MenuCreator::mLastToolRegistration

Definition at line 57 of file Menus.h.

Referenced by MenuCreator().

◆ mRepeatAnalyzerFlags

unsigned MenuCreator::mRepeatAnalyzerFlags

Definition at line 67 of file Menus.h.

Referenced by MenuCreator().

◆ mRepeatEffectFlags

unsigned MenuCreator::mRepeatEffectFlags

Definition at line 66 of file Menus.h.

Referenced by MenuCreator().

◆ mRepeatGeneratorFlags

unsigned MenuCreator::mRepeatGeneratorFlags

Definition at line 65 of file Menus.h.

Referenced by MenuCreator().

◆ mRepeatToolFlags

unsigned MenuCreator::mRepeatToolFlags

Definition at line 68 of file Menus.h.

Referenced by MenuCreator().


The documentation for this class was generated from the following files:
MenuCreator::mLastFlags
CommandFlag mLastFlags
Definition: Menus.h:48
MenuCreator::mRepeatEffectFlags
unsigned mRepeatEffectFlags
Definition: Menus.h:66
MenuCreator::mRepeatAnalyzerFlags
unsigned mRepeatAnalyzerFlags
Definition: Menus.h:67
AlwaysEnabledFlag
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:35
MenuCreator::repeattypeplugin
@ repeattypeplugin
Definition: Menus.h:61
MenuCreator::mLastAnalyzerRegistration
int mLastAnalyzerRegistration
Definition: Menus.h:54
MenuCreator::RebuildMenuBar
void RebuildMenuBar(AudacityProject &project)
Definition: Menus.cpp:486
MenuCreator::CreateMenusAndCommands
void CreateMenusAndCommands(AudacityProject &project)
Definition: Menus.cpp:382
MenuCreator::mRepeatGeneratorFlags
unsigned mRepeatGeneratorFlags
Definition: Menus.h:65
MenuCreator::mRepeatToolFlags
unsigned mRepeatToolFlags
Definition: Menus.h:68
wxFrameEx
Definition: Menus.cpp:481
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
MenuCreator::mLastToolRegistration
int mLastToolRegistration
Definition: Menus.h:57
MenuPathStart
static const auto MenuPathStart
Definition: WaveTrackControls.cpp:483
CommandManager::Get
static CommandManager & Get(AudacityProject &project)
Definition: CommandManager.cpp:207
CommandManager::PurgeData
void PurgeData()
Definition: CommandManager.cpp:342
MenuCreator::repeattypeapplymacro
@ repeattypeapplymacro
Definition: Menus.h:63
MenuCreator::repeattypenone
@ repeattypenone
Definition: Menus.h:60
Registry::OrderingPreferenceInitializer
Definition: Registry.h:273
MenuManager::Visit
static void Visit(ToolbarMenuVisitor &visitor)
Definition: Menus.cpp:437
MenuCreator::repeattypeunique
@ repeattypeunique
Definition: Menus.h:62