Add debouncing to the choose symbol dialog.
More potato pc friendly in theory.
This commit is contained in:
parent
3b33f94c56
commit
d2aeddc6cb
|
@ -33,6 +33,7 @@
|
||||||
#include <wx/srchctrl.h>
|
#include <wx/srchctrl.h>
|
||||||
#include <wx/settings.h>
|
#include <wx/settings.h>
|
||||||
#include <wx/statbmp.h>
|
#include <wx/statbmp.h>
|
||||||
|
#include <wx/timer.h>
|
||||||
|
|
||||||
|
|
||||||
LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable,
|
LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable,
|
||||||
|
@ -57,6 +58,8 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable,
|
||||||
|
|
||||||
m_query_ctrl->ShowCancelButton( true );
|
m_query_ctrl->ShowCancelButton( true );
|
||||||
|
|
||||||
|
m_debounceTimer = new wxTimer( this );
|
||||||
|
|
||||||
// Additional visual cue for GTK, which hides the placeholder text on focus
|
// Additional visual cue for GTK, which hides the placeholder text on focus
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
auto bitmap = new wxStaticBitmap( this, wxID_ANY, wxArtProvider::GetBitmap( wxART_FIND, wxART_FRAME_ICON ) );
|
auto bitmap = new wxStaticBitmap( this, wxID_ANY, wxArtProvider::GetBitmap( wxART_FIND, wxART_FRAME_ICON ) );
|
||||||
|
@ -70,6 +73,8 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable,
|
||||||
m_query_ctrl->Bind( wxEVT_TEXT, &LIB_TREE::onQueryText, this );
|
m_query_ctrl->Bind( wxEVT_TEXT, &LIB_TREE::onQueryText, this );
|
||||||
m_query_ctrl->Bind( wxEVT_TEXT_ENTER, &LIB_TREE::onQueryEnter, this );
|
m_query_ctrl->Bind( wxEVT_TEXT_ENTER, &LIB_TREE::onQueryEnter, this );
|
||||||
m_query_ctrl->Bind( wxEVT_CHAR_HOOK, &LIB_TREE::onQueryCharHook, this );
|
m_query_ctrl->Bind( wxEVT_CHAR_HOOK, &LIB_TREE::onQueryCharHook, this );
|
||||||
|
|
||||||
|
Bind( wxEVT_TIMER, &LIB_TREE::onDebounceTimer, this, m_debounceTimer->GetId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tree control
|
// Tree control
|
||||||
|
@ -322,7 +327,7 @@ void LIB_TREE::setState( const STATE& aState )
|
||||||
|
|
||||||
void LIB_TREE::onQueryText( wxCommandEvent& aEvent )
|
void LIB_TREE::onQueryText( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
Regenerate( false );
|
m_debounceTimer->StartOnce( 200 );
|
||||||
|
|
||||||
// Required to avoid interaction with SetHint()
|
// Required to avoid interaction with SetHint()
|
||||||
// See documentation for wxTextEntry::SetHint
|
// See documentation for wxTextEntry::SetHint
|
||||||
|
@ -337,6 +342,12 @@ void LIB_TREE::onQueryEnter( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LIB_TREE::onDebounceTimer( wxTimerEvent& aEvent )
|
||||||
|
{
|
||||||
|
Regenerate( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke )
|
void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke )
|
||||||
{
|
{
|
||||||
auto const sel = m_tree_ctrl->GetSelection();
|
auto const sel = m_tree_ctrl->GetSelection();
|
||||||
|
|
|
@ -33,6 +33,8 @@ class wxTextCtrl;
|
||||||
class wxHtmlWindow;
|
class wxHtmlWindow;
|
||||||
class wxHtmlLinkEvent;
|
class wxHtmlLinkEvent;
|
||||||
class wxSearchCtrl;
|
class wxSearchCtrl;
|
||||||
|
class wxTimer;
|
||||||
|
class wxTimerEvent;
|
||||||
class ACTION_MENU;
|
class ACTION_MENU;
|
||||||
class LIB_ID;
|
class LIB_ID;
|
||||||
class LIB_TABLE;
|
class LIB_TABLE;
|
||||||
|
@ -167,6 +169,8 @@ protected:
|
||||||
void onPreselect( wxCommandEvent& aEvent );
|
void onPreselect( wxCommandEvent& aEvent );
|
||||||
void onContextMenu( wxDataViewEvent& aEvent );
|
void onContextMenu( wxDataViewEvent& aEvent );
|
||||||
|
|
||||||
|
void onDebounceTimer( wxTimerEvent& aEvent );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LIB_TABLE* m_lib_table;
|
LIB_TABLE* m_lib_table;
|
||||||
|
|
||||||
|
@ -175,6 +179,7 @@ protected:
|
||||||
wxSearchCtrl* m_query_ctrl;
|
wxSearchCtrl* m_query_ctrl;
|
||||||
wxDataViewCtrl* m_tree_ctrl;
|
wxDataViewCtrl* m_tree_ctrl;
|
||||||
wxHtmlWindow* m_details_ctrl;
|
wxHtmlWindow* m_details_ctrl;
|
||||||
|
wxTimer* m_debounceTimer;
|
||||||
|
|
||||||
LIB_ID m_last_libid;
|
LIB_ID m_last_libid;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue