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 "Prefs.h"
16#include "ClientData.h"
18#include "Observer.h"
19
20class wxArrayString;
21class wxCommandEvent;
22class AudacityProject;
23class CommandContext;
24class CommandManager;
25class Track;
26class TrackList;
27class ViewInfo;
28
29enum EffectType : int;
30
31typedef wxString PluginID;
32typedef wxString MacroID;
33typedef wxArrayString PluginIDs;
34
35namespace Registry{ class Visitor; }
36
37class AUDACITY_DLL_API MenuCreator
38{
39public:
42 void CreateMenusAndCommands(AudacityProject &project);
43 void RebuildMenuBar(AudacityProject &project);
44
45 static void RebuildAllMenuBars();
46
47public:
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 };
69};
70
72
75
76class AUDACITY_DLL_API MenuManager final
77 : public MenuCreator
78 , public ClientData::Base
79 , public Observer::Publisher<MenuUpdateMessage>
80 , private PrefsListener
81{
82public:
83
84 static MenuManager &Get( AudacityProject &project );
85 static const MenuManager &Get( const AudacityProject &project );
86
87 explicit
88 MenuManager( AudacityProject &project );
89 MenuManager( const MenuManager & ) PROHIBITED;
90 MenuManager &operator=( const MenuManager & ) PROHIBITED;
92
93 static void Visit( ToolbarMenuVisitor &visitor );
94
95 static void ModifyUndoMenuItems(AudacityProject &project);
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:30
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:611
wxString MacroID
Definition: Menus.h:32
wxArrayString PluginIDs
Definition: Menus.h:33
wxString PluginID
Definition: Menus.h:31
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
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:38
int mLastAnalyzerRegisteredId
Definition: Menus.h:55
CommandFlag mLastFlags
Definition: Menus.h:48
unsigned mRepeatAnalyzerFlags
Definition: Menus.h:67
unsigned mRepeatEffectFlags
Definition: Menus.h:66
unsigned mRepeatGeneratorFlags
Definition: Menus.h:65
int mLastToolRegistration
Definition: Menus.h:57
unsigned mRepeatToolFlags
Definition: Menus.h:68
int mLastAnalyzerRegistration
Definition: Menus.h:54
int mLastToolRegisteredId
Definition: Menus.h:58
MenuManager handles updates to menu state.
Definition: Menus.h:81
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
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
A listener notified of changes in preferences.
Definition: Prefs.h:556
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:1338
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:194
Definition: Menus.h:35
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
A convenient default parameter for class template Site.
Definition: ClientData.h:28
Sent when menus update (such as for changing enablement of items)
Definition: Menus.h:74
Type of message published by UndoManager.
Definition: UndoManager.h:61