TestEngine: update IMGUI_TEST_ENGINE_ITEM_ADD() hooks to support passing item in flags.

This commit is contained in:
ocornut
2023-03-06 18:10:04 +01:00
parent 1c29a8ed18
commit b6586bb06d
4 changed files with 15 additions and 13 deletions

View File

@ -3996,14 +3996,14 @@ bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id)
}
// This is also inlined in ItemAdd()
// Note: if ImGuiItemStatusFlags_HasDisplayRect is set, user needs to set window->DC.LastItemDisplayRect!
// Note: if ImGuiItemStatusFlags_HasDisplayRect is set, user needs to set g.LastItemData.DisplayRect.
void ImGui::SetLastItemData(ImGuiID item_id, ImGuiItemFlags in_flags, ImGuiItemStatusFlags item_flags, const ImRect& item_rect)
{
ImGuiContext& g = *GImGui;
g.LastItemData.ID = item_id;
g.LastItemData.InFlags = in_flags;
g.LastItemData.StatusFlags = item_flags;
g.LastItemData.Rect = item_rect;
g.LastItemData.Rect = g.LastItemData.NavRect = item_rect;
}
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
@ -6400,13 +6400,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
}
}
// [Test Engine] Register whole window in the item system
// [Test Engine] Register whole window in the item system (before submitting further decorations)
#ifdef IMGUI_ENABLE_TEST_ENGINE
if (g.TestEngineHookItems)
{
IM_ASSERT(window->IDStack.Size == 1);
window->IDStack.Size = 0; // As window->IDStack[0] == window->ID here, make sure TestEngine doesn't erroneously see window as parent of itself.
IMGUI_TEST_ENGINE_ITEM_ADD(window->Rect(), window->ID);
IMGUI_TEST_ENGINE_ITEM_ADD(window->ID, window->Rect(), NULL);
IMGUI_TEST_ENGINE_ITEM_INFO(window->ID, window->Name, (g.HoveredWindow == window) ? ImGuiItemStatusFlags_HoveredRect : 0);
window->IDStack.Size = 1;
}
@ -6647,10 +6647,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
DebugLocateItemResolveWithLastItem();
#endif
// [Test Engine] Register title bar / tab
// [Test Engine] Register title bar / tab with MoveId.
#ifdef IMGUI_ENABLE_TEST_ENGINE
if (!(window->Flags & ImGuiWindowFlags_NoTitleBar))
IMGUI_TEST_ENGINE_ITEM_ADD(g.LastItemData.Rect, g.LastItemData.ID);
IMGUI_TEST_ENGINE_ITEM_ADD(g.LastItemData.ID, g.LastItemData.Rect, &g.LastItemData);
#endif
}
else
@ -9229,7 +9229,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
#ifdef IMGUI_ENABLE_TEST_ENGINE
if (id != 0)
IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id);
IMGUI_TEST_ENGINE_ITEM_ADD(id, g.LastItemData.NavRect, &g.LastItemData);
#endif
// Clipping test