Use the setCursor lambda pattern and fix up the initial cursor states
This commit is contained in:
parent
93376fa80e
commit
f5e0754f65
|
@ -90,17 +90,22 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
if( item )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
else
|
||||
m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
if( isText )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
}
|
||||
setCursor();
|
||||
|
||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
|
@ -189,6 +194,9 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( item->Clone() );
|
||||
m_selectionTool->AddItemToSel( item );
|
||||
|
||||
// update the cursor so it looks correct before another event
|
||||
setCursor();
|
||||
}
|
||||
|
||||
getViewControls()->SetCursorPosition( cursorPos, false );
|
||||
|
@ -271,11 +279,19 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
if( !pointEditor->HasPoint() )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
|
@ -411,10 +427,19 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
|||
m_frame->PushTool( tool );
|
||||
Activate();
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
setCursor();
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
|
|
@ -113,12 +113,19 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
|||
else if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( EE_ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( component ? KICURSOR::MOVING : KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( component ? KICURSOR::MOVING : KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
auto cleanup = [&] () {
|
||||
|
@ -187,6 +194,9 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( component->Clone() );
|
||||
m_selectionTool->AddItemToSel( component );
|
||||
|
||||
// Update cursor now that we have a component
|
||||
setCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -304,13 +314,22 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
else if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
if( image )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
else
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( image ? KICURSOR::MOVING : KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( image ? KICURSOR::MOVING : KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
auto cleanup = [&] () {
|
||||
|
@ -390,6 +409,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
m_selectionTool->AddItemToSel( image );
|
||||
|
||||
getViewControls()->SetCursorPosition( cursorPos, false );
|
||||
setCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -485,13 +505,19 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
// Set initial cursor
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
setCursor();
|
||||
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
|
@ -747,13 +773,23 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
// Set initial cursor
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
if( item )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
else
|
||||
m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
auto cleanup = [&] () {
|
||||
|
@ -863,6 +899,9 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( item->Clone() );
|
||||
m_selectionTool->AddItemToSel( item );
|
||||
|
||||
// update the cursor so it looks correct before another event
|
||||
setCursor();
|
||||
}
|
||||
|
||||
getViewControls()->SetCursorPosition( cursorPos, false );
|
||||
|
@ -945,13 +984,19 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
if( !pointEditor->HasPoint() )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
|
|
|
@ -481,13 +481,19 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
|
|||
if( !m_wires.empty() )
|
||||
segment = m_wires.back();
|
||||
|
||||
// Set initial cursor
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::WIRE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::WIRE );
|
||||
setCursor();
|
||||
|
||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||
wxPoint cursorPos = wxPoint( grid.BestSnapAnchor(
|
||||
|
|
|
@ -580,9 +580,18 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
|
||||
controls.ShowCursor( true );
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
setCursor();
|
||||
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||
|
||||
auto clearRuler =
|
||||
|
|
|
@ -77,6 +77,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||
WS_DATA_ITEM::WS_ITEM_TYPE type = aEvent.Parameter<WS_DATA_ITEM::WS_ITEM_TYPE>();
|
||||
VECTOR2I cursorPos;
|
||||
WS_DRAW_ITEM_BASE* item = nullptr;
|
||||
bool isText = aEvent.IsAction( &PL_ACTIONS::placeText );
|
||||
|
||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||
getViewControls()->ShowCursor( true );
|
||||
|
@ -89,11 +90,22 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
if( item )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
else
|
||||
m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor(
|
||||
item ? KICURSOR::ARROW : KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
auto cleanup = [&] () {
|
||||
|
@ -147,6 +159,9 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||
item = dataItem->GetDrawItems()[0];
|
||||
item->SetFlags( IS_NEW | IS_MOVED );
|
||||
m_selectionTool->AddItemToSel( item );
|
||||
|
||||
// update the cursor so it looks correct before another event
|
||||
setCursor();
|
||||
}
|
||||
}
|
||||
// ... and second click places:
|
||||
|
@ -209,11 +224,19 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
if( !pointEditor->HasPoint() )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
|
|
|
@ -135,9 +135,18 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
|||
|
||||
view.Add( &previewRect );
|
||||
|
||||
while( auto evt = Wait() )
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame.GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( auto evt = Wait() )
|
||||
{
|
||||
setCursor();
|
||||
VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||
|
||||
auto cleanup = [&] () {
|
||||
|
|
|
@ -181,9 +181,18 @@ void LENGTH_TUNER_TOOL::performTuning()
|
|||
m_router->Move( end, NULL );
|
||||
updateStatusPopup( statusPopup );
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
setCursor();
|
||||
|
||||
if( evt->IsCancelInteractive() || evt->IsActivate() )
|
||||
{
|
||||
|
@ -271,10 +280,19 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
controls()->ShowCursor( true );
|
||||
frame()->UndoRedoBlock( true );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
setCursor();
|
||||
|
||||
if( evt->IsCancelInteractive() || evt->IsActivate() )
|
||||
{
|
||||
|
|
|
@ -914,9 +914,18 @@ void ROUTER_TOOL::performRouting()
|
|||
if( !prepareInteractive() )
|
||||
return;
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
setCursor();
|
||||
|
||||
// Don't crash if we missed an operation that cancelled routing.
|
||||
if( !m_router->RoutingInProgress() )
|
||||
|
@ -1092,10 +1101,19 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->PrimeTool( m_startSnapPoint );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
@ -1427,9 +1445,18 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
view()->ClearPreview();
|
||||
view()->InitPreview();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
setCursor();
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
|
|
@ -420,14 +420,22 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
if( text )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
else
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( text ? KICURSOR::ARROW : KICURSOR::TEXT );
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor(
|
||||
text ? KICURSOR::ARROW : KICURSOR::TEXT );
|
||||
setCursor();
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
|
||||
auto cleanup = [&]()
|
||||
|
@ -548,6 +556,9 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
m_controls->WarpCursor( text->GetPosition(), true );
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text );
|
||||
m_view->Update( &selection() );
|
||||
|
||||
// update the cursor so it looks correct before another event
|
||||
setCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,13 +656,19 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->PrimeTool( aEvent.Position() );
|
||||
|
||||
// Set initial cursor
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
setCursor();
|
||||
|
||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||
|
@ -1044,13 +1061,19 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
|||
m_frame->PushTool( tool );
|
||||
Activate();
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
setCursor();
|
||||
cursorPos = m_controls->GetCursorPosition();
|
||||
|
||||
if( evt->IsCancelInteractive() || evt->IsActivate() )
|
||||
|
@ -1129,12 +1152,18 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
|||
m_controls->SetAutoPan( true );
|
||||
m_controls->CaptureCursor( false );
|
||||
|
||||
// Set initial cursor
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
setCursor();
|
||||
|
||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||
|
@ -1232,13 +1261,19 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, PCB_SHAPE*
|
|||
|
||||
frame()->SetMsgPanel( graphic );
|
||||
|
||||
// Set initial cursor
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
m_frame->SetMsgPanel( graphic );
|
||||
|
||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||
|
@ -1498,12 +1533,18 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool
|
|||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
// Set initial cursor
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
|
||||
graphic->SetLayer( layer );
|
||||
|
@ -1751,13 +1792,20 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->PrimeTool( aEvent.Position() );
|
||||
|
||||
// Set initial cursor
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
|
||||
LSET layers( m_frame->GetActiveLayer() );
|
||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||
|
|
|
@ -294,9 +294,18 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
statusPopup.Popup();
|
||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
setCursor();
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
|
|
@ -761,12 +761,19 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
|||
else if( aEvent.HasPosition() )
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
if( reselect && module )
|
||||
|
@ -977,12 +984,19 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
|||
m_frame->PushTool( tool );
|
||||
Activate();
|
||||
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
setCursor();
|
||||
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
|
|
|
@ -82,19 +82,22 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
|
|||
if( aOptions & IPO_SINGLE_CLICK )
|
||||
makeNewItem( controls()->GetCursorPosition() );
|
||||
|
||||
// Set initial cursor
|
||||
if( !newItem )
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
else
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
if( !newItem )
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
else
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
setCursor();
|
||||
|
||||
VECTOR2I cursorPos = controls()->GetCursorPosition();
|
||||
aPlacer->m_modifiers = evt->Modifier();
|
||||
|
@ -183,6 +186,8 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
|
|||
|
||||
if( aOptions & IPO_SINGLE_CLICK )
|
||||
makeNewItem( controls()->GetCursorPosition() );
|
||||
|
||||
setCursor();
|
||||
}
|
||||
}
|
||||
else if( evt->IsClick( BUT_RIGHT ) )
|
||||
|
|
|
@ -220,9 +220,18 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
controls.SetAutoPan( false );
|
||||
controls.CaptureCursor( false );
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
setCursor();
|
||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
|
||||
|
|
Loading…
Reference in New Issue