Audacity 3.2.0
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"
19#include "Observer.h"
20
21class wxArrayString;
22class wxCommandEvent;
23class AudacityProject;
24class CommandContext;
25class CommandManager;
26class Track;
27class TrackList;
28class ViewInfo;
29
30enum EffectType : int;
31
32typedef wxString PluginID;
33typedef wxString MacroID;
34typedef wxArrayString PluginIDs;
35
36namespace Registry{ class Visitor; }
37
38class AUDACITY_DLL_API MenuCreator
39{
40public:
43 void CreateMenusAndCommands(AudacityProject &project);
44 void RebuildMenuBar(AudacityProject &project);
45
46 static void RebuildAllMenuBars();
47
48public:
50
51 // Last effect applied to this project
52 PluginID mLastGenerator{};
53 PluginID mLastEffect{};
54 PluginID mLastAnalyzer{};
57 PluginID mLastTool{};
60 enum {
61 repeattypenone = 0,
62 repeattypeplugin = 1,
63 repeattypeunique = 2,
64 repeattypeapplymacro = 3
65 };
70};
71
73
74class AUDACITY_DLL_API MenuManager final
75 : public MenuCreator
76 , public ClientData::Base
77 , private PrefsListener
78{
79public:
80
81 static MenuManager &Get( AudacityProject &project );
82 static const MenuManager &Get( const AudacityProject &project );
83
84 explicit
85 MenuManager( AudacityProject &project );
86 MenuManager( const MenuManager & ) PROHIBITED;
87 MenuManager &operator=( const MenuManager & ) PROHIBITED;
89
90 static void Visit( ToolbarMenuVisitor &visitor );
91
92 static void ModifyUndoMenuItems(AudacityProject &project);
93 static void ModifyToolbarMenus(AudacityProject &project);
94 // Calls ModifyToolbarMenus() on all projects
95 static void ModifyAllProjectToolbarMenus();
96
97 // checkActive is a temporary hack that should be removed as soon as we
98 // get multiple effect preview working
99 void UpdateMenus( bool checkActive = true );
100
101 // If checkActive, do not do complete flags testing on an
102 // inactive project as it is needlessly expensive.
103 CommandFlag GetUpdateFlags( bool checkActive = false ) const;
104 void UpdatePrefs() override;
105
106 // Command Handling
107 bool ReportIfActionNotAllowed(
108 const TranslatableString & Name, CommandFlag & flags, CommandFlag flagsRqd );
109 bool TryToMakeActionAllowed(
110 CommandFlag & flags, CommandFlag flagsRqd );
111
112
113private:
114 void TellUserWhyDisallowed(const TranslatableString & Name, CommandFlag flagsGot,
115 CommandFlag flagsRequired);
116
117 void OnUndoRedo(struct UndoRedoMessage);
118
121
122public:
123 // 0 is grey out, 1 is Autoselect, 2 is Give warnings.
126};
127
128#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
EffectType
wxString PluginID
Definition: EffectManager.h:30
auto Visit(Visitor &&vis, Variant &&var)
Mimic some of std::visit, for the case of one visitor only.
Definition: MemoryX.h:603
wxString MacroID
Definition: Menus.h:33
wxArrayString PluginIDs
Definition: Menus.h:34
wxString PluginID
Definition: Menus.h:32
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
CommandManager implements a system for organizing all user-callable commands.
MenuCreator is responsible for creating the main menu bar.
Definition: Menus.h:39
int mLastAnalyzerRegisteredId
Definition: Menus.h:56
CommandFlag mLastFlags
Definition: Menus.h:49
unsigned mRepeatAnalyzerFlags
Definition: Menus.h:68
unsigned mRepeatEffectFlags
Definition: Menus.h:67
unsigned mRepeatGeneratorFlags
Definition: Menus.h:66
int mLastToolRegistration
Definition: Menus.h:58
unsigned mRepeatToolFlags
Definition: Menus.h:69
int mLastAnalyzerRegistration
Definition: Menus.h:55
int mLastToolRegisteredId
Definition: Menus.h:59
MenuManager handles updates to menu state.
Definition: Menus.h:78
int mWhatIfNoSelection
Definition: Menus.h:124
MenuManager(const MenuManager &) PROHIBITED
MenuManager & operator=(const MenuManager &) PROHIBITED
bool mStopIfWasPaused
Definition: Menus.h:125
Observer::Subscription mUndoSubscription
Definition: Menus.h:119
AudacityProject & mProject
Definition: Menus.h:120
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
A listener notified of changes in preferences.
Definition: Prefs.h:543
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1336
Holds a msgid for the translation catalog; may also bind format arguments.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
Definition: Menus.h:36
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
A convenient default parameter for class template Site.
Definition: ClientData.h:28
Type of message published by UndoManager.
Definition: UndoManager.h:61