MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / ShowExampleAppLog

Function ShowExampleAppLog

imgui_tiny_app/imgui/imgui_demo.cpp:9488–9516  ·  view source on GitHub ↗

Demonstrate creating a simple log window with basic filtering.

Source from the content-addressed store, hash-verified

9486
9487// Demonstrate creating a simple log window with basic filtering.
9488static void ShowExampleAppLog(bool* p_open)
9489{
9490 static ExampleAppLog log;
9491
9492 // For the demo: add a debug button _BEFORE_ the normal log window contents
9493 // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window.
9494 // Most of the contents of the window will be added by the log.Draw() call.
9495 ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
9496 ImGui::Begin("Example: Log", p_open);
9497 IMGUI_DEMO_MARKER("Examples/Log");
9498 if (ImGui::SmallButton("[Debug] Add 5 entries"))
9499 {
9500 static int counter = 0;
9501 const char* categories[3] = { "info", "warn", "error" };
9502 const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" };
9503 for (int n = 0; n < 5; n++)
9504 {
9505 const char* category = categories[counter % IM_COUNTOF(categories)];
9506 const char* word = words[counter % IM_COUNTOF(words)];
9507 log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n",
9508 ImGui::GetFrameCount(), category, ImGui::GetTime(), word);
9509 counter++;
9510 }
9511 }
9512 ImGui::End();
9513
9514 // Actually call in the regular Log helper (which will Begin() into the same window as we just did)
9515 log.Draw("Example: Log", p_open);
9516}
9517
9518//-----------------------------------------------------------------------------
9519// [SECTION] Example App: Simple Layout / ShowExampleAppLayout()

Callers 1

ShowDemoWindowMethod · 0.85

Calls 2

ImVec2Function · 0.85
DrawMethod · 0.45

Tested by

no test coverage detected