Demonstrate creating a simple log window with basic filtering.
| 4094 | |
| 4095 | // Demonstrate creating a simple log window with basic filtering. |
| 4096 | static void ShowExampleAppLog(bool* p_open) |
| 4097 | { |
| 4098 | static ExampleAppLog log; |
| 4099 | |
| 4100 | // For the demo: add a debug button _BEFORE_ the normal log window contents |
| 4101 | // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. |
| 4102 | // Most of the contents of the window will be added by the log.Draw() call. |
| 4103 | ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); |
| 4104 | ImGui::Begin("Example: Log", p_open); |
| 4105 | if (ImGui::SmallButton("[Debug] Add 5 entries")) |
| 4106 | { |
| 4107 | static int counter = 0; |
| 4108 | for (int n = 0; n < 5; n++) |
| 4109 | { |
| 4110 | const char* categories[3] = { "info", "warn", "error" }; |
| 4111 | const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" }; |
| 4112 | log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", |
| 4113 | ImGui::GetFrameCount(), categories[counter % IM_ARRAYSIZE(categories)], ImGui::GetTime(), words[counter % IM_ARRAYSIZE(words)]); |
| 4114 | counter++; |
| 4115 | } |
| 4116 | } |
| 4117 | ImGui::End(); |
| 4118 | |
| 4119 | // Actually call in the regular Log helper (which will Begin() into the same window as we just did) |
| 4120 | log.Draw("Example: Log", p_open); |
| 4121 | } |
| 4122 | |
| 4123 | //----------------------------------------------------------------------------- |
| 4124 | // [SECTION] Example App: Simple Layout / ShowExampleAppLayout() |
no test coverage detected