Demonstrate creating a simple log window with basic filtering.
| 6872 | |
| 6873 | // Demonstrate creating a simple log window with basic filtering. |
| 6874 | static void ShowExampleAppLog(bool* p_open) |
| 6875 | { |
| 6876 | static ExampleAppLog log; |
| 6877 | |
| 6878 | // For the demo: add a debug button _BEFORE_ the normal log window contents |
| 6879 | // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. |
| 6880 | // Most of the contents of the window will be added by the log.Draw() call. |
| 6881 | ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); |
| 6882 | ImGui::Begin("Example: Log", p_open); |
| 6883 | IMGUI_DEMO_MARKER("Examples/Log"); |
| 6884 | if (ImGui::SmallButton("[Debug] Add 5 entries")) |
| 6885 | { |
| 6886 | static int counter = 0; |
| 6887 | const char* categories[3] = { "info", "warn", "error" }; |
| 6888 | const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" }; |
| 6889 | for (int n = 0; n < 5; n++) |
| 6890 | { |
| 6891 | const char* category = categories[counter % IM_ARRAYSIZE(categories)]; |
| 6892 | const char* word = words[counter % IM_ARRAYSIZE(words)]; |
| 6893 | log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", |
| 6894 | ImGui::GetFrameCount(), category, ImGui::GetTime(), word); |
| 6895 | counter++; |
| 6896 | } |
| 6897 | } |
| 6898 | ImGui::End(); |
| 6899 | |
| 6900 | // Actually call in the regular Log helper (which will Begin() into the same window as we just did) |
| 6901 | log.Draw("Example: Log", p_open); |
| 6902 | } |
| 6903 | |
| 6904 | //----------------------------------------------------------------------------- |
| 6905 | // [SECTION] Example App: Simple Layout / ShowExampleAppLayout() |
no test coverage detected