Demonstrate creating a simple log window with basic filtering.
| 7079 | |
| 7080 | // Demonstrate creating a simple log window with basic filtering. |
| 7081 | static void ShowExampleAppLog(bool* p_open) |
| 7082 | { |
| 7083 | static ExampleAppLog log; |
| 7084 | |
| 7085 | // For the demo: add a debug button _BEFORE_ the normal log window contents |
| 7086 | // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. |
| 7087 | // Most of the contents of the window will be added by the log.Draw() call. |
| 7088 | ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); |
| 7089 | ImGui::Begin("Example: Log", p_open); |
| 7090 | IMGUI_DEMO_MARKER("Examples/Log"); |
| 7091 | if (ImGui::SmallButton("[Debug] Add 5 entries")) |
| 7092 | { |
| 7093 | static int counter = 0; |
| 7094 | const char* categories[3] = { "info", "warn", "error" }; |
| 7095 | const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" }; |
| 7096 | for (int n = 0; n < 5; n++) |
| 7097 | { |
| 7098 | const char* category = categories[counter % IM_ARRAYSIZE(categories)]; |
| 7099 | const char* word = words[counter % IM_ARRAYSIZE(words)]; |
| 7100 | log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", |
| 7101 | ImGui::GetFrameCount(), category, ImGui::GetTime(), word); |
| 7102 | counter++; |
| 7103 | } |
| 7104 | } |
| 7105 | ImGui::End(); |
| 7106 | |
| 7107 | // Actually call in the regular Log helper (which will Begin() into the same window as we just did) |
| 7108 | log.Draw("Example: Log", p_open); |
| 7109 | } |
| 7110 | |
| 7111 | //----------------------------------------------------------------------------- |
| 7112 | // [SECTION] Example App: Simple Layout / ShowExampleAppLayout() |
no test coverage detected