Demonstrate creating a window which gets auto-resized according to its content.
| 2283 | |
| 2284 | // Demonstrate creating a window which gets auto-resized according to its content. |
| 2285 | static void ShowExampleAppAutoResize(bool* p_open) |
| 2286 | { |
| 2287 | if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) |
| 2288 | { |
| 2289 | ImGui::End(); |
| 2290 | return; |
| 2291 | } |
| 2292 | |
| 2293 | static int lines = 10; |
| 2294 | 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."); |
| 2295 | ImGui::SliderInt("Number of lines", &lines, 1, 20); |
| 2296 | for (int i = 0; i < lines; i++) |
| 2297 | ImGui::Text("%*sThis is line %d", i*4, "", i); // Pad with space to extend size horizontally |
| 2298 | ImGui::End(); |
| 2299 | } |
| 2300 | |
| 2301 | // Demonstrate creating a window with custom resize constraints. |
| 2302 | static void ShowExampleAppConstrainedResize(bool* p_open) |