Audacity 3.2.0
MenuCreator.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 MenuCreator.h
6
7 Dominic Mazzoni
8
9 Paul Licameli split from Menus.h
10
11**********************************************************************/
12#ifndef __AUDACITY_MENU_CREATOR__
13#define __AUDACITY_MENU_CREATOR__
14
15#include "Callable.h"
16#include "CommandManager.h"
17
18class AUDACITY_DLL_API MenuCreator final : public CommandManager
19{
20public:
21 // For manipulating the enclosing menu or sub-menu directly,
22 // adding any number of items, not using the CommandManager
24 {
25 using Appender = std::function<void(AudacityProject&, wxMenu&)>;
26
27 explicit SpecialItem(const Identifier &internalName, const Appender &fn_)
28 : MenuRegistry::SpecialItem{ internalName }
29 , fn{ fn_ }
30 {}
31 ~SpecialItem() override;
32
34 };
35
36 static constexpr auto Special = Callable::UniqueMaker<SpecialItem>();
37
38 // "permit" allows filtering even if the active window isn't a child of the
39 // project.
40 // Lyrics and MixerTrackCluster classes use it.
41 static bool FilterKeyEvent(AudacityProject &project,
42 const wxKeyEvent & evt, bool permit = false);
43
45 static const MenuCreator &Get(const AudacityProject &project);
46
48 ~MenuCreator() override;
49 void CreateMenusAndCommands();
50 void RebuildMenuBar();
51 static void RebuildAllMenuBars();
52
53 // a temporary hack that should be removed as soon as we
54 // get multiple effect preview working
55 bool ReallyDoQuickCheck() override;
56
57 void RemoveDuplicateShortcuts();
58
59private:
60 void ExecuteCommand(const CommandContext &context,
61 const wxEvent *evt, const CommandListEntry &entry) override;
62};
63
65
66AUDACITY_DLL_API
67NormalizedKeyString KeyEventToKeyString(const wxKeyEvent & keyEvent);
68
69#endif
Functions and classes that generate callable objects.
static ProjectFileIORegistry::AttributeWriterEntry entry
AUDACITY_DLL_API NormalizedKeyString KeyEventToKeyString(const wxKeyEvent &keyEvent)
const auto project
static const auto fn
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.
static CommandManager & Get(AudacityProject &project)
virtual bool ReallyDoQuickCheck()
Default implementation returns true.
virtual void ExecuteCommand(const CommandContext &context, const wxEvent *evt, const CommandListEntry &entry)
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
MenuCreator is responsible for creating the main menu bar.
Definition: MenuCreator.h:19
~MenuCreator() override
std::function< void(AudacityProject &, wxMenu &)> Appender
Definition: MenuCreator.h:25
SpecialItem(const Identifier &internalName, const Appender &fn_)
Definition: MenuCreator.h:27