Attempt to fix duplicate ID issue on MSW.

This commit is contained in:
Jeff Young 2020-06-17 18:27:45 +01:00
parent a7703d1207
commit 754f958be2
3 changed files with 10 additions and 9 deletions

View File

@ -42,7 +42,7 @@ GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) :
APP_SETTINGS_BASE* settings = m_parent->config();
wxArrayString gridsList;
int i = 0;
int i = ID_POPUP_GRID_START;
BuildChoiceList( &gridsList, settings, m_parent->GetUserUnits() != EDA_UNITS::INCHES );
@ -54,7 +54,7 @@ GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) :
OPT_TOOL_EVENT GRID_MENU::eventHandler( const wxMenuEvent& aEvent )
{
OPT_TOOL_EVENT event( ACTIONS::gridPreset.MakeEvent() );
event->SetParameter( (intptr_t) aEvent.GetId() );
event->SetParameter( (intptr_t) aEvent.GetId() - ID_POPUP_GRID_START );
return event;
}

View File

@ -24,6 +24,7 @@
*/
#include <tool/zoom_menu.h>
#include <id.h>
#include <eda_draw_frame.h>
#include <settings/app_settings.h>
#include <tool/actions.h>
@ -41,7 +42,7 @@ ZOOM_MENU::ZOOM_MENU( EDA_DRAW_FRAME* aParent ) :
SetTitle( _( "Zoom" ) );
SetIcon( zoom_selection_xpm );
int i = 1; // 0 reserved for menus which support auto-zoom
int i = ID_POPUP_ZOOM_LEVEL_START + 1; // 0 reserved for menus which support auto-zoom
for( double factor : m_parent->config()->m_Window.zoom_factors )
Append( i++, wxString::Format( _( "Zoom: %.2f" ), factor ), wxEmptyString, wxITEM_CHECK );
@ -51,7 +52,7 @@ ZOOM_MENU::ZOOM_MENU( EDA_DRAW_FRAME* aParent ) :
OPT_TOOL_EVENT ZOOM_MENU::eventHandler( const wxMenuEvent& aEvent )
{
OPT_TOOL_EVENT event( ACTIONS::zoomPreset.MakeEvent() );
event->SetParameter( (intptr_t) aEvent.GetId() );
event->SetParameter( (intptr_t) aEvent.GetId() - ID_POPUP_ZOOM_LEVEL_START );
return event;
}
@ -67,6 +68,6 @@ void ZOOM_MENU::update()
// Search for a value near the current zoom setting:
double rel_error = std::fabs( zoomList[i] - zoom ) / zoom;
// IDs start with 1 (leaving 0 for auto-zoom)
Check( i+1, rel_error < 0.1 );
Check( ID_POPUP_ZOOM_LEVEL_START + i + 1, rel_error < 0.1 );
}
}

View File

@ -157,12 +157,12 @@ enum main_id
* than 15 entries in a context submenu may get too large to display
* cleanly. Add any additional popup zoom IDs above here or the
* zoom event handler will not work properly.
* currently room is provided for 32 levels (this is a very large value).
* Pcbnew use 18 values. For schematic 15 is enought
*/
ID_POPUP_ZOOM_LEVEL_START,
ID_POPUP_ZOOM_LEVEL_END = ID_POPUP_ZOOM_LEVEL_START + 32,
ID_POPUP_ZOOM_END_RANGE, // last zoom id
ID_POPUP_ZOOM_LEVEL_END = ID_POPUP_ZOOM_LEVEL_START + 99,
ID_POPUP_GRID_START,
ID_POPUP_GRID_END = ID_POPUP_ZOOM_LEVEL_START + 99,
ID_ON_GRID_SELECT,
ID_GRID_SETTINGS,