Audacity 3.2.0
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 {
64 };
@ repeattypeplugin
Definition: Menus.h:61
@ repeattypeapplymacro
Definition: Menus.h:63
@ repeattypenone
Definition: Menus.h:60
@ repeattypeunique
Definition: Menus.h:62

Constructor & Destructor Documentation

◆ MenuCreator()

MenuCreator::MenuCreator ( )

◆ ~MenuCreator()

MenuCreator::~MenuCreator ( )

Definition at line 60 of file Menus.cpp.

61{
62}

Member Function Documentation

◆ CreateMenusAndCommands()

void MenuCreator::CreateMenusAndCommands ( AudacityProject project)

Definition at line 377 of file Menus.cpp.

378{
379 // Once only, cause initial population of preferences for the ordering
380 // of some menu items that used to be given in tables but are now separately
381 // registered in several .cpp files; the sequence of registration depends
382 // on unspecified accidents of static initialization order across
383 // compilation units, so we need something specific here to preserve old
384 // default appearance of menus.
385 // But this needs only to mention some strings -- there is no compilation or
386 // link dependency of this source file on those other implementation files.
389 {
390 {wxT(""), wxT(
391"File,Edit,Select,View,Transport,Tracks,Generate,Effect,Analyze,Tools,Window,Optional,Help"
392 )},
393 {wxT("/Optional/Extra/Part1"), wxT(
394"Transport,Tools,Mixer,Edit,PlayAtSpeed,Seek,Device,Select"
395 )},
396 {wxT("/Optional/Extra/Part2"), wxT(
397"Navigation,Focus,Cursor,Track,Scriptables1,Scriptables2"
398 )},
399 {wxT("/View/Windows"), wxT("UndoHistory,Karaoke,MixerBoard")},
400 {wxT("/Analyze/Analyzers/Windows"), wxT("ContrastAnalyser,PlotSpectrum")},
401 {wxT("/Transport/Basic"), wxT("Play,Record,Scrubbing,Cursor")},
402 {wxT("/View/Other/Toolbars/Toolbars/Other"), wxT(
403"ShowTransportTB,ShowToolsTB,ShowRecordMeterTB,ShowPlayMeterTB,"
404//"ShowMeterTB,"
405"ShowMixerTB,"
406"ShowEditTB,ShowTranscriptionTB,ShowScrubbingTB,ShowDeviceTB,ShowSelectionTB,"
407"ShowSpectralSelectionTB") },
408 {wxT("/Tracks/Add/Add"), wxT(
409"NewMonoTrack,NewStereoTrack,NewLabelTrack,NewTimeTrack")},
410 {wxT("/Optional/Extra/Part2/Scriptables1"), wxT(
411"SelectTime,SelectFrequencies,SelectTracks,SetTrackStatus,SetTrackAudio,"
412"SetTrackVisuals,GetPreference,SetPreference,SetClip,SetEnvelope,SetLabel"
413"SetProject") },
414 {wxT("/Optional/Extra/Part2/Scriptables2"), wxT(
415"Select,SetTrack,GetInfo,Message,Help,Import2,Export2,OpenProject2,"
416"SaveProject2,Drag,CompareAudio,Screenshot") },
417 }
418 };
419
420 auto &commandManager = CommandManager::Get( project );
421
422 // The list of defaults to exclude depends on
423 // preference wxT("/GUI/Shortcuts/FullDefaults"), which may have changed.
424 commandManager.SetMaxList();
425
426 auto menubar = commandManager.AddMenuBar(wxT("appmenu"));
427 wxASSERT(menubar);
428
429 MenuItemVisitor visitor{ project, commandManager };
430 MenuManager::Visit( visitor );
431
432 GetProjectFrame( project ).SetMenuBar(menubar.release());
433
435
436#if defined(_DEBUG)
437// c->CheckDups();
438#endif
439}
wxT("CloseDown"))
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
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 ...
static const auto MenuPathStart
static CommandManager & Get(AudacityProject &project)
CommandFlag mLastFlags
Definition: Menus.h:48
static void Visit(ToolbarMenuVisitor &visitor)
Definition: Menus.cpp:441

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

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 621 of file Menus.cpp.

622{
623 for( auto p : AllProjects{} ) {
625#if defined(__WXGTK__)
626 // Workaround for:
627 //
628 // http://bugzilla.audacityteam.org/show_bug.cgi?id=458
629 //
630 // This workaround should be removed when Audacity updates to wxWidgets 3.x which has a fix.
631 auto &window = GetProjectFrame( *p );
632 wxRect r = window.GetRect();
633 window.SetSize(wxSize(1,1));
634 window.SetSize(r.GetSize());
635#endif
636 }
637}
void RebuildMenuBar(AudacityProject &project)
Definition: Menus.cpp:493
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:69

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

Referenced by anonymous_namespace{PluginMenus.cpp}::DoManagePluginsMenu(), AudacityApp::InitPart2(), ViewActions::Handler::OnAdvancedVZoom(), IncompatiblePluginsDialog::OnPluginManagerClicked(), ViewActions::Handler::OnShowExtraMenus(), anonymous_namespace{SpectrumView.cpp}::SpectrogramSettingsHandler::OnSpectrogramSettings(), ProjectFileManager::OpenFile(), EffectsPrefs::PopulateOrExchange(), 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 493 of file Menus.cpp.

494{
495 // On OSX, we can't rebuild the menus while a modal dialog is being shown
496 // since the enabled state for menus like Quit and Preference gets out of
497 // sync with wxWidgets idea of what it should be.
498#if defined(__WXMAC__) && defined(_DEBUG)
499 {
500 wxDialog *dlg =
501 wxDynamicCast(wxGetTopLevelParent(wxWindow::FindFocus()), wxDialog);
502 wxASSERT((!dlg || !dlg->IsModal()));
503 }
504#endif
505
506 // Delete the menus, since we will soon recreate them.
507 // Rather oddly, the menus don't vanish as a result of doing this.
508 {
509 auto &window = static_cast<wxFrameEx&>( GetProjectFrame( project ) );
510 wxWindowPtr<wxMenuBar> menuBar{ window.GetMenuBar() };
511 window.DetachMenuBar();
512 // menuBar gets deleted here
513 }
514
515 CommandManager::Get( project ).PurgeData();
516
517 CreateMenusAndCommands(project);
518}
void CreateMenusAndCommands(AudacityProject &project)
Definition: Menus.cpp:377
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:343

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

Referenced by DoReloadPreferences(), anonymous_namespace{EditMenus.cpp}::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 PluginMenuItems().

◆ 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: