Inhibit point editor while drag-selecting

Fixes https://gitlab.com/kicad/code/kicad/-/issues/6155
This commit is contained in:
Jon Evans 2020-10-25 12:13:25 -04:00
parent 13baea4900
commit 09ade9fe51
4 changed files with 14 additions and 2 deletions

View File

@ -634,4 +634,6 @@ const TOOL_EVENT EVENTS::ClearedEvent( TC_MESSAGE, TA_ACTION, "common.Interactiv
const TOOL_EVENT EVENTS::SelectedItemsModified( TC_MESSAGE, TA_ACTION, "common.Interactive.modified" );
const TOOL_EVENT EVENTS::SelectedItemsMoved( TC_MESSAGE, TA_ACTION, "common.Interactive.moved" );
const TOOL_EVENT EVENTS::InhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.inhibit" );
const TOOL_EVENT EVENTS::UninhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.uninhibit" );

View File

@ -214,6 +214,10 @@ public:
//< Selected items were moved, this can be very high frequency on the canvas, use with care
const static TOOL_EVENT SelectedItemsMoved;
///> Used to inform tools that the selection should temporarily be non-editable
const static TOOL_EVENT InhibitSelectionEditing;
const static TOOL_EVENT UninhibitSelectionEditing;
};
#endif // __ACTIONS_H

View File

@ -394,7 +394,7 @@ void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
{
if( !m_selectionTool )
if( !m_selectionTool || aEvent.Matches( EVENTS::InhibitSelectionEditing ) )
return 0;
const PCBNEW_SELECTION& selection = m_selectionTool->GetSelection();
@ -439,7 +439,8 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( editFrame->IsGridVisible() );
if( !m_editPoints || evt->IsSelectionEvent() )
if( !m_editPoints || evt->IsSelectionEvent() ||
evt->Matches( EVENTS::InhibitSelectionEditing ) )
break;
EDIT_POINT* prevHover = m_hoveredPoint;
@ -2148,4 +2149,6 @@ void POINT_EDITOR::setTransitions()
Go( &POINT_EDITOR::OnSelectionChange, EVENTS::SelectedEvent );
Go( &POINT_EDITOR::OnSelectionChange, EVENTS::UnselectedEvent );
Go( &POINT_EDITOR::changeEditMethod, ACTIONS::changeEditMethod.MakeEvent() );
Go( &POINT_EDITOR::OnSelectionChange, EVENTS::InhibitSelectionEditing );
Go( &POINT_EDITOR::OnSelectionChange, EVENTS::UninhibitSelectionEditing );
}

View File

@ -285,6 +285,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
else if( evt->IsDrag( BUT_LEFT ) )
{
m_frame->FocusOnItem( nullptr );
m_toolMgr->ProcessEvent( EVENTS::InhibitSelectionEditing );
if( modifier_enabled || dragAlwaysSelects )
{
@ -756,6 +757,8 @@ bool SELECTION_TOOL::selectMultiple()
if( !cancelled )
m_selection.ClearReferencePoint();
m_toolMgr->ProcessEvent( EVENTS::UninhibitSelectionEditing );
return cancelled;
}