Fixup toolchaining for immediate mode
The move tool can stack on others, so when we re-enter the previous tool this caused another immediate action. We flag re-entry in the tool stack to check for this and avoid unexpected tool starts
This commit is contained in:
parent
0a9a9d625e
commit
0bab025832
|
@ -63,6 +63,7 @@ void TOOL_EVENT::init()
|
|||
m_hasPosition = false;
|
||||
|
||||
m_forceImmediate = false;
|
||||
m_reactivate = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ void TOOLS_HOLDER::PopTool( const std::string& actionName )
|
|||
|
||||
TOOL_EVENT evt = action->MakeEvent();
|
||||
evt.SetHasPosition( false );
|
||||
evt.SetReactivate( true );
|
||||
GetToolManager()->PostEvent( evt );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ bool SCH_DRAWING_TOOLS::Init()
|
|||
}
|
||||
|
||||
|
||||
int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||
int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
|
||||
SCHLIB_FILTER filter;
|
||||
|
@ -130,7 +130,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
|||
getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) );
|
||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||
}
|
||||
else
|
||||
else if( !aEvent.IsReactivate() )
|
||||
{
|
||||
m_toolMgr->RunAction( EE_ACTIONS::cursorClick );
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
// Prime the pump
|
||||
if( image )
|
||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||
else if( aEvent.HasPosition() )
|
||||
else if( !aEvent.IsReactivate() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
|
@ -903,7 +903,6 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
SCH_ITEM* item = nullptr;
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
EE_GRID_HELPER grid( m_toolMgr );
|
||||
|
||||
if( m_inTwoClickPlace )
|
||||
return 0;
|
||||
else
|
||||
|
@ -924,8 +923,12 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
Activate();
|
||||
|
||||
// Prime the pump
|
||||
if( aEvent.HasPosition() || isText || isGlobalLabel || isHierLabel || isNetLabel )
|
||||
// If the tool isn't being re-activated
|
||||
if( aEvent.HasPosition() || ( !aEvent.IsReactivate()
|
||||
&& ( isText || isGlobalLabel || isHierLabel || isNetLabel ) ) )
|
||||
{
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
}
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -997,7 +1000,6 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else if( evt->IsMoveTool() )
|
||||
{
|
||||
// leave ourselves on the stack so we come back after the move
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -85,7 +85,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
Activate();
|
||||
|
||||
// Prime the pump
|
||||
if( aEvent.HasPosition() )
|
||||
if( aEvent.HasPosition() || ( isText && !aEvent.IsReactivate() ) )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
|
|
|
@ -136,6 +136,8 @@ public:
|
|||
|
||||
TOOL_ACTION_SCOPE GetScope() const { return m_scope; }
|
||||
|
||||
void* GetParam() const { return m_param; }
|
||||
|
||||
/**
|
||||
* Return name of the tool associated with the action. It is basically the action name
|
||||
* stripped of the last part (e.g. for "pcbnew.InteractiveDrawing.drawCircle" it is
|
||||
|
|
|
@ -113,11 +113,14 @@ enum TOOL_ACTIONS
|
|||
// Tool activation event.
|
||||
TA_ACTIVATE = 0x100000,
|
||||
|
||||
// Tool re-activation event for tools already on the stack
|
||||
TA_REACTIVATE = 0x200000,
|
||||
|
||||
// Model has changed (partial update).
|
||||
TA_MODEL_CHANGE = 0x200000,
|
||||
TA_MODEL_CHANGE = 0x400000,
|
||||
|
||||
// Tool priming event (a special mouse click)
|
||||
TA_PRIME = 0x400001,
|
||||
TA_PRIME = 0x800001,
|
||||
|
||||
TA_ANY = 0xffffffff
|
||||
};
|
||||
|
@ -266,6 +269,10 @@ public:
|
|||
TOOL_BASE* FirstResponder() const { return m_firstResponder; }
|
||||
void SetFirstResponder( TOOL_BASE* aTool ) { m_firstResponder = aTool; }
|
||||
|
||||
///< Controls whether the tool is first being pushed to the stack or being reactivated after a pause
|
||||
bool IsReactivate() const { return m_reactivate; }
|
||||
void SetReactivate( bool aReactivate = true ) { m_reactivate = aReactivate; }
|
||||
|
||||
///< Returns information about difference between current mouse cursor position and the place
|
||||
///< where dragging has started.
|
||||
const VECTOR2D Delta() const
|
||||
|
@ -527,6 +534,9 @@ private:
|
|||
bool m_hasPosition;
|
||||
bool m_forceImmediate;
|
||||
|
||||
///< True when the tool is being re-activated from the stack
|
||||
bool m_reactivate;
|
||||
|
||||
///< Difference between mouse cursor position and
|
||||
///< the point where dragging event has started
|
||||
VECTOR2D m_mouseDelta;
|
||||
|
|
|
@ -88,7 +88,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||
Activate();
|
||||
|
||||
// Prime the pump
|
||||
if( aEvent.HasPosition() || isText )
|
||||
if( aEvent.HasPosition() || ( !aEvent.IsReactivate() && isText ) )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
|
|
|
@ -818,7 +818,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, fp );
|
||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||
}
|
||||
else
|
||||
else if( !aEvent.IsReactivate() )
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
|
|
|
@ -436,7 +436,8 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
Activate();
|
||||
|
||||
// Prime the pump
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
if( !aEvent.IsReactivate() )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
|
Loading…
Reference in New Issue