Audacity 3.2.0
ExtraMenus.cpp
Go to the documentation of this file.
1#include "../CommonCommandFlags.h"
2#include "../Menus.h"
3#include "Prefs.h"
4#include "Project.h"
5#include "ProjectWindows.h"
6#include "../commands/CommandContext.h"
7#include "../commands/CommandManager.h"
8#include "../toolbars/ToolManager.h"
9
10#include <wx/frame.h>
11
12// helper functions and classes
13namespace {
14
15// Menu handler functions
16
17void OnFullScreen(const CommandContext &context)
18{
19 auto &project = context.project;
20 auto &window = GetProjectFrame( project );
21
22 bool bChecked = !window.wxTopLevelWindow::IsFullScreen();
23 window.wxTopLevelWindow::ShowFullScreen(bChecked);
24
25 ToolManager::Get(project).ModifyToolbarMenus(project);
26}
27
28// Menu definitions
29
30using namespace MenuTable;
31
33{
34 // Table of menu factories.
35 static BaseItemSharedPtr extraItems{ Items( wxEmptyString,
36 Section( "Part1" ),
37 Section( "Part2" )
38 ) };
39
40 static const auto pred =
41 []{ return gPrefs->ReadBool(wxT("/GUI/ShowExtraMenus"), false); };
42 static BaseItemSharedPtr menu{
43 ConditionalItems( wxT("Optional"),
44 pred, Menu( wxT("Extra"), XXO("Ext&ra"), extraItems ) )
45 };
46 return menu;
47}
48
50 wxT(""),
51 Shared( ExtraMenu() )
52};
53
54// Under /MenuBar/Optional/Extra/Part2
56{
58
59 // Not a menu.
60 static BaseItemSharedPtr items{
61 Items( wxT("Misc"),
62 // Delayed evaluation
63 []( AudacityProject &project ) {
64
65 static const auto key =
66#ifdef __WXMAC__
67 wxT("Ctrl+/")
68#else
69 wxT("F11")
70#endif
71 ;
72
73 return (
74 // Accel key is not bindable.
75 Command( wxT("FullScreenOnOff"), XXO("&Full Screen (on/off)"),
78 Options{ key }.CheckTest( []( const AudacityProject &project ) {
79 return GetProjectFrame( project )
80 .wxTopLevelWindow::IsFullScreen(); } ) )
81 );
82 }
83 ) };
84 return items;
85}
86
88 Placement{ wxT("Optional/Extra/Part2"), { OrderingHint::End } },
90};
91
92}
wxT("CloseDown"))
AttachedItem sAttachment1
AttachedItem sAttachment2
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
static const AudacityProject::AttachedObjects::RegisteredFactory key
XXO("&Cut/Copy/Paste Toolbar")
FileConfig * gPrefs
Definition: Prefs.cpp:70
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
accessors for certain important windows associated with each 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,...
AudacityProject & project
static ToolManager & Get(AudacityProject &project)
static void ModifyToolbarMenus(AudacityProject &project)
std::unique_ptr< MenuItem > Menu(const Identifier &internalName, const TranslatableString &title, Args &&... args)
std::unique_ptr< MenuPart > Section(const Identifier &internalName, Args &&... args)
std::unique_ptr< ConditionalGroupItem > ConditionalItems(const Identifier &internalName, ConditionalGroupItem::Condition condition, Args &&... args)
std::unique_ptr< MenuItems > Items(const Identifier &internalName, Args &&... args)
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:72
void OnFullScreen(const CommandContext &context)
Definition: ExtraMenus.cpp:17
BaseItemSharedPtr ExtraMiscItems()
Definition: ExtraMenus.cpp:55