mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Windows: Fixed IsItemXXXX() functions not working on append-version of EndChild(). (#8350)
Also made some of the fields accessible after BeginChild() to match Begin() logic.
This commit is contained in:
parent
5a28f188ff
commit
134fbe1245
3 changed files with 25 additions and 6 deletions
28
imgui.cpp
28
imgui.cpp
|
|
@ -1256,6 +1256,7 @@ static void RenderWindowTitleBarContents(ImGuiWindow* window, const
|
|||
static void RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32 col);
|
||||
static void RenderDimmedBackgrounds();
|
||||
static void SetLastItemDataForWindow(ImGuiWindow* window, const ImRect& rect);
|
||||
static void SetLastItemDataForChildWindowItem(ImGuiWindow* window, const ImRect& rect);
|
||||
|
||||
// Viewports
|
||||
const ImGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111; // Using an arbitrary constant instead of e.g. ImHashStr("ViewportDefault", 0); so it's easier to spot in the debugger. The exact value doesn't matter.
|
||||
|
|
@ -4704,6 +4705,18 @@ void ImGui::SetLastItemData(ImGuiID item_id, ImGuiItemFlags item_flags, ImGuiIte
|
|||
g.LastItemData.Rect = g.LastItemData.NavRect = item_rect;
|
||||
}
|
||||
|
||||
static void ImGui::SetLastItemDataForWindow(ImGuiWindow* window, const ImRect& rect)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
SetLastItemData(window->MoveId, g.CurrentItemFlags, window->DC.WindowItemStatusFlags, rect);
|
||||
}
|
||||
|
||||
static void ImGui::SetLastItemDataForChildWindowItem(ImGuiWindow* window, const ImRect& rect)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
SetLastItemData(window->ChildId, g.CurrentItemFlags, window->DC.WindowItemStatusFlags, rect);
|
||||
}
|
||||
|
||||
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
||||
{
|
||||
if (wrap_pos_x < 0.0f)
|
||||
|
|
@ -6157,7 +6170,14 @@ void ImGui::EndChild()
|
|||
}
|
||||
if (g.HoveredWindow == child_window)
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow;
|
||||
child_window->DC.WindowItemStatusFlags = g.LastItemData.StatusFlags;
|
||||
//SetLastItemDataForChildWindowItem(child_window, child_window->Rect()); // Not needed, effectively done by ItemAdd()
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastItemDataForChildWindowItem(child_window, child_window->Rect());
|
||||
}
|
||||
|
||||
g.WithinEndChildID = backup_within_end_child_id;
|
||||
g.LogLinePosY = -FLT_MAX; // To enforce a carriage return
|
||||
}
|
||||
|
|
@ -7612,6 +7632,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
|
||||
// We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
|
||||
// This is useful to allow creating context menus on title bar only, etc.
|
||||
window->DC.WindowItemStatusFlags = ImGuiItemStatusFlags_None;
|
||||
window->DC.WindowItemStatusFlags |= IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0;
|
||||
SetLastItemDataForWindow(window, title_bar_rect);
|
||||
|
||||
// [DEBUG]
|
||||
|
|
@ -7717,12 +7739,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
return !window->SkipItems;
|
||||
}
|
||||
|
||||
static void ImGui::SetLastItemDataForWindow(ImGuiWindow* window, const ImRect& rect)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
SetLastItemData(window->MoveId, g.CurrentItemFlags, IsMouseHoveringRect(rect.Min, rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0, rect);
|
||||
}
|
||||
|
||||
void ImGui::End()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue