From 063478b3dc2257641a43fa9830902fcdd89976d5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 8 Jan 2023 14:27:54 +0000 Subject: [PATCH] Implement brightening for Find Next hotkey actions. Fixes https://gitlab.com/kicad/code/kicad/issues/13421 --- eeschema/tools/sch_editor_control.cpp | 30 +++++++++++++++++++++++++++ eeschema/tools/sch_editor_control.h | 21 ++++++++++--------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index fc91f93197..8314c6932a 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -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 ); diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index 6e11a67523..27cf02cec9 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -42,7 +42,8 @@ public: EE_TOOL_BASE( "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 m_supplementaryClipboard; + std::map m_supplementaryClipboard; // A map of KIID_PATH --> symbol instances for the clipboard contents. std::map m_clipboardSymbolInstances; // A map of KIID_PATH --> sheet instances for the clipboard contents. - std::map m_clipboardSheetInstances; - - // A timer during which a subsequent FindNext will result in a wrap-around - wxTimer m_wrapAroundTimer; + std::map m_clipboardSheetInstances; };