mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
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_hasPosition = false;
|
||||||
|
|
||||||
m_forceImmediate = false;
|
m_forceImmediate = false;
|
||||||
|
m_reactivate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ void TOOLS_HOLDER::PopTool( const std::string& actionName )
|
|||||||
|
|
||||||
TOOL_EVENT evt = action->MakeEvent();
|
TOOL_EVENT evt = action->MakeEvent();
|
||||||
evt.SetHasPosition( false );
|
evt.SetHasPosition( false );
|
||||||
|
evt.SetReactivate( true );
|
||||||
GetToolManager()->PostEvent( evt );
|
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*>();
|
SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
|
||||||
SCHLIB_FILTER filter;
|
SCHLIB_FILTER filter;
|
||||||
@ -130,7 +130,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
|||||||
getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) );
|
getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) );
|
||||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||||
}
|
}
|
||||||
else
|
else if( !aEvent.IsReactivate() )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::cursorClick );
|
m_toolMgr->RunAction( EE_ACTIONS::cursorClick );
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||||||
// Prime the pump
|
// Prime the pump
|
||||||
if( image )
|
if( image )
|
||||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||||
else if( aEvent.HasPosition() )
|
else if( !aEvent.IsReactivate() )
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
@ -903,7 +903,6 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||||||
SCH_ITEM* item = nullptr;
|
SCH_ITEM* item = nullptr;
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
EE_GRID_HELPER grid( m_toolMgr );
|
EE_GRID_HELPER grid( m_toolMgr );
|
||||||
|
|
||||||
if( m_inTwoClickPlace )
|
if( m_inTwoClickPlace )
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
@ -924,8 +923,12 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Prime the pump
|
// 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 );
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
}
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
@ -997,7 +1000,6 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||||||
}
|
}
|
||||||
else if( evt->IsMoveTool() )
|
else if( evt->IsMoveTool() )
|
||||||
{
|
{
|
||||||
// leave ourselves on the stack so we come back after the move
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -85,7 +85,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Prime the pump
|
// Prime the pump
|
||||||
if( aEvent.HasPosition() )
|
if( aEvent.HasPosition() || ( isText && !aEvent.IsReactivate() ) )
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
|
@ -136,6 +136,8 @@ public:
|
|||||||
|
|
||||||
TOOL_ACTION_SCOPE GetScope() const { return m_scope; }
|
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
|
* 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
|
* stripped of the last part (e.g. for "pcbnew.InteractiveDrawing.drawCircle" it is
|
||||||
|
@ -113,11 +113,14 @@ enum TOOL_ACTIONS
|
|||||||
// Tool activation event.
|
// Tool activation event.
|
||||||
TA_ACTIVATE = 0x100000,
|
TA_ACTIVATE = 0x100000,
|
||||||
|
|
||||||
|
// Tool re-activation event for tools already on the stack
|
||||||
|
TA_REACTIVATE = 0x200000,
|
||||||
|
|
||||||
// Model has changed (partial update).
|
// Model has changed (partial update).
|
||||||
TA_MODEL_CHANGE = 0x200000,
|
TA_MODEL_CHANGE = 0x400000,
|
||||||
|
|
||||||
// Tool priming event (a special mouse click)
|
// Tool priming event (a special mouse click)
|
||||||
TA_PRIME = 0x400001,
|
TA_PRIME = 0x800001,
|
||||||
|
|
||||||
TA_ANY = 0xffffffff
|
TA_ANY = 0xffffffff
|
||||||
};
|
};
|
||||||
@ -266,6 +269,10 @@ public:
|
|||||||
TOOL_BASE* FirstResponder() const { return m_firstResponder; }
|
TOOL_BASE* FirstResponder() const { return m_firstResponder; }
|
||||||
void SetFirstResponder( TOOL_BASE* aTool ) { m_firstResponder = aTool; }
|
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
|
///< Returns information about difference between current mouse cursor position and the place
|
||||||
///< where dragging has started.
|
///< where dragging has started.
|
||||||
const VECTOR2D Delta() const
|
const VECTOR2D Delta() const
|
||||||
@ -527,6 +534,9 @@ private:
|
|||||||
bool m_hasPosition;
|
bool m_hasPosition;
|
||||||
bool m_forceImmediate;
|
bool m_forceImmediate;
|
||||||
|
|
||||||
|
///< True when the tool is being re-activated from the stack
|
||||||
|
bool m_reactivate;
|
||||||
|
|
||||||
///< Difference between mouse cursor position and
|
///< Difference between mouse cursor position and
|
||||||
///< the point where dragging event has started
|
///< the point where dragging event has started
|
||||||
VECTOR2D m_mouseDelta;
|
VECTOR2D m_mouseDelta;
|
||||||
|
@ -88,7 +88,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Prime the pump
|
// Prime the pump
|
||||||
if( aEvent.HasPosition() || isText )
|
if( aEvent.HasPosition() || ( !aEvent.IsReactivate() && isText ) )
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
auto setCursor =
|
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( PCB_ACTIONS::selectItem, true, fp );
|
||||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||||
}
|
}
|
||||||
else
|
else if( !aEvent.IsReactivate() )
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::cursorClick );
|
m_toolMgr->RunAction( PCB_ACTIONS::cursorClick );
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
|
@ -436,7 +436,8 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Prime the pump
|
// Prime the pump
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
if( !aEvent.IsReactivate() )
|
||||||
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user