From 4dd049ee8f34928151a2bd92490f3cfe34dec1d6 Mon Sep 17 00:00:00 2001 From: John Beard Date: Sun, 5 May 2024 04:17:26 +0800 Subject: [PATCH] Add action to focus tree searches The default hotkey is Ctrl+L, as this is not bound by default in the FP or symbol editor, and it is the hotkey that is used to focus the address bar in web browsers, which is a similar kind of action. --- eeschema/symbol_editor/symbol_edit_frame.cpp | 6 ++++++ eeschema/symbol_editor/symbol_edit_frame.h | 1 + eeschema/tools/ee_actions.cpp | 6 ++++++ eeschema/tools/ee_actions.h | 1 + eeschema/tools/symbol_editor_control.cpp | 19 +++++++++++++++++++ eeschema/tools/symbol_editor_control.h | 1 + pcbnew/footprint_edit_frame.cpp | 6 ++++++ pcbnew/footprint_edit_frame.h | 1 + pcbnew/tools/footprint_editor_control.cpp | 11 +++++++++++ pcbnew/tools/footprint_editor_control.h | 1 + pcbnew/tools/pcb_actions.cpp | 6 ++++++ pcbnew/tools/pcb_actions.h | 1 + 12 files changed, 60 insertions(+) diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index b7eaacb92f..074027cdec 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -711,6 +711,12 @@ bool SYMBOL_EDIT_FRAME::IsSymbolTreeShown() const } +void SYMBOL_EDIT_FRAME::FocusSearchTreeInput() +{ + m_treePane->GetLibTree()->FocusSearchFieldIfExists(); +} + + void SYMBOL_EDIT_FRAME::FreezeLibraryTree() { m_treePane->Freeze(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 02111f7e3c..095e75de32 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -185,6 +185,7 @@ public: void ToggleProperties() override; bool IsSymbolTreeShown() const; + void FocusSearchTreeInput(); void FreezeLibraryTree(); void ThawLibraryTree(); diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 22db126cec..03cefffa9b 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -289,6 +289,12 @@ TOOL_ACTION EE_ACTIONS::hideSymbolTree( TOOL_ACTION_ARGS() .FriendlyName( _( "Hide Symbol Tree" ) ) .Icon( BITMAPS::search_tree ) ); +TOOL_ACTION EE_ACTIONS::symbolTreeSearch( TOOL_ACTION_ARGS() + .Name( "eeschema.SymbolLibraryControl.symbolTreeSearch" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Focus Symbol Tree Search Field" ) ) + .DefaultHotkey( MD_CTRL + 'L' ) ); + TOOL_ACTION EE_ACTIONS::exportSymbolView( TOOL_ACTION_ARGS() .Name( "eeschema.SymbolLibraryControl.exportSymbolView" ) .Scope( AS_GLOBAL ) diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index db4feb9032..813970f50a 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -251,6 +251,7 @@ public: static TOOL_ACTION showPinNumbers; static TOOL_ACTION showSymbolTree; static TOOL_ACTION hideSymbolTree; + static TOOL_ACTION symbolTreeSearch; static TOOL_ACTION drawSheetOnClipboard; static TOOL_ACTION importGraphics; static TOOL_ACTION exportSymbolView; diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index 53681f7f0f..c65c0807a0 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -550,6 +550,24 @@ int SYMBOL_EDITOR_CONTROL::ToggleSymbolTree( const TOOL_EVENT& aEvent ) } +int SYMBOL_EDITOR_CONTROL::SymbolTreeSearch( const TOOL_EVENT& aEvent ) +{ + if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) + { + SYMBOL_EDIT_FRAME& sym_edit_frame = static_cast( *m_frame ); + + if( !sym_edit_frame.IsSymbolTreeShown() ) + { + wxCommandEvent dummy; + sym_edit_frame.OnToggleSymbolTree( dummy ); + } + sym_edit_frame.FocusSearchTreeInput(); + } + + return 0; +} + + int SYMBOL_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent ) { if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) @@ -814,6 +832,7 @@ void SYMBOL_EDITOR_CONTROL::setTransitions() Go( &SYMBOL_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::showSymbolTree.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::hideSymbolTree.MakeEvent() ); + Go( &SYMBOL_EDITOR_CONTROL::SymbolTreeSearch, EE_ACTIONS::symbolTreeSearch.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() ); diff --git a/eeschema/tools/symbol_editor_control.h b/eeschema/tools/symbol_editor_control.h index 2319256d9d..3c5742831c 100644 --- a/eeschema/tools/symbol_editor_control.h +++ b/eeschema/tools/symbol_editor_control.h @@ -69,6 +69,7 @@ public: int PinLibrary( const TOOL_EVENT& aEvent ); int UnpinLibrary( const TOOL_EVENT& aEvent ); int ToggleSymbolTree( const TOOL_EVENT& aEvent ); + int SymbolTreeSearch( const TOOL_EVENT& aEvent ); int ToggleProperties( const TOOL_EVENT& aEvent ); int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index ce326be7bb..4b54a631bb 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -397,6 +397,12 @@ void FOOTPRINT_EDIT_FRAME::ToggleSearchTree() } +void FOOTPRINT_EDIT_FRAME::FocusSearchTreeInput() +{ + m_treePane->FocusSearchFieldIfExists(); +} + + void FOOTPRINT_EDIT_FRAME::ToggleLayersManager() { FOOTPRINT_EDITOR_SETTINGS* settings = GetSettings(); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 65a92e0232..51410cb87e 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -140,6 +140,7 @@ public: bool IsSearchTreeShown() const; void ToggleSearchTree(); + void FocusSearchTreeInput(); void ToggleLayersManager(); /** diff --git a/pcbnew/tools/footprint_editor_control.cpp b/pcbnew/tools/footprint_editor_control.cpp index f730e2ca0a..d6c028b5c5 100644 --- a/pcbnew/tools/footprint_editor_control.cpp +++ b/pcbnew/tools/footprint_editor_control.cpp @@ -670,6 +670,16 @@ int FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree( const TOOL_EVENT& aEvent ) } +int FOOTPRINT_EDITOR_CONTROL::FootprintTreeSearch( const TOOL_EVENT& aEvent ) +{ + if (!m_frame->IsSearchTreeShown()) { + m_frame->ToggleSearchTree(); + } + m_frame->FocusSearchTreeInput(); + return 0; +} + + int FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager( const TOOL_EVENT& aEvent ) { m_frame->ToggleLayersManager(); @@ -857,6 +867,7 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions() Go( &FOOTPRINT_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::showFootprintTree.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::hideFootprintTree.MakeEvent() ); + Go( &FOOTPRINT_EDITOR_CONTROL::FootprintTreeSearch, PCB_ACTIONS::footprintTreeSearch.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::Properties, PCB_ACTIONS::footprintProperties.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.MakeEvent() ); Go( &FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() ); diff --git a/pcbnew/tools/footprint_editor_control.h b/pcbnew/tools/footprint_editor_control.h index 85078e2c66..7b0d895f46 100644 --- a/pcbnew/tools/footprint_editor_control.h +++ b/pcbnew/tools/footprint_editor_control.h @@ -68,6 +68,7 @@ public: int PinLibrary( const TOOL_EVENT& aEvent ); int UnpinLibrary( const TOOL_EVENT& aEvent ); int ToggleFootprintTree( const TOOL_EVENT& aEvent ); + int FootprintTreeSearch( const TOOL_EVENT& aEvent ); int ToggleLayersManager( const TOOL_EVENT& aEvent ); int ToggleProperties( const TOOL_EVENT& aEvent ); int Properties( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 96ff01a05a..30020725af 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -697,6 +697,12 @@ TOOL_ACTION PCB_ACTIONS::hideFootprintTree( TOOL_ACTION_ARGS() .FriendlyName( _( "Hide Footprint Tree" ) ) .Icon( BITMAPS::search_tree ) ); +TOOL_ACTION PCB_ACTIONS::footprintTreeSearch( TOOL_ACTION_ARGS() + .Name( "pcbnew.ModuleEditor.footprintTreeSearch" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Focus the Footprint Tree Search Field" ) ) + .DefaultHotkey( MD_CTRL + 'L' ) ); + TOOL_ACTION PCB_ACTIONS::newFootprint( TOOL_ACTION_ARGS() .Name( "pcbnew.ModuleEditor.newFootprint" ) .Scope( AS_GLOBAL ) diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 5d10826047..3f55fa5efa 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -448,6 +448,7 @@ public: static TOOL_ACTION showFootprintTree; static TOOL_ACTION hideFootprintTree; + static TOOL_ACTION footprintTreeSearch; // We don't use ACTION::new here because we need to distinguish between New Library // and New Footprint.