Fixed cursor freeze in pcbnew (GAL).
This commit is contained in:
parent
656790a672
commit
d010703eaf
|
@ -642,6 +642,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
|
|||
}
|
||||
|
||||
aState->theTool->SetTransitions();
|
||||
m_viewControls->Reset();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,3 +35,13 @@ void VIEW_CONTROLS::ShowCursor( bool aEnabled )
|
|||
m_view->GetGAL()->SetCursorEnabled( aEnabled );
|
||||
}
|
||||
|
||||
|
||||
void VIEW_CONTROLS::Reset()
|
||||
{
|
||||
SetSnapping( false );
|
||||
SetAutoPan( false );
|
||||
ForceCursorPosition( false );
|
||||
ShowCursor( false );
|
||||
CaptureCursor( false );
|
||||
SetGrabMouse( false );
|
||||
}
|
||||
|
|
|
@ -316,12 +316,12 @@ void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent )
|
|||
|
||||
void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
|
||||
{
|
||||
VIEW_CONTROLS::SetGrabMouse( aEnabled );
|
||||
|
||||
if( aEnabled )
|
||||
if( aEnabled && !m_grabMouse )
|
||||
m_parentPanel->CaptureMouse();
|
||||
else
|
||||
else if( !aEnabled && m_grabMouse )
|
||||
m_parentPanel->ReleaseMouse();
|
||||
|
||||
VIEW_CONTROLS::SetGrabMouse( aEnabled );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -200,6 +200,12 @@ public:
|
|||
*/
|
||||
virtual void CenterOnCursor() const = 0;
|
||||
|
||||
/**
|
||||
* Function Reset()
|
||||
* Restores the default VIEW_CONTROLS settings.
|
||||
*/
|
||||
virtual void Reset();
|
||||
|
||||
protected:
|
||||
/// Pointer to controlled VIEW.
|
||||
VIEW* m_view;
|
||||
|
|
|
@ -665,9 +665,6 @@ int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
|
|||
handleCommonEvents( *evt );
|
||||
}
|
||||
|
||||
// Restore the default settings
|
||||
m_ctls->SetAutoPan( false );
|
||||
m_ctls->ShowCursor( false );
|
||||
frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
// Store routing settings till the next invocation
|
||||
|
@ -799,7 +796,6 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
ctls->SetAutoPan( false );
|
||||
ctls->ForceCursorPosition( false );
|
||||
ctls->ShowCursor( false );
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -158,8 +158,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
m_updateFlag = KIGFX::VIEW_ITEM::GEOMETRY;
|
||||
|
||||
controls->ShowCursor( true );
|
||||
//controls->SetSnapping( true );
|
||||
controls->ForceCursorPosition( false );
|
||||
|
||||
// cumulative translation
|
||||
wxPoint totalMovement( 0, 0 );
|
||||
|
@ -340,9 +338,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
ratsnest->Recalculate();
|
||||
|
||||
controls->ShowCursor( false );
|
||||
//controls->SetSnapping( false );
|
||||
controls->SetAutoPan( false );
|
||||
controls->ForceCursorPosition( false );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -638,12 +638,15 @@ static bool setDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
|
|||
|
||||
int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
Activate();
|
||||
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
assert( picker );
|
||||
|
||||
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->Activate();
|
||||
Wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -691,12 +694,16 @@ int PCB_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
Activate();
|
||||
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
assert( picker );
|
||||
|
||||
m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_PENCIL, _( "Highlight net" ) );
|
||||
picker->SetClickHandler( boost::bind( highlightNet, m_toolMgr, _1 ) );
|
||||
picker->SetSnapping( false );
|
||||
picker->Activate();
|
||||
Wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -639,6 +639,8 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
Activate();
|
||||
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
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" ) );
|
||||
picker->SetClickHandler( boost::bind( setOrigin, getView(), m_frame, m_gridOrigin, _1 ) );
|
||||
picker->Activate();
|
||||
Wait();
|
||||
}
|
||||
|
||||
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?" ) ) )
|
||||
aToolMgr->RunAction( COMMON_ACTIONS::remove, true );
|
||||
|
||||
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
else
|
||||
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -727,6 +730,8 @@ static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
|||
|
||||
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
Activate();
|
||||
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
assert( picker );
|
||||
|
||||
|
@ -735,6 +740,7 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|||
picker->SetSnapping( false );
|
||||
picker->SetClickHandler( boost::bind( deleteItem, m_toolMgr, _1 ) );
|
||||
picker->Activate();
|
||||
Wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -42,11 +42,9 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
assert( !m_picking );
|
||||
m_picking = true;
|
||||
m_picked = boost::optional<VECTOR2D>();
|
||||
m_picked = boost::none;
|
||||
|
||||
controls->ShowCursor( m_cursorVisible );
|
||||
controls->SetSnapping( m_cursorSnapping );
|
||||
controls->SetAutoPan( m_autoPanning );
|
||||
setControls();
|
||||
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
|
@ -60,6 +58,8 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( !getNext )
|
||||
break;
|
||||
else
|
||||
setControls();
|
||||
}
|
||||
|
||||
else if( evt->IsCancel() || evt->IsActivate() )
|
||||
|
@ -67,10 +67,6 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
reset();
|
||||
|
||||
controls->SetAutoPan( false );
|
||||
controls->SetSnapping( false );
|
||||
controls->ShowCursor( false );
|
||||
getEditFrame<PCB_BASE_FRAME>()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
|
@ -90,5 +86,15 @@ void PICKER_TOOL::reset()
|
|||
m_autoPanning = true;
|
||||
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -112,6 +112,9 @@ private:
|
|||
|
||||
///> Reinitializes tool to its initial state.
|
||||
void reset();
|
||||
|
||||
///> Applies the requested VIEW_CONTROLS settings.
|
||||
void setControls();
|
||||
};
|
||||
|
||||
#endif /* PICKER_TOOL_H */
|
||||
|
|
|
@ -352,7 +352,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
|||
controls->ShowCursor( false );
|
||||
controls->SetAutoPan( false );
|
||||
controls->SetSnapping( false );
|
||||
controls->ForceCursorPosition( false );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue