Demonstrate creating a window which gets auto-resized according to its content.
| 9785 | |
| 9786 | // Demonstrate creating a window which gets auto-resized according to its content. |
| 9787 | static void ShowExampleAppAutoResize(bool* p_open) |
| 9788 | { |
| 9789 | if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) |
| 9790 | { |
| 9791 | ImGui::End(); |
| 9792 | return; |
| 9793 | } |
| 9794 | IMGUI_DEMO_MARKER("Examples/Auto-resizing window"); |
| 9795 | |
| 9796 | static int lines = 10; |
| 9797 | ImGui::TextUnformatted( |
| 9798 | "Window will resize every-frame to the size of its content.\n" |
| 9799 | "Note that you probably don't want to query the window size to\n" |
| 9800 | "output your content because that would create a feedback loop."); |
| 9801 | ImGui::SliderInt("Number of lines", &lines, 1, 20); |
| 9802 | for (int i = 0; i < lines; i++) |
| 9803 | ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally |
| 9804 | ImGui::End(); |
| 9805 | } |
| 9806 | |
| 9807 | //----------------------------------------------------------------------------- |
| 9808 | // [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() |
no test coverage detected