mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 07:01:04 +01:00 
			
		
		
		
	Refactor: moving ItemAdd() into a section abote ItemSize(). No logic change (part 1)
Moved KeepAliveID() as well for increased locality. Adding dummy ItemAdd() placeholder to facilitate diffing (otherwise single commit single diff is a mess).
This commit is contained in:
		
							
								
								
									
										53
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -75,6 +75,7 @@ CODE
 | 
				
			|||||||
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
 | 
					// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
 | 
				
			||||||
// [SECTION] INPUTS
 | 
					// [SECTION] INPUTS
 | 
				
			||||||
// [SECTION] ERROR CHECKING
 | 
					// [SECTION] ERROR CHECKING
 | 
				
			||||||
 | 
					// [SECTION] ITEM SUBMISSION
 | 
				
			||||||
// [SECTION] LAYOUT
 | 
					// [SECTION] LAYOUT
 | 
				
			||||||
// [SECTION] SCROLLING
 | 
					// [SECTION] SCROLLING
 | 
				
			||||||
// [SECTION] TOOLTIPS
 | 
					// [SECTION] TOOLTIPS
 | 
				
			||||||
@@ -3924,17 +3925,6 @@ ImGuiID ImGui::GetHoveredID()
 | 
				
			|||||||
    return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame;
 | 
					    return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// This is called by ItemAdd().
 | 
					 | 
				
			||||||
// Code not using ItemAdd() may need to call this manually otherwise ActiveId will be cleared. In IMGUI_VERSION_NUM < 18717 this was called by GetID().
 | 
					 | 
				
			||||||
void ImGui::KeepAliveID(ImGuiID id)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    ImGuiContext& g = *GImGui;
 | 
					 | 
				
			||||||
    if (g.ActiveId == id)
 | 
					 | 
				
			||||||
        g.ActiveIdIsAlive = id;
 | 
					 | 
				
			||||||
    if (g.ActiveIdPreviousFrame == id)
 | 
					 | 
				
			||||||
        g.ActiveIdPreviousFrameIsAlive = true;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ImGui::MarkItemEdited(ImGuiID id)
 | 
					void ImGui::MarkItemEdited(ImGuiID id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
 | 
					    // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
 | 
				
			||||||
@@ -9728,12 +9718,46 @@ void ImGuiStackSizes::CompareWithContextState(ImGuiContext* ctx)
 | 
				
			|||||||
    IM_ASSERT(SizeOfFocusScopeStack == g.FocusScopeStack.Size   && "PushFocusScope/PopFocusScope Mismatch!");
 | 
					    IM_ASSERT(SizeOfFocusScopeStack == g.FocusScopeStack.Size   && "PushFocusScope/PopFocusScope Mismatch!");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// [SECTION] ITEM SUBMISSION
 | 
				
			||||||
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// - KeepAliveID()
 | 
				
			||||||
 | 
					// - ItemAdd()
 | 
				
			||||||
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Code not using ItemAdd() may need to call this manually otherwise ActiveId will be cleared. In IMGUI_VERSION_NUM < 18717 this was called by GetID().
 | 
				
			||||||
 | 
					void ImGui::KeepAliveID(ImGuiID id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ImGuiContext& g = *GImGui;
 | 
				
			||||||
 | 
					    if (g.ActiveId == id)
 | 
				
			||||||
 | 
					        g.ActiveIdIsAlive = id;
 | 
				
			||||||
 | 
					    if (g.ActiveIdPreviousFrame == id)
 | 
				
			||||||
 | 
					        g.ActiveIdPreviousFrameIsAlive = true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 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;
 | 
				
			||||||
 | 
					    ImGuiWindow* window = g.CurrentWindow;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
// [SECTION] LAYOUT
 | 
					// [SECTION] LAYOUT
 | 
				
			||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
// - ItemSize()
 | 
					// - ItemSize()
 | 
				
			||||||
// - ItemAdd()
 | 
					 | 
				
			||||||
// - SameLine()
 | 
					// - SameLine()
 | 
				
			||||||
// - GetCursorScreenPos()
 | 
					// - GetCursorScreenPos()
 | 
				
			||||||
// - SetCursorScreenPos()
 | 
					// - SetCursorScreenPos()
 | 
				
			||||||
@@ -9801,10 +9825,7 @@ void ImGui::ItemSize(const ImVec2& size, float text_baseline_y)
 | 
				
			|||||||
        SameLine();
 | 
					        SameLine();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 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)
 | 
					bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGuiItemFlags extra_flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ImGuiContext& g = *GImGui;
 | 
					    ImGuiContext& g = *GImGui;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user