Demonstrate creating a window which gets auto-resized according to its content.
| 7120 | |
| 7121 | // Demonstrate creating a window which gets auto-resized according to its content. |
| 7122 | static void ShowExampleAppAutoResize(bool* p_open) |
| 7123 | { |
| 7124 | if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) |
| 7125 | { |
| 7126 | ImGui::End(); |
| 7127 | return; |
| 7128 | } |
| 7129 | IMGUI_DEMO_MARKER("Examples/Auto-resizing window"); |
| 7130 | |
| 7131 | static int lines = 10; |
| 7132 | ImGui::TextUnformatted( |
| 7133 | "Window will resize every-frame to the size of its content.\n" |
| 7134 | "Note that you probably don't want to query the window size to\n" |
| 7135 | "output your content because that would create a feedback loop."); |
| 7136 | ImGui::SliderInt("Number of lines", &lines, 1, 20); |
| 7137 | for (int i = 0; i < lines; i++) |
| 7138 | ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally |
| 7139 | ImGui::End(); |
| 7140 | } |
| 7141 | |
| 7142 | //----------------------------------------------------------------------------- |
| 7143 | // [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() |