1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 14:20:06 +02:00

Hide details of managing occult command items

This commit is contained in:
Paul Licameli 2018-10-20 14:01:20 -04:00
parent 01875db4bd
commit 5277584bb0
3 changed files with 22 additions and 12 deletions

View File

@ -390,7 +390,6 @@ void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
{
auto menubar = c->AddMenuBar(wxT("appmenu"));
wxASSERT(menubar);
c->SetOccultCommands( false );
/////////////////////////////////////////////////////////////////////////////
// File menu
@ -1394,14 +1393,9 @@ void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
bool bShowExtraMenus;
gPrefs->Read(wxT("/GUI/ShowExtraMenus"), &bShowExtraMenus, false);
std::unique_ptr<wxMenuBar> menubar2;
if( !bShowExtraMenus )
{
// Make a temporary menu bar collecting items added below.
// This bar will be discarded but other side effects on the command
// manager persist.
menubar2 = c->AddMenuBar(wxT("ext-menu"));
c->SetOccultCommands(true);
c->BeginOccultCommands();
}
/////////////////////////////////////////////////////////////////////////////
@ -1794,8 +1788,7 @@ void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
if (!bShowExtraMenus)
{
c->PopMenuBar();
c->SetOccultCommands(false);
c->EndOccultCommands();
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -1831,9 +1831,24 @@ void CommandManager::WriteXML(XMLWriter &xmlFile) const
xmlFile.EndTag(wxT("audacitykeyboard"));
}
void CommandManager::SetOccultCommands( bool bOccult)
void CommandManager::BeginOccultCommands()
{
bMakingOccultCommands = bOccult;
// To do: perhaps allow occult item switching at lower levels of the
// menu tree.
wxASSERT( !CurrentMenu() );
// Make a temporary menu bar collecting items added after.
// This bar will be discarded but other side effects on the command
// manager persist.
mTempMenuBar = AddMenuBar(wxT("ext-menu"));
bMakingOccultCommands = true;
}
void CommandManager::EndOccultCommands()
{
PopMenuBar();
bMakingOccultCommands = false;
mTempMenuBar.reset();
}
void CommandManager::SetCommandFlags(const wxString &name,

View File

@ -212,7 +212,8 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
CommandFlag flags);
void PopMenuBar();
void SetOccultCommands( bool bOccult);
void BeginOccultCommands();
void EndOccultCommands();
void SetCommandFlags(const wxString &name, CommandFlag flags, CommandMask mask);
@ -394,6 +395,7 @@ private:
wxMenu *mCurrentMenu {};
bool bMakingOccultCommands;
std::unique_ptr< wxMenuBar > mTempMenuBar;
};
#endif