imgui icon indicating copy to clipboard operation
imgui copied to clipboard

`SetNextWindowCollapsed(false)` will cause auto-resized window to lose its size for a frame

Open achabense opened this issue 1 year ago • 0 comments

Version/Branch of Dear ImGui:

Version 1.90.8

Back-ends:

imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer2.cpp

Compiler, OS:

Windows 10 + MSVC 2022

Full config/build information:

No response

Details:

(Shown in 10.0FPS; the grey color is due to poor gif quality) For the following code, if I un-collapse the window by the button, the content will appear in full size directly: expected However, (by pressing space key) if the window is un-collapsed by SetNextWindowCollapsed(false), there will be a frame that the window is minimal-sized. It will cause the window to flick in normal framerate: bykey

I need to control the collapse by code. How can I achieve the same effect as if it is un-collapsed by the button?

(The flicking effect doesn't happen if the window is not opened in ImGuiWindowFlags_AlwaysAutoResize. However, in my use case I need that flag.) (Update: even without ImGuiWindowFlags_AlwaysAutoResize, the two way of un-collapse is slightly different as to their scrollbar behaviors.)

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

void test() {
    if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
        ImGui::SetNextWindowCollapsed(false, ImGuiCond_Always);
    }
    if (ImGui::Begin("-Test-", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings)) {
        ImGui::Button("Test\n    Test");
    }
    ImGui::End();
}

achabense avatar Jun 14 '24 10:06 achabense