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
26}
27
28// Menu definitions
29
30using namespace MenuTable;
31
33{
34 static const auto pred =
35 []{ return gPrefs->ReadBool(wxT("/GUI/ShowExtraMenus"), false); };
36 static auto menu = std::shared_ptr{
37 ConditionalItems("Optional", pred,
38 Menu("Extra", XXO("Ext&ra"),
39 Section("Part1"),
40 Section("Part2"))
41 )
42 };
43 return menu;
44}
45
47 wxT(""),
49};
50
51// Under /MenuBar/Optional/Extra/Part2
53{
55
56 // Not a menu.
57 static BaseItemSharedPtr items{
58 Items( wxT("Misc"),
59 // Delayed evaluation
61
62 static const auto key =
63#ifdef __WXMAC__
64 wxT("Ctrl+/")
65#else
66 wxT("F11")
67#endif
68 ;
69
70 return (
71 // Accel key is not bindable.
72 Command( wxT("FullScreenOnOff"), XXO("Enable &Full Screen"),
75 Options{ key }.CheckTest( []( const AudacityProject &project ) {
76 return GetProjectFrame( project )
77 .wxTopLevelWindow::IsFullScreen(); } ) )
78 );
79 }
80 ) };
81 return items;
82}
83
85 Placement{ wxT("Optional/Extra/Part2"), { OrderingHint::End } },
87};
88
89}
wxT("CloseDown"))
AttachedItem sAttachment1
AttachedItem sAttachment2
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
static const AudacityProject::AttachedObjects::RegisteredFactory key
XXO("&Cut/Copy/Paste Toolbar")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
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
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,...
AudacityProject & project
static ToolManager & Get(AudacityProject &project)
static void ModifyToolbarMenus(AudacityProject &project)
bool ReadBool(const wxString &key, bool defaultValue) const
constexpr auto Section
constexpr auto Menu
Items will appear in a main toolbar menu or in a sub-menu.
constexpr auto Items
constexpr auto Command
constexpr auto ConditionalItems
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:113
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:78
void OnFullScreen(const CommandContext &context)
Definition: ExtraMenus.cpp:17
BaseItemSharedPtr ExtraMiscItems()
Definition: ExtraMenus.cpp:52