mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	Tests: Adding imgui-test engine hooks (experimental) to provide missing widget state to the testing system.
This commit is contained in:
		
							
								
								
									
										20
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -957,14 +957,6 @@ static void             UpdateMouseWheel(); | ||||
| static void             UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]); | ||||
| } | ||||
|  | ||||
| // Test engine hooks (imgui-test) | ||||
| //#define IMGUI_ENABLE_TEST_ENGINE_HOOKS | ||||
| #ifdef IMGUI_ENABLE_TEST_ENGINE_HOOKS | ||||
| extern void             ImGuiTestEngineHook_PreNewFrame(); | ||||
| extern void             ImGuiTestEngineHook_PostNewFrame(); | ||||
| extern void             ImGuiTestEngineHook_ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg); | ||||
| #endif | ||||
|  | ||||
| //----------------------------------------------------------------------------- | ||||
| // [SECTION] CONTEXT AND MEMORY ALLOCATORS | ||||
| //----------------------------------------------------------------------------- | ||||
| @@ -2607,10 +2599,6 @@ void ImGui::ItemSize(const ImRect& bb, float text_offset_y) | ||||
| // declare their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd(). | ||||
| bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg) | ||||
| { | ||||
| #ifdef IMGUI_ENABLE_TEST_ENGINE_HOOKS | ||||
|     ImGuiTestEngineHook_ItemAdd(bb, id, nav_bb_arg); | ||||
| #endif | ||||
|  | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     ImGuiWindow* window = g.CurrentWindow; | ||||
|  | ||||
| @@ -2632,6 +2620,10 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg) | ||||
|     window->DC.LastItemRect = bb; | ||||
|     window->DC.LastItemStatusFlags = 0; | ||||
|  | ||||
| #ifdef IMGUI_ENABLE_TEST_ENGINE | ||||
|     ImGuiTestEngineHook_ItemAdd(id, bb); | ||||
| #endif | ||||
|  | ||||
|     // Clipping test | ||||
|     const bool is_clipped = IsClippedEx(bb, id, false); | ||||
|     if (is_clipped) | ||||
| @@ -3130,7 +3122,7 @@ void ImGui::NewFrame() | ||||
|     IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?"); | ||||
|     ImGuiContext& g = *GImGui; | ||||
|  | ||||
| #ifdef IMGUI_ENABLE_TEST_ENGINE_HOOKS | ||||
| #ifdef IMGUI_ENABLE_TEST_ENGINE | ||||
|     ImGuiTestEngineHook_PreNewFrame(); | ||||
| #endif | ||||
|  | ||||
| @@ -3305,7 +3297,7 @@ void ImGui::NewFrame() | ||||
|     SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver); | ||||
|     Begin("Debug##Default"); | ||||
|  | ||||
| #ifdef IMGUI_ENABLE_TEST_ENGINE_HOOKS | ||||
| #ifdef IMGUI_ENABLE_TEST_ENGINE | ||||
|     ImGuiTestEngineHook_PostNewFrame(); | ||||
| #endif | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user