Demonstrate creating a window which gets auto-resized according to its content.
| 9567 | |
| 9568 | // Demonstrate creating a window which gets auto-resized according to its content. |
| 9569 | static void ShowExampleAppAutoResize(bool* p_open) |
| 9570 | { |
| 9571 | if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) |
| 9572 | { |
| 9573 | ImGui::End(); |
| 9574 | return; |
| 9575 | } |
| 9576 | IMGUI_DEMO_MARKER("Examples/Auto-resizing window"); |
| 9577 | |
| 9578 | static int lines = 10; |
| 9579 | ImGui::TextUnformatted( |
| 9580 | "Window will resize every-frame to the size of its content.\n" |
| 9581 | "Note that you probably don't want to query the window size to\n" |
| 9582 | "output your content because that would create a feedback loop."); |
| 9583 | ImGui::SliderInt("Number of lines", &lines, 1, 20); |
| 9584 | for (int i = 0; i < lines; i++) |
| 9585 | ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally |
| 9586 | ImGui::End(); |
| 9587 | } |
| 9588 | |
| 9589 | //----------------------------------------------------------------------------- |
| 9590 | // [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() |