mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	Debug: move debug assertion in post-clip code to reduce overhead. (#4796 and more).
Amend c80179921
			
			
This commit is contained in:
		
							
								
								
									
										27
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -9613,6 +9613,7 @@ void ImGuiStackSizes::CompareWithContextState(ImGuiContext* ctx) | ||||
| // Advance cursor given item size for layout. | ||||
| // Register minimum needed size so it can extend the bounding box used for auto-fit calculation. | ||||
| // See comments in ItemAdd() about how/why the size provided to ItemSize() vs ItemAdd() may often different. | ||||
| // THIS IS IN THE PERFORMANCE CRITICAL PATH. | ||||
| void ImGui::ItemSize(const ImVec2& size, float text_baseline_y) | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
| @@ -9652,6 +9653,7 @@ void ImGui::ItemSize(const ImVec2& size, float text_baseline_y) | ||||
| // Declare item bounding box for clipping and interaction. | ||||
| // Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface | ||||
| // declare their minimum size requirement to ItemSize() and provide a larger region to ItemAdd() which is used drawing/interaction. | ||||
| // THIS IS IN THE PERFORMANCE CRITICAL PATH (UNTIL THE CLIPPING TEST AND EARLY-RETURN) | ||||
| bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGuiItemFlags extra_flags) | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
| @@ -9666,11 +9668,11 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu | ||||
|     g.LastItemData.StatusFlags = ImGuiItemStatusFlags_None; | ||||
|     // Note: we don't copy 'g.NextItemData.SelectionUserData' to an hypothetical g.LastItemData.SelectionUserData: since the former is not cleared. | ||||
|  | ||||
|     // Directional navigation processing | ||||
|     if (id != 0) | ||||
|     { | ||||
|         KeepAliveID(id); | ||||
|  | ||||
|         // Directional navigation processing | ||||
|         // Runs prior to clipping early-out | ||||
|         //  (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget | ||||
|         //  (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests | ||||
| @@ -9689,12 +9691,9 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu | ||||
|                     if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened)) | ||||
|                         NavProcessItem(); | ||||
|         } | ||||
|  | ||||
|         // [DEBUG] People keep stumbling on this problem and using "" as identifier in the root of a window instead of "##something". | ||||
|         // Empty identifier are valid and useful in a small amount of cases, but 99.9% of the time you want to use "##something". | ||||
|         // READ THE FAQ: https://dearimgui.com/faq | ||||
|         IM_ASSERT(id != window->ID && "Cannot have an empty ID at the root of a window. If you need an empty label, use ## and read the FAQ about how the ID Stack works!"); | ||||
|     } | ||||
|  | ||||
|     // Lightweight clear of SetNextItemXXX data. | ||||
|     g.NextItemData.Flags = ImGuiNextItemDataFlags_None; | ||||
|     g.NextItemData.ItemFlags = ImGuiItemFlags_None; | ||||
|  | ||||
| @@ -9704,7 +9703,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu | ||||
| #endif | ||||
|  | ||||
|     // Clipping test | ||||
|     // (FIXME: This is a modified copy of IsClippedEx() so we can reuse the is_rect_visible value) | ||||
|     // (this is a modified copy of IsClippedEx() so we can reuse the is_rect_visible value) | ||||
|     //const bool is_clipped = IsClippedEx(bb, id); | ||||
|     //if (is_clipped) | ||||
|     //    return false; | ||||
| @@ -9716,12 +9715,20 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu | ||||
|  | ||||
|     // [DEBUG] | ||||
| #ifndef IMGUI_DISABLE_DEBUG_TOOLS | ||||
|     if (id != 0 && id == g.DebugLocateId) | ||||
|         DebugLocateItemResolveWithLastItem(); | ||||
| #endif | ||||
|     if (id != 0) | ||||
|     { | ||||
|         if (id == g.DebugLocateId) | ||||
|             DebugLocateItemResolveWithLastItem(); | ||||
|  | ||||
|         // [DEBUG] People keep stumbling on this problem and using "" as identifier in the root of a window instead of "##something". | ||||
|         // Empty identifier are valid and useful in a small amount of cases, but 99.9% of the time you want to use "##something". | ||||
|         // READ THE FAQ: https://dearimgui.com/faq | ||||
|         IM_ASSERT(id != window->ID && "Cannot have an empty ID at the root of a window. If you need an empty label, use ## and read the FAQ about how the ID Stack works!"); | ||||
|     } | ||||
|     //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG] | ||||
|     //if ((g.LastItemData.InFlags & ImGuiItemFlags_NoNav) == 0) | ||||
|     //    window->DrawList->AddRect(g.LastItemData.NavRect.Min, g.LastItemData.NavRect.Max, IM_COL32(255,255,0,255)); // [DEBUG] | ||||
| #endif | ||||
|  | ||||
|     // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them) | ||||
|     if (is_rect_visible) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user