3D viewer: fix preferences/grid issues: grid menuitems always disabled.

This commit is contained in:
jean-pierre charras 2019-07-30 19:12:16 +02:00
parent 58cfc13649
commit 9b6c8c885b
3 changed files with 34 additions and 19 deletions

View File

@ -167,7 +167,7 @@ void EDA_3D_VIEWER::CreateMenuBar()
auto showAxesCondition = [ this ] ( const SELECTION& aSel ) {
return m_settings.GetFlag( FL_AXIS );
};
prefsMenu->AddItem( ID_TOOL_SET_VISIBLE_ITEMS, _( "Display Options" ), "",
read_setup_xpm, SELECTION_CONDITIONS::ShowAlways );
@ -281,7 +281,7 @@ void EDA_3D_VIEWER::CreateMenuBar()
setcolor_board_body_xpm, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddMenu( colorSubmenu );
prefsMenu->AddCheckItem( ID_MENU3D_AXIS_ONOFF, _( "Show 3D &Axis" ), "",
axis3d_front_xpm, showAxesCondition );
@ -306,25 +306,25 @@ void EDA_3D_VIEWER::CreateMenuBar()
return m_settings.GridGet() == GRID3D_1MM;
};
gridSubmenu->AddItem( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), "",
nullptr, noGridCondition );
gridSubmenu->AddItem( ID_MENU3D_GRID_10_MM, _( "3D Grid 10mm" ), "",
nullptr, grid10mmCondition );
gridSubmenu->AddItem( ID_MENU3D_GRID_5_MM, _( "3D Grid 5mm" ), "",
nullptr, grid5mmCondition );
gridSubmenu->AddItem( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5mm" ), "",
nullptr, grid2p5mmCondition );
gridSubmenu->AddItem( ID_MENU3D_GRID_1_MM, _( "3D Grid 1mm" ), "",
nullptr, grid_1mmCondition );
gridSubmenu->AddCheckItem( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), "",
nullptr, noGridCondition );
gridSubmenu->AddCheckItem( ID_MENU3D_GRID_10_MM, _( "3D Grid 10mm" ), "",
nullptr, grid10mmCondition );
gridSubmenu->AddCheckItem( ID_MENU3D_GRID_5_MM, _( "3D Grid 5mm" ), "",
nullptr, grid5mmCondition );
gridSubmenu->AddCheckItem( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5mm" ), "",
nullptr, grid2p5mmCondition );
gridSubmenu->AddCheckItem( ID_MENU3D_GRID_1_MM, _( "3D Grid 1mm" ), "",
nullptr, grid_1mmCondition );
prefsMenu->AddMenu( gridSubmenu, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AppendSeparator();
prefsMenu->AddItem( ID_MENU3D_RESET_DEFAULTS, _( "Reset to Default Settings" ), "",
tools_xpm, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->Resolve();
//-- Menubar -------------------------------------------------------------
//
menuBar->Append( fileMenu, _( "&File" ) );

View File

@ -571,6 +571,21 @@ void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
default: wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::On3DGridSelection()" );
}
int menu_ids[]
{
ID_MENU3D_GRID_NOGRID, ID_MENU3D_GRID_10_MM, ID_MENU3D_GRID_5_MM,
ID_MENU3D_GRID_2P5_MM, ID_MENU3D_GRID_1_MM
};
// Refresh checkmarks
wxMenuBar* menuBar = GetMenuBar();
for( int ii = 0; ii < 5; ii++ )
{
wxMenuItem* item = menuBar->FindItem( menu_ids[ii] );
item->Check( menu_ids[ii] == id );
}
if( m_canvas )
m_canvas->Request_refresh();
}

View File

@ -70,7 +70,7 @@ static const wxString entryMaximized = "Maximized"; ///< Nonzero iff frame is m
BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuOpen )
EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuOpen )
@ -192,7 +192,7 @@ void EDA_BASE_FRAME::PopTool( const std::string& actionName )
// If there's something underneath us, and it's now the top of the stack, then
// re-activate it
if( ( --i ) >= 0 && i == m_toolStack.size() - 1 )
if( ( --i ) >= 0 && i == (int)m_toolStack.size() - 1 )
{
std::string back = m_toolStack[ i ];
TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( back );
@ -372,7 +372,7 @@ void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
helpMenu->Add( ACTIONS::gettingStarted );
helpMenu->Add( ACTIONS::listHotKeys );
helpMenu->Add( ACTIONS::getInvolved );
helpMenu->AppendSeparator();
helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
@ -608,7 +608,7 @@ void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
wxTreebook* book = dlg.GetTreebook();
book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
book->AddPage( hotkeysPanel, _( "Hotkeys" ) );