Skip to content

Commit f12fcc0

Browse files
committed
add for log 2nd for #21
1 parent ce05768 commit f12fcc0

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/panes/LogPaneSecondView.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,32 @@ void LogPaneSecondView::DrawMenuBar() {
146146
}
147147
}
148148

149+
void LogPaneSecondView::goOnNextSelection() {
150+
int32_t max_idx = m_LogDatas.size();
151+
for (int32_t idx = m_LogListClipper.DisplayStart + 1; idx < max_idx; ++idx) {
152+
const auto infos_ptr = m_LogDatas.at(idx).lock();
153+
if (infos_ptr) {
154+
if (LogEngine::Instance()->isSignalShown(infos_ptr->category, infos_ptr->name)) {
155+
ImGui::SetScrollY(ImGui::GetScrollY() + ImGui::GetTextLineHeightWithSpacing() * (idx - m_LogListClipper.DisplayStart));
156+
break;
157+
}
158+
}
159+
}
160+
}
161+
162+
void LogPaneSecondView::goOnBackSelection() {
163+
int32_t max_idx = m_LogDatas.size();
164+
for (int32_t idx = m_LogListClipper.DisplayStart - 1; idx >= 0; --idx) {
165+
const auto infos_ptr = m_LogDatas.at(idx).lock();
166+
if (infos_ptr) {
167+
if (LogEngine::Instance()->isSignalShown(infos_ptr->category, infos_ptr->name)) {
168+
ImGui::SetScrollY(ImGui::GetScrollY() + ImGui::GetTextLineHeightWithSpacing() * (idx - m_LogListClipper.DisplayStart));
169+
break;
170+
}
171+
}
172+
}
173+
}
174+
149175
void LogPaneSecondView::DrawTable() {
150176
ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY |
151177
ImGuiTableFlags_NoHostExtendY;
@@ -211,6 +237,16 @@ void LogPaneSecondView::DrawTable() {
211237
color = 0U;
212238
}
213239

240+
if (m_nextSelectionNeeded) {
241+
m_nextSelectionNeeded = false;
242+
goOnNextSelection();
243+
}
244+
245+
if (m_backSelectionNeeded) {
246+
m_backSelectionNeeded = false;
247+
goOnBackSelection();
248+
}
249+
214250
if (ImGui::TableNextColumn()) // time
215251
{
216252
ImGui::Selectable(ez::str::toStr("%f", infos_ptr->time_epoch).c_str(), &selected, ImGuiSelectableFlags_SpanAllColumns);

src/panes/LogPaneSecondView.h

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class LogPaneSecondView : public AbstractPane {
3131
SignalTicksWeakContainer m_LogDatas;
3232
std::vector<double> m_ValuesToHide;
3333
bool m_need_re_preparation = false;
34+
bool m_nextSelectionNeeded = false;
35+
bool m_backSelectionNeeded = false;
3436

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

4446
private:
47+
void goOnNextSelection();
48+
void goOnBackSelection();
4549
void DrawMenuBar();
4650
void DrawTable();
4751

0 commit comments

Comments
 (0)