Skip to content

Commit a05d547

Browse files
committed
Windows: separating WindowItemStatusFlags from ChildItemStatusFlag, because IsItemXXX _after_ BeginChild()>Begin() shouldn't return last status emitted by e.g. EndChild()
As IsItemXXX() after is specced as returning title bar data we don't want to lock ourselves up from adding them to child window (e.g. MDI idea using windows to host child windows).
1 parent 134fbe1 commit a05d547

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

imgui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4714,7 +4714,7 @@ static void ImGui::SetLastItemDataForWindow(ImGuiWindow* window, const ImRect& r
47144714
static void ImGui::SetLastItemDataForChildWindowItem(ImGuiWindow* window, const ImRect& rect)
47154715
{
47164716
ImGuiContext& g = *GImGui;
4717-
SetLastItemData(window->ChildId, g.CurrentItemFlags, window->DC.WindowItemStatusFlags, rect);
4717+
SetLastItemData(window->ChildId, g.CurrentItemFlags, window->DC.ChildItemStatusFlags, rect);
47184718
}
47194719

47204720
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
@@ -6170,7 +6170,7 @@ void ImGui::EndChild()
61706170
}
61716171
if (g.HoveredWindow == child_window)
61726172
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow;
6173-
child_window->DC.WindowItemStatusFlags = g.LastItemData.StatusFlags;
6173+
child_window->DC.ChildItemStatusFlags = g.LastItemData.StatusFlags;
61746174
//SetLastItemDataForChildWindowItem(child_window, child_window->Rect()); // Not needed, effectively done by ItemAdd()
61756175
}
61766176
else

imgui_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,7 @@ struct IMGUI_API ImGuiWindowTempData
24572457
ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
24582458
ImU32 ModalDimBgColor;
24592459
ImGuiItemStatusFlags WindowItemStatusFlags;
2460+
ImGuiItemStatusFlags ChildItemStatusFlags;
24602461

24612462
// Local parameters stacks
24622463
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.

0 commit comments

Comments
 (0)