Skip to content

Commit

Permalink
add for log 2nd for #21
Browse files Browse the repository at this point in the history
  • Loading branch information
aiekick committed Dec 1, 2024
1 parent ce05768 commit f12fcc0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/panes/LogPaneSecondView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/panes/LogPaneSecondView.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class LogPaneSecondView : public AbstractPane {
SignalTicksWeakContainer m_LogDatas;
std::vector<double> m_ValuesToHide;
bool m_need_re_preparation = false;
bool m_nextSelectionNeeded = false;
bool m_backSelectionNeeded = false;

public:
bool Init() override;
Expand All @@ -42,6 +44,8 @@ class LogPaneSecondView : public AbstractPane {
void PrepareLog(); // Prevent unwanted destruction};

private:
void goOnNextSelection();
void goOnBackSelection();
void DrawMenuBar();
void DrawTable();

Expand Down

0 comments on commit f12fcc0

Please sign in to comment.