ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.71k stars 10.16k forks source link

Auto resize window with an auto-size combo will expand indefinitely #7439

Open arnaud-neny opened 6 months ago

arnaud-neny commented 6 months ago

Version/Branch of Dear ImGui:

Version 1.90.4, Branch: docking

Back-ends:

imgui_impl_d3d9.cpp + imgui_impl_win32.cpp

Compiler, OS:

Windows 10 + MSVC 2022

Full config/build information:

Using imgui_demo.c, ShowExampleAppAutoResize

Details:

Adding the code from the example is making the window grows indefinitively.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

ImGui::SetNextItemWidth(-FLT_MIN);
static int test_type = 0;
ImGui::Combo("Test type", &test_type,
    "Single call to TextUnformatted()\0"
    "Multiple calls to Text(), clipped\0"
    "Multiple calls to Text(), not clipped (slow)\0");
cfillion commented 6 months ago

The label width (and item spacing between the combo and the label) gets added to the item's total width, which then keeps pushing the window's content size.

Disable the label to prevent the window from growing forever:

ImGui::Combo("##unique_id_here", ...);

(You can read more about the ## syntax here: https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-can-i-have-widgets-with-an-empty-label)