Windows: using SetNextWindowPos() with a pivot while a window is hidden and measuring size will still apply temporary position until size is figured out. (#9568)

This commit is contained in:
ocornut 2026-11-03 20:03:57 +01:00
parent 67f442d5de
commit 9d0b72573a
2 changed files with 9 additions and 2 deletions

View File

@ -72,6 +72,9 @@ Other Changes:
shape and look of arrows. Made default arrow stroked. (#5233, #2431, #2235, #6730, #8243)
Legacy arrow: size: (0.60f,0.70f), thickness: 0.0f
New arrow: size: (0.72f,0.40f), thickness: 0.30f
- Windows:
- Using `SetNextWindowPos()` with a pivot while a window is hidden and measuring
size will still apply temporary position until size is figured out. (#9568)
- TreeNode:
- TreeNodeGetOpen(): added flags parameter to allow passing `ImGuiTreeNodeFlags_DefaultOpen`
or `ImGuiTreeNodeFlags_Leaf`. (#9569, #9592, #3823, #9251) [@adalisk-emikhaylov, @Yaki-Blake]

View File

@ -7994,9 +7994,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->Pos = parent_window->DC.CursorPos;
}
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFramesCannotSkipItems == 0);
if (window_pos_with_pivot)
if (window->SetWindowPosVal.x != FLT_MAX)
{
const ImVec2 backup_pos_val = window->SetWindowPosVal;
SetWindowPos(window, window->SetWindowPosVal - window->Size * window->SetWindowPosPivot, 0); // Position given a pivot (e.g. for centering)
if (window->HiddenFramesCannotSkipItems != 0)
window->SetWindowPosVal = backup_pos_val; // Restore set request while hidden, so an updated size will be accounted for. (#9568)
}
else if ((flags & ImGuiWindowFlags_ChildMenu) != 0)
window->Pos = FindBestWindowPosForPopup(window);
else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)