Update tool manager to handle the std::any parameters
This commit is contained in:
parent
8b833211b5
commit
9ebe6e7614
|
@ -285,7 +285,7 @@ bool TOOL_MANAGER::InvokeTool( const std::string& aToolName )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, void* aParam )
|
bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, std::any aParam )
|
||||||
{
|
{
|
||||||
TOOL_ACTION* action = m_actionMgr->FindAction( aActionName );
|
TOOL_ACTION* action = m_actionMgr->FindAction( aActionName );
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ VECTOR2D TOOL_MANAGER::GetCursorPosition() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam )
|
bool TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, std::any aParam )
|
||||||
{
|
{
|
||||||
if( m_shuttingDown )
|
if( m_shuttingDown )
|
||||||
return true;
|
return true;
|
||||||
|
@ -331,7 +331,7 @@ bool TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aPara
|
||||||
event.SetMousePosition( GetCursorPosition() );
|
event.SetMousePosition( GetCursorPosition() );
|
||||||
|
|
||||||
// Allow to override the action parameter
|
// Allow to override the action parameter
|
||||||
if( aParam )
|
if( aParam.has_value() )
|
||||||
event.SetParameter( aParam );
|
event.SetParameter( aParam );
|
||||||
|
|
||||||
if( aNow )
|
if( aNow )
|
||||||
|
|
|
@ -138,17 +138,14 @@ public:
|
||||||
* depends on the action.
|
* depends on the action.
|
||||||
* @return False if the action was not found.
|
* @return False if the action was not found.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
bool RunAction( const std::string& aActionName, bool aNow, std::any aParam );
|
||||||
bool RunAction( const std::string& aActionName, bool aNow = false, T aParam = NULL )
|
|
||||||
{
|
|
||||||
return RunAction( aActionName, aNow, reinterpret_cast<void*>( aParam ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RunAction( const std::string& aActionName, bool aNow, void* aParam );
|
|
||||||
|
|
||||||
bool RunAction( const std::string& aActionName, bool aNow = false )
|
bool RunAction( const std::string& aActionName, bool aNow = false )
|
||||||
{
|
{
|
||||||
return RunAction( aActionName, aNow, (void*) NULL );
|
// Default initialize the parameter argument to an empty std::any
|
||||||
|
std::any a;
|
||||||
|
|
||||||
|
return RunAction( aActionName, aNow, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,17 +161,14 @@ public:
|
||||||
* depends on the action.
|
* depends on the action.
|
||||||
* @return True if the action was handled immediately
|
* @return True if the action was handled immediately
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
bool RunAction( const TOOL_ACTION& aAction, bool aNow, std::any aParam );
|
||||||
bool RunAction( const TOOL_ACTION& aAction, bool aNow = false, T aParam = NULL )
|
|
||||||
{
|
|
||||||
return RunAction( aAction, aNow, reinterpret_cast<void*>( aParam ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam );
|
|
||||||
|
|
||||||
bool RunAction( const TOOL_ACTION& aAction, bool aNow = false )
|
bool RunAction( const TOOL_ACTION& aAction, bool aNow = false )
|
||||||
{
|
{
|
||||||
return RunAction( aAction, aNow, (void*) NULL );
|
// Default initialize the parameter argument to an empty std::any
|
||||||
|
std::any a;
|
||||||
|
|
||||||
|
return RunAction( aAction, aNow, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue