MenuBar: Fixed an issue where layouting an item in the menu-bar would erroneously egister contents size. (#6789)

In dire need of removing BeginGroup()/EndGroup() from menu-bar code, fo r sanity.
This commit is contained in:
ocornut 2023-09-06 12:39:39 +02:00
parent 56a7b8b724
commit fa2e5710ac
3 changed files with 19 additions and 10 deletions

View File

@ -47,6 +47,9 @@ Other changes:
- InputTextMultiline: Fixed a crash pressing Down on last empty line of a multiline buffer. - InputTextMultiline: Fixed a crash pressing Down on last empty line of a multiline buffer.
(regression from 1.89.2, only happened in some states). (#6783, #6000) (regression from 1.89.2, only happened in some states). (#6783, #6000)
- BeginListBox(): Fixed not consuming SetNextWindowXXX data when returning false. - BeginListBox(): Fixed not consuming SetNextWindowXXX data when returning false.
- MenuBar: Fixed an issue where layouting an item in the menu-bar would erroneously
register contents size in a way that would affect the scrolling layer.
Was most often noticable when using an horizontal scrollbar. (#6789)
- Backends: GLFW: Clear emscripten's MouseWheel callback before shutdown. (#6790, #6096, #4019) [@halx99] - Backends: GLFW: Clear emscripten's MouseWheel callback before shutdown. (#6790, #6096, #4019) [@halx99]

View File

@ -7035,12 +7035,18 @@ void ImGui::EndMenuBar()
PopClipRect(); PopClipRect();
PopID(); PopID();
window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->Pos.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos. window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->Pos.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
g.GroupStack.back().EmitItem = false;
EndGroup(); // Restore position on layer 0 // FIXME: Extremely confusing, cleanup by (a) working on WorkRect stack system (b) not using a Group confusingly here.
ImGuiGroupData& group_data = g.GroupStack.back();
group_data.EmitItem = false;
ImVec2 restore_cursor_max_pos = group_data.BackupCursorMaxPos;
window->DC.IdealMaxPos.x = ImMax(window->DC.IdealMaxPos.x, window->DC.CursorMaxPos.x - window->Scroll.x); // Convert ideal extents for scrolling layer equivalent.
EndGroup(); // Restore position on layer 0 // FIXME: Misleading to use a group for that backup/restore
window->DC.LayoutType = ImGuiLayoutType_Vertical; window->DC.LayoutType = ImGuiLayoutType_Vertical;
window->DC.IsSameLine = false; window->DC.IsSameLine = false;
window->DC.NavLayerCurrent = ImGuiNavLayer_Main; window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
window->DC.MenuBarAppending = false; window->DC.MenuBarAppending = false;
window->DC.CursorMaxPos = restore_cursor_max_pos;
} }
// Important: calling order matters! // Important: calling order matters!