Skip to content

Commit ce05768

Browse files
committed
add arrow key for quickly go next/back on the first selected signal in log view for #21
1 parent ab59f5d commit ce05768

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

src/headers/LogToGraphBuild.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#define LogToGraph_Prefix "LogToGraph"
4-
#define LogToGraph_BuildNumber 3600
4+
#define LogToGraph_BuildNumber 3618
55
#define LogToGraph_MinorNumber 3
66
#define LogToGraph_MajorNumber 0
7-
#define LogToGraph_BuildId "0.3.3600"
7+
#define LogToGraph_BuildId "0.3.3618"

src/panes/LogPane.cpp

+49-4
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ bool LogPane::DrawPanes(const uint32_t& /*vCurrentFrame*/, bool* vOpened, ImGuiC
6363
}
6464
}
6565

66-
// MainFrame::sAnyWindowsHovered |= ImGui::IsWindowHovered();
67-
6866
ImGui::End();
6967
}
7068
return change;
@@ -124,6 +122,16 @@ void LogPane::DrawMenuBar() {
124122
ImGui::EndMenu();
125123
}
126124

125+
if (!ProjectFile::Instance()->m_CollapseLogSelection) {
126+
if (ImGui::MenuItem("<<")) {
127+
m_backSelectionNeeded = true;
128+
}
129+
130+
if (ImGui::MenuItem(">>")) {
131+
m_nextSelectionNeeded = true;
132+
}
133+
}
134+
127135
if (ProjectFile::Instance()->m_HideSomeLogValues) {
128136
ImGui::Text("(?)");
129137
if (ImGui::IsItemHovered()) {
@@ -149,6 +157,32 @@ void LogPane::DrawMenuBar() {
149157
}
150158
}
151159

160+
void LogPane::goOnNextSelection() {
161+
int32_t max_idx = m_LogDatas.size();
162+
for (int32_t idx = m_LogListClipper.DisplayStart + 1; idx < max_idx; ++idx) {
163+
const auto infos_ptr = m_LogDatas.at(idx).lock();
164+
if (infos_ptr) {
165+
if (LogEngine::Instance()->isSignalShown(infos_ptr->category, infos_ptr->name)) {
166+
ImGui::SetScrollY(ImGui::GetScrollY() + ImGui::GetTextLineHeightWithSpacing() * (idx - m_LogListClipper.DisplayStart));
167+
break;
168+
}
169+
}
170+
}
171+
}
172+
173+
void LogPane::goOnBackSelection() {
174+
int32_t max_idx = m_LogDatas.size();
175+
for (int32_t idx = m_LogListClipper.DisplayStart - 1; idx >= 0; --idx) {
176+
const auto infos_ptr = m_LogDatas.at(idx).lock();
177+
if (infos_ptr) {
178+
if (LogEngine::Instance()->isSignalShown(infos_ptr->category, infos_ptr->name)) {
179+
ImGui::SetScrollY(ImGui::GetScrollY() + ImGui::GetTextLineHeightWithSpacing() * (idx - m_LogListClipper.DisplayStart));
180+
break;
181+
}
182+
}
183+
}
184+
}
185+
152186
void LogPane::DrawTable() {
153187
ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_NoHostExtendY;
154188

@@ -189,7 +223,7 @@ void LogPane::DrawTable() {
189223
bool selected = false;
190224
m_LogListClipper.Begin((int)_count_logs, ImGui::GetTextLineHeightWithSpacing());
191225
while (m_LogListClipper.Step()) {
192-
for (int i = m_LogListClipper.DisplayStart; i < m_LogListClipper.DisplayEnd; ++i) {
226+
for (int32_t i = m_LogListClipper.DisplayStart; i < m_LogListClipper.DisplayEnd; ++i) {
193227
if (i < 0)
194228
continue;
195229

@@ -211,6 +245,16 @@ void LogPane::DrawTable() {
211245
color = 0U;
212246
}
213247

248+
if (m_nextSelectionNeeded) {
249+
m_nextSelectionNeeded = false;
250+
goOnNextSelection();
251+
}
252+
253+
if (m_backSelectionNeeded) {
254+
m_backSelectionNeeded = false;
255+
goOnBackSelection();
256+
}
257+
214258
if (ImGui::TableNextColumn()) // time
215259
{
216260
ImGui::Selectable(ez::str::toStr("%f", infos_ptr->time_epoch).c_str(), &selected, ImGuiSelectableFlags_SpanAllColumns);
@@ -291,8 +335,9 @@ void LogPane::PrepareLog() {
291335
}
292336

293337
auto selected = LogEngine::Instance()->isSignalShown(infos_ptr->category, infos_ptr->name);
294-
if (_collapseSelection && !selected)
338+
if (_collapseSelection && !selected) {
295339
continue;
340+
}
296341

297342
if (ProjectFile::Instance()->m_HideSomeLogValues) {
298343
bool found = false;

src/panes/LogPane.h

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class LogPane : 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 LogPane : public AbstractPane {
4244
void PrepareLog();
4345

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

0 commit comments

Comments
 (0)