-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Open
Labels
Description
Version/Branch of Dear ImGui:
Version 1.92.2b
Back-ends:
Any (imgui_impl_sdl3.cpp + imgui_impl_sdlrenderer3.cpp)
Compiler, OS:
Any
Full config/build information:
No response
Details:
If an auto-resized window contains another auto-resized child window, it cannot be correctly centered with SetNextWindowPos (on appearing; when the window size is unknown).
Screenshots/Video:
Minimal, Complete and Verifiable Example code:
static void issue() {
static bool open = false;
if (ImGui::Begin("Control", 0, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings)) {
ImGui::Checkbox("Issue window", &open);
}
ImGui::End();
if (open) {
// Window-centering doesn't work in this case (auto-resized parent window + auto-resized child window).
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
if (ImGui::Begin("Issue", &open, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings)) {
ImGui::Button("Settings");
// Background:
// Using child window for scrollable area with fixed height.
// Using ImGuiChildFlags_AutoResizeX to avoid complex size calculation.
if (ImGui::BeginChild("For scroll area", ImVec2(0, 100), ImGuiChildFlags_AutoResizeX)) {
ImGui::Text("1234567890abcdefghijklmnopqrstuvwxyz");
ImGui::Button("Button", ImVec2(200, 200));
}
ImGui::EndChild();
}
ImGui::End();
}
}