diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp index 95099bdde4..8792830884 100644 --- a/eeschema/dialogs/dialog_choose_component.cpp +++ b/eeschema/dialogs/dialog_choose_component.cpp @@ -55,6 +55,23 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const m_componentView->SetLayoutDirection( wxLayout_LeftToRight ); m_dbl_click_timer = std::make_unique( this ); + // Search box styling. wxSearchBox can handle this, but it's buggy... + m_searchBox->SetHint( _( "Search" ) ); + #if defined( __WXMAC__ ) || defined( __WINDOWS__ ) + { + // On Linux, the "Search" hint disappears when the dialog is focused, + // meaning it's not present initially when the dialog opens. To ensure + // the box is understood, a search icon is also provided. + // + // The icon provided by wx is ugly on macOS and Windows, *plus* these + // ports display the "Search" hint in the empty field even when the + // field is focused. Therefore, the icon is not required on these + // platforms. + m_searchBoxIcon->Hide(); + m_searchBoxIcon->GetParent()->Layout(); + } + #endif // __WXMAC__ + // Initialize footprint preview through Kiway m_footprintPreviewPanel = FOOTPRINT_PREVIEW_PANEL::InstallOnPanel( Kiway(), m_footprintView, true ); @@ -68,6 +85,7 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const #ifndef KICAD_FOOTPRINT_SELECTOR // Footprint chooser isn't implemented yet or isn't selected, don't show it. m_chooseFootprint->Hide(); + m_chooseFootprint->GetParent()->Layout(); #endif Bind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this ); diff --git a/eeschema/dialogs/dialog_choose_component_base.cpp b/eeschema/dialogs/dialog_choose_component_base.cpp index 60b4b818a9..2c50b51548 100644 --- a/eeschema/dialogs/dialog_choose_component_base.cpp +++ b/eeschema/dialogs/dialog_choose_component_base.cpp @@ -27,12 +27,17 @@ DIALOG_CHOOSE_COMPONENT_BASE::DIALOG_CHOOSE_COMPONENT_BASE( wxWindow* parent, wx wxBoxSizer* bSizer10; bSizer10 = new wxBoxSizer( wxVERTICAL ); - m_searchBox = new wxSearchCtrl( m_panel3, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); - #ifndef __WXMAC__ - m_searchBox->ShowSearchButton( true ); - #endif - m_searchBox->ShowCancelButton( false ); - bSizer10->Add( m_searchBox, 0, wxALL|wxEXPAND, 5 ); + wxBoxSizer* m_searchBoxSizer; + m_searchBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_searchBoxIcon = new wxStaticBitmap( m_panel3, wxID_ANY, wxArtProvider::GetBitmap( wxART_FIND, wxART_FRAME_ICON ), wxDefaultPosition, wxDefaultSize, 0 ); + m_searchBoxSizer->Add( m_searchBoxIcon, 0, wxALIGN_CENTER|wxALL, 5 ); + + m_searchBox = new wxTextCtrl( m_panel3, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_searchBoxSizer->Add( m_searchBox, 1, wxALIGN_CENTER|wxALL|wxEXPAND, 5 ); + + + bSizer10->Add( m_searchBoxSizer, 0, wxEXPAND, 5 ); m_libraryComponentTree = new TWO_COLUMN_TREE_LIST( m_panel3, wxID_ANY, wxDefaultPosition, wxSize( 320,240 ), wxTL_DEFAULT_STYLE ); @@ -103,8 +108,7 @@ DIALOG_CHOOSE_COMPONENT_BASE::DIALOG_CHOOSE_COMPONENT_BASE( wxWindow* parent, wx // Connect Events this->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnIdle ) ); this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInitDialog ) ); - m_searchBox->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInterceptSearchBoxKey ), NULL, this ); - m_searchBox->Connect( wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxEnter ), NULL, this ); + m_searchBox->Connect( wxEVT_KEY_UP, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInterceptSearchBoxKey ), NULL, this ); m_searchBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxChange ), NULL, this ); m_searchBox->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxEnter ), NULL, this ); m_libraryComponentTree->Connect( wxEVT_KEY_UP, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInterceptTreeEnter ), NULL, this ); @@ -120,8 +124,7 @@ DIALOG_CHOOSE_COMPONENT_BASE::~DIALOG_CHOOSE_COMPONENT_BASE() // Disconnect Events this->Disconnect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnIdle ) ); this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInitDialog ) ); - m_searchBox->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInterceptSearchBoxKey ), NULL, this ); - m_searchBox->Disconnect( wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxEnter ), NULL, this ); + m_searchBox->Disconnect( wxEVT_KEY_UP, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInterceptSearchBoxKey ), NULL, this ); m_searchBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxChange ), NULL, this ); m_searchBox->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxEnter ), NULL, this ); m_libraryComponentTree->Disconnect( wxEVT_KEY_UP, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInterceptTreeEnter ), NULL, this ); diff --git a/eeschema/dialogs/dialog_choose_component_base.fbp b/eeschema/dialogs/dialog_choose_component_base.fbp index 53a3f6ee0e..4566f3cc6c 100644 --- a/eeschema/dialogs/dialog_choose_component_base.fbp +++ b/eeschema/dialogs/dialog_choose_component_base.fbp @@ -263,94 +263,185 @@ none 5 - wxALL|wxEXPAND + wxEXPAND 0 - - 1 - 1 - 1 - 1 - - - - - - - 0 - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 + - 1 - m_searchBox - 1 - - - protected - 1 - - Resizable - 1 - 1 - - wxTE_PROCESS_ENTER - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - OnInterceptSearchBoxKey - - - - - - - - - - - - - - - - - OnSearchBoxEnter - - - OnSearchBoxChange - OnSearchBoxEnter - + m_searchBoxSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + Load From Art Provider; wxART_FIND; wxART_FRAME_ICON + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_searchBoxIcon + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER|wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_searchBox + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_PROCESS_ENTER + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + OnInterceptSearchBoxKey + + + + + + + + + + + + + + + + + + OnSearchBoxChange + OnSearchBoxEnter + + + + + diff --git a/eeschema/dialogs/dialog_choose_component_base.h b/eeschema/dialogs/dialog_choose_component_base.h index b67b1d8845..bb5933586c 100644 --- a/eeschema/dialogs/dialog_choose_component_base.h +++ b/eeschema/dialogs/dialog_choose_component_base.h @@ -15,15 +15,19 @@ class DIALOG_SHIM; class TWO_COLUMN_TREE_LIST; #include "dialog_shim.h" -#include -#include +#include +#include +#include +#include #include #include #include #include +#include +#include +#include #include #include -#include #include #include #include @@ -43,7 +47,8 @@ class DIALOG_CHOOSE_COMPONENT_BASE : public DIALOG_SHIM protected: wxSplitterWindow* m_splitter1; wxPanel* m_panel3; - wxSearchCtrl* m_searchBox; + wxStaticBitmap* m_searchBoxIcon; + wxTextCtrl* m_searchBox; TWO_COLUMN_TREE_LIST* m_libraryComponentTree; wxHtmlWindow* m_componentDetails; wxPanel* m_panel4; @@ -58,8 +63,8 @@ class DIALOG_CHOOSE_COMPONENT_BASE : public DIALOG_SHIM virtual void OnIdle( wxIdleEvent& event ) { event.Skip(); } virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); } virtual void OnInterceptSearchBoxKey( wxKeyEvent& event ) { event.Skip(); } - virtual void OnSearchBoxEnter( wxCommandEvent& event ) { event.Skip(); } virtual void OnSearchBoxChange( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSearchBoxEnter( wxCommandEvent& event ) { event.Skip(); } virtual void OnInterceptTreeEnter( wxKeyEvent& event ) { event.Skip(); } virtual void OnDoubleClickTreeActivation( wxTreeListEvent& event ) { event.Skip(); } virtual void OnTreeSelect( wxTreeListEvent& event ) { event.Skip(); }