Demonstrate creating a window which gets auto-resized according to its content.
| 7648 | |
| 7649 | // Demonstrate creating a window which gets auto-resized according to its content. |
| 7650 | static void ShowExampleAppAutoResize(bool* p_open) |
| 7651 | { |
| 7652 | if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) |
| 7653 | { |
| 7654 | ImGui::End(); |
| 7655 | return; |
| 7656 | } |
| 7657 | IMGUI_DEMO_MARKER("Examples/Auto-resizing window"); |
| 7658 | |
| 7659 | static int lines = 10; |
| 7660 | ImGui::TextUnformatted( |
| 7661 | "Window will resize every-frame to the size of its content.\n" |
| 7662 | "Note that you probably don't want to query the window size to\n" |
| 7663 | "output your content because that would create a feedback loop."); |
| 7664 | ImGui::SliderInt("Number of lines", &lines, 1, 20); |
| 7665 | for (int i = 0; i < lines; i++) |
| 7666 | ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally |
| 7667 | ImGui::End(); |
| 7668 | } |
| 7669 | |
| 7670 | //----------------------------------------------------------------------------- |
| 7671 | // [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() |