Fixed cursor freeze in pcbnew (GAL).

This commit is contained in:
Maciej Suminski 2015-07-24 10:58:47 +02:00
parent 656790a672
commit d010703eaf
11 changed files with 54 additions and 24 deletions

View File

@ -642,6 +642,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
} }
aState->theTool->SetTransitions(); aState->theTool->SetTransitions();
m_viewControls->Reset();
} }

View File

@ -35,3 +35,13 @@ void VIEW_CONTROLS::ShowCursor( bool aEnabled )
m_view->GetGAL()->SetCursorEnabled( aEnabled ); m_view->GetGAL()->SetCursorEnabled( aEnabled );
} }
void VIEW_CONTROLS::Reset()
{
SetSnapping( false );
SetAutoPan( false );
ForceCursorPosition( false );
ShowCursor( false );
CaptureCursor( false );
SetGrabMouse( false );
}

View File

@ -316,12 +316,12 @@ void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent )
void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled ) void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
{ {
VIEW_CONTROLS::SetGrabMouse( aEnabled ); if( aEnabled && !m_grabMouse )
if( aEnabled )
m_parentPanel->CaptureMouse(); m_parentPanel->CaptureMouse();
else else if( !aEnabled && m_grabMouse )
m_parentPanel->ReleaseMouse(); m_parentPanel->ReleaseMouse();
VIEW_CONTROLS::SetGrabMouse( aEnabled );
} }

View File

@ -200,6 +200,12 @@ public:
*/ */
virtual void CenterOnCursor() const = 0; virtual void CenterOnCursor() const = 0;
/**
* Function Reset()
* Restores the default VIEW_CONTROLS settings.
*/
virtual void Reset();
protected: protected:
/// Pointer to controlled VIEW. /// Pointer to controlled VIEW.
VIEW* m_view; VIEW* m_view;

View File

@ -665,9 +665,6 @@ int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
handleCommonEvents( *evt ); handleCommonEvents( *evt );
} }
// Restore the default settings
m_ctls->SetAutoPan( false );
m_ctls->ShowCursor( false );
frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
// Store routing settings till the next invocation // Store routing settings till the next invocation
@ -799,7 +796,6 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
} }
ctls->SetAutoPan( false ); ctls->SetAutoPan( false );
ctls->ForceCursorPosition( false );
ctls->ShowCursor( false ); ctls->ShowCursor( false );
return 0; return 0;

View File

@ -158,8 +158,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
m_updateFlag = KIGFX::VIEW_ITEM::GEOMETRY; m_updateFlag = KIGFX::VIEW_ITEM::GEOMETRY;
controls->ShowCursor( true ); controls->ShowCursor( true );
//controls->SetSnapping( true );
controls->ForceCursorPosition( false );
// cumulative translation // cumulative translation
wxPoint totalMovement( 0, 0 ); wxPoint totalMovement( 0, 0 );
@ -340,9 +338,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
ratsnest->Recalculate(); ratsnest->Recalculate();
controls->ShowCursor( false ); controls->ShowCursor( false );
//controls->SetSnapping( false );
controls->SetAutoPan( false ); controls->SetAutoPan( false );
controls->ForceCursorPosition( false );
return 0; return 0;
} }

View File

@ -638,12 +638,15 @@ static bool setDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent ) int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
{ {
Activate();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>(); PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
assert( picker ); assert( picker );
m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust zero" ) ); m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust zero" ) );
picker->SetClickHandler( boost::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin, _1 ) ); picker->SetClickHandler( boost::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin, _1 ) );
picker->Activate(); picker->Activate();
Wait();
return 0; return 0;
} }
@ -691,12 +694,16 @@ int PCB_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent ) int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
{ {
Activate();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>(); PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
assert( picker ); assert( picker );
m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_PENCIL, _( "Highlight net" ) ); m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_PENCIL, _( "Highlight net" ) );
picker->SetClickHandler( boost::bind( highlightNet, m_toolMgr, _1 ) ); picker->SetClickHandler( boost::bind( highlightNet, m_toolMgr, _1 ) );
picker->SetSnapping( false );
picker->Activate(); picker->Activate();
Wait();
return 0; return 0;
} }

View File

@ -639,6 +639,8 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
} }
else else
{ {
Activate();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>(); PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
assert( picker ); assert( picker );
@ -646,6 +648,7 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) ); m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
picker->SetClickHandler( boost::bind( setOrigin, getView(), m_frame, m_gridOrigin, _1 ) ); picker->SetClickHandler( boost::bind( setOrigin, getView(), m_frame, m_gridOrigin, _1 ) );
picker->Activate(); picker->Activate();
Wait();
} }
return 0; return 0;
@ -718,8 +721,8 @@ static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
if( IsOK( aToolMgr->GetEditFrame(), _( "Are you sure you want to delete item?" ) ) ) if( IsOK( aToolMgr->GetEditFrame(), _( "Are you sure you want to delete item?" ) ) )
aToolMgr->RunAction( COMMON_ACTIONS::remove, true ); aToolMgr->RunAction( COMMON_ACTIONS::remove, true );
else
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
return true; return true;
} }
@ -727,6 +730,8 @@ static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{ {
Activate();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>(); PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
assert( picker ); assert( picker );
@ -735,6 +740,7 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
picker->SetSnapping( false ); picker->SetSnapping( false );
picker->SetClickHandler( boost::bind( deleteItem, m_toolMgr, _1 ) ); picker->SetClickHandler( boost::bind( deleteItem, m_toolMgr, _1 ) );
picker->Activate(); picker->Activate();
Wait();
return 0; return 0;
} }

View File

@ -42,11 +42,9 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
assert( !m_picking ); assert( !m_picking );
m_picking = true; m_picking = true;
m_picked = boost::optional<VECTOR2D>(); m_picked = boost::none;
controls->ShowCursor( m_cursorVisible ); setControls();
controls->SetSnapping( m_cursorSnapping );
controls->SetAutoPan( m_autoPanning );
while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() )
{ {
@ -60,6 +58,8 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
if( !getNext ) if( !getNext )
break; break;
else
setControls();
} }
else if( evt->IsCancel() || evt->IsActivate() ) else if( evt->IsCancel() || evt->IsActivate() )
@ -67,10 +67,6 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
} }
reset(); reset();
controls->SetAutoPan( false );
controls->SetSnapping( false );
controls->ShowCursor( false );
getEditFrame<PCB_BASE_FRAME>()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); getEditFrame<PCB_BASE_FRAME>()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0; return 0;
@ -90,5 +86,15 @@ void PICKER_TOOL::reset()
m_autoPanning = true; m_autoPanning = true;
m_picking = false; m_picking = false;
m_clickHandler = boost::optional<CLICK_HANDLER>(); m_clickHandler = boost::none;
}
void PICKER_TOOL::setControls()
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
controls->ShowCursor( m_cursorVisible );
controls->SetSnapping( m_cursorSnapping );
controls->SetAutoPan( m_autoPanning );
} }

View File

@ -112,6 +112,9 @@ private:
///> Reinitializes tool to its initial state. ///> Reinitializes tool to its initial state.
void reset(); void reset();
///> Applies the requested VIEW_CONTROLS settings.
void setControls();
}; };
#endif /* PICKER_TOOL_H */ #endif /* PICKER_TOOL_H */

View File

@ -352,7 +352,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
controls->ShowCursor( false ); controls->ShowCursor( false );
controls->SetAutoPan( false ); controls->SetAutoPan( false );
controls->SetSnapping( false ); controls->SetSnapping( false );
controls->ForceCursorPosition( false );
} }
return 0; return 0;