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.
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 76feb98..2717fc9 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -47,6 +47,9 @@
- 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)
- 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]
diff --git a/imgui_internal.h b/imgui_internal.h
index 7f6dbe3..65201ca 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1868,14 +1868,14 @@
ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
// Shared stacks
- ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
- ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
- ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
- ImVector<ImGuiID> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
- ImVector<ImGuiItemFlags>ItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
- ImVector<ImGuiGroupData>GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
- ImVector<ImGuiPopupData>OpenPopupStack; // Which popups are open (persistent)
- ImVector<ImGuiPopupData>BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
+ ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
+ ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
+ ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
+ ImVector<ImGuiID> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
+ ImVector<ImGuiItemFlags> ItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
+ ImVector<ImGuiGroupData> GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
+ ImVector<ImGuiPopupData> OpenPopupStack; // Which popups are open (persistent)
+ ImVector<ImGuiPopupData> BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
ImVector<ImGuiNavTreeNodeData> NavTreeNodeStack; // Stack for TreeNode() when a NavLeft requested is emitted.
int BeginMenuCount;
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index d63a629..e4ade8c 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -7035,12 +7035,18 @@
PopClipRect();
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.
- 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.IsSameLine = false;
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
window->DC.MenuBarAppending = false;
+ window->DC.CursorMaxPos = restore_cursor_max_pos;
}
// Important: calling order matters!