From facf40d3ce195ffcf6dd9429a531bb62cf2be3e8 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 23 Apr 2020 23:57:34 +0100 Subject: [PATCH] libedit: Add drag to move behavior ADDED: Drag to move behavior in the symbol editor Fixes https://gitlab.com/kicad/code/kicad/issues/1904 --- eeschema/tools/ee_actions.cpp | 4 +- eeschema/tools/ee_actions.h | 5 ++- eeschema/tools/ee_selection_tool.cpp | 65 ++++++++++++++++++---------- eeschema/tools/lib_move_tool.cpp | 4 +- 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 790bfcdedb..51f729150b 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -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 ); diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 60e2ac6920..66b2e26be6 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -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 TranslateLegacyId( int aId ) override + virtual OPT TranslateLegacyId( int aId ) override { return OPT(); } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 8872143ace..9f14bbd7f8 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -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 { diff --git a/eeschema/tools/lib_move_tool.cpp b/eeschema/tools/lib_move_tool.cpp index f3f43d39a5..77441127a5 100644 --- a/eeschema/tools/lib_move_tool.cpp +++ b/eeschema/tools/lib_move_tool.cpp @@ -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() ); }