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

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

References AlwaysEnabledFlag, CommandManager::Get(), GetProjectFrame(), MenuPathStart, project, 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 614 of file Menus.cpp.

615{
616 for( auto p : AllProjects{} ) {
618#if defined(__WXGTK__)
619 // Workaround for:
620 //
621 // http://bugzilla.audacityteam.org/show_bug.cgi?id=458
622 //
623 // This workaround should be removed when Audacity updates to wxWidgets 3.x which has a fix.
624 auto &window = GetProjectFrame( *p );
625 wxRect r = window.GetRect();
626 window.SetSize(wxSize(1,1));
627 window.SetSize(r.GetSize());
628#endif
629 }
630}
void RebuildMenuBar(AudacityProject &project)
Definition: Menus.cpp:486
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 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
509
511}
void CreateMenusAndCommands(AudacityProject &project)
Definition: Menus.cpp:370
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(), project, 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: