Audacity  3.0.3
Menus.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Menus.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 #ifndef __AUDACITY_MENUS__
11 #define __AUDACITY_MENUS__
12 
13 #include "Identifier.h"
14 
15 #include <wx/string.h> // member variable
16 #include "Prefs.h"
17 #include "ClientData.h"
18 #include "commands/CommandFlag.h"
19 
20 class wxArrayString;
21 class wxCommandEvent;
22 class AudacityProject;
23 class CommandContext;
24 class CommandManager;
25 class Track;
26 class TrackList;
27 class ViewInfo;
28 
29 enum EffectType : int;
30 
31 typedef wxString PluginID;
32 typedef wxString MacroID;
33 typedef wxArrayString PluginIDs;
34 
35 namespace Registry{ class Visitor; }
36 
37 class AUDACITY_DLL_API MenuCreator
38 {
39 public:
40  MenuCreator();
41  ~MenuCreator();
42  void CreateMenusAndCommands(AudacityProject &project);
43  void RebuildMenuBar(AudacityProject &project);
44 
45  static void RebuildAllMenuBars();
46 
47 public:
49 
50  // Last effect applied to this project
51  PluginID mLastGenerator{};
52  PluginID mLastEffect{};
53  PluginID mLastAnalyzer{};
56  PluginID mLastTool{};
59  enum {
60  repeattypenone = 0,
61  repeattypeplugin = 1,
62  repeattypeunique = 2,
63  repeattypeapplymacro = 3
64  };
68  unsigned mRepeatToolFlags;
69 };
70 
71 struct ToolbarMenuVisitor;
72 
73 class AUDACITY_DLL_API MenuManager final
74  : public MenuCreator
75  , public ClientData::Base
76  , private PrefsListener
77 {
78 public:
79 
80  static MenuManager &Get( AudacityProject &project );
81  static const MenuManager &Get( const AudacityProject &project );
82 
83  explicit
84  MenuManager( AudacityProject &project );
85  MenuManager( const MenuManager & ) PROHIBITED;
86  MenuManager &operator=( const MenuManager & ) PROHIBITED;
87  ~MenuManager();
88 
89  static void Visit( ToolbarMenuVisitor &visitor );
90 
91  static void ModifyUndoMenuItems(AudacityProject &project);
92  static void ModifyToolbarMenus(AudacityProject &project);
93  // Calls ModifyToolbarMenus() on all projects
94  static void ModifyAllProjectToolbarMenus();
95 
96  // checkActive is a temporary hack that should be removed as soon as we
97  // get multiple effect preview working
98  void UpdateMenus( bool checkActive = true );
99 
100  // If checkActive, do not do complete flags testing on an
101  // inactive project as it is needlessly expensive.
102  CommandFlag GetUpdateFlags( bool checkActive = false ) const;
103  void UpdatePrefs() override;
104 
105  // Command Handling
106  bool ReportIfActionNotAllowed(
107  const TranslatableString & Name, CommandFlag & flags, CommandFlag flagsRqd );
108  bool TryToMakeActionAllowed(
109  CommandFlag & flags, CommandFlag flagsRqd );
110 
111 
112 private:
113  void TellUserWhyDisallowed(const TranslatableString & Name, CommandFlag flagsGot,
114  CommandFlag flagsRequired);
115 
116  void OnUndoRedo( wxCommandEvent &evt );
117 
119 
120 public:
121  // 0 is grey out, 1 is Autoselect, 2 is Give warnings.
124 };
125 
126 #endif
MenuCreator::mLastToolRegisteredId
int mLastToolRegisteredId
Definition: Menus.h:58
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
Registry
Definition: Menus.h:35
MenuManager
MenuManager handles updates to menu state.
Definition: Menus.h:77
MenuCreator::mLastFlags
CommandFlag mLastFlags
Definition: Menus.h:48
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1280
MenuCreator::mRepeatEffectFlags
unsigned mRepeatEffectFlags
Definition: Menus.h:66
ViewInfo
Definition: ViewInfo.h:202
MenuCreator::mLastAnalyzerRegisteredId
int mLastAnalyzerRegisteredId
Definition: Menus.h:55
MenuCreator::mRepeatAnalyzerFlags
unsigned mRepeatAnalyzerFlags
Definition: Menus.h:67
ClientData::Base
A convenient default parameter for class template Site.
Definition: ClientData.h:28
TrackInfo::UpdatePrefs
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
CommandFlag
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
ClientData.h
Utility ClientData::Site to register hooks into a host class that attach client data.
PrefsListener
A listener notified of changes in preferences.
Definition: Prefs.h:392
PluginIDs
wxArrayString PluginIDs
Definition: PluginManager.h:169
Registry::Visitor
Definition: Registry.h:242
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:34
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
MenuCreator::mLastAnalyzerRegistration
int mLastAnalyzerRegistration
Definition: Menus.h:54
PluginID
wxString PluginID
Definition: EffectManager.h:30
Identifier.h
MenuManager::mWhatIfNoSelection
int mWhatIfNoSelection
Definition: Menus.h:122
ToolbarMenuVisitor
Definition: CommandManager.h:409
MenuManager::mProject
AudacityProject & mProject
Definition: Menus.h:118
MenuCreator::mRepeatGeneratorFlags
unsigned mRepeatGeneratorFlags
Definition: Menus.h:65
MenuCreator::mRepeatToolFlags
unsigned mRepeatToolFlags
Definition: Menus.h:68
MenuManager::MenuManager
MenuManager(const MenuManager &) PROHIBITED
MenuCreator
MenuCreator is responsible for creating the main menu bar.
Definition: Menus.h:38
Registry::Visit
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry)
Definition: Registry.cpp:713
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
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
CommandManager implements a system for organizing all user-callable commands.
Definition: CommandManager.h:59
Prefs.h
MenuCreator::mLastToolRegistration
int mLastToolRegistration
Definition: Menus.h:57
EffectType
EffectType
Definition: EffectInterface.h:55
MenuManager::operator=
MenuManager & operator=(const MenuManager &) PROHIBITED
MenuManager::mStopIfWasPaused
bool mStopIfWasPaused
Definition: Menus.h:123
CommandFlag.h