Architecturally-simpler fix for grid context menu unit changes.

Fixes: lp:1777519
* https://bugs.launchpad.net/kicad/+bug/1777519
This commit is contained in:
Jeff Young 2018-06-20 16:51:47 +01:00
parent 77217b2089
commit 79e0bb08d0
3 changed files with 13 additions and 14 deletions

View File

@ -51,13 +51,6 @@ GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) : m_parent( aParent )
}
CONTEXT_MENU* GRID_MENU::Clone() const
{
// Just return a fresh menu. This keeps the units up-to-date.
return create();
}
OPT_TOOL_EVENT GRID_MENU::eventHandler( const wxMenuEvent& aEvent )
{
OPT_TOOL_EVENT event( ACTIONS::gridPreset.MakeEvent() );
@ -70,9 +63,17 @@ OPT_TOOL_EVENT GRID_MENU::eventHandler( const wxMenuEvent& aEvent )
void GRID_MENU::update()
{
for( unsigned int i = 0; i < GetMenuItemCount(); ++i )
Check( ID_POPUP_GRID_SELECT + 1 + i, false );
BASE_SCREEN* screen = m_parent->GetScreen();
int currentId = screen->GetGridCmdId();
wxArrayString gridsList;
// Check the current grid size
Check( m_parent->GetScreen()->GetGridCmdId(), true );
screen->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES );
for( unsigned int i = 0; i < GetMenuItemCount(); ++i )
{
int menuId = ID_POPUP_GRID_SELECT + 1 + i;
SetLabel( menuId, gridsList[i] ); // Refresh label in case units have changed
Check( menuId, menuId == currentId ); // Refresh checkmark
}
}

View File

@ -142,7 +142,7 @@ public:
/**
* Creates a deep, recursive copy of this CONTEXT_MENU.
*/
virtual CONTEXT_MENU* Clone() const;
CONTEXT_MENU* Clone() const;
protected:
///> Returns an instance of this class. It has to be overridden in inheriting classes.

View File

@ -34,8 +34,6 @@ class GRID_MENU : public CONTEXT_MENU
public:
GRID_MENU( EDA_DRAW_FRAME* aParent );
CONTEXT_MENU* Clone() const override;
private:
CONTEXT_MENU* create() const override
{