Loading common/tool/action_manager.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction ) // action name without specifying at least toolName is not valid assert( aAction->GetName().find( '.', 0 ) != std::string::npos ); // TOOL_ACTIONs must have unique names & ids assert( m_actionNameIndex.find( aAction->m_name ) == m_actionNameIndex.end() ); assert( m_actionIdIndex.find( aAction->m_id ) == m_actionIdIndex.end() ); Loading @@ -60,6 +61,8 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction ) if( aAction->HasHotKey() ) m_actionHotKeys[aAction->m_currentHotKey].push_back( aAction ); aAction->setActionMgr( this ); } Loading @@ -69,6 +72,7 @@ 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() ) Loading common/tool/context_menu.cpp +6 −9 Original line number Diff line number Diff line Loading @@ -73,14 +73,8 @@ CONTEXT_MENU::CONTEXT_MENU( const CONTEXT_MENU& aMenu ) : void CONTEXT_MENU::setupEvents() { Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); Connect( wxEVT_COMMAND_MENU_SELECTED, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); // Workaround for the case when mouse cursor never reaches menu (it hangs up tools using menu) wxMenuEvent menuEvent( wxEVT_MENU_HIGHLIGHT, -1, this ); AddPendingEvent( menuEvent ); Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); Connect( wxEVT_COMMAND_MENU_SELECTED, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); } Loading Loading @@ -191,8 +185,11 @@ void CONTEXT_MENU::onMenuEvent( wxEvent& aEvent ) } } assert( m_tool ); // without tool & tool manager we cannot handle events // forward the action/update event to the TOOL_MANAGER TOOL_MANAGER::Instance().ProcessEvent( *evt ); if( evt && m_tool ) m_tool->GetManager()->ProcessEvent( *evt ); } Loading common/tool/tool_manager.cpp +1 −8 Original line number Diff line number Diff line Loading @@ -103,14 +103,6 @@ TOOL_MANAGER::TOOL_MANAGER() : TOOL_MANAGER::~TOOL_MANAGER() { DeleteAll(); delete m_actionMgr; } void TOOL_MANAGER::DeleteAll() { std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end; Loading @@ -122,6 +114,7 @@ void TOOL_MANAGER::DeleteAll() } m_toolState.clear(); delete m_actionMgr; } Loading include/tool/tool_action.h +13 −4 Original line number Diff line number Diff line Loading @@ -52,12 +52,12 @@ public: m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ), m_menuDescription( aMenuDesc ), m_id( -1 ) { TOOL_MANAGER::Instance().RegisterAction( this ); TOOL_MANAGER::GetActionList().push_back( this ); } ~TOOL_ACTION() { TOOL_MANAGER::Instance().UnregisterAction( this ); TOOL_MANAGER::GetActionList().remove( this ); } bool operator==( const TOOL_ACTION& aRhs ) const Loading Loading @@ -195,6 +195,12 @@ 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; Loading @@ -219,6 +225,9 @@ 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; Loading include/tool/tool_manager.h +14 −13 Original line number Diff line number Diff line Loading @@ -48,20 +48,10 @@ class wxWindow; class TOOL_MANAGER { public: static TOOL_MANAGER& Instance() { static TOOL_MANAGER manager; return manager; } TOOL_MANAGER(); ~TOOL_MANAGER(); /** * Deletes all the tools that were registered in the TOOL_MANAGER. */ void DeleteAll(); /** * Generates an unique ID from for a tool with given name. */ Loading Loading @@ -251,9 +241,20 @@ public: m_passEvent = true; } private: TOOL_MANAGER(); /** * 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; Loading Loading
common/tool/action_manager.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction ) // action name without specifying at least toolName is not valid assert( aAction->GetName().find( '.', 0 ) != std::string::npos ); // TOOL_ACTIONs must have unique names & ids assert( m_actionNameIndex.find( aAction->m_name ) == m_actionNameIndex.end() ); assert( m_actionIdIndex.find( aAction->m_id ) == m_actionIdIndex.end() ); Loading @@ -60,6 +61,8 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction ) if( aAction->HasHotKey() ) m_actionHotKeys[aAction->m_currentHotKey].push_back( aAction ); aAction->setActionMgr( this ); } Loading @@ -69,6 +72,7 @@ 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() ) Loading
common/tool/context_menu.cpp +6 −9 Original line number Diff line number Diff line Loading @@ -73,14 +73,8 @@ CONTEXT_MENU::CONTEXT_MENU( const CONTEXT_MENU& aMenu ) : void CONTEXT_MENU::setupEvents() { Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); Connect( wxEVT_COMMAND_MENU_SELECTED, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); // Workaround for the case when mouse cursor never reaches menu (it hangs up tools using menu) wxMenuEvent menuEvent( wxEVT_MENU_HIGHLIGHT, -1, this ); AddPendingEvent( menuEvent ); Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); Connect( wxEVT_COMMAND_MENU_SELECTED, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); } Loading Loading @@ -191,8 +185,11 @@ void CONTEXT_MENU::onMenuEvent( wxEvent& aEvent ) } } assert( m_tool ); // without tool & tool manager we cannot handle events // forward the action/update event to the TOOL_MANAGER TOOL_MANAGER::Instance().ProcessEvent( *evt ); if( evt && m_tool ) m_tool->GetManager()->ProcessEvent( *evt ); } Loading
common/tool/tool_manager.cpp +1 −8 Original line number Diff line number Diff line Loading @@ -103,14 +103,6 @@ TOOL_MANAGER::TOOL_MANAGER() : TOOL_MANAGER::~TOOL_MANAGER() { DeleteAll(); delete m_actionMgr; } void TOOL_MANAGER::DeleteAll() { std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end; Loading @@ -122,6 +114,7 @@ void TOOL_MANAGER::DeleteAll() } m_toolState.clear(); delete m_actionMgr; } Loading
include/tool/tool_action.h +13 −4 Original line number Diff line number Diff line Loading @@ -52,12 +52,12 @@ public: m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ), m_menuDescription( aMenuDesc ), m_id( -1 ) { TOOL_MANAGER::Instance().RegisterAction( this ); TOOL_MANAGER::GetActionList().push_back( this ); } ~TOOL_ACTION() { TOOL_MANAGER::Instance().UnregisterAction( this ); TOOL_MANAGER::GetActionList().remove( this ); } bool operator==( const TOOL_ACTION& aRhs ) const Loading Loading @@ -195,6 +195,12 @@ 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; Loading @@ -219,6 +225,9 @@ 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; Loading
include/tool/tool_manager.h +14 −13 Original line number Diff line number Diff line Loading @@ -48,20 +48,10 @@ class wxWindow; class TOOL_MANAGER { public: static TOOL_MANAGER& Instance() { static TOOL_MANAGER manager; return manager; } TOOL_MANAGER(); ~TOOL_MANAGER(); /** * Deletes all the tools that were registered in the TOOL_MANAGER. */ void DeleteAll(); /** * Generates an unique ID from for a tool with given name. */ Loading Loading @@ -251,9 +241,20 @@ public: m_passEvent = true; } private: TOOL_MANAGER(); /** * 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; Loading