Demonstrate creating a simple log window with basic filtering.
| 9249 | |
| 9250 | // Demonstrate creating a simple log window with basic filtering. |
| 9251 | static void ShowExampleAppLog(bool* p_open) |
| 9252 | { |
| 9253 | static ExampleAppLog log; |
| 9254 | |
| 9255 | // For the demo: add a debug button _BEFORE_ the normal log window contents |
| 9256 | // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. |
| 9257 | // Most of the contents of the window will be added by the log.Draw() call. |
| 9258 | ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); |
| 9259 | ImGui::Begin("Example: Log", p_open); |
| 9260 | IMGUI_DEMO_MARKER("Examples/Log"); |
| 9261 | if (ImGui::SmallButton("[Debug] Add 5 entries")) |
| 9262 | { |
| 9263 | static int counter = 0; |
| 9264 | const char* categories[3] = { "info", "warn", "error" }; |
| 9265 | const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" }; |
| 9266 | for (int n = 0; n < 5; n++) |
| 9267 | { |
| 9268 | const char* category = categories[counter % IM_ARRAYSIZE(categories)]; |
| 9269 | const char* word = words[counter % IM_ARRAYSIZE(words)]; |
| 9270 | log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", |
| 9271 | ImGui::GetFrameCount(), category, ImGui::GetTime(), word); |
| 9272 | counter++; |
| 9273 | } |
| 9274 | } |
| 9275 | ImGui::End(); |
| 9276 | |
| 9277 | // Actually call in the regular Log helper (which will Begin() into the same window as we just did) |
| 9278 | log.Draw("Example: Log", p_open); |
| 9279 | } |
| 9280 | |
| 9281 | //----------------------------------------------------------------------------- |
| 9282 | // [SECTION] Example App: Simple Layout / ShowExampleAppLayout() |
no test coverage detected