Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
achabense opened this issue Jun 14, 2024 · 0 comments

Comments

@achabense
Copy link

achabense commented Jun 14, 2024

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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants