Skip to content

Commit

Permalink
Windows: fixed background order of overlapping childs submitted seque…
Browse files Browse the repository at this point in the history
…ntially. (ocornut#4493)

Amend 0770449
  • Loading branch information
ocornut authored and AnClark committed Aug 30, 2021
1 parent 7363b23 commit ebba9e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Breaking Changes:

Other Changes:

- Windows: fixed background order of overlapping childs submitted sequentially. (#4493)
- InputTextMultiline: Fixed label size not being included into window contents rect unless
the whole widget is clipped.
- TextUnformatted: Accept null ranges including (NULL,NULL) without asserting, in order to conform
Expand Down
15 changes: 10 additions & 5 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6214,16 +6214,21 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha * 0.25f), g.Style.WindowRounding);
}

// Since 1.71, child window can render their decoration (bg color, border, scrollbars, etc.) within their parent to save a draw call.
// Child windows can render their decoration (bg color, border, scrollbars, etc.) within their parent to save a draw call (since 1.71)
// When using overlapping child windows, this will break the assumption that child z-order is mapped to submission order.
// We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping child.
// We also disabled this when we have dimming overlay behind this specific one child.
// FIXME: More code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected.
// FIXME: User code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected (github #4493)
{
bool render_decorations_in_parent = false;
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip)
if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_window->DrawList->VtxBuffer.Size > 0)
{
// - We test overlap with the previous child window only (testing all would end up being O(log N) not a good investment here)
// - We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping childs
ImGuiWindow* previous_child = parent_window->DC.ChildWindows.Size >= 2 ? parent_window->DC.ChildWindows[parent_window->DC.ChildWindows.Size - 2] : NULL;
bool previous_child_overlapping = previous_child ? previous_child->Rect().Overlaps(window->Rect()) : false;
bool parent_is_empty = parent_window->DrawList->VtxBuffer.Size > 0;
if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_is_empty && !previous_child_overlapping)
render_decorations_in_parent = true;
}
if (render_decorations_in_parent)
window->DrawList = parent_window->DrawList;

Expand Down
2 changes: 1 addition & 1 deletion imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Index of this file:
// Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
#define IMGUI_VERSION "1.85 WIP"
#define IMGUI_VERSION_NUM 18408
#define IMGUI_VERSION_NUM 18409
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
#define IMGUI_HAS_TABLE

Expand Down

0 comments on commit ebba9e8

Please sign in to comment.