Add checking to languages menu.

This also required having KICAD_MANAGER_CONTROL handle UpdateMenu
since there's no seletion tool for the Kicad Manager frame.
This commit is contained in:
Jeff Young 2019-06-16 20:11:08 +01:00
parent de67f3f1e9
commit b2ee2a4d88
3 changed files with 22 additions and 6 deletions

View File

@ -38,6 +38,7 @@
extern LANGUAGE_DESCR LanguagesList[];
using namespace std::placeholders;
/**
* Function AddMenuLanguageList
@ -54,11 +55,8 @@ void AddMenuLanguageList( CONDITIONAL_MENU* aMasterMenu, TOOL_INTERACTIVE* aCont
aMasterMenu->AddMenu( langsMenu );
wxString tooltip;
// Fix me: find the way to return true for the menutitem having the same m_WX_Lang_Identifier
// value as Pgm().GetSelectedLanguageIdentifier()
auto isCurrentLanguage = [] ( const SELECTION& aSel )
{
return false;
auto isCurrentLang = [] ( int aLangIdentifier ) {
return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
};
for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
@ -72,6 +70,6 @@ void AddMenuLanguageList( CONDITIONAL_MENU* aMasterMenu, TOOL_INTERACTIVE* aCont
langsMenu->AddCheckItem( LanguagesList[ii].m_KI_Lang_Identifier, // wxMenuItem wxID
label, tooltip, LanguagesList[ii].m_Lang_Icon,
isCurrentLanguage );
std::bind( isCurrentLang, LanguagesList[ii].m_WX_Lang_Identifier ) );
}
}

View File

@ -398,6 +398,22 @@ int KICAD_MANAGER_CONTROL::Refresh( const TOOL_EVENT& aEvent )
}
int KICAD_MANAGER_CONTROL::UpdateMenu( const TOOL_EVENT& aEvent )
{
ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
SELECTION dummySel;
if( conditionalMenu )
conditionalMenu->Evaluate( dummySel );
if( actionMenu )
actionMenu->UpdateAll();
return 0;
}
int KICAD_MANAGER_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
{
FRAME_T playerType = FRAME_SCH_VIEWER;
@ -568,6 +584,7 @@ void KICAD_MANAGER_CONTROL::setTransitions()
Go( &KICAD_MANAGER_CONTROL::OpenProject, KICAD_MANAGER_ACTIONS::openProject.MakeEvent() );
Go( &KICAD_MANAGER_CONTROL::Refresh, ACTIONS::zoomRedraw.MakeEvent() );
Go( &KICAD_MANAGER_CONTROL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() );
Go( &KICAD_MANAGER_CONTROL::ShowPlayer, KICAD_MANAGER_ACTIONS::editSchematic.MakeEvent() );
Go( &KICAD_MANAGER_CONTROL::ShowPlayer, KICAD_MANAGER_ACTIONS::editSymbols.MakeEvent() );

View File

@ -50,6 +50,7 @@ public:
int OpenProject( const TOOL_EVENT& aEvent );
int Refresh( const TOOL_EVENT& aEvent );
int UpdateMenu( const TOOL_EVENT& aEvent );
int ShowPlayer( const TOOL_EVENT& aEvent );
int Execute( const TOOL_EVENT& aEvent );