Moved EDIT_TOOL::hoverSelection() code to SELECTION_TOOL::CursorSelection()

This commit is contained in:
Maciej Suminski 2017-02-09 09:47:32 +01:00 committed by Maciej Suminski
parent 14b9e5991b
commit a16586756f
2 changed files with 17 additions and 21 deletions

View File

@ -867,26 +867,8 @@ wxPoint EDIT_TOOL::getModificationPoint( const SELECTION& aSelection )
bool EDIT_TOOL::hoverSelection( bool aSanitize )
{
const SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Empty() ) // Try to find an item that could be modified
{
m_toolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true );
if( m_selectionTool->CheckLock() == SELECTION_LOCKED )
{
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
return false;
}
}
if( aSanitize )
m_selectionTool->SanitizeSelection();
if( selection.Empty() ) // TODO is it necessary?
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
return !selection.Empty();
m_toolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true, aSanitize );
return !m_selectionTool->GetSelection().Empty();
}

View File

@ -507,7 +507,21 @@ SELECTION_LOCK_FLAGS SELECTION_TOOL::CheckLock()
int SELECTION_TOOL::CursorSelection( const TOOL_EVENT& aEvent )
{
selectCursor( true );
bool sanitize = (bool) aEvent.Parameter<intptr_t>();
if( m_selection.Empty() ) // Try to find an item that could be modified
{
selectCursor( true );
if( CheckLock() == SELECTION_LOCKED )
{
clearSelection();
return 0;
}
}
if( sanitize )
SanitizeSelection();
return 0;
}