Commit 99e52289 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Moved the list of TOOL_ACTIONs to ACTION_MANAGER.

parent 1cd3cfa2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@
ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
    m_toolMgr( aToolManager )
{
    // Register known actions
    std::list<TOOL_ACTION*>& actionList = GetActionList();
    BOOST_FOREACH( TOOL_ACTION* action, actionList )
        RegisterAction( action );
}


+18 −0
Original line number Diff line number Diff line
@@ -23,6 +23,24 @@
 */

#include <tool/tool_action.h>
#include <tool/action_manager.h>

TOOL_ACTION::TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope,
        int aDefaultHotKey, const wxString aMenuItem, const wxString& aMenuDesc,
        const BITMAP_OPAQUE* aIcon, TOOL_ACTION_FLAGS aFlags, void* aParam ) :
    m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
    m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ), m_menuDescription( aMenuDesc ),
    m_icon( aIcon ), m_id( -1 ), m_flags( aFlags ), m_param( aParam )
{
    ACTION_MANAGER::GetActionList().push_back( this );
}


TOOL_ACTION::~TOOL_ACTION()
{
    ACTION_MANAGER::GetActionList().remove( this );
}


std::string TOOL_ACTION::GetToolName() const
{
+0 −5
Original line number Diff line number Diff line
@@ -202,11 +202,6 @@ TOOL_MANAGER::TOOL_MANAGER() :
    m_passEvent( false )
{
    m_actionMgr = new ACTION_MANAGER( this );

    // Register known actions
    std::list<TOOL_ACTION*>& actionList = GetActionList();
    BOOST_FOREACH( TOOL_ACTION* action, actionList )
        RegisterAction( action );
}


+13 −0
Original line number Diff line number Diff line
@@ -90,6 +90,19 @@ public:
     */
    bool RunHotKey( int aHotKey ) const;

    /**
     * Returns list of TOOL_ACTIONs. TOOL_ACTIONs add themselves to the list upon their
     * creation.
     * @return List of TOOL_ACTIONs.
     */
    static std::list<TOOL_ACTION*>& GetActionList()
    {
        // TODO I am afraid this approach won't work when we reach multitab version of kicad.
        static std::list<TOOL_ACTION*> actionList;

        return actionList;
    }

private:
    ///> Tool manager needed to run actions
    TOOL_MANAGER* m_toolMgr;
+4 −2
Original line number Diff line number Diff line
@@ -26,11 +26,13 @@
#ifndef __CONTEXT_MENU_H
#define __CONTEXT_MENU_H

#include <wx/menu.h>
#include <tool/tool_action.h>
#include <map>
#include <list>
#include <boost/function.hpp>

#include <wx/menu.h>
#include <tool/tool_action.h>

class TOOL_INTERACTIVE;

/**
Loading