mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-24 23:33:50 +02:00
... Mostly into CommonCommandFlags.cpp, but some elsewhere, to avoid giving that new file problematic dependencies on LabelTrack, ControlToolBar, and EffectManager. Note that CutCopyAvailableFlag is critically ordered, for message purposes, only with AudioIONotAvailableFlag, the only flag with a message that it combines with in menu item definitions. The dependency on LabelTrack.cpp might not be a bad one later, if the track and its view can be separated, and that would allow CutCopyAvailableFlag to be put with the others. But much other work on LabelTrack must happen first.
259 lines
7.0 KiB
C++
259 lines
7.0 KiB
C++
#include "../CommonCommandFlags.h"
|
|
#include "../Prefs.h"
|
|
#include "../Project.h"
|
|
#include "../commands/CommandContext.h"
|
|
#include "../commands/CommandManager.h"
|
|
#include "../toolbars/MixerToolBar.h"
|
|
#include "../toolbars/DeviceToolBar.h"
|
|
|
|
#include <wx/frame.h>
|
|
|
|
// helper functions and classes
|
|
namespace {
|
|
}
|
|
|
|
/// Namespace for helper functions for Extra menu
|
|
namespace ExtraActions {
|
|
|
|
// exported helper functions
|
|
// none
|
|
|
|
// Menu handler functions
|
|
|
|
struct Handler : CommandHandlerObject {
|
|
|
|
void OnOutputGain(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto tb = &MixerToolBar::Get( project );
|
|
|
|
if (tb) {
|
|
tb->ShowOutputGainDialog();
|
|
}
|
|
}
|
|
|
|
void OnOutputGainInc(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto tb = &MixerToolBar::Get( project );
|
|
|
|
if (tb) {
|
|
tb->AdjustOutputGain(1);
|
|
}
|
|
}
|
|
|
|
void OnOutputGainDec(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto tb = &MixerToolBar::Get( project );
|
|
|
|
if (tb) {
|
|
tb->AdjustOutputGain(-1);
|
|
}
|
|
}
|
|
|
|
void OnInputGain(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto tb = &MixerToolBar::Get( project );
|
|
|
|
if (tb) {
|
|
tb->ShowInputGainDialog();
|
|
}
|
|
}
|
|
|
|
void OnInputGainInc(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto tb = &MixerToolBar::Get( project );
|
|
|
|
if (tb) {
|
|
tb->AdjustInputGain(1);
|
|
}
|
|
}
|
|
|
|
void OnInputGainDec(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto tb = &MixerToolBar::Get( project );
|
|
|
|
if (tb) {
|
|
tb->AdjustInputGain(-1);
|
|
}
|
|
}
|
|
|
|
void OnInputDevice(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto &tb = DeviceToolBar::Get( project );
|
|
tb.ShowInputDialog();
|
|
}
|
|
|
|
void OnOutputDevice(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto &tb = DeviceToolBar::Get( project );
|
|
tb.ShowOutputDialog();
|
|
}
|
|
|
|
void OnInputChannels(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto &tb = DeviceToolBar::Get( project );
|
|
tb.ShowChannelsDialog();
|
|
}
|
|
|
|
void OnAudioHost(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto &tb = DeviceToolBar::Get( project );
|
|
tb.ShowHostDialog();
|
|
}
|
|
|
|
void OnFullScreen(const CommandContext &context)
|
|
{
|
|
auto &project = context.project;
|
|
auto &window = GetProjectFrame( project );
|
|
auto &commandManager = CommandManager::Get( project );
|
|
|
|
bool bChecked = !window.wxTopLevelWindow::IsFullScreen();
|
|
window.wxTopLevelWindow::ShowFullScreen(bChecked);
|
|
commandManager.Check(wxT("FullScreenOnOff"), bChecked);
|
|
}
|
|
|
|
}; // struct Handler
|
|
|
|
} // namespace
|
|
|
|
static CommandHandlerObject &findCommandHandler(AudacityProject &) {
|
|
// Handler is not stateful. Doesn't need a factory registered with
|
|
// AudacityProject.
|
|
static ExtraActions::Handler instance;
|
|
return instance;
|
|
};
|
|
|
|
// Menu definitions
|
|
|
|
#define FN(X) findCommandHandler, \
|
|
static_cast<CommandFunctorPointer>(& ExtraActions::Handler :: X)
|
|
#define XXO(X) _(X), wxString{X}.Contains("...")
|
|
|
|
// Imported menu item definitions
|
|
|
|
MenuTable::BaseItemPtr ExtraEditMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraSelectionMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraCursorMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraSeekMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraToolsMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraTransportMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraPlayAtSpeedMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraTrackMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraScriptablesIMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraScriptablesIIMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraWindowItems( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraGlobalCommands( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraFocusMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraMenu( AudacityProject& );
|
|
MenuTable::BaseItemPtr ExtraMixerMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraDeviceMenu( AudacityProject & );
|
|
MenuTable::BaseItemPtr ExtraMiscItems( AudacityProject & );
|
|
|
|
// Table of menu factories.
|
|
// TODO: devise a registration system instead.
|
|
static const std::shared_ptr<MenuTable::BaseItem> extraItems = MenuTable::Items(
|
|
ExtraTransportMenu
|
|
, ExtraToolsMenu
|
|
, ExtraMixerMenu
|
|
, ExtraEditMenu
|
|
, ExtraPlayAtSpeedMenu
|
|
, ExtraSeekMenu
|
|
, ExtraDeviceMenu
|
|
, ExtraSelectionMenu
|
|
|
|
, MenuTable::Separator()
|
|
|
|
, ExtraGlobalCommands
|
|
, ExtraFocusMenu
|
|
, ExtraCursorMenu
|
|
, ExtraTrackMenu
|
|
, ExtraScriptablesIMenu
|
|
, ExtraScriptablesIIMenu
|
|
, ExtraMiscItems
|
|
);
|
|
|
|
MenuTable::BaseItemPtr ExtraMenu( AudacityProject & )
|
|
{
|
|
using namespace MenuTable;
|
|
static const auto pred =
|
|
[]{ return gPrefs->ReadBool(wxT("/GUI/ShowExtraMenus"), false); };
|
|
static const auto factory =
|
|
[](AudacityProject &){ return extraItems; };
|
|
return ConditionalItems( pred, Menu( _("Ext&ra"), factory ) );
|
|
}
|
|
|
|
MenuTable::BaseItemPtr ExtraMixerMenu( AudacityProject & )
|
|
{
|
|
using namespace MenuTable;
|
|
return Menu( _("Mi&xer"),
|
|
Command( wxT("OutputGain"), XXO("Ad&just Playback Volume..."),
|
|
FN(OnOutputGain), AlwaysEnabledFlag ),
|
|
Command( wxT("OutputGainInc"), XXO("&Increase Playback Volume"),
|
|
FN(OnOutputGainInc), AlwaysEnabledFlag ),
|
|
Command( wxT("OutputGainDec"), XXO("&Decrease Playback Volume"),
|
|
FN(OnOutputGainDec), AlwaysEnabledFlag ),
|
|
Command( wxT("InputGain"), XXO("Adj&ust Recording Volume..."),
|
|
FN(OnInputGain), AlwaysEnabledFlag ),
|
|
Command( wxT("InputGainInc"), XXO("I&ncrease Recording Volume"),
|
|
FN(OnInputGainInc), AlwaysEnabledFlag ),
|
|
Command( wxT("InputGainDec"), XXO("D&ecrease Recording Volume"),
|
|
FN(OnInputGainDec), AlwaysEnabledFlag )
|
|
);
|
|
}
|
|
|
|
MenuTable::BaseItemPtr ExtraDeviceMenu( AudacityProject & )
|
|
{
|
|
using namespace MenuTable;
|
|
return Menu( _("De&vice"),
|
|
Command( wxT("InputDevice"), XXO("Change &Recording Device..."),
|
|
FN(OnInputDevice),
|
|
AudioIONotBusyFlag, wxT("Shift+I") ),
|
|
Command( wxT("OutputDevice"), XXO("Change &Playback Device..."),
|
|
FN(OnOutputDevice),
|
|
AudioIONotBusyFlag, wxT("Shift+O") ),
|
|
Command( wxT("AudioHost"), XXO("Change Audio &Host..."), FN(OnAudioHost),
|
|
AudioIONotBusyFlag, wxT("Shift+H") ),
|
|
Command( wxT("InputChannels"), XXO("Change Recording Cha&nnels..."),
|
|
FN(OnInputChannels),
|
|
AudioIONotBusyFlag, wxT("Shift+N") )
|
|
);
|
|
}
|
|
|
|
MenuTable::BaseItemPtr ExtraMiscItems( AudacityProject &project )
|
|
{
|
|
using namespace MenuTable;
|
|
using Options = CommandManager::Options;
|
|
|
|
constexpr auto key =
|
|
#ifdef __WXMAC__
|
|
wxT("Ctrl+/")
|
|
#else
|
|
wxT("F11")
|
|
#endif
|
|
;
|
|
|
|
// Not a menu.
|
|
return Items(
|
|
// Accel key is not bindable.
|
|
Command( wxT("FullScreenOnOff"), XXO("&Full Screen (on/off)"),
|
|
FN(OnFullScreen),
|
|
AlwaysEnabledFlag,
|
|
Options{ key }.CheckState(
|
|
GetProjectFrame( project ).wxTopLevelWindow::IsFullScreen() ) ),
|
|
|
|
ExtraWindowItems
|
|
);
|
|
}
|
|
|
|
#undef XXO
|
|
#undef FN
|