Selection: refactor modifier checking
This commit is contained in:
parent
78b5dbead6
commit
0e75bf02fa
|
@ -83,6 +83,12 @@ void SELECTION_TOOL::setModifiersState( bool aShiftState, bool aCtrlState, bool
|
|||
}
|
||||
|
||||
|
||||
bool SELECTION_TOOL::hasModifier()
|
||||
{
|
||||
return m_subtractive || m_additive || m_exclusive_or;
|
||||
}
|
||||
|
||||
|
||||
int SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
|
||||
|
|
|
@ -344,8 +344,6 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
|
||||
evt->Modifier( MD_ALT ) );
|
||||
|
||||
bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or;
|
||||
|
||||
MOUSE_DRAG_ACTION drag_action = m_frame->GetDragAction();
|
||||
EE_GRID_HELPER grid( m_toolMgr );
|
||||
|
||||
|
@ -354,7 +352,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
// Avoid triggering when running under other tools
|
||||
// Distinguish point editor from selection modification by checking modifiers
|
||||
if( m_frame->ToolStackIsEmpty() && m_toolMgr->GetTool<EE_POINT_EDITOR>()
|
||||
&& ( !m_toolMgr->GetTool<EE_POINT_EDITOR>()->HasPoint() || modifier_enabled ) )
|
||||
&& ( !m_toolMgr->GetTool<EE_POINT_EDITOR>()->HasPoint() || hasModifier() ) )
|
||||
{
|
||||
m_originalCursor = m_toolMgr->GetMousePosition();
|
||||
m_disambiguateTimer.StartOnce( 500 );
|
||||
|
@ -381,7 +379,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
CollectHits( collector, evt->Position() );
|
||||
narrowSelection( collector, evt->Position(), false );
|
||||
|
||||
if( collector.GetCount() == 1 && !m_isSymbolEditor && !modifier_enabled )
|
||||
if( collector.GetCount() == 1 && !m_isSymbolEditor && !hasModifier() )
|
||||
{
|
||||
OPT_TOOL_EVENT autostart = autostartEvent( evt, grid, collector[0] );
|
||||
|
||||
|
@ -498,7 +496,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
|
||||
schframe->FocusOnItem( nullptr );
|
||||
|
||||
if( modifier_enabled || drag_action == MOUSE_DRAG_ACTION::SELECT )
|
||||
if( hasModifier() || drag_action == MOUSE_DRAG_ACTION::SELECT )
|
||||
{
|
||||
selectMultiple();
|
||||
}
|
||||
|
@ -611,7 +609,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
narrowSelection( collector, evt->Position(), false );
|
||||
|
||||
if( collector.GetCount() == 1 && !modifier_enabled )
|
||||
if( collector.GetCount() == 1 && !hasModifier() )
|
||||
{
|
||||
OPT_TOOL_EVENT autostartEvt = autostartEvent( evt, grid, collector[0] );
|
||||
|
||||
|
|
|
@ -116,6 +116,11 @@ protected:
|
|||
*/
|
||||
void setModifiersState( bool aShiftState, bool aCtrlState, bool aAltState );
|
||||
|
||||
/**
|
||||
* True if a selection modifier is enabled, false otherwise.
|
||||
*/
|
||||
bool hasModifier();
|
||||
|
||||
/**
|
||||
* Determines if ctrl-click is highlight net or XOR selection.
|
||||
*/
|
||||
|
|
|
@ -89,8 +89,6 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
|
||||
evt->Modifier( MD_ALT ) );
|
||||
|
||||
bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or;
|
||||
|
||||
if( evt->IsMouseDown( BUT_LEFT ) )
|
||||
{
|
||||
// Avoid triggering when running under other tools
|
||||
|
@ -144,7 +142,7 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
m_disambiguateTimer.Stop();
|
||||
|
||||
if( modifier_enabled || m_selection.Empty() )
|
||||
if( hasModifier() || m_selection.Empty() )
|
||||
{
|
||||
selectMultiple();
|
||||
}
|
||||
|
@ -187,7 +185,7 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( m_frame->ToolStackIsEmpty() )
|
||||
{
|
||||
if( !modifier_enabled
|
||||
if( !hasModifier()
|
||||
&& !m_selection.Empty()
|
||||
&& m_frame->GetDragAction() == MOUSE_DRAG_ACTION::DRAG_SELECTED
|
||||
&& evt->HasPosition()
|
||||
|
|
|
@ -272,7 +272,6 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
|
||||
evt->Modifier( MD_ALT ) );
|
||||
|
||||
bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or;
|
||||
PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
|
||||
bool brd_editor = frame && frame->IsType( FRAME_PCB_EDITOR );
|
||||
ROUTER_TOOL* router = m_toolMgr->GetTool<ROUTER_TOOL>();
|
||||
|
@ -370,7 +369,7 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
m_frame->FocusOnItem( nullptr );
|
||||
m_toolMgr->ProcessEvent( EVENTS::InhibitSelectionEditing );
|
||||
|
||||
if( modifier_enabled || dragAction == MOUSE_DRAG_ACTION::SELECT )
|
||||
if( hasModifier() || dragAction == MOUSE_DRAG_ACTION::SELECT )
|
||||
{
|
||||
selectMultiple();
|
||||
}
|
||||
|
@ -477,7 +476,7 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
if( m_frame->ToolStackIsEmpty() )
|
||||
{
|
||||
// move cursor prediction
|
||||
if( !modifier_enabled
|
||||
if( !hasModifier()
|
||||
&& dragAction == MOUSE_DRAG_ACTION::DRAG_SELECTED
|
||||
&& !m_selection.Empty()
|
||||
&& evt->HasPosition()
|
||||
|
|
Loading…
Reference in New Issue