Reorder for better readability and consistency.

This commit is contained in:
Jeff Young 2021-03-29 11:04:06 +01:00
parent 1b163c5dd3
commit 455e7dc3a8
1 changed files with 46 additions and 46 deletions

View File

@ -345,12 +345,6 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_frame->PushTool( tool );
Activate();
// Prime the pump
if( image )
m_toolMgr->RunAction( ACTIONS::refreshPreview );
else if( !aEvent.IsReactivate() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
auto setCursor =
[&]()
{
@ -360,6 +354,21 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
};
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_view->ClearPreview();
delete image;
image = nullptr;
};
// Prime the pump
if( image )
m_toolMgr->RunAction( ACTIONS::refreshPreview );
else if( !aEvent.IsReactivate() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Set initial cursor
setCursor();
@ -369,15 +378,6 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
setCursor();
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_view->ClearPreview();
delete image;
image = nullptr;
};
if( evt->IsCancelInteractive() )
{
if( image )
@ -490,7 +490,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_view->AddToPreview( image->Clone() );
m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
}
else if( item && evt->IsAction( &ACTIONS::doDelete ) )
else if( image && evt->IsAction( &ACTIONS::doDelete ) )
{
cleanup();
}
@ -919,14 +919,6 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_frame->PushTool( tool );
Activate();
// Prime the pump
// If the tool isn't being re-activated
if( aEvent.HasPosition() || ( !aEvent.IsReactivate()
&& ( isText || isGlobalLabel || isHierLabel || isNetLabel ) ) )
{
m_toolMgr->RunAction( ACTIONS::cursorClick );
}
auto setCursor =
[&]()
{
@ -944,6 +936,23 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
};
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_view->ClearPreview();
delete item;
item = nullptr;
};
// Prime the pump
// If the tool isn't being re-activated
if( aEvent.HasPosition() || ( !aEvent.IsReactivate()
&& ( isText || isGlobalLabel || isHierLabel || isNetLabel ) ) )
{
m_toolMgr->RunAction( ACTIONS::cursorClick );
}
// Set initial cursor
setCursor();
@ -958,15 +967,6 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
cursorPos = grid.BestSnapAnchor( cursorPos, snapLayer, item );
controls->ForceCursorPosition( true, cursorPos );
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_view->ClearPreview();
delete item;
item = nullptr;
};
if( evt->IsCancelInteractive() )
{
if( item )
@ -1160,16 +1160,25 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
m_frame->PushTool( tool );
Activate();
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
auto setCursor =
[&]()
{
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
};
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_view->ClearPreview();
delete sheet;
sheet = nullptr;
};
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Set initial cursor
setCursor();
@ -1180,15 +1189,6 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_view->ClearPreview();
delete sheet;
sheet = nullptr;
};
if( evt->IsCancelInteractive() )
{
if( sheet )