GCC Code Coverage Report


./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
0 of 59, 0 excluded
0.0%
Functions:
0 of 7, 0 excluded
0.0%
Branches:
0 of 59, 0 excluded
0.0%

libs/imgui/src/eu/imgui/debug.cc
Line Branch Exec Source
1 #include "eu/imgui/debug.h"
2
3 #include "imgui.h"
4
5 namespace eu::imgui
6 {
7
8
9 ✗ void ImLog::begin()
10 {
11 ✗ messages.clear();
12 ✗ }
13
14
15 ✗ void ImLog::add(std::string m)
16 {
17 ✗ messages.emplace_back(std::move(m));
18 ✗ }
19
20 ✗ void ImLog::draw(LogStyle style)
21 {
22 ✗ switch (style)
23 {
24 ✗ case LogStyle::basic:
25 ✗ draw_basic();
26 ✗ break;
27 ✗ case LogStyle::filter:
28 ✗ draw_filter();
29 ✗ break;
30 ✗ default:
31 ✗ DIE("Unhandled style");
32 ✗ break;
33 }
34 ✗ }
35
36 ✗ void ImLog::draw_basic() const
37 {
38 ✗ for (const auto& m : messages)
39 {
40 ✗ ImGui::TextUnformatted(m.c_str());
41 }
42 ✗ }
43
44 ✗ void ImLog::draw_filter()
45 {
46 ✗ filter.Draw("filter");
47
48 ✗ if (ImGui::BeginChild("scrolling", ImVec2(0, 0), ImGuiChildFlags_None, ImGuiWindowFlags_HorizontalScrollbar))
49 {
50 ✗ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
51 ✗ if (filter.IsActive())
52 {
53 ✗ for (const auto& m : messages)
54 {
55 // todo(Gustav): optimize both filtering and clipper?
56 ✗ const char* line_start = m.c_str();
57 ✗ const char* line_end = m.c_str() + m.length() + 1;
58 ✗ if (filter.PassFilter(line_start, line_end))
59 {
60 ✗ ImGui::TextUnformatted(line_start, line_end);
61 ✗ ImGui::TextUnformatted(m.c_str());
62 }
63 }
64 }
65 else
66 {
67 ✗ ImGuiListClipper clipper;
68
69 using clipper_int = int;
70 ✗ ASSERT(std::cmp_less(messages.size(), std::numeric_limits<clipper_int>::max()));
71 ✗ clipper.Begin(static_cast<clipper_int>(messages.size()));
72 ✗ while (clipper.Step())
73 {
74 ✗ for (auto line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++)
75 {
76 ✗ const auto& m = messages[line_no];
77 ✗ const char* line_start = m.c_str();
78 ✗ const char* line_end = m.c_str() + m.length() + 1;
79 ✗ ImGui::TextUnformatted(line_start, line_end);
80 }
81 }
82 ✗ clipper.End();
83 ✗ }
84 ✗ ImGui::PopStyleVar();
85 }
86 ✗ ImGui::EndChild();
87 ✗ }
88
89
90 ✗ bool ImTweak::get_bool(const std::string& name)
91 {
92 ✗ auto found = booleans.find(name);
93 ✗ if (found != booleans.end())
94 {
95 ✗ return found->second;
96 }
97 ✗ booleans[name] = false;
98 ✗ return false;
99 }
100
101 ✗ void ImTweak::draw()
102 {
103 ✗ ImGui::PushID("booleans");
104 ✗ for (auto& [key, check] : booleans)
105 {
106 ✗ ImGui::Checkbox(key.c_str(), &check);
107 }
108 ✗ ImGui::PopID();
109 ✗ }
110
111
112 }
113