Simplify forcing action parameters to have a specific type
This commit is contained in:
parent
07cc85e76c
commit
3718ecfcd8
|
@ -376,7 +376,7 @@ TOOL_ACTION ACTIONS::zoomTool( "common.Control.zoomTool",
|
|||
TOOL_ACTION ACTIONS::zoomPreset( TOOL_ACTION_ARGS()
|
||||
.Name( "common.Control.zoomPreset" )
|
||||
.Scope( AS_GLOBAL )
|
||||
.Parameter( static_cast<int>( 0 ) ) ); // Default parameter is the 0th item in the list
|
||||
.Parameter<int>( 0 ) ); // Default parameter is the 0th item in the list
|
||||
|
||||
TOOL_ACTION ACTIONS::centerContents( "common.Control.centerContents",
|
||||
AS_GLOBAL );
|
||||
|
@ -546,7 +546,7 @@ TOOL_ACTION ACTIONS::gridResetOrigin( "common.Control.gridResetOrigin",
|
|||
TOOL_ACTION ACTIONS::gridPreset( TOOL_ACTION_ARGS()
|
||||
.Name( "common.Control.gridPreset" )
|
||||
.Scope( AS_GLOBAL )
|
||||
.Parameter( static_cast<int>( 0 ) ) ); // Default to the 1st element of the list
|
||||
.Parameter<int>( 0 ) ); // Default to the 1st element of the list
|
||||
|
||||
TOOL_ACTION ACTIONS::toggleGrid( "common.Control.toggleGrid",
|
||||
AS_GLOBAL, 0, "",
|
||||
|
|
|
@ -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( aEvent.GetId() - ID_POPUP_GRID_START );
|
||||
event->SetParameter<int>( aEvent.GetId() - ID_POPUP_GRID_START );
|
||||
return event;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,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( aEvent.GetId() - ID_POPUP_ZOOM_LEVEL_START );
|
||||
event->SetParameter<int>( aEvent.GetId() - ID_POPUP_ZOOM_LEVEL_START );
|
||||
return event;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,8 @@ public:
|
|||
/**
|
||||
* Custom parameter to pass information to the tool.
|
||||
*/
|
||||
TOOL_ACTION_ARGS& Parameter( std::any aParam )
|
||||
template<typename T>
|
||||
TOOL_ACTION_ARGS& Parameter( T aParam )
|
||||
{
|
||||
m_param = aParam;
|
||||
return *this;
|
||||
|
|
|
@ -470,7 +470,8 @@ public:
|
|||
*
|
||||
* @param aParam is the new parameter.
|
||||
*/
|
||||
void SetParameter(const std::any& aParam)
|
||||
template<typename T>
|
||||
void SetParameter(T aParam)
|
||||
{
|
||||
m_param = aParam;
|
||||
}
|
||||
|
|
|
@ -878,7 +878,7 @@ TOOL_ACTION PCB_ACTIONS::hideNetInRatsnest( TOOL_ACTION_ARGS()
|
|||
.MenuText( _( "Hide Net in Ratsnest" ) )
|
||||
.Tooltip( _( "Hide the selected net in the ratsnest of unconnected net lines/arcs" ) )
|
||||
.Icon( BITMAPS::hide_ratsnest )
|
||||
.Parameter( static_cast<int>( 0 ) ) ); // Default to hiding selected net
|
||||
.Parameter<int>( 0 ) ); // Default to hiding selected net
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::showNetInRatsnest( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.EditorControl.showNet" )
|
||||
|
@ -886,7 +886,7 @@ TOOL_ACTION PCB_ACTIONS::showNetInRatsnest( TOOL_ACTION_ARGS()
|
|||
.MenuText( _( "Show Net in Ratsnest" ) )
|
||||
.Tooltip( _( "Show the selected net in the ratsnest of unconnected net lines/arcs" ) )
|
||||
.Icon( BITMAPS::show_ratsnest )
|
||||
.Parameter( static_cast<int>( 0 ) ) ); // Default to showing selected net
|
||||
.Parameter<int>( 0 ) ); // Default to showing selected net
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::showEeschema( "pcbnew.EditorControl.showEeschema",
|
||||
AS_GLOBAL, 0, "",
|
||||
|
|
Loading…
Reference in New Issue