Commit c5c83bd2 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Added TOOL_MANAGER & ACTION_MANAGER::RunAction( const TOOL_ACTION aAction ).

Selection clearing is invoked using TOOL_ACTION object rather than its name.
parent 94cfed4b
Loading
Loading
Loading
Loading
+10 −10
Original line number Original line Diff line number Diff line
@@ -94,12 +94,20 @@ bool ACTION_MANAGER::RunAction( const std::string& aActionName ) const
    if( it == m_actionNameIndex.end() )
    if( it == m_actionNameIndex.end() )
        return false; // no action with given name found
        return false; // no action with given name found


    runAction( it->second );
    RunAction( it->second );


    return true;
    return true;
}
}




void ACTION_MANAGER::RunAction( const TOOL_ACTION* aAction ) const
{
    TOOL_EVENT event = aAction->MakeEvent();

    m_toolMgr->ProcessEvent( event );
}


bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
{
{
    std::map<int, TOOL_ACTION*>::const_iterator it = m_actionHotKeys.find( aHotKey );
    std::map<int, TOOL_ACTION*>::const_iterator it = m_actionHotKeys.find( aHotKey );
@@ -107,7 +115,7 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
    if( it == m_actionHotKeys.end() )
    if( it == m_actionHotKeys.end() )
        return false; // no appropriate action found for the hotkey
        return false; // no appropriate action found for the hotkey


    runAction( it->second );
    RunAction( it->second );


    return true;
    return true;
}
}
@@ -117,11 +125,3 @@ void ACTION_MANAGER::ClearHotKey( int aHotKey )
{
{
    m_actionHotKeys.erase( aHotKey );
    m_actionHotKeys.erase( aHotKey );
}
}


void ACTION_MANAGER::runAction( const TOOL_ACTION* aAction ) const
{
    TOOL_EVENT event = aAction->MakeEvent();

    m_toolMgr->ProcessEvent( event );
}
+6 −0
Original line number Original line Diff line number Diff line
@@ -196,6 +196,12 @@ bool TOOL_MANAGER::RunAction( const std::string& aActionName )
}
}




void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction )
{
    m_actionMgr->RunAction( &aAction );
}


bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
{
{
    wxASSERT( aTool != NULL );
    wxASSERT( aTool != NULL );
+8 −8
Original line number Original line Diff line number Diff line
@@ -81,6 +81,14 @@ public:
     */
     */
    bool RunAction( const std::string& aActionName ) const;
    bool RunAction( const std::string& aActionName ) const;


    /**
     * Function RunAction()
     * Prepares an appropriate event and sends it to the destination specified in a TOOL_ACTION
     * object.
     * @param aAction is the action to be run.
     */
    void RunAction( const TOOL_ACTION* aAction ) const;

    /**
    /**
     * Function RunHotKey()
     * Function RunHotKey()
     * Runs an action associated with a hotkey (if there is one available).
     * Runs an action associated with a hotkey (if there is one available).
@@ -108,14 +116,6 @@ private:


    ///> Map for indexing actions by their hotkeys
    ///> Map for indexing actions by their hotkeys
    std::map<int, TOOL_ACTION*> m_actionHotKeys;
    std::map<int, TOOL_ACTION*> m_actionHotKeys;

    /**
     * Function runAction()
     * Prepares an appropriate event and sends it to the destination specified in a TOOL_ACTION
     * object.
     * @param aAction is the action to be run.
     */
    void runAction( const TOOL_ACTION* aAction ) const;
};
};


#endif /* ACTION_MANAGER_H_ */
#endif /* ACTION_MANAGER_H_ */
+9 −1
Original line number Original line Diff line number Diff line
@@ -101,13 +101,21 @@ public:


    /**
    /**
     * Function RunAction()
     * Function RunAction()
     * Runs the specified action. The common format is "application.ToolName.Action".
     * Runs the specified action. The common format for action names is "application.ToolName.Action".
     *
     *
     * @param aActionName is the name of action to be invoked.
     * @param aActionName is the name of action to be invoked.
     * @return True if the action finished successfully, false otherwise.
     * @return True if the action finished successfully, false otherwise.
     */
     */
    bool RunAction( const std::string& aActionName );
    bool RunAction( const std::string& aActionName );


    /**
     * Function RunAction()
     * Runs the specified action.
     *
     * @param aAction is the action to be invoked.
     */
    void RunAction( const TOOL_ACTION& aAction );

    /**
    /**
     * Function FindTool()
     * Function FindTool()
     * Searches for a tool with given ID.
     * Searches for a tool with given ID.
+1 −0
Original line number Original line Diff line number Diff line
@@ -1458,6 +1458,7 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
    if( IsGalCanvasActive() )
    if( IsGalCanvasActive() )
    {
    {
        std::string actionName = COMMON_ACTIONS::TranslateLegacyId( id );
        std::string actionName = COMMON_ACTIONS::TranslateLegacyId( id );

        if( !actionName.empty() )
        if( !actionName.empty() )
            m_toolManager->RunAction( actionName );
            m_toolManager->RunAction( actionName );


Loading