Demonstrate creating a window which gets auto-resized according to its content.
| 4297 | |
| 4298 | // Demonstrate creating a window which gets auto-resized according to its content. |
| 4299 | static void ShowExampleAppAutoResize(bool* p_open) |
| 4300 | { |
| 4301 | if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) |
| 4302 | { |
| 4303 | ImGui::End(); |
| 4304 | return; |
| 4305 | } |
| 4306 | |
| 4307 | static int lines = 10; |
| 4308 | ImGui::Text("Window will resize every-frame to the size of its content.\nNote that you probably don't want to query the window size to\noutput your content because that would create a feedback loop."); |
| 4309 | ImGui::SliderInt("Number of lines", &lines, 1, 20); |
| 4310 | for (int i = 0; i < lines; i++) |
| 4311 | ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally |
| 4312 | ImGui::End(); |
| 4313 | } |
| 4314 | |
| 4315 | //----------------------------------------------------------------------------- |
| 4316 | // [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() |