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,16 +98,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
@ -189,10 +193,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_frame->OnModify();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
@ -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,16 +261,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) && !item )
@ -301,13 +309,11 @@ 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 )
|| !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) )
if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing )
|| !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) )
{
item->EndEdit();
item->ClearEditFlags();
@ -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,16 +127,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
@ -179,10 +183,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
m_view->ClearPreview();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
@ -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,16 +269,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
@ -324,10 +331,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_view->ClearPreview();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
@ -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,16 +494,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
@ -579,10 +589,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_view->ClearPreview();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
@ -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,16 +664,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) && !sheet )
@ -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,16 +473,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
//------------------------------------------------------------------------
// Handle finish:
@ -499,10 +503,7 @@ 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,16 +104,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
@ -145,10 +149,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
m_frame->OnModify();
if( immediateMode )
{
m_frame->PopTool();
break;
}
}
}
else if( evt->IsClick( BUT_RIGHT ) )
@ -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,16 +214,20 @@ 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;
break;
}
}
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
@ -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;
}