From 9b67ee04e6a62d90221503e8855bbdb7a77f225b Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 1 Apr 2014 14:35:09 +0200 Subject: [PATCH] If tool was previously active and it is called again, it is brought to the top of the active tool stack. It fixes issue of dragging of items that have EDIT_POINTs, when dragging was activated by hovering over an item and using hot key. --- common/tool/tool_manager.cpp | 8 +++++++- pcbnew/tools/edit_tool.cpp | 26 ++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 0d25c88434..207ee71152 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -253,9 +253,15 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool ) return false; } - // If the tool is already active, do not invoke it again + // If the tool is already active, bring it to the top of the active tools stack if( isActive( aTool ) ) + { + m_activeTools.erase( std::find( m_activeTools.begin(), m_activeTools.end(), + aTool->GetId() ) ); + m_activeTools.push_front( aTool->GetId() ); + return false; + } aTool->Reset( TOOL_INTERACTIVE::RUN ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 3f912e42e5..92c0c218a2 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -79,7 +79,13 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent ) // Be sure that there is at least one item that we can modify if( !makeSelection( selection ) ) + { + setTransitions(); + return 0; + } + + Activate(); m_dragging = false; // Are selected items being dragged? bool restore = false; // Should items' state be restored when finishing the tool? @@ -205,7 +211,11 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent ) bool unselect = selection.Empty(); if( !makeSelection( selection ) ) + { + setTransitions(); + return 0; + } // Properties are displayed when there is only one item selected if( selection.Size() == 1 ) @@ -471,20 +481,8 @@ wxPoint EDIT_TOOL::getModificationPoint( const SELECTION_TOOL::SELECTION& aSelec bool EDIT_TOOL::makeSelection( const SELECTION_TOOL::SELECTION& aSelection ) { - if( aSelection.Empty() ) - { - // Try to find an item that could be modified + if( aSelection.Empty() ) // Try to find an item that could be modified m_toolMgr->RunAction( COMMON_ACTIONS::selectionSingle ); - if( aSelection.Empty() ) - { - // This is necessary, so later the tool may be activated upon - // reception of the activation event - setTransitions(); - - return false; // Still no items to work with - } - } - - return true; + return !aSelection.Empty(); }