Tests: Changed prototype of ImGuiTestEngineHook_ItemAdd to match functions called in same spot. Made ButtonBehavior submit fallback item info if ItemAdd() was not called (for resize grips, resize borders, scrollbar, columns, etc.)

This commit is contained in:
omar 2018-12-14 11:27:02 +01:00
parent 8497948ba0
commit 587506dd57
3 changed files with 7 additions and 2 deletions

View File

@ -2630,7 +2630,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None; window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None;
#ifdef IMGUI_ENABLE_TEST_ENGINE #ifdef IMGUI_ENABLE_TEST_ENGINE
ImGuiTestEngineHook_ItemAdd(id, bb); ImGuiTestEngineHook_ItemAdd(bb, id);
#endif #endif
// Clipping test // Clipping test

View File

@ -1427,7 +1427,7 @@ IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned ch
#ifdef IMGUI_ENABLE_TEST_ENGINE #ifdef IMGUI_ENABLE_TEST_ENGINE
extern void ImGuiTestEngineHook_PreNewFrame(); extern void ImGuiTestEngineHook_PreNewFrame();
extern void ImGuiTestEngineHook_PostNewFrame(); extern void ImGuiTestEngineHook_PostNewFrame();
extern void ImGuiTestEngineHook_ItemAdd(ImGuiID id, const ImRect& bb); extern void ImGuiTestEngineHook_ItemAdd(const ImRect& bb, ImGuiID id);
extern void ImGuiTestEngineHook_ItemInfo(ImGuiID id, const char* label, int flags); extern void ImGuiTestEngineHook_ItemInfo(ImGuiID id, const char* label, int flags);
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) ImGuiTestEngineHook_ItemInfo(_ID, _LABEL, _FLAGS) // Register status flags #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) ImGuiTestEngineHook_ItemInfo(_ID, _LABEL, _FLAGS) // Register status flags
#else #else

View File

@ -396,6 +396,11 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
if ((flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window) if ((flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window)
g.HoveredWindow = window; g.HoveredWindow = window;
#ifdef IMGUI_ENABLE_TEST_ENGINE
if (window->DC.LastItemId != id)
ImGuiTestEngineHook_ItemAdd(bb, id);
#endif
bool pressed = false; bool pressed = false;
bool hovered = ItemHoverable(bb, id); bool hovered = ItemHoverable(bb, id);