Demonstrate creating a simple log window with basic filtering.
| 9372 | |
| 9373 | // Demonstrate creating a simple log window with basic filtering. |
| 9374 | static void ShowExampleAppLog(bool* p_open) |
| 9375 | { |
| 9376 | static ExampleAppLog log; |
| 9377 | |
| 9378 | // For the demo: add a debug button _BEFORE_ the normal log window contents |
| 9379 | // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. |
| 9380 | // Most of the contents of the window will be added by the log.Draw() call. |
| 9381 | ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); |
| 9382 | ImGui::Begin("Example: Log", p_open); |
| 9383 | IMGUI_DEMO_MARKER("Examples/Log"); |
| 9384 | if (ImGui::SmallButton("[Debug] Add 5 entries")) |
| 9385 | { |
| 9386 | static int counter = 0; |
| 9387 | const char* categories[3] = { "info", "warn", "error" }; |
| 9388 | const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" }; |
| 9389 | for (int n = 0; n < 5; n++) |
| 9390 | { |
| 9391 | const char* category = categories[counter % IM_COUNTOF(categories)]; |
| 9392 | const char* word = words[counter % IM_COUNTOF(words)]; |
| 9393 | log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", |
| 9394 | ImGui::GetFrameCount(), category, ImGui::GetTime(), word); |
| 9395 | counter++; |
| 9396 | } |
| 9397 | } |
| 9398 | ImGui::End(); |
| 9399 | |
| 9400 | // Actually call in the regular Log helper (which will Begin() into the same window as we just did) |
| 9401 | log.Draw("Example: Log", p_open); |
| 9402 | } |
| 9403 | |
| 9404 | //----------------------------------------------------------------------------- |
| 9405 | // [SECTION] Example App: Simple Layout / ShowExampleAppLayout() |
no test coverage detected