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 );
|
||||
|
||||
m_frame->GetCanvas()->SetCurrentCursor( component ? KICURSOR::MOVING : KICURSOR::PENCIL );
|
||||
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 );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
};
|
||||
|
||||
// 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 = (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 );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
if( item )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
else
|
||||
m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL );
|
||||
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 );
|
||||
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
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();
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::WIRE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::WIRE );
|
||||
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 );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
setCursor();
|
||||
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||
|
||||
auto clearRuler =
|
||||
|
|
|
@ -76,7 +76,8 @@ 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;
|
||||
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:
|
||||
|
@ -208,12 +223,20 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
// Prime the pump
|
||||
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 );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame.GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( auto evt = Wait() )
|
||||
{
|
||||
frame.GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
setCursor();
|
||||
VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||
|
||||
auto cleanup = [&] () {
|
||||
|
|
|
@ -181,9 +181,18 @@ void LENGTH_TUNER_TOOL::performTuning()
|
|||
m_router->Move( end, NULL );
|
||||
updateStatusPopup( statusPopup );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
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;
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
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();
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
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() );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
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() );
|
||||
|
@ -1043,14 +1060,20 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
|||
std::string tool = aEvent.GetCommandStr().get();
|
||||
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 );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
setCursor();
|
||||
|
||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||
|
@ -1231,14 +1260,20 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, PCB_SHAPE*
|
|||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
frame()->SetMsgPanel( graphic );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
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
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
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 );
|
||||
|
@ -1750,14 +1791,21 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
// Prime the pump
|
||||
if( aEvent.HasPosition() )
|
||||
m_toolMgr->PrimeTool( aEvent.Position() );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
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 ) );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
||||
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 );
|
||||
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
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() );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
if( !newItem )
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
else
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
if( !newItem )
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
else
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
setCursor();
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
if( !newItem )
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
else
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
||||
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 ) )
|
||||
|
|
|
@ -219,10 +219,19 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
controls.ShowCursor( true );
|
||||
controls.SetAutoPan( false );
|
||||
controls.CaptureCursor( false );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
setCursor();
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
||||
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