Commit ee3f47ae authored by Maciej Suminski's avatar Maciej Suminski

Added autopanning to the selection tool.

parent 8e88a621
...@@ -319,8 +319,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -319,8 +319,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
for ( int i = 0; i < 10; i++ ) for ( int i = 0; i < 10; i++ )
m_Macros[i].m_Record.clear(); m_Macros[i].m_Record.clear();
setupTools();
SetBoard( new BOARD() ); SetBoard( new BOARD() );
...@@ -482,6 +480,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -482,6 +480,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
} }
} }
setupTools();
} }
PCB_EDIT_FRAME::~PCB_EDIT_FRAME() PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
#include <collectors.h> #include <collectors.h>
#include <view/view_controls.h>
#include <tool/context_menu.h> #include <tool/context_menu.h>
...@@ -59,13 +60,15 @@ void SELECTION_TOOL::Reset() ...@@ -59,13 +60,15 @@ void SELECTION_TOOL::Reset()
{ {
m_selectedItems.clear(); m_selectedItems.clear();
// the tool launches upon reception of activate ("pcbnew.InteractiveSelection") // The tool launches upon reception of activate ("pcbnew.InteractiveSelection")
Go( &SELECTION_TOOL::Main, TOOL_EVENT( TC_Command, TA_ActivateTool, GetName() ) ); //"pcbnew.InteractiveSelection")); Go( &SELECTION_TOOL::Main, TOOL_EVENT( TC_Command, TA_ActivateTool, GetName() ) );
} }
int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{ {
bool dragging = false;
// Main loop: keep receiving events // Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() )
{ {
...@@ -76,18 +79,42 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -76,18 +79,42 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
if( !m_selectedItems.empty() ) if( !m_selectedItems.empty() )
clearSelection(); clearSelection();
else else
return 0; break; // Finish
} }
// single click? Select single object // single click? Select single object
if( evt->IsClick( MB_Left ) ) if( evt->IsClick( MB_Left ) )
selectSingle( evt->Position() ); selectSingle( evt->Position() );
// drag with LMB? Select multiple objects (or at least draw a selection box) // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
if( evt->IsDrag( MB_Left ) ) if( evt->IsDrag( MB_Left ) )
selectMultiple(); {
dragging = true;
getViewControls()->SetAutoPan( true );
if( m_selectedItems.empty() || m_additive )
{
// If nothings has been selected or user wants to select more
// draw the selection box
selectMultiple();
}
else
{
// Now user wants to drag the selected items
m_toolMgr->InvokeTool( "pcbnew.InteractiveMove" );
}
}
else if( dragging )
{
dragging = false;
getViewControls()->SetAutoPan( false );
}
} }
// Restore the default settings
getViewControls()->SetAutoPan( false );
return 0; return 0;
} }
...@@ -213,7 +240,7 @@ void SELECTION_TOOL::selectMultiple() ...@@ -213,7 +240,7 @@ void SELECTION_TOOL::selectMultiple()
m_selArea->SetOrigin( evt->DragOrigin() ); m_selArea->SetOrigin( evt->DragOrigin() );
m_selArea->SetEnd( evt->Position() ); m_selArea->SetEnd( evt->Position() );
m_selArea->ViewSetVisible( true ); m_selArea->ViewSetVisible( true );
m_selArea->ViewUpdate( VIEW_ITEM::APPEARANCE | VIEW_ITEM::GEOMETRY ); m_selArea->ViewUpdate( VIEW_ITEM::GEOMETRY );
} }
if( evt->IsMouseUp( MB_Left ) ) if( evt->IsMouseUp( MB_Left ) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment