Handle de-highlighting items outside selection when selection changes.

Also adds selection cleared event to handled events.

And a small performance boost to not scan items for selection changes
when find is not seleciton-based.
This commit is contained in:
Jeff Young 2023-02-23 16:22:21 +00:00
parent d9a77e6a64
commit ddf8d115c4
1 changed files with 28 additions and 28 deletions

View File

@ -64,50 +64,50 @@ int SCH_FIND_REPLACE_TOOL::UpdateFind( const TOOL_EVENT& aEvent )
} }
}; };
auto visitAll =
[&]()
{
for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
{
visit( item, &m_frame->GetCurrentSheet() );
item->RunOnChildren(
[&]( SCH_ITEM* aChild )
{
visit( aChild, &m_frame->GetCurrentSheet() );
} );
}
};
if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace ) if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
|| aEvent.IsAction( &ACTIONS::updateFind ) ) || aEvent.IsAction( &ACTIONS::updateFind ) )
{ {
m_foundItemHighlighted = false; m_foundItemHighlighted = false;
visitAll();
for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
{
visit( item, &m_frame->GetCurrentSheet() );
item->RunOnChildren(
[&]( SCH_ITEM* aChild )
{
visit( aChild, &m_frame->GetCurrentSheet() );
} );
}
} }
else if( aEvent.Matches( EVENTS::SelectedItemsModified ) else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
|| aEvent.Matches( EVENTS::PointSelectedEvent ) {
for( EDA_ITEM* item : m_selectionTool->GetSelection() )
visit( item, &m_frame->GetCurrentSheet() );
}
else if( aEvent.Matches( EVENTS::PointSelectedEvent )
|| aEvent.Matches( EVENTS::SelectedEvent ) || aEvent.Matches( EVENTS::SelectedEvent )
|| aEvent.Matches( EVENTS::UnselectedEvent ) ) || aEvent.Matches( EVENTS::UnselectedEvent )
|| aEvent.Matches( EVENTS::ClearedEvent ) )
{ {
// Normal find modifies the selection, but selection-based find does // Normal find modifies the selection, but selection-based find does
// not so we want to start over in the items we are searching through when // not so we want to start over in the items we are searching through when
// the selection changes // the selection changes
if( selectedOnly ) if( selectedOnly )
{
m_afterItem = nullptr; m_afterItem = nullptr;
visitAll();
for( EDA_ITEM* item : m_selectionTool->GetSelection() ) }
visit( item, &m_frame->GetCurrentSheet() );
} }
else if( m_foundItemHighlighted ) else if( m_foundItemHighlighted )
{ {
m_foundItemHighlighted = false; m_foundItemHighlighted = false;
visitAll();
for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
{
visit( item, &m_frame->GetCurrentSheet() );
item->RunOnChildren(
[&]( SCH_ITEM* aChild )
{
visit( aChild, &m_frame->GetCurrentSheet() );
} );
}
} }
getView()->UpdateItems(); getView()->UpdateItems();