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; delete item;
item = nullptr; item = nullptr;
if( evt->IsActivate() || immediateMode ) if( immediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
@ -189,10 +193,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_frame->OnModify(); m_frame->OnModify();
if( immediateMode ) if( immediateMode )
{
m_frame->PopTool();
break; break;
}
} }
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
@ -216,6 +217,9 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
if( immediateMode )
m_frame->PopTool();
return 0; return 0;
} }
@ -257,16 +261,20 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
delete item; delete item;
item = nullptr; item = nullptr;
if( evt->IsActivate() || immediateMode ) if( immediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
else if( evt->IsClick( BUT_LEFT ) && !item ) else if( evt->IsClick( BUT_LEFT ) && !item )
@ -301,13 +309,11 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_selectionTool->AddItemToSel( item ); m_selectionTool->AddItemToSel( item );
} }
else if( item && ( evt->IsClick( BUT_LEFT ) else if( item && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT )
|| evt->IsDblClick( BUT_LEFT )
|| evt->IsAction( &EE_ACTIONS::finishDrawing ) ) ) || evt->IsAction( &EE_ACTIONS::finishDrawing ) ) )
{ {
if( evt->IsDblClick( BUT_LEFT ) if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing )
|| evt->IsAction( &EE_ACTIONS::finishDrawing ) || !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) )
|| !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) )
{ {
item->EndEdit(); item->EndEdit();
item->ClearEditFlags(); item->ClearEditFlags();
@ -322,14 +328,13 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( immediateMode ) if( immediateMode )
{ {
m_frame->PopTool(); m_toolMgr->RunAction( ACTIONS::activatePointEditor );
break; break;
} }
} }
} }
else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
|| evt->IsMotion() ) )
{ {
item->CalcEdit( wxPoint( cursorPos.x, -cursorPos.y) ); item->CalcEdit( wxPoint( cursorPos.x, -cursorPos.y) );
m_view->ClearPreview(); m_view->ClearPreview();
@ -355,6 +360,9 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
if( immediateMode )
m_frame->PopTool();
return 0; return 0;
} }

View File

@ -127,16 +127,20 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
delete component; delete component;
component = nullptr; component = nullptr;
if( evt->IsActivate() || immediateMode ) if( immediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
@ -179,10 +183,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
m_view->ClearPreview(); m_view->ClearPreview();
if( immediateMode ) if( immediateMode )
{
m_frame->PopTool();
break; break;
}
} }
} }
else if( evt->IsClick( BUT_RIGHT ) ) 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 ) else if( component && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
|| evt->IsMotion() ) )
{ {
component->SetPosition( (wxPoint)cursorPos ); component->SetPosition( (wxPoint)cursorPos );
m_view->ClearPreview(); m_view->ClearPreview();
@ -220,6 +220,9 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( component != nullptr ); getViewControls()->CaptureCursor( component != nullptr );
} }
if( immediateMode )
m_frame->PopTool();
return 0; return 0;
} }
@ -266,16 +269,20 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
delete image; delete image;
image = nullptr; image = nullptr;
if( evt->IsActivate() || immediateMode ) if( immediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
@ -324,10 +331,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_view->ClearPreview(); m_view->ClearPreview();
if( immediateMode ) if( immediateMode )
{
m_frame->PopTool();
break; break;
}
} }
} }
else if( evt->IsClick( BUT_RIGHT ) ) 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() ); m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
} }
else if( image && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) else if( image && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
|| evt->IsMotion() ) )
{ {
image->SetPosition( (wxPoint)cursorPos ); image->SetPosition( (wxPoint)cursorPos );
m_view->ClearPreview(); m_view->ClearPreview();
@ -352,6 +355,9 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( image != nullptr ); getViewControls()->CaptureCursor( image != nullptr );
} }
if( immediateMode )
m_frame->PopTool();
return 0; return 0;
} }
@ -488,16 +494,20 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
delete item; delete item;
item = nullptr; item = nullptr;
if( evt->IsActivate() || immediateMode ) if( immediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
@ -579,10 +589,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_view->ClearPreview(); m_view->ClearPreview();
if( immediateMode ) if( immediateMode )
{
m_frame->PopTool();
break; break;
}
} }
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
@ -607,10 +614,9 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
else else
item = nullptr; item = nullptr;
} }
else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
|| evt->IsMotion() ) )
{ {
static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint)cursorPos ); static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint) cursorPos );
m_view->ClearPreview(); m_view->ClearPreview();
m_view->AddToPreview( item->Clone() ); m_view->AddToPreview( item->Clone() );
} }
@ -620,6 +626,9 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
if( immediateMode )
m_frame->PopTool();
return 0; return 0;
} }
@ -655,16 +664,20 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
delete sheet; delete sheet;
sheet = nullptr; sheet = nullptr;
if( evt->IsActivate() || immediateMode ) if( immediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
else if( evt->IsClick( BUT_LEFT ) && !sheet ) else if( evt->IsClick( BUT_LEFT ) && !sheet )
@ -700,14 +713,10 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
sheet = nullptr; sheet = nullptr;
if( immediateMode ) if( immediateMode )
{
m_frame->PopTool();
break; break;
}
} }
else if( sheet && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) else if( sheet && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
|| evt->IsMotion() ) )
{ {
sizeSheet( sheet, cursorPos ); sizeSheet( sheet, cursorPos );
m_view->ClearPreview(); m_view->ClearPreview();
@ -728,6 +737,9 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( sheet != nullptr); getViewControls()->CaptureCursor( sheet != nullptr);
} }
if( immediateMode )
m_frame->PopTool();
return 0; 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->ClearPreview();
m_view->ShowPreview( false ); m_view->ShowPreview( false );
if( evt->IsActivate() || aImmediateMode ) if( aImmediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Handle finish: // Handle finish:
@ -499,10 +503,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
} }
if( aImmediateMode ) if( aImmediateMode )
{
m_frame->PopTool();
break; break;
}
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Handle click: // Handle click:
@ -646,6 +647,9 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
getViewControls()->CaptureCursor( aSegment != nullptr ); getViewControls()->CaptureCursor( aSegment != nullptr );
} }
if( aImmediateMode )
m_frame->PopTool();
return 0; 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 // There's nothing to roll-back, but we still need to pop the undo stack
m_frame->RollbackFromUndo(); m_frame->RollbackFromUndo();
if( evt->IsActivate() || immediateMode ) if( immediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
@ -145,10 +149,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
m_frame->OnModify(); m_frame->OnModify();
if( immediateMode ) if( immediateMode )
{
m_frame->PopTool();
break; break;
}
} }
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
@ -172,6 +173,9 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
if( immediateMode )
m_frame->PopTool();
return 0; return 0;
} }
@ -210,16 +214,20 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
item = nullptr; item = nullptr;
m_frame->RollbackFromUndo(); m_frame->RollbackFromUndo();
if( evt->IsActivate() || immediateMode ) if( immediateMode )
break; break;
} }
else else
{ {
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_frame->PopTool(); m_frame->PopTool();
break;
break; }
} }
if( evt->IsActivate() )
break;
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
@ -245,7 +253,6 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( immediateMode ) if( immediateMode )
{ {
m_frame->PopTool();
m_toolMgr->RunAction( ACTIONS::activatePointEditor ); m_toolMgr->RunAction( ACTIONS::activatePointEditor );
break; break;
} }
@ -276,6 +283,9 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
if( immediateMode )
m_frame->PopTool();
return 0; return 0;
} }