29 assert(ctx.
logLines &&
"DrawContext::logLines must not be null");
30 assert(ctx.
logAutoScroll &&
"DrawContext::logAutoScroll must not be null");
31 assert(ctx.
logNeedsReload &&
"DrawContext::logNeedsReload must not be null");
36 if (ImGui::Button(
"Reload"))
39 if (ImGui::Button(
"Clear"))
44 ImGui::TextDisabled(
"%d lines",
static_cast<int>(ctx.
logLines->size()));
47 ImGui::BeginChild(
"##LogScroll", ImVec2(0, 0), ImGuiChildFlags_None,
48 ImGuiWindowFlags_HorizontalScrollbar);
49 ImGuiListClipper clipper;
50 clipper.Begin(
static_cast<int>(ctx.
logLines->size()));
51 while (clipper.Step())
53 for (
int i = clipper.DisplayStart; i < clipper.DisplayEnd; ++i)
55 const auto& line = (*ctx.
logLines)[i];
56 if (line.find(
"ERROR") != std::string::npos)
57 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.4f, 0.4f, 1.0f));
58 else if (line.find(
"WARNING") != std::string::npos)
59 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 0.3f, 1.0f));
61 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.7f, 0.7f, 0.7f, 1.0f));
62 ImGui::TextUnformatted(line.c_str());
63 ImGui::PopStyleColor();
66 if (*ctx.
logAutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY() - 20.0f)
67 ImGui::SetScrollHereY(1.0f);
Per-frame context for the log panel.
std::vector< std::string > * logLines