mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Tests: Added hook/tweaks for imgui-test engine. + Fixed warnings.
This commit is contained in:
		@@ -2899,7 +2899,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
 | 
			
		||||
 | 
			
		||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
 | 
			
		||||
    if (id != 0)
 | 
			
		||||
        ImGuiTestEngineHook_ItemAdd(&g, nav_bb_arg ? *nav_bb_arg : bb, id);
 | 
			
		||||
        IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // Clipping test
 | 
			
		||||
@@ -6099,6 +6099,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
 | 
			
		||||
            window->DC.LastItemStatusFlags = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0;
 | 
			
		||||
            window->DC.LastItemRect = title_bar_rect;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
 | 
			
		||||
        if (!(window->Flags & ImGuiWindowFlags_NoTitleBar))
 | 
			
		||||
            IMGUI_TEST_ENGINE_ITEM_ADD(window->DC.LastItemRect, window->DC.LastItemId);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1808,8 +1808,10 @@ extern void                 ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx);
 | 
			
		||||
extern void                 ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx);
 | 
			
		||||
extern void                 ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
 | 
			
		||||
extern void                 ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags);
 | 
			
		||||
#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB, _ID)                ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID)               // Register status flags
 | 
			
		||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS)  ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS)   // Register status flags
 | 
			
		||||
#else
 | 
			
		||||
#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB, _ID)                do { } while (0)
 | 
			
		||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS)  do { } while (0)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5123,7 +5123,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
 | 
			
		||||
        SetItemAllowOverlap();
 | 
			
		||||
 | 
			
		||||
    // In this branch, TreeNodeBehavior() cannot toggle the selection so this will never trigger.
 | 
			
		||||
    if (selected != was_selected)
 | 
			
		||||
    if (selected != was_selected) //-V547
 | 
			
		||||
        window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection;
 | 
			
		||||
 | 
			
		||||
    // Render
 | 
			
		||||
@@ -5371,7 +5371,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
 | 
			
		||||
        SetItemAllowOverlap();
 | 
			
		||||
 | 
			
		||||
    // In this branch, Selectable() cannot toggle the selection so this will never trigger.
 | 
			
		||||
    if (selected != was_selected)
 | 
			
		||||
    if (selected != was_selected) //-V547
 | 
			
		||||
        window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection;
 | 
			
		||||
 | 
			
		||||
    // Render
 | 
			
		||||
@@ -5395,6 +5395,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
 | 
			
		||||
    // Automatically close popups
 | 
			
		||||
    if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(window->DC.ItemFlags & ImGuiItemFlags_SelectableDontClosePopup))
 | 
			
		||||
        CloseCurrentPopup();
 | 
			
		||||
 | 
			
		||||
    IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags);
 | 
			
		||||
    return pressed;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -5744,6 +5746,7 @@ ImGuiMenuColumns::ImGuiMenuColumns()
 | 
			
		||||
void ImGuiMenuColumns::Update(int count, float spacing, bool clear)
 | 
			
		||||
{
 | 
			
		||||
    IM_ASSERT(count == IM_ARRAYSIZE(Pos));
 | 
			
		||||
    IM_UNUSED(count);
 | 
			
		||||
    Width = NextWidth = 0.0f;
 | 
			
		||||
    Spacing = spacing;
 | 
			
		||||
    if (clear)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user