Commit 18898fe8 authored by Maciej Suminski's avatar Maciej Suminski

tool: Added a generic parameter for RunAction().

parent 383fec15
...@@ -292,21 +292,19 @@ void TOOL_MANAGER::UnregisterAction( TOOL_ACTION* aAction ) ...@@ -292,21 +292,19 @@ void TOOL_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
} }
bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow ) bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, void* aParam )
{ {
TOOL_ACTION* action = m_actionMgr->FindAction( aActionName ); TOOL_ACTION* action = m_actionMgr->FindAction( aActionName );
if( action ) if( action )
{ {
TOOL_EVENT event = action->MakeEvent();
event.SetParameter( aParam );
if( aNow ) if( aNow )
{
TOOL_EVENT event = action->MakeEvent();
ProcessEvent( event ); ProcessEvent( event );
}
else else
{ PostEvent( event );
PostEvent( action->MakeEvent() );
}
return true; return true;
} }
...@@ -315,17 +313,15 @@ bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow ) ...@@ -315,17 +313,15 @@ bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow )
} }
void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow ) void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam )
{ {
TOOL_EVENT event = aAction.MakeEvent();
event.SetParameter( aParam );
if( aNow ) if( aNow )
{
TOOL_EVENT event = aAction.MakeEvent();
ProcessEvent( event ); ProcessEvent( event );
}
else else
{ PostEvent( event );
PostEvent( aAction.MakeEvent() );
}
} }
......
...@@ -165,7 +165,8 @@ public: ...@@ -165,7 +165,8 @@ public:
m_scope( aScope ), m_scope( aScope ),
m_mouseButtons( 0 ), m_mouseButtons( 0 ),
m_keyCode( 0 ), m_keyCode( 0 ),
m_modifiers( 0 ) {} m_modifiers( 0 ),
m_param( NULL ) {}
TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam, TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam,
TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) : TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
...@@ -174,7 +175,8 @@ public: ...@@ -174,7 +175,8 @@ public:
m_scope( aScope ), m_scope( aScope ),
m_mouseButtons( 0 ), m_mouseButtons( 0 ),
m_keyCode( 0 ), m_keyCode( 0 ),
m_modifiers( 0 ) m_modifiers( 0 ),
m_param( NULL )
{ {
if( aCategory == TC_MOUSE ) if( aCategory == TC_MOUSE )
{ {
...@@ -202,7 +204,8 @@ public: ...@@ -202,7 +204,8 @@ public:
m_scope( aScope ), m_scope( aScope ),
m_mouseButtons( 0 ), m_mouseButtons( 0 ),
m_keyCode( 0 ), m_keyCode( 0 ),
m_modifiers( 0 ) m_modifiers( 0 ),
m_param( NULL )
{ {
if( aCategory == TC_COMMAND || aCategory == TC_MESSAGE ) if( aCategory == TC_COMMAND || aCategory == TC_MESSAGE )
m_commandStr = aExtraParam; m_commandStr = aExtraParam;
...@@ -352,6 +355,27 @@ public: ...@@ -352,6 +355,27 @@ public:
*/ */
bool IsAction( const TOOL_ACTION* aAction ) const; bool IsAction( const TOOL_ACTION* aAction ) const;
/**
* Function Parameter()
* Returns a non-standard parameter assigned to the event. Its meaning depends on the
* target tool.
*/
void* Parameter() const
{
return m_param;
}
/**
* Function SetParameter()
* Sets a non-standard parameter assigned to the event. Its meaning depends on the
* target tool.
* @param aParam is the new parameter.
*/
void SetParameter(void* aParam)
{
m_param = aParam;
}
boost::optional<int> GetCommandId() const boost::optional<int> GetCommandId() const
{ {
return m_commandId; return m_commandId;
...@@ -388,6 +412,9 @@ private: ...@@ -388,6 +412,9 @@ private:
///> State of key modifierts (Ctrl/Alt/etc.) ///> State of key modifierts (Ctrl/Alt/etc.)
int m_modifiers; int m_modifiers;
///> Generic parameter used for passing non-standard data.
void* m_param;
boost::optional<int> m_commandId; boost::optional<int> m_commandId;
boost::optional<std::string> m_commandStr; boost::optional<std::string> m_commandStr;
}; };
......
...@@ -108,9 +108,11 @@ public: ...@@ -108,9 +108,11 @@ public:
* @param aActionName is the name of action to be invoked. * @param aActionName is the name of action to be invoked.
* @param aNow decides if the action has to be run immediately or after the current coroutine * @param aNow decides if the action has to be run immediately or after the current coroutine
* is preemptied. * is preemptied.
* @param aParam is an optional parameter that might be used by the invoked action. Its meaning
* depends on the action.
* @return False if the action was not found. * @return False if the action was not found.
*/ */
bool RunAction( const std::string& aActionName, bool aNow = false ); bool RunAction( const std::string& aActionName, bool aNow = false, void* aParam = NULL );
/** /**
* Function RunAction() * Function RunAction()
...@@ -119,8 +121,10 @@ public: ...@@ -119,8 +121,10 @@ public:
* @param aAction is the action to be invoked. * @param aAction is the action to be invoked.
* @param aNow decides if the action has to be run immediately or after the current coroutine * @param aNow decides if the action has to be run immediately or after the current coroutine
* is preemptied. * is preemptied.
* @param aParam is an optional parameter that might be used by the invoked action. Its meaning
* depends on the action.
*/ */
void RunAction( const TOOL_ACTION& aAction, bool aNow = false ); void RunAction( const TOOL_ACTION& aAction, bool aNow = false, void* aParam = NULL );
/** /**
* Function FindTool() * Function FindTool()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment