Browse Source

Moved the list of TOOL_ACTIONs to ACTION_MANAGER.

pull/4/head
Maciej Suminski 11 years ago
parent
commit
99e5228948
  1. 4
      common/tool/action_manager.cpp
  2. 18
      common/tool/tool_action.cpp
  3. 5
      common/tool/tool_manager.cpp
  4. 13
      include/tool/action_manager.h
  5. 6
      include/tool/context_menu.h
  6. 15
      include/tool/tool_action.h
  7. 13
      include/tool/tool_manager.h
  8. 1
      pcbnew/cross-probing.cpp
  9. 1
      pcbnew/router/length_tuner_tool.cpp
  10. 1
      pcbnew/router/router_tool.cpp
  11. 1
      pcbnew/tools/common_actions.cpp
  12. 2
      pcbnew/tools/common_actions.h
  13. 1
      pcbnew/tools/module_tools.cpp
  14. 1
      pcbnew/tools/pcb_editor_control.cpp
  15. 1
      pcbnew/tools/placement_tool.cpp

4
common/tool/action_manager.cpp

@ -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
common/tool/tool_action.cpp

@ -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
{

5
common/tool/tool_manager.cpp

@ -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
include/tool/action_manager.h

@ -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;

6
include/tool/context_menu.h

@ -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;
/**

15
include/tool/tool_action.h

@ -29,7 +29,7 @@
#include <string>
#include <cassert>
#include <tool/tool_manager.h>
#include <tool/tool_event.h>
struct BITMAP_OPAQUE;
@ -49,18 +49,9 @@ public:
TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope = AS_CONTEXT,
int aDefaultHotKey = 0, const wxString aMenuItem = wxEmptyString,
const wxString& aMenuDesc = wxEmptyString, const BITMAP_OPAQUE* aIcon = NULL,
TOOL_ACTION_FLAGS aFlags = AF_NONE, void* aParam = NULL ) :
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 )
{
TOOL_MANAGER::GetActionList().push_back( this );
}
TOOL_ACTION_FLAGS aFlags = AF_NONE, void* aParam = NULL );
~TOOL_ACTION()
{
TOOL_MANAGER::GetActionList().remove( this );
}
~TOOL_ACTION();
bool operator==( const TOOL_ACTION& aRhs ) const
{

13
include/tool/tool_manager.h

@ -308,19 +308,6 @@ public:
*/
std::string GetClipboard() 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:
struct TOOL_STATE;
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;

1
pcbnew/cross-probing.cpp

@ -26,6 +26,7 @@
#include <pcbnew.h>
#include <tools/common_actions.h>
#include <tool/tool_manager.h>
#include <pcb_draw_panel_gal.h>
/* Execute a remote command send by Eeschema via a socket,

1
pcbnew/router/length_tuner_tool.cpp

@ -32,6 +32,7 @@
#include <dialogs/dialog_pns_length_tuning_settings.h>
#include <tool/context_menu.h>
#include <tool/tool_manager.h>
#include <tools/common_actions.h>
#include "pns_segment.h"

1
pcbnew/router/router_tool.cpp

@ -40,6 +40,7 @@
#include <base_units.h>
#include <tool/context_menu.h>
#include <tool/tool_manager.h>
#include <tools/common_actions.h>
#include <ratsnest_data.h>

1
pcbnew/tools/common_actions.cpp

@ -26,6 +26,7 @@
#include <tool/action_manager.h>
#include <pcbnew_id.h>
#include <layers_id_colors_and_visibility.h>
#include <bitmaps.h>
#include <wx/defs.h>
// These members are static in class COMMON_ACTIONS: Build them here:

2
pcbnew/tools/common_actions.h

@ -294,6 +294,6 @@ public:
static boost::optional<TOOL_EVENT> TranslateLegacyId( int aId );
};
void registerAllTools ( TOOL_MANAGER *aToolManager );
void registerAllTools( TOOL_MANAGER* aToolManager );
#endif

1
pcbnew/tools/module_tools.cpp

@ -25,6 +25,7 @@
#include "module_tools.h"
#include "selection_tool.h"
#include "common_actions.h"
#include <tool/tool_manager.h>
#include <class_draw_panel_gal.h>
#include <view/view_controls.h>

1
pcbnew/tools/pcb_editor_control.cpp

@ -26,6 +26,7 @@
#include "pcb_editor_control.h"
#include "common_actions.h"
#include <tool/tool_manager.h>
#include "selection_tool.h"

1
pcbnew/tools/placement_tool.cpp

@ -25,6 +25,7 @@
#include "placement_tool.h"
#include "common_actions.h"
#include "selection_tool.h"
#include <tool/tool_manager.h>
#include <wxPcbStruct.h>
#include <class_board.h>

Loading…
Cancel
Save