Push/pop tools even when selected from the toolbar.
This commit is contained in:
parent
7dd247f1dc
commit
dcbd897a95
|
@ -419,19 +419,14 @@ void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_FRAME::SetTool( const std::string& actionName )
|
|
||||||
{
|
|
||||||
if( !m_toolStack.empty() )
|
|
||||||
m_toolStack.pop_back();
|
|
||||||
|
|
||||||
PushTool( actionName );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_FRAME::PushTool( const std::string& actionName )
|
void EDA_DRAW_FRAME::PushTool( const std::string& actionName )
|
||||||
{
|
{
|
||||||
m_toolStack.push_back( actionName );
|
m_toolStack.push_back( actionName );
|
||||||
|
|
||||||
|
// Human cognitive stacking is very shallow; deeper tool stacks just get annoying
|
||||||
|
if( m_toolStack.size() > 3 )
|
||||||
|
m_toolStack.pop_front();
|
||||||
|
|
||||||
TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( actionName );
|
TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( actionName );
|
||||||
|
|
||||||
if( action )
|
if( action )
|
||||||
|
@ -451,6 +446,9 @@ void EDA_DRAW_FRAME::PopTool()
|
||||||
|
|
||||||
if( action )
|
if( action )
|
||||||
{
|
{
|
||||||
|
// Pop the action as running it will push it back onto the stack
|
||||||
|
m_toolStack.pop_back();
|
||||||
|
|
||||||
TOOL_EVENT evt = action->MakeEvent();
|
TOOL_EVENT evt = action->MakeEvent();
|
||||||
evt.SetHasPosition( false );
|
evt.SetHasPosition( false );
|
||||||
GetToolManager()->PostEvent( evt );
|
GetToolManager()->PostEvent( evt );
|
||||||
|
|
|
@ -176,9 +176,7 @@ bool TOOL_EVENT::IsDblClick( int aButtonMask ) const
|
||||||
|
|
||||||
bool TOOL_EVT_UTILS::IsCancelInteractive( const TOOL_EVENT& aEvt )
|
bool TOOL_EVT_UTILS::IsCancelInteractive( const TOOL_EVENT& aEvt )
|
||||||
{
|
{
|
||||||
return aEvt.IsAction( &ACTIONS::cancelInteractive )
|
return aEvt.IsAction( &ACTIONS::cancelInteractive ) || aEvt.IsCancel();
|
||||||
|| aEvt.IsActivate()
|
|
||||||
|| aEvt.IsCancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <tools/ee_actions.h>
|
#include <tools/ee_actions.h>
|
||||||
#include <core/typeinfo.h>
|
#include <core/typeinfo.h>
|
||||||
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
|
||||||
|
|
||||||
// Actions, being statically-defined, require specialized I18N handling. We continue to
|
// Actions, being statically-defined, require specialized I18N handling. We continue to
|
||||||
|
@ -612,13 +613,13 @@ TOOL_ACTION EE_ACTIONS::drawWire( "eeschema.InteractiveDrawingLineWireBus.drawWi
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
'W', LEGACY_HK_NAME( "Begin Wire" ),
|
'W', LEGACY_HK_NAME( "Begin Wire" ),
|
||||||
_( "Add Wire" ), _( "Add a wire" ),
|
_( "Add Wire" ), _( "Add a wire" ),
|
||||||
add_line_xpm, AF_ACTIVATE );
|
add_line_xpm, AF_ACTIVATE, (void*) LAYER_WIRE );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::drawBus( "eeschema.InteractiveDrawingLineWireBus.drawBusses",
|
TOOL_ACTION EE_ACTIONS::drawBus( "eeschema.InteractiveDrawingLineWireBus.drawBusses",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
'B', LEGACY_HK_NAME( "Begin Bus" ),
|
'B', LEGACY_HK_NAME( "Begin Bus" ),
|
||||||
_( "Add Bus" ), _( "Add a bus" ),
|
_( "Add Bus" ), _( "Add a bus" ),
|
||||||
add_bus_xpm, AF_ACTIVATE );
|
add_bus_xpm, AF_ACTIVATE, (void*) LAYER_BUS );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::unfoldBus( "eeschema.InteractiveDrawingLineWireBus.unfoldBus",
|
TOOL_ACTION EE_ACTIONS::unfoldBus( "eeschema.InteractiveDrawingLineWireBus.unfoldBus",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
|
@ -630,7 +631,7 @@ TOOL_ACTION EE_ACTIONS::drawLines( "eeschema.InteractiveDrawingLineWireBus.drawL
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
'I', LEGACY_HK_NAME( "Add Graphic PolyLine" ),
|
'I', LEGACY_HK_NAME( "Add Graphic PolyLine" ),
|
||||||
_( "Add Lines" ), _( "Add connected graphic lines" ),
|
_( "Add Lines" ), _( "Add connected graphic lines" ),
|
||||||
add_dashed_line_xpm, AF_ACTIVATE );
|
add_dashed_line_xpm, AF_ACTIVATE, (void*) LAYER_NOTES );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::finishLineWireOrBus( "eeschema.InteractiveDrawingLineWireBus.finish",
|
TOOL_ACTION EE_ACTIONS::finishLineWireOrBus( "eeschema.InteractiveDrawingLineWireBus.finish",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
|
|
|
@ -88,7 +88,7 @@ int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( m_cancelHandler )
|
if( m_cancelHandler )
|
||||||
{
|
{
|
||||||
|
|
|
@ -301,15 +301,17 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||||
inDrag = false;
|
inDrag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( inDrag ) // Restore the last change
|
if( inDrag ) // Restore the last change
|
||||||
{
|
{
|
||||||
rollbackFromUndo();
|
rollbackFromUndo();
|
||||||
|
inDrag = false;
|
||||||
modified = false;
|
modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ESC should clear selection along with edit points
|
// ESC should clear selection along with edit points
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -406,7 +406,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsCancel() )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
{
|
{
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearHighlight, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearHighlight, true );
|
||||||
|
@ -653,7 +653,7 @@ bool EE_SELECTION_TOOL::selectMultiple()
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -66,55 +66,22 @@ bool LIB_DRAWING_TOOLS::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int LIB_DRAWING_TOOLS::PlacePin( const TOOL_EVENT& aEvent )
|
int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( aEvent.HasPosition() )
|
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
||||||
{
|
bool immediateMode = aEvent.HasPosition();
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
LIB_PIN_TOOL* pinTool = type == LIB_PIN_T ? m_toolMgr->GetTool<LIB_PIN_TOOL>() : nullptr;
|
||||||
doTwoClickPlace( LIB_PIN_T, true );
|
|
||||||
m_frame->PopTool();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
doTwoClickPlace( LIB_PIN_T, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int LIB_DRAWING_TOOLS::PlaceText( const TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
if( aEvent.HasPosition() )
|
|
||||||
{
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
|
||||||
doTwoClickPlace( LIB_TEXT_T, true );
|
|
||||||
m_frame->PopTool();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
doTwoClickPlace( LIB_TEXT_T, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
|
||||||
{
|
|
||||||
LIB_PIN_TOOL* pinTool = aType == LIB_PIN_T ? m_toolMgr->GetTool<LIB_PIN_TOOL>() : nullptr;
|
|
||||||
VECTOR2I cursorPos;
|
VECTOR2I cursorPos;
|
||||||
EDA_ITEM* item = nullptr;
|
EDA_ITEM* item = nullptr;
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
|
|
||||||
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Prime the pump
|
// Prime the pump
|
||||||
if( aImmediateMode )
|
if( immediateMode )
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
|
@ -122,7 +89,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
||||||
{
|
{
|
||||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( item )
|
if( item )
|
||||||
{
|
{
|
||||||
|
@ -131,15 +98,17 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
||||||
delete item;
|
delete item;
|
||||||
item = nullptr;
|
item = nullptr;
|
||||||
|
|
||||||
if( !evt->IsActivate() && !aImmediateMode )
|
if( evt->IsActivate() || immediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( !evt->IsActivate() && !aImmediateMode )
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
|
@ -153,7 +122,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
switch( aType )
|
switch( type )
|
||||||
{
|
{
|
||||||
case LIB_PIN_T:
|
case LIB_PIN_T:
|
||||||
{
|
{
|
||||||
|
@ -178,7 +147,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( "doTwoClickPlace(): unknown type" );
|
wxFAIL_MSG( "TwoClickPlace(): unknown type" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore cursor after dialog
|
// Restore cursor after dialog
|
||||||
|
@ -210,7 +179,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
||||||
item->ClearEditFlags();
|
item->ClearEditFlags();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( "doTwoClickPlace(): unknown type" );
|
wxFAIL_MSG( "TwoClickPlace(): unknown type" );
|
||||||
}
|
}
|
||||||
|
|
||||||
item = nullptr;
|
item = nullptr;
|
||||||
|
@ -219,10 +188,13 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
||||||
m_frame->RebuildView();
|
m_frame->RebuildView();
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
if( aImmediateMode )
|
if( immediateMode )
|
||||||
|
{
|
||||||
|
m_frame->PopTool();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
{
|
{
|
||||||
// Warp after context menu only if dragging...
|
// Warp after context menu only if dragging...
|
||||||
|
@ -240,8 +212,8 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is an item to be placed
|
// Enable autopanning and cursor capture only when there is an item to be placed
|
||||||
getViewControls()->SetAutoPan( !!item );
|
getViewControls()->SetAutoPan( item != nullptr );
|
||||||
getViewControls()->CaptureCursor( !!item );
|
getViewControls()->CaptureCursor( item != nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -251,6 +223,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
|
||||||
int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
||||||
|
bool immediateMode = aEvent.HasPosition();
|
||||||
|
|
||||||
// We might be running as the same shape in another co-routine. Make sure that one
|
// We might be running as the same shape in another co-routine. Make sure that one
|
||||||
// gets whacked.
|
// gets whacked.
|
||||||
|
@ -259,19 +232,22 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
LIB_PART* part = m_frame->GetCurPart();
|
LIB_PART* part = m_frame->GetCurPart();
|
||||||
LIB_ITEM* item = nullptr;
|
LIB_ITEM* item = nullptr;
|
||||||
|
|
||||||
|
// Prime the pump
|
||||||
|
if( immediateMode )
|
||||||
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( auto evt = Wait() )
|
while( auto evt = Wait() )
|
||||||
{
|
{
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
m_view->ClearPreview();
|
m_view->ClearPreview();
|
||||||
|
@ -281,15 +257,17 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
delete item;
|
delete item;
|
||||||
item = nullptr;
|
item = nullptr;
|
||||||
|
|
||||||
if( !evt->IsActivate() )
|
if( evt->IsActivate() || immediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( !evt->IsActivate() )
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) && !item )
|
else if( evt->IsClick( BUT_LEFT ) && !item )
|
||||||
{
|
{
|
||||||
|
@ -341,6 +319,12 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_frame->RebuildView();
|
m_frame->RebuildView();
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
|
if( immediateMode )
|
||||||
|
{
|
||||||
|
m_frame->PopTool();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,8 +351,8 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is a shape being drawn
|
// Enable autopanning and cursor capture only when there is a shape being drawn
|
||||||
getViewControls()->SetAutoPan( !!item );
|
getViewControls()->SetAutoPan( item != nullptr );
|
||||||
getViewControls()->CaptureCursor( !!item );
|
getViewControls()->CaptureCursor( item != nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -377,17 +361,16 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
|
||||||
|
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
getViewControls()->SetSnapping( true );
|
getViewControls()->SetSnapping( true );
|
||||||
|
|
||||||
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +401,6 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,8 +438,8 @@ int LIB_DRAWING_TOOLS::RepeatDrawItem( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
void LIB_DRAWING_TOOLS::setTransitions()
|
void LIB_DRAWING_TOOLS::setTransitions()
|
||||||
{
|
{
|
||||||
Go( &LIB_DRAWING_TOOLS::PlacePin, EE_ACTIONS::placeSymbolPin.MakeEvent() );
|
Go( &LIB_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeSymbolPin.MakeEvent() );
|
||||||
Go( &LIB_DRAWING_TOOLS::PlaceText, EE_ACTIONS::placeSymbolText.MakeEvent() );
|
Go( &LIB_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeSymbolText.MakeEvent() );
|
||||||
Go( &LIB_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolRectangle.MakeEvent() );
|
Go( &LIB_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolRectangle.MakeEvent() );
|
||||||
Go( &LIB_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolCircle.MakeEvent() );
|
Go( &LIB_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolCircle.MakeEvent() );
|
||||||
Go( &LIB_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolArc.MakeEvent() );
|
Go( &LIB_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolArc.MakeEvent() );
|
||||||
|
|
|
@ -45,8 +45,7 @@ public:
|
||||||
/// @copydoc TOOL_INTERACTIVE::Init()
|
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||||
bool Init() override;
|
bool Init() override;
|
||||||
|
|
||||||
int PlacePin( const TOOL_EVENT& aEvent );
|
int TwoClickPlace( const TOOL_EVENT& aEvent );
|
||||||
int PlaceText( const TOOL_EVENT& aEvent );
|
|
||||||
int DrawShape( const TOOL_EVENT& aEvent );
|
int DrawShape( const TOOL_EVENT& aEvent );
|
||||||
int PlaceAnchor( const TOOL_EVENT& aEvent );
|
int PlaceAnchor( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
|
|
@ -293,17 +293,17 @@ static bool deleteItem( SCH_BASE_FRAME* aFrame, const VECTOR2D& aPosition )
|
||||||
|
|
||||||
int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
||||||
wxCHECK( picker, 0 );
|
wxCHECK( picker, 0 );
|
||||||
|
|
||||||
picker->SetClickHandler( std::bind( deleteItem, m_frame, std::placeholders::_1 ) );
|
picker->SetClickHandler( std::bind( deleteItem, m_frame, std::placeholders::_1 ) );
|
||||||
picker->SetCancelHandler( [this]() { m_frame->ClearToolStack(); } );
|
|
||||||
picker->Activate();
|
picker->Activate();
|
||||||
Wait();
|
Wait();
|
||||||
|
|
||||||
|
m_frame->PopTool();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
controls->ShowCursor( true );
|
controls->ShowCursor( true );
|
||||||
controls->SetAutoPan( true );
|
controls->SetAutoPan( true );
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Handle cancel
|
// Handle cancel
|
||||||
//
|
//
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( m_moveInProgress )
|
if( m_moveInProgress )
|
||||||
restore_state = true;
|
restore_state = true;
|
||||||
|
@ -279,7 +279,6 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_moveInProgress = false;
|
m_moveInProgress = false;
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,10 +100,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||||
m_selectionTool->AddItemToSel( component );
|
m_selectionTool->AddItemToSel( component );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
else
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
|
@ -121,7 +118,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( component )
|
if( component )
|
||||||
{
|
{
|
||||||
|
@ -130,15 +127,17 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||||
delete component;
|
delete component;
|
||||||
component = nullptr;
|
component = nullptr;
|
||||||
|
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
if( evt->IsActivate() || immediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
if( !component )
|
if( !component )
|
||||||
|
@ -178,6 +177,12 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||||
component = nullptr;
|
component = nullptr;
|
||||||
|
|
||||||
m_view->ClearPreview();
|
m_view->ClearPreview();
|
||||||
|
|
||||||
|
if( immediateMode )
|
||||||
|
{
|
||||||
|
m_frame->PopTool();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
|
@ -211,13 +216,10 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is a module to be placed
|
// Enable autopanning and cursor capture only when there is a module to be placed
|
||||||
getViewControls()->SetAutoPan( !!component );
|
getViewControls()->SetAutoPan( component != nullptr );
|
||||||
getViewControls()->CaptureCursor( !!component );
|
getViewControls()->CaptureCursor( component != nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PopTool();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,10 +229,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
|
SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
|
||||||
bool immediateMode = image || aEvent.HasPosition();
|
bool immediateMode = image || aEvent.HasPosition();
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
else
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
|
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
||||||
|
|
||||||
|
@ -258,7 +257,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( image )
|
if( image )
|
||||||
{
|
{
|
||||||
|
@ -267,15 +266,17 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
delete image;
|
delete image;
|
||||||
image = nullptr;
|
image = nullptr;
|
||||||
|
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
if( evt->IsActivate() || immediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
if( !image )
|
if( !image )
|
||||||
|
@ -323,9 +324,12 @@ 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 ) )
|
||||||
{
|
{
|
||||||
// Warp after context menu only if dragging...
|
// Warp after context menu only if dragging...
|
||||||
|
@ -344,13 +348,10 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is a module to be placed
|
// Enable autopanning and cursor capture only when there is a module to be placed
|
||||||
getViewControls()->SetAutoPan( !!image );
|
getViewControls()->SetAutoPan( image != nullptr );
|
||||||
getViewControls()->CaptureCursor( !!image );
|
getViewControls()->CaptureCursor( image != nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PopTool();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,11 +385,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
getViewControls()->SetSnapping( true );
|
getViewControls()->SetSnapping( true );
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
else
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Prime the pump
|
// Prime the pump
|
||||||
|
@ -400,9 +397,9 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -445,17 +442,17 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( immediateMode )
|
if( immediateMode )
|
||||||
|
{
|
||||||
|
m_frame->PopTool();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
{
|
{
|
||||||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PopTool();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,10 +466,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
else
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
|
@ -485,7 +479,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( item )
|
if( item )
|
||||||
{
|
{
|
||||||
|
@ -494,15 +488,17 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
delete item;
|
delete item;
|
||||||
item = nullptr;
|
item = nullptr;
|
||||||
|
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
if( evt->IsActivate() || immediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
// First click creates...
|
// First click creates...
|
||||||
|
@ -583,9 +579,12 @@ 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 ) )
|
||||||
{
|
{
|
||||||
// Warp after context menu only if dragging...
|
// Warp after context menu only if dragging...
|
||||||
|
@ -621,9 +620,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,10 +632,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
else
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
|
@ -652,7 +645,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
m_view->ClearPreview();
|
m_view->ClearPreview();
|
||||||
|
@ -662,15 +655,17 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
delete sheet;
|
delete sheet;
|
||||||
sheet = nullptr;
|
sheet = nullptr;
|
||||||
|
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
if( evt->IsActivate() || immediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( !evt->IsActivate() && !immediateMode )
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) && !sheet )
|
else if( evt->IsClick( BUT_LEFT ) && !sheet )
|
||||||
{
|
{
|
||||||
|
@ -705,8 +700,11 @@ 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() ) )
|
||||||
|
@ -726,13 +724,10 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is a sheet to be placed
|
// Enable autopanning and cursor capture only when there is a sheet to be placed
|
||||||
getViewControls()->SetAutoPan( !!sheet );
|
getViewControls()->SetAutoPan( sheet != nullptr );
|
||||||
getViewControls()->CaptureCursor( !!sheet );
|
getViewControls()->CaptureCursor( sheet != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( immediateMode )
|
|
||||||
m_frame->PopTool();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -935,7 +935,7 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
||||||
|
@ -985,16 +985,13 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->SetCancelHandler( [this] () {
|
|
||||||
m_frame->ClearToolStack();
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->Activate();
|
picker->Activate();
|
||||||
Wait();
|
Wait();
|
||||||
|
|
||||||
if( m_pickerItem )
|
if( m_pickerItem )
|
||||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||||
|
|
||||||
|
m_frame->PopTool();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -692,17 +692,17 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
||||||
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
||||||
m_frame->RecalculateConnections();
|
m_frame->RecalculateConnections();
|
||||||
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
||||||
wxCHECK( picker, 0 );
|
wxCHECK( picker, 0 );
|
||||||
|
|
||||||
picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, std::placeholders::_1 ) );
|
picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, std::placeholders::_1 ) );
|
||||||
picker->SetCancelHandler( [this]() { m_frame->ClearToolStack(); } );
|
|
||||||
picker->Activate();
|
picker->Activate();
|
||||||
Wait();
|
Wait();
|
||||||
|
|
||||||
|
m_frame->PopTool();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ private:
|
||||||
{
|
{
|
||||||
frame->RecalculateConnections();
|
frame->RecalculateConnections();
|
||||||
|
|
||||||
// Have to pick up the pointer again because it may have been changed by SchematicCleanUp
|
// Pick up the pointer again because it may have been changed by SchematicCleanUp
|
||||||
selection = selTool->RequestSelection( busType );
|
selection = selTool->RequestSelection( busType );
|
||||||
bus = (SCH_LINE*) selection.Front();
|
bus = (SCH_LINE*) selection.Front();
|
||||||
}
|
}
|
||||||
|
@ -250,43 +250,15 @@ bool SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( const SELECTION& aSelection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_LINE_WIRE_BUS_TOOL::DrawWires( const TOOL_EVENT& aEvent )
|
int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( aEvent.HasPosition() ) // Start drawing
|
SCH_LAYER_ID layer = aEvent.Parameter<SCH_LAYER_ID>();
|
||||||
{
|
|
||||||
|
if( aEvent.HasPosition() )
|
||||||
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
|
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
|
||||||
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
doDrawSegments( LAYER_WIRE, nullptr, true );
|
return doDrawSegments( layer, nullptr, aEvent.HasPosition() );
|
||||||
m_frame->PopTool();
|
|
||||||
}
|
|
||||||
else // Invoke the tool
|
|
||||||
{
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
doDrawSegments( LAYER_WIRE, nullptr, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int SCH_LINE_WIRE_BUS_TOOL::DrawBusses( const TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
if( aEvent.HasPosition() ) // Start drawing
|
|
||||||
{
|
|
||||||
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
|
|
||||||
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
|
||||||
doDrawSegments( LAYER_BUS, nullptr, true );
|
|
||||||
m_frame->PopTool();
|
|
||||||
}
|
|
||||||
else // Invoke the tool
|
|
||||||
{
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
doDrawSegments( LAYER_BUS, nullptr, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,6 +270,7 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
if( netPtr )
|
if( netPtr )
|
||||||
|
@ -327,20 +300,15 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !net.IsEmpty() )
|
|
||||||
{
|
|
||||||
// Break a wire for the given net out of the bus
|
// Break a wire for the given net out of the bus
|
||||||
|
if( !net.IsEmpty() )
|
||||||
segment = doUnfoldBus( net );
|
segment = doUnfoldBus( net );
|
||||||
}
|
|
||||||
|
|
||||||
// If we have an unfolded wire to draw, then draw it
|
// If we have an unfolded wire to draw, then draw it
|
||||||
if( segment )
|
if( segment )
|
||||||
{
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
|
||||||
doDrawSegments( LAYER_WIRE, segment, true );
|
doDrawSegments( LAYER_WIRE, segment, true );
|
||||||
m_frame->PopTool();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
m_frame->PopTool();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,26 +336,6 @@ SCH_LINE* SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus( const wxString& aNet )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_LINE_WIRE_BUS_TOOL::DrawLines( const TOOL_EVENT& aEvent)
|
|
||||||
{
|
|
||||||
if( aEvent.HasPosition() ) // Start drawing
|
|
||||||
{
|
|
||||||
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
|
|
||||||
|
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
|
||||||
doDrawSegments( LAYER_NOTES, nullptr, true );
|
|
||||||
m_frame->PopTool();
|
|
||||||
}
|
|
||||||
else // Invoke the tool
|
|
||||||
{
|
|
||||||
m_frame->SetTool( aEvent.GetCommandStr().get() );
|
|
||||||
doDrawSegments( LAYER_NOTES, nullptr, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Storage for the line segments while drawing
|
// Storage for the line segments while drawing
|
||||||
static DLIST<SCH_LINE> s_wires;
|
static DLIST<SCH_LINE> s_wires;
|
||||||
|
|
||||||
|
@ -491,6 +439,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
|
// Prime the pump
|
||||||
if( aImmediateMode && !aSegment )
|
if( aImmediateMode && !aSegment )
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
|
@ -502,7 +451,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Handle cancel:
|
// Handle cancel:
|
||||||
//
|
//
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( aSegment || m_busUnfold.in_progress )
|
if( aSegment || m_busUnfold.in_progress )
|
||||||
{
|
{
|
||||||
|
@ -524,15 +473,17 @@ 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( evt->IsActivate() || aImmediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( !evt->IsActivate() && !aImmediateMode )
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Handle finish:
|
// Handle finish:
|
||||||
//
|
//
|
||||||
|
@ -548,8 +499,11 @@ 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:
|
||||||
//
|
//
|
||||||
|
@ -688,8 +642,8 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is a segment to be placed
|
// Enable autopanning and cursor capture only when there is a segment to be placed
|
||||||
getViewControls()->SetAutoPan( !!aSegment );
|
getViewControls()->SetAutoPan( aSegment != nullptr );
|
||||||
getViewControls()->CaptureCursor( !!aSegment );
|
getViewControls()->CaptureCursor( aSegment != nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -889,9 +843,9 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments()
|
||||||
|
|
||||||
void SCH_LINE_WIRE_BUS_TOOL::setTransitions()
|
void SCH_LINE_WIRE_BUS_TOOL::setTransitions()
|
||||||
{
|
{
|
||||||
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawWires, EE_ACTIONS::drawWire.MakeEvent() );
|
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawSegments, EE_ACTIONS::drawWire.MakeEvent() );
|
||||||
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawBusses, EE_ACTIONS::drawBus.MakeEvent() );
|
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawSegments, EE_ACTIONS::drawBus.MakeEvent() );
|
||||||
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawLines, EE_ACTIONS::drawLines.MakeEvent() );
|
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawSegments, EE_ACTIONS::drawLines.MakeEvent() );
|
||||||
|
|
||||||
Go( &SCH_LINE_WIRE_BUS_TOOL::UnfoldBus, EE_ACTIONS::unfoldBus.MakeEvent() );
|
Go( &SCH_LINE_WIRE_BUS_TOOL::UnfoldBus, EE_ACTIONS::unfoldBus.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,7 @@ public:
|
||||||
/// @copydoc TOOL_INTERACTIVE::Init()
|
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||||
bool Init() override;
|
bool Init() override;
|
||||||
|
|
||||||
int DrawWires( const TOOL_EVENT& aEvent );
|
int DrawSegments( const TOOL_EVENT& aEvent );
|
||||||
int DrawBusses( const TOOL_EVENT& aEvent );
|
|
||||||
int DrawLines( const TOOL_EVENT& aEvent );
|
|
||||||
|
|
||||||
int UnfoldBus( const TOOL_EVENT& aEvent );
|
int UnfoldBus( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
// SELECTION_CONDITIONs:
|
// SELECTION_CONDITIONs:
|
||||||
|
|
|
@ -445,7 +445,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
m_dragAdditions.clear();
|
m_dragAdditions.clear();
|
||||||
m_moveInProgress = false;
|
m_moveInProgress = false;
|
||||||
m_frame->PopTool();
|
m_frame->PopTool();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -300,7 +300,6 @@ public:
|
||||||
* a single TOOL_BASE derived class to implement several user "tools", such as rectangle
|
* a single TOOL_BASE derived class to implement several user "tools", such as rectangle
|
||||||
* and circle, or wire and bus. So each user-level tool is actually a TOOL_ACTION.
|
* and circle, or wire and bus. So each user-level tool is actually a TOOL_ACTION.
|
||||||
*/
|
*/
|
||||||
virtual void SetTool( const std::string& actionName );
|
|
||||||
virtual void PushTool( const std::string& actionName );
|
virtual void PushTool( const std::string& actionName );
|
||||||
virtual void PopTool();
|
virtual void PopTool();
|
||||||
virtual void ClearToolStack();
|
virtual void ClearToolStack();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <tool/tool_action.h>
|
#include <tool/tool_action.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <tools/pl_actions.h>
|
#include <tools/pl_actions.h>
|
||||||
|
#include <ws_data_item.h>
|
||||||
|
|
||||||
|
|
||||||
// Actions, being statically-defined, require specialized I18N handling. We continue to
|
// Actions, being statically-defined, require specialized I18N handling. We continue to
|
||||||
|
@ -39,42 +40,22 @@
|
||||||
TOOL_ACTION PL_ACTIONS::drawLine( "plEditor.InteractiveDrawing.drawLine",
|
TOOL_ACTION PL_ACTIONS::drawLine( "plEditor.InteractiveDrawing.drawLine",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Add Line" ), _( "Add a line" ),
|
_( "Add Line" ), _( "Add a line" ),
|
||||||
add_graphical_segments_xpm, AF_ACTIVATE );
|
add_graphical_segments_xpm, AF_ACTIVATE, (void*) WS_DATA_ITEM::WS_SEGMENT );
|
||||||
|
|
||||||
TOOL_ACTION PL_ACTIONS::drawRectangle( "plEditor.InteractiveDrawing.drawRectangle",
|
TOOL_ACTION PL_ACTIONS::drawRectangle( "plEditor.InteractiveDrawing.drawRectangle",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Add Rectangle" ), _( "Add a rectangle" ),
|
_( "Add Rectangle" ), _( "Add a rectangle" ),
|
||||||
add_rectangle_xpm, AF_ACTIVATE );
|
add_rectangle_xpm, AF_ACTIVATE, (void*) WS_DATA_ITEM::WS_RECT );
|
||||||
|
|
||||||
TOOL_ACTION PL_ACTIONS::placeText( "plEditor.InteractiveDrawing.placeText",
|
TOOL_ACTION PL_ACTIONS::placeText( "plEditor.InteractiveDrawing.placeText",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Add Text" ), _( "Add a text item" ),
|
_( "Add Text" ), _( "Add a text item" ),
|
||||||
text_xpm, AF_ACTIVATE );
|
text_xpm, AF_ACTIVATE, (void*) WS_DATA_ITEM::WS_TEXT );
|
||||||
|
|
||||||
TOOL_ACTION PL_ACTIONS::placeImage( "plEditor.InteractiveDrawing.placeImage",
|
TOOL_ACTION PL_ACTIONS::placeImage( "plEditor.InteractiveDrawing.placeImage",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Add Bitmap" ), _( "Add a bitmap image" ),
|
_( "Add Bitmap" ), _( "Add a bitmap image" ),
|
||||||
image_xpm, AF_ACTIVATE );
|
image_xpm, AF_ACTIVATE, (void*) WS_DATA_ITEM::WS_BITMAP );
|
||||||
|
|
||||||
TOOL_ACTION PL_ACTIONS::addLine( "plEditor.InteractiveDrawing.addLine",
|
|
||||||
AS_GLOBAL, 0, "",
|
|
||||||
_( "Add Line" ), _( "Add a line" ),
|
|
||||||
add_dashed_line_xpm, AF_ACTIVATE );
|
|
||||||
|
|
||||||
TOOL_ACTION PL_ACTIONS::addRectangle( "plEditor.InteractiveDrawing.addRectangle",
|
|
||||||
AS_GLOBAL, 0, "",
|
|
||||||
_( "Add Rectangle" ), _( "Add a rectangle" ),
|
|
||||||
add_rectangle_xpm, AF_ACTIVATE );
|
|
||||||
|
|
||||||
TOOL_ACTION PL_ACTIONS::addText( "plEditor.InteractiveDrawing.addText",
|
|
||||||
AS_GLOBAL, 0, "",
|
|
||||||
_( "Add Text" ), _( "Add a text item" ),
|
|
||||||
text_xpm, AF_ACTIVATE );
|
|
||||||
|
|
||||||
TOOL_ACTION PL_ACTIONS::addImage( "plEditor.InteractiveDrawing.addImage",
|
|
||||||
AS_GLOBAL, 0, "",
|
|
||||||
_( "Add Bitmap" ), _( "Add a bitmap image" ),
|
|
||||||
image_xpm, AF_ACTIVATE );
|
|
||||||
|
|
||||||
|
|
||||||
// PL_EDIT_TOOL
|
// PL_EDIT_TOOL
|
||||||
|
|
|
@ -64,10 +64,6 @@ public:
|
||||||
static TOOL_ACTION placeImage;
|
static TOOL_ACTION placeImage;
|
||||||
static TOOL_ACTION drawRectangle;
|
static TOOL_ACTION drawRectangle;
|
||||||
static TOOL_ACTION drawLine;
|
static TOOL_ACTION drawLine;
|
||||||
static TOOL_ACTION addText;
|
|
||||||
static TOOL_ACTION addImage;
|
|
||||||
static TOOL_ACTION addRectangle;
|
|
||||||
static TOOL_ACTION addLine;
|
|
||||||
static TOOL_ACTION appendImportedWorksheet;
|
static TOOL_ACTION appendImportedWorksheet;
|
||||||
|
|
||||||
// Editing
|
// Editing
|
||||||
|
|
|
@ -73,46 +73,27 @@ void PL_DRAWING_TOOLS::Reset( RESET_REASON aReason )
|
||||||
|
|
||||||
int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
bool isText;
|
WS_DATA_ITEM::WS_ITEM_TYPE type = aEvent.Parameter<WS_DATA_ITEM::WS_ITEM_TYPE>();
|
||||||
bool isImmediate = false;
|
bool immediateMode = aEvent.HasPosition();
|
||||||
|
|
||||||
if( aEvent.IsAction( &PL_ACTIONS::placeText ) )
|
|
||||||
{
|
|
||||||
isText = true;
|
|
||||||
m_frame->SetToolID( ID_PL_TEXT_TOOL, wxCURSOR_PENCIL, _( "Add text" ) );
|
|
||||||
}
|
|
||||||
else if( aEvent.IsAction( &PL_ACTIONS::placeImage ) )
|
|
||||||
{
|
|
||||||
isText = false;
|
|
||||||
m_frame->SetToolID( ID_PL_IMAGE_TOOL, wxCURSOR_PENCIL, _( "Add image" ) );
|
|
||||||
}
|
|
||||||
else if( aEvent.IsAction( & PL_ACTIONS::addText ) )
|
|
||||||
{
|
|
||||||
isText = true;
|
|
||||||
isImmediate = true;
|
|
||||||
}
|
|
||||||
else if( aEvent.IsAction( & PL_ACTIONS::addImage ) )
|
|
||||||
{
|
|
||||||
isText = false;
|
|
||||||
isImmediate = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
wxCHECK_MSG( false, 0, "Unknown action in PL_DRAWING_TOOLS::PlaceItem()" );
|
|
||||||
|
|
||||||
VECTOR2I cursorPos;
|
VECTOR2I cursorPos;
|
||||||
WS_DRAW_ITEM_BASE* item = nullptr;
|
WS_DRAW_ITEM_BASE* item = nullptr;
|
||||||
|
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
|
|
||||||
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
|
// Prime the pump
|
||||||
|
if( immediateMode )
|
||||||
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( item )
|
if( item )
|
||||||
{
|
{
|
||||||
|
@ -123,14 +104,19 @@ 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() && !isImmediate )
|
if( evt->IsActivate() || immediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) || ( isImmediate && !item ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
// First click creates...
|
// First click creates...
|
||||||
if( !item )
|
if( !item )
|
||||||
|
@ -140,8 +126,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
WS_DATA_ITEM* dataItem;
|
WS_DATA_ITEM* dataItem;
|
||||||
dataItem = m_frame->AddPageLayoutItem( isText ? WS_DATA_ITEM::WS_TEXT
|
dataItem = m_frame->AddPageLayoutItem( type );
|
||||||
: WS_DATA_ITEM::WS_BITMAP );
|
|
||||||
item = dataItem->GetDrawItems()[0];
|
item = dataItem->GetDrawItems()[0];
|
||||||
item->SetFlags( IS_NEW | IS_MOVED );
|
item->SetFlags( IS_NEW | IS_MOVED );
|
||||||
m_selectionTool->AddItemToSel( item );
|
m_selectionTool->AddItemToSel( item );
|
||||||
|
@ -159,10 +144,13 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
if( isImmediate )
|
if( immediateMode )
|
||||||
|
{
|
||||||
|
m_frame->PopTool();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
{
|
{
|
||||||
// Warp after context menu only if dragging...
|
// Warp after context menu only if dragging...
|
||||||
|
@ -180,61 +168,40 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is an item to be placed
|
// Enable autopanning and cursor capture only when there is an item to be placed
|
||||||
getViewControls()->SetAutoPan( !!item );
|
getViewControls()->SetAutoPan( item != nullptr );
|
||||||
getViewControls()->CaptureCursor( !!item );
|
getViewControls()->CaptureCursor( item != nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->SetNoToolSelected();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
WS_DATA_ITEM::WS_ITEM_TYPE type = aEvent.Parameter<WS_DATA_ITEM::WS_ITEM_TYPE>();
|
||||||
|
bool immediateMode = aEvent.HasPosition();
|
||||||
|
WS_DRAW_ITEM_BASE* item = nullptr;
|
||||||
|
|
||||||
// We might be running as the same shape in another co-routine. Make sure that one
|
// We might be running as the same shape in another co-routine. Make sure that one
|
||||||
// gets whacked.
|
// gets whacked.
|
||||||
m_toolMgr->DeactivateTool();
|
m_toolMgr->DeactivateTool();
|
||||||
|
|
||||||
bool isDrawLine;
|
|
||||||
bool isImmediate = false;
|
|
||||||
|
|
||||||
if( aEvent.IsAction( &PL_ACTIONS::drawLine ) )
|
|
||||||
{
|
|
||||||
isDrawLine = true;
|
|
||||||
m_frame->SetToolID( ID_PL_LINE_TOOL, wxCURSOR_PENCIL, _( "Draw line" ) );
|
|
||||||
}
|
|
||||||
else if( aEvent.IsAction( &PL_ACTIONS::drawRectangle ) )
|
|
||||||
{
|
|
||||||
isDrawLine = false;
|
|
||||||
m_frame->SetToolID( ID_PL_RECTANGLE_TOOL, wxCURSOR_PENCIL, _( "Draw rectangle" ) );
|
|
||||||
}
|
|
||||||
else if( aEvent.IsAction( &PL_ACTIONS::addLine ) )
|
|
||||||
{
|
|
||||||
isDrawLine = true;
|
|
||||||
isImmediate = true;
|
|
||||||
}
|
|
||||||
else if( aEvent.IsAction( &PL_ACTIONS::addRectangle ) )
|
|
||||||
{
|
|
||||||
isDrawLine = false;
|
|
||||||
isImmediate = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
wxCHECK_MSG( false, 0, "Unknown action in PL_DRAWING_TOOLS::DrawShape()" );
|
|
||||||
|
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
|
|
||||||
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
WS_DRAW_ITEM_BASE* item = nullptr;
|
// Prime the pump
|
||||||
|
if( immediateMode )
|
||||||
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
|
@ -243,28 +210,26 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
item = nullptr;
|
item = nullptr;
|
||||||
m_frame->RollbackFromUndo();
|
m_frame->RollbackFromUndo();
|
||||||
|
|
||||||
if( !evt->IsActivate() && !isImmediate )
|
if( evt->IsActivate() || immediateMode )
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
|
m_frame->PopTool();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) || ( isImmediate && !item ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
if( !item ) // start drawing
|
if( !item ) // start drawing
|
||||||
{
|
{
|
||||||
m_frame->SaveCopyInUndoList();
|
m_frame->SaveCopyInUndoList();
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
WS_DATA_ITEM::WS_ITEM_TYPE dataType;
|
WS_DATA_ITEM* dataItem = m_frame->AddPageLayoutItem( type );
|
||||||
|
|
||||||
if( isDrawLine )
|
|
||||||
dataType = WS_DATA_ITEM::WS_SEGMENT;
|
|
||||||
else
|
|
||||||
dataType = WS_DATA_ITEM::WS_RECT;
|
|
||||||
|
|
||||||
WS_DATA_ITEM* dataItem = m_frame->AddPageLayoutItem( dataType );
|
|
||||||
dataItem->MoveToUi( (wxPoint) cursorPos );
|
dataItem->MoveToUi( (wxPoint) cursorPos );
|
||||||
|
|
||||||
item = dataItem->GetDrawItems()[0];
|
item = dataItem->GetDrawItems()[0];
|
||||||
|
@ -278,8 +243,9 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
if( isImmediate )
|
if( immediateMode )
|
||||||
{
|
{
|
||||||
|
m_frame->PopTool();
|
||||||
m_toolMgr->RunAction( ACTIONS::activatePointEditor );
|
m_toolMgr->RunAction( ACTIONS::activatePointEditor );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -306,12 +272,10 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is a shape being drawn
|
// Enable autopanning and cursor capture only when there is a shape being drawn
|
||||||
getViewControls()->SetAutoPan( !!item );
|
getViewControls()->SetAutoPan( item != nullptr );
|
||||||
getViewControls()->CaptureCursor( !!item );
|
getViewControls()->CaptureCursor( item != nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->SetNoToolSelected();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,9 +286,4 @@ void PL_DRAWING_TOOLS::setTransitions()
|
||||||
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::drawRectangle.MakeEvent() );
|
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::drawRectangle.MakeEvent() );
|
||||||
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::placeText.MakeEvent() );
|
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::placeText.MakeEvent() );
|
||||||
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::placeImage.MakeEvent() );
|
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::placeImage.MakeEvent() );
|
||||||
|
|
||||||
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::addLine.MakeEvent() );
|
|
||||||
Go( &PL_DRAWING_TOOLS::DrawShape, PL_ACTIONS::addRectangle.MakeEvent() );
|
|
||||||
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::addText.MakeEvent() );
|
|
||||||
Go( &PL_DRAWING_TOOLS::PlaceItem, PL_ACTIONS::addImage.MakeEvent() );
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,9 +101,9 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
if( selection.Empty() )
|
if( selection.Empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
m_frame->SetToolID( ID_PL_MOVE_TOOL, wxCURSOR_DEFAULT, _( "Move Items" ) );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
controls->ShowCursor( true );
|
controls->ShowCursor( true );
|
||||||
controls->SetAutoPan( true );
|
controls->SetAutoPan( true );
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Handle cancel
|
// Handle cancel
|
||||||
//
|
//
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( m_moveInProgress )
|
if( m_moveInProgress )
|
||||||
restore_state = true;
|
restore_state = true;
|
||||||
|
@ -232,9 +232,6 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
if( !chain_commands )
|
if( !chain_commands )
|
||||||
m_moveOffset = { 0, 0 };
|
m_moveOffset = { 0, 0 };
|
||||||
|
|
||||||
m_moveInProgress = false;
|
|
||||||
m_frame->SetNoToolSelected();
|
|
||||||
|
|
||||||
selection.ClearReferencePoint();
|
selection.ClearReferencePoint();
|
||||||
|
|
||||||
for( auto item : selection )
|
for( auto item : selection )
|
||||||
|
@ -248,6 +245,8 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
else
|
else
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
|
m_moveInProgress = false;
|
||||||
|
m_frame->PopTool();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
setControls();
|
setControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( m_cancelHandler )
|
if( m_cancelHandler )
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,7 +192,6 @@ int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->SaveCopyInUndoList();
|
m_frame->SaveCopyInUndoList();
|
||||||
controls->ForceCursorPosition( false );
|
controls->ForceCursorPosition( false );
|
||||||
m_frame->PushTool( _( "Drag Point" ).ToStdString() );
|
|
||||||
inDrag = true;
|
inDrag = true;
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
@ -206,21 +205,20 @@ int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||||
else if( inDrag && evt->IsMouseUp( BUT_LEFT ) )
|
else if( inDrag && evt->IsMouseUp( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
controls->SetAutoPan( false );
|
controls->SetAutoPan( false );
|
||||||
m_frame->PopTool();
|
|
||||||
inDrag = false;
|
inDrag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( inDrag ) // Restore the last change
|
if( inDrag ) // Restore the last change
|
||||||
{
|
{
|
||||||
m_frame->PopTool();
|
|
||||||
m_frame->RollbackFromUndo();
|
m_frame->RollbackFromUndo();
|
||||||
inDrag = false;
|
inDrag = false;
|
||||||
modified = false;
|
modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ESC should clear selection along with edit points
|
// ESC should clear selection along with edit points
|
||||||
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -71,10 +71,10 @@ bool PL_SELECTION_TOOL::Init()
|
||||||
auto& menu = m_menu.GetMenu();
|
auto& menu = m_menu.GetMenu();
|
||||||
|
|
||||||
menu.AddSeparator( 200 );
|
menu.AddSeparator( 200 );
|
||||||
menu.AddItem( PL_ACTIONS::addLine, PL_CONDITIONS::Idle, 250 );
|
menu.AddItem( PL_ACTIONS::drawLine, PL_CONDITIONS::Idle, 250 );
|
||||||
menu.AddItem( PL_ACTIONS::addRectangle, PL_CONDITIONS::Idle, 250 );
|
menu.AddItem( PL_ACTIONS::drawRectangle, PL_CONDITIONS::Idle, 250 );
|
||||||
menu.AddItem( PL_ACTIONS::addText, PL_CONDITIONS::Idle, 250 );
|
menu.AddItem( PL_ACTIONS::placeText, PL_CONDITIONS::Idle, 250 );
|
||||||
menu.AddItem( PL_ACTIONS::addImage, PL_CONDITIONS::Idle, 250 );
|
menu.AddItem( PL_ACTIONS::placeImage, PL_CONDITIONS::Idle, 250 );
|
||||||
menu.AddItem( PL_ACTIONS::appendImportedWorksheet, PL_CONDITIONS::Idle, 250 );
|
menu.AddItem( PL_ACTIONS::appendImportedWorksheet, PL_CONDITIONS::Idle, 250 );
|
||||||
|
|
||||||
menu.AddSeparator( 1000 );
|
menu.AddSeparator( 1000 );
|
||||||
|
@ -305,7 +305,7 @@ bool PL_SELECTION_TOOL::selectMultiple()
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -189,7 +189,7 @@ void LENGTH_TUNER_TOOL::performTuning()
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
break;
|
break;
|
||||||
else if( evt->IsMotion() )
|
else if( evt->IsMotion() )
|
||||||
{
|
{
|
||||||
|
@ -295,7 +295,7 @@ int LENGTH_TUNER_TOOL::mainLoop( PNS::ROUTER_MODE aMode )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
break; // Finish
|
break; // Finish
|
||||||
}
|
}
|
||||||
|
|
|
@ -808,7 +808,7 @@ void ROUTER_TOOL::performRouting()
|
||||||
still_routing = m_router->FixRoute( m_endSnapPoint, m_endItem );
|
still_routing = m_router->FixRoute( m_endSnapPoint, m_endItem );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate()
|
||||||
|| evt->IsUndoRedo()
|
|| evt->IsUndoRedo()
|
||||||
|| evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
|
|| evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
|
||||||
break;
|
break;
|
||||||
|
@ -916,7 +916,7 @@ int ROUTER_TOOL::mainLoop( PNS::ROUTER_MODE aMode )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
break; // Finish
|
break; // Finish
|
||||||
}
|
}
|
||||||
|
@ -1014,7 +1014,8 @@ void ROUTER_TOOL::performDragging( int aMode )
|
||||||
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
|
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsUndoRedo() )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate()
|
||||||
|
|| evt->IsUndoRedo() )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,7 +294,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
if( reselect && text )
|
if( reselect && text )
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( text )
|
if( text )
|
||||||
{
|
{
|
||||||
|
@ -490,7 +490,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), nullptr );
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), nullptr );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
m_controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
m_controls->SetAutoPan( false );
|
m_controls->SetAutoPan( false );
|
||||||
|
|
||||||
|
@ -803,7 +803,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_view->Update( &preview );
|
m_view->Update( &preview );
|
||||||
}
|
}
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
preview.FreeItems();
|
preview.FreeItems();
|
||||||
break;
|
break;
|
||||||
|
@ -874,7 +874,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_menu.ShowContextMenu( selection() );
|
m_menu.ShowContextMenu( selection() );
|
||||||
}
|
}
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,7 +961,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
|
||||||
frame()->SetMsgPanel( aGraphic );
|
frame()->SetMsgPanel( aGraphic );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
preview.Clear();
|
preview.Clear();
|
||||||
m_view->Update( &preview );
|
m_view->Update( &preview );
|
||||||
|
@ -1185,7 +1185,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
|
||||||
// update, but don't step the manager state
|
// update, but don't step the manager state
|
||||||
arcManager.AddPoint( cursorPos, false );
|
arcManager.AddPoint( cursorPos, false );
|
||||||
}
|
}
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
preview.Clear();
|
preview.Clear();
|
||||||
delete aGraphic;
|
delete aGraphic;
|
||||||
|
@ -1340,7 +1340,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), layers );
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), layers );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
m_controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
// pre-empted by another tool, give up
|
// pre-empted by another tool, give up
|
||||||
// cancelled without an inprogress polygon, give up
|
// cancelled without an inprogress polygon, give up
|
||||||
|
|
|
@ -1131,7 +1131,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
|
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
|
||||||
controls.ForceCursorPosition(true, cursorPos );
|
controls.ForceCursorPosition(true, cursorPos );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
VECTOR2I cursorPos = controls.GetCursorPosition();
|
VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
// overriding action, or we're cancelling without
|
// overriding action, or we're cancelling without
|
||||||
// an in-progress preview area
|
// an in-progress preview area
|
||||||
|
|
|
@ -482,7 +482,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that cancel-current-action has been handled, check for cancel-tool.
|
// Now that cancel-current-action has been handled, check for cancel-tool.
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
commit.Push( _( "Renumber pads" ) );
|
commit.Push( _( "Renumber pads" ) );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -542,7 +542,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
||||||
if( reselect && module )
|
if( reselect && module )
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( module )
|
if( module )
|
||||||
{
|
{
|
||||||
|
@ -719,7 +719,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
|
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
|
||||||
|
|
|
@ -76,7 +76,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer
|
||||||
VECTOR2I cursorPos = controls()->GetCursorPosition();
|
VECTOR2I cursorPos = controls()->GetCursorPosition();
|
||||||
aPlacer->m_modifiers = evt->Modifier();
|
aPlacer->m_modifiers = evt->Modifier();
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( newItem )
|
if( newItem )
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,7 +83,7 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
setControls();
|
setControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( m_cancelHandler )
|
if( m_cancelHandler )
|
||||||
{
|
{
|
||||||
|
|
|
@ -382,7 +382,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||||
m_refill = true;
|
m_refill = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( inDrag ) // Restore the last change
|
if( inDrag ) // Restore the last change
|
||||||
commit.Revert();
|
commit.Revert();
|
||||||
|
|
|
@ -525,7 +525,7 @@ bool SELECTION_TOOL::selectMultiple()
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue