FifoPlayerDlg: Improve navigating through search results.

This commit is contained in:
NeoBrainX 2013-05-06 22:18:46 +02:00
parent 0247b2a97a
commit 6871cc9700
2 changed files with 21 additions and 10 deletions

View File

@ -55,7 +55,7 @@ FifoPlayerDlg::~FifoPlayerDlg()
m_ObjectToCtrl->Unbind(wxEVT_COMMAND_SPINCTRL_UPDATED, &FifoPlayerDlg::OnObjectTo, this); m_ObjectToCtrl->Unbind(wxEVT_COMMAND_SPINCTRL_UPDATED, &FifoPlayerDlg::OnObjectTo, this);
m_EarlyMemoryUpdates->Unbind(wxEVT_COMMAND_CHECKBOX_CLICKED, &FifoPlayerDlg::OnCheckEarlyMemoryUpdates, this); m_EarlyMemoryUpdates->Unbind(wxEVT_COMMAND_CHECKBOX_CLICKED, &FifoPlayerDlg::OnCheckEarlyMemoryUpdates, this);
m_RecordStop->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FifoPlayerDlg::OnRecordStop, this); m_RecordStop->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FifoPlayerDlg::OnRecordStop, this);
m_Save->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FifoPlayerDlg::OnSaveFile, this); m_Save->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FifoPlayerDlg::OnSaveFile, this);
m_FramesToRecordCtrl->Unbind(wxEVT_COMMAND_SPINCTRL_UPDATED, &FifoPlayerDlg::OnNumFramesToRecord, this); m_FramesToRecordCtrl->Unbind(wxEVT_COMMAND_SPINCTRL_UPDATED, &FifoPlayerDlg::OnNumFramesToRecord, this);
m_Close->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FifoPlayerDlg::OnCloseClick, this); m_Close->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &FifoPlayerDlg::OnCloseClick, this);
@ -253,9 +253,7 @@ void FifoPlayerDlg::CreateGUIControls()
m_findNext = new wxButton(m_AnalyzePage, wxID_ANY, _("Find next")); m_findNext = new wxButton(m_AnalyzePage, wxID_ANY, _("Find next"));
m_findPrevious = new wxButton(m_AnalyzePage, wxID_ANY, _("Find previous")); m_findPrevious = new wxButton(m_AnalyzePage, wxID_ANY, _("Find previous"));
m_beginSearch->Disable(); ResetSearch();
m_findNext->Disable();
m_findPrevious->Disable();
sSearchButtons->Add(m_beginSearch, 0, wxALL, 5); sSearchButtons->Add(m_beginSearch, 0, wxALL, 5);
sSearchButtons->Add(m_findNext, 0, wxALL, 5); sSearchButtons->Add(m_findNext, 0, wxALL, 5);
@ -500,16 +498,12 @@ void FifoPlayerDlg::OnBeginSearch(wxCommandEvent& event)
ChangeSearchResult(0); ChangeSearchResult(0);
m_beginSearch->Disable(); m_beginSearch->Disable();
m_findNext->Enable();
m_findPrevious->Enable();
m_numResultsText->SetLabel(wxString::Format(_("Found %d results for \'"), search_results.size()) + m_searchField->GetValue() + _("\'")); m_numResultsText->SetLabel(wxString::Format(_("Found %d results for \'"), search_results.size()) + m_searchField->GetValue() + _("\'"));
} }
void FifoPlayerDlg::OnSearchFieldTextChanged(wxCommandEvent& event) void FifoPlayerDlg::OnSearchFieldTextChanged(wxCommandEvent& event)
{ {
m_beginSearch->Enable(m_searchField->GetLineLength(0) > 0); ResetSearch();
m_findNext->Disable();
m_findPrevious->Disable();
} }
void FifoPlayerDlg::OnFindNextClick(wxCommandEvent& event) void FifoPlayerDlg::OnFindNextClick(wxCommandEvent& event)
@ -552,7 +546,7 @@ void FifoPlayerDlg::OnFindPreviousClick(wxCommandEvent& event)
void FifoPlayerDlg::ChangeSearchResult(unsigned int result_idx) void FifoPlayerDlg::ChangeSearchResult(unsigned int result_idx)
{ {
if (search_results.size() > result_idx) if (result_idx < search_results.size()) // if index is valid
{ {
m_search_result_idx = result_idx; m_search_result_idx = result_idx;
int prev_frame = m_framesList->GetSelection(); int prev_frame = m_framesList->GetSelection();
@ -578,6 +572,9 @@ void FifoPlayerDlg::ChangeSearchResult(unsigned int result_idx)
ev.SetInt(m_objectCmdList->GetSelection()); ev.SetInt(m_objectCmdList->GetSelection());
OnObjectCmdListSelectionChanged(ev); OnObjectCmdListSelectionChanged(ev);
} }
m_findNext->Enable(result_idx+1 < search_results.size());
m_findPrevious->Enable(result_idx != 0);
} }
else if (search_results.size()) else if (search_results.size())
{ {
@ -585,6 +582,15 @@ void FifoPlayerDlg::ChangeSearchResult(unsigned int result_idx)
} }
} }
void FifoPlayerDlg::ResetSearch()
{
m_beginSearch->Enable(m_searchField->GetLineLength(0) > 0);
m_findNext->Disable();
m_findPrevious->Disable();
search_results.clear();
}
void FifoPlayerDlg::OnFrameListSelectionChanged(wxCommandEvent& event) void FifoPlayerDlg::OnFrameListSelectionChanged(wxCommandEvent& event)
{ {
FifoPlayer& player = FifoPlayer::GetInstance(); FifoPlayer& player = FifoPlayer::GetInstance();
@ -601,6 +607,8 @@ void FifoPlayerDlg::OnFrameListSelectionChanged(wxCommandEvent& event)
wxCommandEvent ev = wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); wxCommandEvent ev = wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
ev.SetInt(-1); ev.SetInt(-1);
OnObjectListSelectionChanged(ev); OnObjectListSelectionChanged(ev);
ResetSearch();
} }
void FifoPlayerDlg::OnObjectListSelectionChanged(wxCommandEvent& event) void FifoPlayerDlg::OnObjectListSelectionChanged(wxCommandEvent& event)
@ -728,6 +736,8 @@ void FifoPlayerDlg::OnObjectListSelectionChanged(wxCommandEvent& event)
wxCommandEvent ev = wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); wxCommandEvent ev = wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
ev.SetInt(-1); ev.SetInt(-1);
OnObjectCmdListSelectionChanged(ev); OnObjectCmdListSelectionChanged(ev);
ResetSearch();
} }
void FifoPlayerDlg::OnObjectCmdListSelectionChanged(wxCommandEvent& event) void FifoPlayerDlg::OnObjectCmdListSelectionChanged(wxCommandEvent& event)

View File

@ -37,6 +37,7 @@ private:
void OnFindPreviousClick(wxCommandEvent& event); void OnFindPreviousClick(wxCommandEvent& event);
void OnSearchFieldTextChanged(wxCommandEvent& event); void OnSearchFieldTextChanged(wxCommandEvent& event);
void ChangeSearchResult(unsigned int result_idx); void ChangeSearchResult(unsigned int result_idx);
void ResetSearch();
void OnRecordingFinished(wxEvent& event); void OnRecordingFinished(wxEvent& event);
void OnFrameWritten(wxEvent& event); void OnFrameWritten(wxEvent& event);