One more try getting <ESC>/PopTool behaviour right.

This commit is contained in:
Jeff Young 2019-06-18 22:34:31 +01:00
parent aaa7661b94
commit 581b5257e1
4 changed files with 100 additions and 66 deletions

View File

@ -98,18 +98,22 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
delete item;
item = nullptr;
if( evt->IsActivate() || immediateMode )
if( immediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
LIB_PART* part = m_frame->GetCurPart();
@ -189,12 +193,9 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_frame->OnModify();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// Warp after context menu only if dragging...
@ -216,6 +217,9 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr );
}
if( immediateMode )
m_frame->PopTool();
return 0;
}
@ -257,18 +261,22 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
delete item;
item = nullptr;
if( evt->IsActivate() || immediateMode )
if( immediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) && !item )
{
if( !part )
@ -301,12 +309,10 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_selectionTool->AddItemToSel( item );
}
else if( item && ( evt->IsClick( BUT_LEFT )
|| evt->IsDblClick( BUT_LEFT )
else if( item && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT )
|| evt->IsAction( &EE_ACTIONS::finishDrawing ) ) )
{
if( evt->IsDblClick( BUT_LEFT )
|| evt->IsAction( &EE_ACTIONS::finishDrawing )
if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing )
|| !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) )
{
item->EndEdit();
@ -322,14 +328,13 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( immediateMode )
{
m_frame->PopTool();
m_toolMgr->RunAction( ACTIONS::activatePointEditor );
break;
}
}
}
else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
item->CalcEdit( wxPoint( cursorPos.x, -cursorPos.y) );
m_view->ClearPreview();
@ -355,6 +360,9 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr );
}
if( immediateMode )
m_frame->PopTool();
return 0;
}

View File

@ -127,17 +127,21 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
delete component;
component = nullptr;
if( evt->IsActivate() || immediateMode )
if( immediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( !component )
@ -179,12 +183,9 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
m_view->ClearPreview();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// Warp after context menu only if dragging...
@ -207,8 +208,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
}
}
}
else if( component && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
else if( component && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
component->SetPosition( (wxPoint)cursorPos );
m_view->ClearPreview();
@ -220,6 +220,9 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( component != nullptr );
}
if( immediateMode )
m_frame->PopTool();
return 0;
}
@ -266,17 +269,21 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
delete image;
image = nullptr;
if( evt->IsActivate() || immediateMode )
if( immediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( !image )
@ -324,12 +331,9 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_view->ClearPreview();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// Warp after context menu only if dragging...
@ -338,8 +342,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( image && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
else if( image && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
image->SetPosition( (wxPoint)cursorPos );
m_view->ClearPreview();
@ -352,6 +355,9 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( image != nullptr );
}
if( immediateMode )
m_frame->PopTool();
return 0;
}
@ -488,17 +494,21 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
delete item;
item = nullptr;
if( evt->IsActivate() || immediateMode )
if( immediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
// First click creates...
@ -579,12 +589,9 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_view->ClearPreview();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// Warp after context menu only if dragging...
@ -607,10 +614,9 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
else
item = nullptr;
}
else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint)cursorPos );
static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint) cursorPos );
m_view->ClearPreview();
m_view->AddToPreview( item->Clone() );
}
@ -620,6 +626,9 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr );
}
if( immediateMode )
m_frame->PopTool();
return 0;
}
@ -655,18 +664,22 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
delete sheet;
sheet = nullptr;
if( evt->IsActivate() || immediateMode )
if( immediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) && !sheet )
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
@ -700,14 +713,10 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
sheet = nullptr;
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
else if( sheet && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
else if( sheet && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
sizeSheet( sheet, cursorPos );
m_view->ClearPreview();
@ -728,6 +737,9 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( sheet != nullptr);
}
if( immediateMode )
m_frame->PopTool();
return 0;
}

View File

@ -473,17 +473,21 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
m_view->ClearPreview();
m_view->ShowPreview( false );
if( evt->IsActivate() || aImmediateMode )
if( aImmediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
//------------------------------------------------------------------------
// Handle finish:
//
@ -499,11 +503,8 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
}
if( aImmediateMode )
{
m_frame->PopTool();
break;
}
}
//------------------------------------------------------------------------
// Handle click:
//
@ -646,6 +647,9 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
getViewControls()->CaptureCursor( aSegment != nullptr );
}
if( aImmediateMode )
m_frame->PopTool();
return 0;
}

View File

@ -104,18 +104,22 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
// There's nothing to roll-back, but we still need to pop the undo stack
m_frame->RollbackFromUndo();
if( evt->IsActivate() || immediateMode )
if( immediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
// First click creates...
@ -145,12 +149,9 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
m_frame->OnModify();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// Warp after context menu only if dragging...
@ -172,6 +173,9 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr );
}
if( immediateMode )
m_frame->PopTool();
return 0;
}
@ -210,18 +214,22 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
item = nullptr;
m_frame->RollbackFromUndo();
if( evt->IsActivate() || immediateMode )
if( immediateMode )
break;
}
else
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool();
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( !item ) // start drawing
@ -245,7 +253,6 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( immediateMode )
{
m_frame->PopTool();
m_toolMgr->RunAction( ACTIONS::activatePointEditor );
break;
}
@ -276,6 +283,9 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr );
}
if( immediateMode )
m_frame->PopTool();
return 0;
}