Skip to content

Commit

Permalink
add arrow key for quickly go next/back on the first selected signal i…
Browse files Browse the repository at this point in the history
…n log view for #21
  • Loading branch information
aiekick committed Dec 1, 2024
1 parent ab59f5d commit ce05768
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/headers/LogToGraphBuild.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define LogToGraph_Prefix "LogToGraph"
#define LogToGraph_BuildNumber 3600
#define LogToGraph_BuildNumber 3618
#define LogToGraph_MinorNumber 3
#define LogToGraph_MajorNumber 0
#define LogToGraph_BuildId "0.3.3600"
#define LogToGraph_BuildId "0.3.3618"
53 changes: 49 additions & 4 deletions src/panes/LogPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ bool LogPane::DrawPanes(const uint32_t& /*vCurrentFrame*/, bool* vOpened, ImGuiC
}
}

// MainFrame::sAnyWindowsHovered |= ImGui::IsWindowHovered();

ImGui::End();
}
return change;
Expand Down Expand Up @@ -124,6 +122,16 @@ void LogPane::DrawMenuBar() {
ImGui::EndMenu();
}

if (!ProjectFile::Instance()->m_CollapseLogSelection) {
if (ImGui::MenuItem("<<")) {
m_backSelectionNeeded = true;
}

if (ImGui::MenuItem(">>")) {
m_nextSelectionNeeded = true;
}
}

if (ProjectFile::Instance()->m_HideSomeLogValues) {
ImGui::Text("(?)");
if (ImGui::IsItemHovered()) {
Expand All @@ -149,6 +157,32 @@ void LogPane::DrawMenuBar() {
}
}

void LogPane::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 LogPane::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 LogPane::DrawTable() {
ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_NoHostExtendY;

Expand Down Expand Up @@ -189,7 +223,7 @@ void LogPane::DrawTable() {
bool selected = false;
m_LogListClipper.Begin((int)_count_logs, ImGui::GetTextLineHeightWithSpacing());
while (m_LogListClipper.Step()) {
for (int i = m_LogListClipper.DisplayStart; i < m_LogListClipper.DisplayEnd; ++i) {
for (int32_t i = m_LogListClipper.DisplayStart; i < m_LogListClipper.DisplayEnd; ++i) {
if (i < 0)
continue;

Expand All @@ -211,6 +245,16 @@ void LogPane::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 Expand Up @@ -291,8 +335,9 @@ void LogPane::PrepareLog() {
}

auto selected = LogEngine::Instance()->isSignalShown(infos_ptr->category, infos_ptr->name);
if (_collapseSelection && !selected)
if (_collapseSelection && !selected) {
continue;
}

if (ProjectFile::Instance()->m_HideSomeLogValues) {
bool found = false;
Expand Down
4 changes: 4 additions & 0 deletions src/panes/LogPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class LogPane : 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 LogPane : public AbstractPane {
void PrepareLog();

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

Expand Down

0 comments on commit ce05768

Please sign in to comment.