Skip to content

Commit

Permalink
feature: added coloring for delayed timestamp 1/2 indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
klonyyy committed Sep 29, 2024
1 parent 4631f42 commit 9a31947
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
7 changes: 5 additions & 2 deletions src/Gui/Gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ class Gui
valueChanged(str);
}
template <typename T>
void drawDescriptionWithNumber(const char* description, T number, std::string unit = "", size_t decimalPlaces = 5)
void drawDescriptionWithNumber(const char* description, T number, std::string unit = "", size_t decimalPlaces = 5, float threshold = std::nan(""), ImVec4 thresholdExceededColor = {0.0f, 0.0f, 0.0f, 1.0f})
{
ImGui::Text("%s", description);
if (threshold != std::nan("") && number > threshold)
ImGui::TextColored(thresholdExceededColor, "%s", description);
else
ImGui::Text("%s", description);
ImGui::SameLine();
std::ostringstream formattedNum;
formattedNum << std::fixed << std::setprecision(decimalPlaces) << number;
Expand Down
23 changes: 4 additions & 19 deletions src/Gui/GuiSwoControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,11 @@ void Gui::drawIndicatorsSwo()
drawDescriptionWithNumber("frames total: ", indicators.framesTotal);
drawDescriptionWithNumber("sleep cycles: ", indicators.sleepCycles);
drawDescriptionWithNumber("error frames total: ", indicators.errorFramesTotal);

const char* inView = "error frames in view: ";
if (indicators.errorFramesInView > 0)
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "%s", inView);
else
ImGui::Text("%s", inView);
ImGui::SameLine();
ImGui::Text("%s", (std::to_string(indicators.errorFramesInView)).c_str());

drawDescriptionWithNumber("delayed timestamp 1: ", indicators.delayedTimestamp1);
drawDescriptionWithNumber("delayed timestamp 2: ", indicators.delayedTimestamp2);
drawDescriptionWithNumber("error frames in view: ", indicators.errorFramesInView, "", 5, 0, {1, 0, 0, 1});
drawDescriptionWithNumber("delayed timestamp 1: ", indicators.delayedTimestamp1, "", 5, 0, {1, 1, 0, 1});
drawDescriptionWithNumber("delayed timestamp 2: ", indicators.delayedTimestamp2, "", 5, 0, {1, 1, 0, 1});
drawDescriptionWithNumber("delayed timestamp 3: ", indicators.delayedTimestamp3);

const char* timestampDelayed3inView = "delayed timestamp 3 in view: ";
if (indicators.delayedTimestamp3InView > 0)
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "%s", timestampDelayed3inView);
else
ImGui::Text("%s", timestampDelayed3inView);
ImGui::SameLine();
ImGui::Text("%s", (std::to_string(indicators.delayedTimestamp3InView)).c_str());
drawDescriptionWithNumber("delayed timestamp 3 in view: ", indicators.delayedTimestamp3InView, "", 5, 0, {1, 0, 0, 1});
}

void Gui::drawPlotsTreeSwo()
Expand Down

0 comments on commit 9a31947

Please sign in to comment.