Implement brightening for Find Next hotkey actions.

Fixes https://gitlab.com/kicad/code/kicad/issues/13421
This commit is contained in:
Jeff Young 2023-01-08 14:27:54 +00:00
parent 4d5c4c4ea8
commit 063478b3dc
2 changed files with 41 additions and 10 deletions

View File

@ -337,6 +337,7 @@ int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
{
aItem->SetForceVisible( true );
m_selectionTool->BrightenItem( aItem );
m_foundItemHighlighted = true;
}
else if( aItem->IsBrightened() )
{
@ -348,6 +349,7 @@ int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
|| aEvent.IsAction( &ACTIONS::updateFind ) )
{
m_foundItemHighlighted = false;
m_selectionTool->ClearSelection();
for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
@ -366,6 +368,21 @@ int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
for( EDA_ITEM* item : m_selectionTool->GetSelection() )
visit( item, &m_frame->GetCurrentSheet() );
}
else if( m_foundItemHighlighted )
{
m_foundItemHighlighted = false;
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();
m_frame->GetCanvas()->Refresh();
@ -550,6 +567,17 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
if( item )
{
if( !item->IsBrightened() )
{
// Clear any previous brightening
UpdateFind( aEvent );
// Brighten (and show) found object
item->SetForceVisible( true );
m_selectionTool->BrightenItem( item );
m_foundItemHighlighted = true;
}
m_selectionTool->AddItemToSel( item );
m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
m_frame->GetCanvas()->Refresh();
@ -2615,6 +2643,8 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::ReplaceAll, ACTIONS::replaceAll.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::UpdateFind, ACTIONS::updateFind.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::UpdateFind, EVENTS::SelectedItemsModified );
Go( &SCH_EDITOR_CONTROL::UpdateFind, EVENTS::PointSelectedEvent );
Go( &SCH_EDITOR_CONTROL::UpdateFind, EVENTS::SelectedEvent );
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::PointSelectedEvent );
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::SelectedEvent );

View File

@ -42,7 +42,8 @@ public:
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" ),
m_probingPcbToSch( false ),
m_pickerItem( nullptr ),
m_duplicateIsHoverSelection( false )
m_duplicateIsHoverSelection( false ),
m_foundItemHighlighted( false )
{ }
~SCH_EDITOR_CONTROL() { }
@ -225,25 +226,25 @@ private:
EDA_SEARCH_DATA& aData );
private:
bool m_probingPcbToSch; // Recursion guard when cross-probing to schematic editor
EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
bool m_probingPcbToSch; // Recursion guard for PCB to schematic cross-probing
EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
// Temporary storage location for Duplicate action
std::string m_duplicateClipboard;
std::string m_duplicateClipboard; // Temporary storage for Duplicate action
bool m_duplicateIsHoverSelection;
bool m_foundItemHighlighted;
wxTimer m_wrapAroundTimer; // A timer during which a subsequent FindNext will
// result in a wrap-around
// A map of sheet filename --> screens for the clipboard contents. We use these to hook up
// cut/paste operations for unsaved sheet content.
std::map<wxString, SCH_SCREEN*> m_supplementaryClipboard;
std::map<wxString, SCH_SCREEN*> m_supplementaryClipboard;
// A map of KIID_PATH --> symbol instances for the clipboard contents.
std::map<KIID_PATH, SCH_SYMBOL_INSTANCE> m_clipboardSymbolInstances;
// A map of KIID_PATH --> sheet instances for the clipboard contents.
std::map<KIID_PATH, SCH_SHEET_INSTANCE> m_clipboardSheetInstances;
// A timer during which a subsequent FindNext will result in a wrap-around
wxTimer m_wrapAroundTimer;
std::map<KIID_PATH, SCH_SHEET_INSTANCE> m_clipboardSheetInstances;
};