mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Menus.cpp no longer link dependent on top level menu definitions...
... They all use the registry. (This link dependency was not shown in diagrams generated by scripts/graph.pl, because it was not reflected in Menus.h but was done using extern declarations within Menus.cpp. That was a cheat, but it let all the other dependencies be exposed in the graph and mitigated first.)
This commit is contained in:
parent
d9d3f95570
commit
de08d9ff86
@ -945,29 +945,6 @@ void Visit( Visitor &visitor, BaseItem *pTopItem, GroupItem *pRegistry )
|
||||
/// changes in configured preferences - for example changes in key-bindings
|
||||
/// affect the short-cut key legend that appears beside each command,
|
||||
|
||||
MenuTable::BaseItemSharedPtr FileMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr EditMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr SelectMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr ViewMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr TransportMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr TracksMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr GenerateMenu();
|
||||
MenuTable::BaseItemSharedPtr EffectMenu();
|
||||
MenuTable::BaseItemSharedPtr AnalyzeMenu();
|
||||
MenuTable::BaseItemSharedPtr ToolsMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr WindowMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr ExtraMenu();
|
||||
|
||||
MenuTable::BaseItemSharedPtr HelpMenu();
|
||||
|
||||
namespace {
|
||||
static Registry::GroupItem &sRegistry()
|
||||
{
|
||||
@ -982,24 +959,6 @@ MenuTable::AttachedItem::AttachedItem(
|
||||
Registry::RegisterItem( sRegistry(), placement, std::move( pItem ) );
|
||||
}
|
||||
|
||||
// Table of menu factories.
|
||||
// TODO: devise a registration system instead.
|
||||
static const auto menuTree = MenuTable::Items( MenuPathStart
|
||||
, FileMenu()
|
||||
, EditMenu()
|
||||
, SelectMenu()
|
||||
, ViewMenu()
|
||||
, TransportMenu()
|
||||
, TracksMenu()
|
||||
, GenerateMenu()
|
||||
, EffectMenu()
|
||||
, AnalyzeMenu()
|
||||
, ToolsMenu()
|
||||
, WindowMenu()
|
||||
, ExtraMenu()
|
||||
, HelpMenu()
|
||||
);
|
||||
|
||||
namespace {
|
||||
|
||||
// Once only, cause initial population of preferences for the ordering
|
||||
@ -1014,6 +973,9 @@ void InitializeMenuOrdering()
|
||||
{
|
||||
using Pair = std::pair<const wxChar *, const wxChar *>;
|
||||
static const Pair pairs [] = {
|
||||
{wxT(""), wxT(
|
||||
"File,Edit,Select,View,Transport,Tracks,Generate,Effect,Analyze,Tools,Window,Optional,Help"
|
||||
)},
|
||||
{wxT("/View/Windows"), wxT("UndoHistory,Karaoke,MixerBoard")},
|
||||
{wxT("/Analyze/Analyzers/Windows"), wxT("ContrastAnalyser,PlotSpectrum")},
|
||||
};
|
||||
@ -1160,6 +1122,7 @@ void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
|
||||
|
||||
void MenuManager::Visit( MenuVisitor &visitor )
|
||||
{
|
||||
static const auto menuTree = MenuTable::Items( MenuPathStart );
|
||||
Registry::Visit( visitor, menuTree.get(), &sRegistry() );
|
||||
}
|
||||
|
||||
|
@ -1024,10 +1024,10 @@ static const ReservedCommandFlag
|
||||
cutCopyOptions()
|
||||
}; return flag; }
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr EditMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
BaseItemSharedPtr EditMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
|
||||
static const auto NotBusyTimeAndTracksFlags =
|
||||
@ -1164,10 +1164,15 @@ MenuTable::BaseItemSharedPtr EditMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( EditMenu() )
|
||||
};
|
||||
}
|
||||
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraEditMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
static const auto flags =
|
||||
AudioIONotBusyFlag() | TracksSelectedFlag() | TimeSelectedFlag();
|
||||
|
@ -151,15 +151,16 @@ MenuTable::BaseItemSharedPtr ExtraScriptablesIIMenu();
|
||||
MenuTable::BaseItemSharedPtr ExtraWindowItems();
|
||||
MenuTable::BaseItemSharedPtr ExtraGlobalCommands();
|
||||
MenuTable::BaseItemSharedPtr ExtraFocusMenu();
|
||||
MenuTable::BaseItemSharedPtr ExtraMenu();
|
||||
MenuTable::BaseItemSharedPtr ExtraMixerMenu();
|
||||
MenuTable::BaseItemSharedPtr ExtraDeviceMenu();
|
||||
MenuTable::BaseItemPtr ExtraMiscItems( AudacityProject & );
|
||||
|
||||
MenuTable::BaseItemSharedPtr ExtraMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
|
||||
BaseItemSharedPtr ExtraMixerMenu();
|
||||
BaseItemSharedPtr ExtraDeviceMenu();
|
||||
BaseItemPtr ExtraMiscItems( AudacityProject & );
|
||||
|
||||
BaseItemSharedPtr ExtraMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
|
||||
// Table of menu factories.
|
||||
// TODO: devise a registration system instead.
|
||||
static BaseItemSharedPtr extraItems{ Items( wxEmptyString,
|
||||
@ -196,10 +197,14 @@ MenuTable::BaseItemSharedPtr ExtraMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( ExtraMenu() )
|
||||
};
|
||||
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraMixerMenu()
|
||||
BaseItemSharedPtr ExtraMixerMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Mixer"), XO("Mi&xer"),
|
||||
@ -220,9 +225,8 @@ MenuTable::BaseItemSharedPtr ExtraMixerMenu()
|
||||
}
|
||||
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraDeviceMenu()
|
||||
BaseItemSharedPtr ExtraDeviceMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Device"), XO("De&vice"),
|
||||
@ -242,9 +246,8 @@ MenuTable::BaseItemSharedPtr ExtraDeviceMenu()
|
||||
}
|
||||
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemPtr ExtraMiscItems( AudacityProject &project )
|
||||
BaseItemPtr ExtraMiscItems( AudacityProject &project )
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
|
||||
constexpr auto key =
|
||||
@ -269,4 +272,6 @@ MenuTable::BaseItemPtr ExtraMiscItems( AudacityProject &project )
|
||||
) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#undef FN
|
||||
|
@ -551,10 +551,11 @@ static CommandHandlerObject &findCommandHandler(AudacityProject &) {
|
||||
|
||||
#define FN(X) (& FileActions::Handler :: X)
|
||||
|
||||
// under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr FileMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
|
||||
BaseItemSharedPtr FileMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
|
||||
static BaseItemSharedPtr menu{
|
||||
@ -705,4 +706,10 @@ MenuTable::BaseItemSharedPtr FileMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( FileMenu() )
|
||||
};
|
||||
}
|
||||
|
||||
#undef FN
|
||||
|
@ -523,10 +523,10 @@ static CommandHandlerObject &findCommandHandler(AudacityProject &) {
|
||||
|
||||
#define FN(X) (& HelpActions::Handler :: X)
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr HelpMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
BaseItemSharedPtr HelpMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Help"), XO("&Help"),
|
||||
@ -602,4 +602,11 @@ MenuTable::BaseItemSharedPtr HelpMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( HelpMenu() )
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#undef FN
|
||||
|
@ -701,9 +701,10 @@ MenuTable::BaseItemPtrs PopulateMacrosMenu( CommandFlag flags )
|
||||
// Menu definitions
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr GenerateMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
BaseItemSharedPtr GenerateMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
// All of this is a bit hacky until we can get more things connected into
|
||||
// the plugin manager...sorry! :-(
|
||||
|
||||
@ -737,10 +738,13 @@ static const ReservedCommandFlag
|
||||
}
|
||||
}; return flag; } //lll
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr EffectMenu()
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( GenerateMenu() )
|
||||
};
|
||||
|
||||
BaseItemSharedPtr EffectMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
// All of this is a bit hacky until we can get more things connected into
|
||||
// the plugin manager...sorry! :-(
|
||||
|
||||
@ -787,10 +791,13 @@ MenuTable::BaseItemSharedPtr EffectMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr AnalyzeMenu()
|
||||
AttachedItem sAttachment2{
|
||||
wxT(""),
|
||||
Shared( EffectMenu() )
|
||||
};
|
||||
|
||||
BaseItemSharedPtr AnalyzeMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
// All of this is a bit hacky until we can get more things connected into
|
||||
// the plugin manager...sorry! :-(
|
||||
|
||||
@ -819,10 +826,13 @@ MenuTable::BaseItemSharedPtr AnalyzeMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr ToolsMenu()
|
||||
AttachedItem sAttachment3{
|
||||
wxT(""),
|
||||
Shared( AnalyzeMenu() )
|
||||
};
|
||||
|
||||
BaseItemSharedPtr ToolsMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
|
||||
static BaseItemSharedPtr menu{
|
||||
@ -903,11 +913,15 @@ MenuTable::BaseItemSharedPtr ToolsMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment4{
|
||||
wxT(""),
|
||||
Shared( ToolsMenu() )
|
||||
};
|
||||
}
|
||||
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraScriptablesIMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
|
||||
// These are the more useful to VI user Scriptables.
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
@ -956,8 +970,6 @@ MenuTable::BaseItemSharedPtr ExtraScriptablesIMenu()
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraScriptablesIIMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
|
||||
// Less useful to VI users.
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
|
@ -1030,10 +1030,10 @@ static CommandHandlerObject &findCommandHandler(AudacityProject &project) {
|
||||
|
||||
MenuTable::BaseItemSharedPtr ClipSelectMenu();
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr SelectMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
BaseItemSharedPtr SelectMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
@ -1144,10 +1144,15 @@ MenuTable::BaseItemSharedPtr SelectMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( SelectMenu() )
|
||||
};
|
||||
}
|
||||
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraSelectionMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Select"), XO("&Selection"),
|
||||
@ -1192,7 +1197,6 @@ MenuTable::BaseItemSharedPtr ClipCursorItems();
|
||||
// Under /MenuBar/Transport
|
||||
MenuTable::BaseItemSharedPtr CursorMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
static const auto CanStopFlags = AudioIONotBusyFlag() | CanStopAudioStreamFlag();
|
||||
|
||||
@ -1240,8 +1244,6 @@ MenuTable::BaseItemSharedPtr ExtraClipCursorItems();
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraCursorMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Cursor"), XO("&Cursor"),
|
||||
@ -1272,7 +1274,6 @@ MenuTable::BaseItemSharedPtr ExtraCursorMenu()
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraSeekMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Seek"), XO("See&k"),
|
||||
|
@ -1278,10 +1278,11 @@ static CommandHandlerObject &findCommandHandler(AudacityProject &) {
|
||||
#define FN(X) (& TrackActions::Handler :: X)
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr TracksMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
BaseItemSharedPtr TracksMenu()
|
||||
{
|
||||
// Tracks Menu (formerly Project Menu)
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
|
||||
static BaseItemSharedPtr menu{
|
||||
@ -1437,10 +1438,15 @@ MenuTable::BaseItemSharedPtr TracksMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( TracksMenu() )
|
||||
};
|
||||
}
|
||||
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraTrackMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Track"), XO("&Track"),
|
||||
|
@ -971,9 +971,10 @@ static CommandHandlerObject &findCommandHandler(AudacityProject &) {
|
||||
MenuTable::BaseItemSharedPtr CursorMenu();
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr TransportMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
BaseItemSharedPtr TransportMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
|
||||
static const auto checkOff = Options{}.CheckState( false );
|
||||
@ -1098,10 +1099,15 @@ MenuTable::BaseItemSharedPtr TransportMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( TransportMenu() )
|
||||
};
|
||||
}
|
||||
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraTransportMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Transport"), XO("T&ransport"),
|
||||
@ -1153,7 +1159,6 @@ MenuTable::BaseItemSharedPtr ExtraTransportMenu()
|
||||
// Under /MenuBar/Optional/Extra
|
||||
MenuTable::BaseItemSharedPtr ExtraPlayAtSpeedMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("PlayAtSpeed"), XO("&Play-at-Speed"),
|
||||
|
@ -385,9 +385,10 @@ static CommandHandlerObject &findCommandHandler(AudacityProject &project) {
|
||||
MenuTable::BaseItemSharedPtr ToolbarsMenu();
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr ViewMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
BaseItemSharedPtr ViewMenu()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
using Options = CommandManager::Options;
|
||||
|
||||
static const auto checkOff = Options{}.CheckState( false );
|
||||
@ -463,4 +464,10 @@ MenuTable::BaseItemSharedPtr ViewMenu()
|
||||
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( ViewMenu() )
|
||||
};
|
||||
}
|
||||
|
||||
#undef FN
|
||||
|
@ -118,13 +118,13 @@ static CommandHandlerObject &findCommandHandler(AudacityProject &) {
|
||||
|
||||
#define FN(X) (& WindowActions::Handler :: X)
|
||||
|
||||
// Under /MenuBar
|
||||
MenuTable::BaseItemSharedPtr WindowMenu()
|
||||
namespace {
|
||||
using namespace MenuTable;
|
||||
BaseItemSharedPtr WindowMenu()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// poor imitation of the Mac Windows Menu
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr menu{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Menu( wxT("Window"), XO("&Window"),
|
||||
@ -149,10 +149,16 @@ MenuTable::BaseItemSharedPtr WindowMenu()
|
||||
return menu;
|
||||
}
|
||||
|
||||
AttachedItem sAttachment1{
|
||||
wxT(""),
|
||||
Shared( WindowMenu() )
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Under /MenuBar/Optional/Extra/Misc
|
||||
MenuTable::BaseItemSharedPtr ExtraWindowItems()
|
||||
{
|
||||
using namespace MenuTable;
|
||||
static BaseItemSharedPtr items{
|
||||
( FinderScope{ findCommandHandler },
|
||||
Items( wxT("MacWindows"),
|
||||
@ -170,11 +176,6 @@ MenuTable::BaseItemSharedPtr ExtraWindowItems()
|
||||
#else
|
||||
|
||||
// Not WXMAC. Stub functions.
|
||||
MenuTable::BaseItemSharedPtr WindowMenu()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MenuTable::BaseItemSharedPtr ExtraWindowItems()
|
||||
{
|
||||
return nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user