libedit: Add drag to move behavior
ADDED: Drag to move behavior in the symbol editor Fixes https://gitlab.com/kicad/code/kicad/issues/1904
This commit is contained in:
parent
60891f0b6d
commit
facf40d3ce
|
@ -677,4 +677,6 @@ TOOL_ACTION EE_ACTIONS::moveActivate( "eeschema.InteractiveMove",
|
|||
AS_GLOBAL, 0, "",
|
||||
_( "Move Activate" ), "", move_xpm, AF_ACTIVATE );
|
||||
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::symbolMoveActivate( "eeschema.SymbolMoveTool",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "Symbol Move Activate" ), "", move_xpm, AF_ACTIVATE );
|
||||
|
|
|
@ -111,7 +111,8 @@ public:
|
|||
static TOOL_ACTION finishDrawing;
|
||||
|
||||
// Interactive Editing
|
||||
static TOOL_ACTION moveActivate;
|
||||
static TOOL_ACTION symbolMoveActivate; // Symbol editor move tool activate
|
||||
static TOOL_ACTION moveActivate; // Schematic editor move tool activate
|
||||
static TOOL_ACTION move;
|
||||
static TOOL_ACTION drag;
|
||||
static TOOL_ACTION repeatDrawItem;
|
||||
|
@ -206,7 +207,7 @@ public:
|
|||
static TOOL_ACTION highlightNetTool;
|
||||
|
||||
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
|
||||
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override
|
||||
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override
|
||||
{
|
||||
return OPT<TOOL_EVENT>();
|
||||
}
|
||||
|
|
|
@ -255,27 +255,43 @@ int EE_SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
const KICAD_T movableSchematicItems[] =
|
||||
{
|
||||
SCH_MARKER_T,
|
||||
SCH_JUNCTION_T,
|
||||
SCH_NO_CONNECT_T,
|
||||
SCH_BUS_BUS_ENTRY_T,
|
||||
SCH_BUS_WIRE_ENTRY_T,
|
||||
SCH_LINE_T,
|
||||
SCH_BITMAP_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_FIELD_T,
|
||||
SCH_COMPONENT_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
SCH_SHEET_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T movableSymbolItems[] =
|
||||
{
|
||||
LIB_ARC_T,
|
||||
LIB_CIRCLE_T,
|
||||
LIB_TEXT_T,
|
||||
LIB_RECTANGLE_T,
|
||||
LIB_POLYLINE_T,
|
||||
LIB_BEZIER_T,
|
||||
LIB_PIN_T,
|
||||
LIB_FIELD_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
const KICAD_T movableItems[] =
|
||||
{
|
||||
SCH_MARKER_T,
|
||||
SCH_JUNCTION_T,
|
||||
SCH_NO_CONNECT_T,
|
||||
SCH_BUS_BUS_ENTRY_T,
|
||||
SCH_BUS_WIRE_ENTRY_T,
|
||||
SCH_LINE_T,
|
||||
SCH_BITMAP_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_FIELD_T,
|
||||
SCH_COMPONENT_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
SCH_SHEET_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
|
@ -351,14 +367,19 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
// selection is empty? try to start dragging the item under the point where drag
|
||||
// started
|
||||
if( m_selection.Empty() )
|
||||
m_selection = RequestSelection( movableItems );
|
||||
if( m_isLibEdit && m_selection.Empty() )
|
||||
m_selection = RequestSelection( movableSymbolItems );
|
||||
else if( m_selection.Empty() )
|
||||
m_selection = RequestSelection( movableSchematicItems );
|
||||
|
||||
// Check if dragging has started within any of selected items bounding box
|
||||
if( selectionContains( evt->Position() ) )
|
||||
{
|
||||
// Yes -> run the move tool and wait till it finishes
|
||||
m_toolMgr->InvokeTool( "eeschema.InteractiveMove" );
|
||||
if( m_isLibEdit )
|
||||
m_toolMgr->InvokeTool( "eeschema.SymbolMoveTool" );
|
||||
else
|
||||
m_toolMgr->InvokeTool( "eeschema.InteractiveMove" );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -106,7 +106,8 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
||||
|| evt->IsAction( &ACTIONS::refreshPreview ) )
|
||||
|| evt->IsAction( &ACTIONS::refreshPreview )
|
||||
|| evt->IsAction( &EE_ACTIONS::symbolMoveActivate ) )
|
||||
{
|
||||
if( !m_moveInProgress ) // Prepare to start moving/dragging
|
||||
{
|
||||
|
@ -334,4 +335,5 @@ bool LIB_MOVE_TOOL::updateModificationPoint( EE_SELECTION& aSelection )
|
|||
void LIB_MOVE_TOOL::setTransitions()
|
||||
{
|
||||
Go( &LIB_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
|
||||
Go( &LIB_MOVE_TOOL::Main, EE_ACTIONS::symbolMoveActivate.MakeEvent() );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue