diff --git a/src/panes/LogPaneSecondView.cpp b/src/panes/LogPaneSecondView.cpp index af6fa19..f97a227 100644 --- a/src/panes/LogPaneSecondView.cpp +++ b/src/panes/LogPaneSecondView.cpp @@ -146,6 +146,32 @@ void LogPaneSecondView::DrawMenuBar() { } } +void LogPaneSecondView::goOnNextSelection() { + int32_t max_idx = m_LogDatas.size(); + for (int32_t idx = m_LogListClipper.DisplayStart + 1; idx < max_idx; ++idx) { + const auto infos_ptr = m_LogDatas.at(idx).lock(); + if (infos_ptr) { + if (LogEngine::Instance()->isSignalShown(infos_ptr->category, infos_ptr->name)) { + ImGui::SetScrollY(ImGui::GetScrollY() + ImGui::GetTextLineHeightWithSpacing() * (idx - m_LogListClipper.DisplayStart)); + break; + } + } + } +} + +void LogPaneSecondView::goOnBackSelection() { + int32_t max_idx = m_LogDatas.size(); + for (int32_t idx = m_LogListClipper.DisplayStart - 1; idx >= 0; --idx) { + const auto infos_ptr = m_LogDatas.at(idx).lock(); + if (infos_ptr) { + if (LogEngine::Instance()->isSignalShown(infos_ptr->category, infos_ptr->name)) { + ImGui::SetScrollY(ImGui::GetScrollY() + ImGui::GetTextLineHeightWithSpacing() * (idx - m_LogListClipper.DisplayStart)); + break; + } + } + } +} + void LogPaneSecondView::DrawTable() { ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_NoHostExtendY; @@ -211,6 +237,16 @@ void LogPaneSecondView::DrawTable() { color = 0U; } + if (m_nextSelectionNeeded) { + m_nextSelectionNeeded = false; + goOnNextSelection(); + } + + if (m_backSelectionNeeded) { + m_backSelectionNeeded = false; + goOnBackSelection(); + } + if (ImGui::TableNextColumn()) // time { ImGui::Selectable(ez::str::toStr("%f", infos_ptr->time_epoch).c_str(), &selected, ImGuiSelectableFlags_SpanAllColumns); diff --git a/src/panes/LogPaneSecondView.h b/src/panes/LogPaneSecondView.h index fab8915..9152513 100644 --- a/src/panes/LogPaneSecondView.h +++ b/src/panes/LogPaneSecondView.h @@ -31,6 +31,8 @@ class LogPaneSecondView : public AbstractPane { SignalTicksWeakContainer m_LogDatas; std::vector m_ValuesToHide; bool m_need_re_preparation = false; + bool m_nextSelectionNeeded = false; + bool m_backSelectionNeeded = false; public: bool Init() override; @@ -42,6 +44,8 @@ class LogPaneSecondView : public AbstractPane { void PrepareLog(); // Prevent unwanted destruction}; private: + void goOnNextSelection(); + void goOnBackSelection(); void DrawMenuBar(); void DrawTable();