Commit 0694f2fa authored by Maciej Suminski's avatar Maciej Suminski
Browse files

TOOL_EVENTs autoregister themselves in ACTION_MANAGER.

ROUTER_TOOL events have temporarily changed their hotkeys assignment.
parent 42684489
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -60,8 +60,6 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )

        m_actionHotKeys[aAction->m_currentHotKey] = aAction;
    }

    aAction->setActionMgr( this );
}


@@ -71,7 +69,6 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
    m_actionIdIndex.erase( aAction->m_id );

    // Indicate that the ACTION_MANAGER no longer care about the object
    aAction->setActionMgr( NULL );
    aAction->setId( -1 );

    if( aAction->HasHotKey() )
+4 −13
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include <cassert>

#include <tool/tool_base.h>
#include <tool/action_manager.h>
#include <tool/tool_manager.h>

/**
 * Class TOOL_ACTION
@@ -50,14 +50,14 @@ public:
            const std::string& aMenuDesc = std::string( "" ) ) :
        m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
        m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ),
        m_menuDescription( aMenuDesc ), m_id( -1 ), m_actionMgr( NULL )
        m_menuDescription( aMenuDesc ), m_id( -1 )
    {
        TOOL_MANAGER::Instance().RegisterAction( this );
    }

    ~TOOL_ACTION()
    {
        if( m_actionMgr )
            m_actionMgr->UnregisterAction( this );
        TOOL_MANAGER::Instance().UnregisterAction( this );
    }

    bool operator==( const TOOL_ACTION& aRhs ) const
@@ -180,12 +180,6 @@ private:
        m_id = aId;
    }

    /// Assigns ACTION_MANAGER object that handles the TOOL_ACTION.
    void setActionMgr( ACTION_MANAGER* aManager )
    {
        m_actionMgr = aManager;
    }

    /// Name of the action (convention is: app.[tool.]action.name)
    std::string m_name;

@@ -210,9 +204,6 @@ private:
    /// Unique ID for fast matching. Assigned by ACTION_MANAGER.
    int m_id;

    /// Action manager that handles this TOOL_ACTION.
    ACTION_MANAGER* m_actionMgr;

    /// Origin of the action
// const TOOL_BASE* m_origin;

+9 −1
Original line number Diff line number Diff line
@@ -48,7 +48,13 @@ class wxWindow;
class TOOL_MANAGER
{
public:
    TOOL_MANAGER();
    static TOOL_MANAGER& Instance()
    {
        static TOOL_MANAGER manager;

        return manager;
    }

    ~TOOL_MANAGER();

    /**
@@ -211,6 +217,8 @@ public:
    }

private:
    TOOL_MANAGER();

    struct TOOL_STATE;
    typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;

+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ protected:
    /// main window.
    wxAuiToolBar*       m_auxiliaryToolBar;

    TOOL_MANAGER*       m_toolManager;
    TOOL_MANAGER&       m_toolManager;
    TOOL_DISPATCHER*    m_toolDispatcher;

    void updateGridSelectBox();
+2 −2
Original line number Diff line number Diff line
@@ -131,10 +131,10 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
                                const wxString& aTitle,
                                const wxPoint& aPos, const wxSize& aSize,
                                long aStyle, const wxString & aFrameName) :
    EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
    EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
    m_toolManager( TOOL_MANAGER::Instance() )
{
    m_Pcb                 = NULL;
    m_toolManager         = NULL;
    m_toolDispatcher      = NULL;

    m_DisplayPadFill      = true;   // How to draw pads
Loading