1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 14:02:57 +02:00

Only one public CommandManager fn to begin a menu and one to end...

... It knows the nesting, so it decides for itself whether to manage the menu
as main or sub-.
This commit is contained in:
Paul Licameli
2018-10-18 08:52:37 -04:00
parent 32efcd43c4
commit 7f5e6d12b1
4 changed files with 144 additions and 117 deletions

View File

@@ -614,18 +614,44 @@ void CommandManager::SwapMenuBars()
///
/// This starts a NEW menu
///
void CommandManager::BeginMenu(const wxString & tName)
wxMenu *CommandManager::BeginMenu(const wxString & tName)
{
if ( mCurrentMenu )
return BeginSubMenu( tName );
else
return BeginMainMenu( tName );
}
///
/// This attaches a menu, if it's main, to the menubar
// and in all cases ends the menu
///
void CommandManager::EndMenu()
{
if ( mSubMenuList.empty() )
EndMainMenu();
else
EndSubMenu();
}
///
/// This starts a NEW menu
///
wxMenu *CommandManager::BeginMainMenu(const wxString & tName)
{
uCurrentMenu = std::make_unique<wxMenu>();
mCurrentMenu = uCurrentMenu.get();
mCurrentMenuName = tName;
return mCurrentMenu;
}
///
/// This attaches a menu to the menubar and ends the menu
///
void CommandManager::EndMenu()
void CommandManager::EndMainMenu()
{
// Add the menu to the menubar after all menu items have been
// added to the menu to allow OSX to rearrange special menu

View File

@@ -140,12 +140,9 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
// You may either called SetCurrentMenu later followed by ClearCurrentMenu,
// or else BeginMenu followed by EndMenu. Don't mix them.
void BeginMenu(const wxString & tName);
wxMenu *BeginMenu(const wxString & tName);
void EndMenu();
wxMenu* BeginSubMenu(const wxString & tName);
void EndSubMenu();
// For specifying unusual arguments in AddItem
struct Options
{
@@ -349,6 +346,10 @@ protected:
//
void Enable(CommandListEntry *entry, bool enabled);
wxMenu *BeginMainMenu(const wxString & tName);
void EndMainMenu();
wxMenu* BeginSubMenu(const wxString & tName);
void EndSubMenu();
//
// Accessing