Demonstrate creating a simple log window with basic filtering.
| 4074 | |
| 4075 | // Demonstrate creating a simple log window with basic filtering. |
| 4076 | static void ShowExampleAppLog(bool* p_open) |
| 4077 | { |
| 4078 | static ExampleAppLog log; |
| 4079 | |
| 4080 | // For the demo: add a debug button _BEFORE_ the normal log window contents |
| 4081 | // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. |
| 4082 | // Most of the contents of the window will be added by the log.Draw() call. |
| 4083 | ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); |
| 4084 | ImGui::Begin("Example: Log", p_open); |
| 4085 | if (ImGui::SmallButton("[Debug] Add 5 entries")) |
| 4086 | { |
| 4087 | static int counter = 0; |
| 4088 | for (int n = 0; n < 5; n++) |
| 4089 | { |
| 4090 | const char* categories[3] = { "info", "warn", "error" }; |
| 4091 | const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" }; |
| 4092 | log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", |
| 4093 | ImGui::GetFrameCount(), categories[counter % IM_ARRAYSIZE(categories)], ImGui::GetTime(), words[counter % IM_ARRAYSIZE(words)]); |
| 4094 | counter++; |
| 4095 | } |
| 4096 | } |
| 4097 | ImGui::End(); |
| 4098 | |
| 4099 | // Actually call in the regular Log helper (which will Begin() into the same window as we just did) |
| 4100 | log.Draw("Example: Log", p_open); |
| 4101 | } |
| 4102 | |
| 4103 | //----------------------------------------------------------------------------- |
| 4104 | // [SECTION] Example App: Simple Layout / ShowExampleAppLayout() |
no test coverage detected