Demonstrate creating a window which gets auto-resized according to its content.
| 9883 | |
| 9884 | // Demonstrate creating a window which gets auto-resized according to its content. |
| 9885 | static void ShowExampleAppAutoResize(bool* p_open) |
| 9886 | { |
| 9887 | if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) |
| 9888 | { |
| 9889 | ImGui::End(); |
| 9890 | return; |
| 9891 | } |
| 9892 | IMGUI_DEMO_MARKER("Examples/Auto-resizing window"); |
| 9893 | |
| 9894 | static int lines = 10; |
| 9895 | ImGui::TextUnformatted( |
| 9896 | "Window will resize every-frame to the size of its content.\n" |
| 9897 | "Note that you probably don't want to query the window size to\n" |
| 9898 | "output your content because that would create a feedback loop."); |
| 9899 | ImGui::SliderInt("Number of lines", &lines, 1, 20); |
| 9900 | for (int i = 0; i < lines; i++) |
| 9901 | ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally |
| 9902 | ImGui::End(); |
| 9903 | } |
| 9904 | |
| 9905 | //----------------------------------------------------------------------------- |
| 9906 | // [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() |
no test coverage detected