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 MenuTable {
36 struct Traits;
37 template<typename MenuTraits> struct Visitor;
38}
39
40class AUDACITY_DLL_API MenuCreator
41{
42public:
45 void CreateMenusAndCommands(AudacityProject &project);
46 void RebuildMenuBar(AudacityProject &project);
47
48 static void RebuildAllMenuBars();
49
50public:
52
53 // Last effect applied to this project
54 PluginID mLastGenerator{};
55 PluginID mLastEffect{};
56 PluginID mLastAnalyzer{};
59 PluginID mLastTool{};
62 enum {
63 repeattypenone = 0,
64 repeattypeplugin = 1,
65 repeattypeunique = 2,
66 repeattypeapplymacro = 3
67 };
72};
73
76
77class AUDACITY_DLL_API MenuManager final
78 : public MenuCreator
79 , public ClientData::Base
80 , public Observer::Publisher<MenuUpdateMessage>
81 , private PrefsListener
82{
83public:
84
86 static const MenuManager &Get( const AudacityProject &project );
87
88 explicit
90 MenuManager( const MenuManager & ) = delete;
91 MenuManager &operator=( const MenuManager & ) = delete;
93
94 static void Visit(
96
97 static void ModifyUndoMenuItems(AudacityProject &project);
98
99 // checkActive is a temporary hack that should be removed as soon as we
100 // get multiple effect preview working
101 void UpdateMenus( bool checkActive = true );
102
103 // If checkActive, do not do complete flags testing on an
104 // inactive project as it is needlessly expensive.
105 CommandFlag GetUpdateFlags( bool checkActive = false ) const;
106 void UpdatePrefs() override;
107
108 // Command Handling
109 bool ReportIfActionNotAllowed(
110 const TranslatableString & Name, CommandFlag & flags, CommandFlag flagsRqd );
111 bool TryToMakeActionAllowed(
112 CommandFlag & flags, CommandFlag flagsRqd );
113
114
115private:
116 void TellUserWhyDisallowed(const TranslatableString & Name, CommandFlag flagsGot,
117 CommandFlag flagsRequired);
118
119 void OnUndoRedo(struct UndoRedoMessage);
120
123
124public:
125 // 0 is grey out, 1 is Autoselect, 2 is Give warnings.
128};
129
130#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
wxString MacroID
Definition: Menus.h:32
wxArrayString PluginIDs
Definition: Menus.h:33
wxString PluginID
Definition: Menus.h:31
const auto project
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:41
int mLastAnalyzerRegisteredId
Definition: Menus.h:58
CommandFlag mLastFlags
Definition: Menus.h:51
unsigned mRepeatAnalyzerFlags
Definition: Menus.h:70
unsigned mRepeatEffectFlags
Definition: Menus.h:69
unsigned mRepeatGeneratorFlags
Definition: Menus.h:68
int mLastToolRegistration
Definition: Menus.h:60
unsigned mRepeatToolFlags
Definition: Menus.h:71
int mLastAnalyzerRegistration
Definition: Menus.h:57
int mLastToolRegisteredId
Definition: Menus.h:61
MenuManager handles updates to menu state.
Definition: Menus.h:82
int mWhatIfNoSelection
Definition: Menus.h:126
MenuManager & operator=(const MenuManager &)=delete
MenuManager(const MenuManager &)=delete
bool mStopIfWasPaused
Definition: Menus.h:127
Observer::Subscription mUndoSubscription
Definition: Menus.h:121
AudacityProject & mProject
Definition: Menus.h:122
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:561
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:123
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:987
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:196
REGISTRIES_API void Visit(VisitorBase &visitor, const GroupItemBase *pTopItem, const GroupItemBase *pRegistry, void *pComputedItemContext)
Definition: Registry.cpp:725
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:75
Type of message published by UndoManager.
Definition: UndoManager.h:55