mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-03 17:24:24 +00:00 
			
		
		
		
	Refactored duplicated code into an inline function & made more readable
This commit is contained in:
		
							
								
								
									
										19
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -4238,6 +4238,17 @@ void ImGui::LabelText(const char* label, const char* fmt, ...)
 | 
			
		||||
    va_end(args);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline bool IsWindowContentHoverable(ImGuiWindow* window)
 | 
			
		||||
{
 | 
			
		||||
    ImGuiState& g = *GImGui;
 | 
			
		||||
 | 
			
		||||
    ImGuiWindow* focused_window = g.FocusedWindow;
 | 
			
		||||
    if (focused_window && (focused_window->Flags & ImGuiWindowFlags_Popup) != 0 && focused_window->WasVisible && focused_window != window)
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool IsHovered(const ImRect& bb, ImGuiID id)
 | 
			
		||||
{
 | 
			
		||||
    ImGuiState& g = *GImGui;
 | 
			
		||||
@@ -4247,14 +4258,10 @@ static bool IsHovered(const ImRect& bb, ImGuiID id)
 | 
			
		||||
        if (g.HoveredRootWindow == window->RootWindow)
 | 
			
		||||
        {
 | 
			
		||||
            if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdIsFocusedOnly) && IsMouseHoveringRect(bb))
 | 
			
		||||
            {
 | 
			
		||||
                if (g.FocusedWindow == g.HoveredRootWindow || !((g.FocusedWindow->Flags & ImGuiWindowFlags_Popup) != 0 && g.FocusedWindow->WasVisible))
 | 
			
		||||
                {
 | 
			
		||||
                if (IsWindowContentHoverable(g.HoveredRootWindow))
 | 
			
		||||
                    return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -7008,7 +7015,7 @@ static bool ItemAdd(const ImRect& bb, const ImGuiID* id)
 | 
			
		||||
        window->DC.LastItemHoveredRect = true;
 | 
			
		||||
        window->DC.LastItemHoveredAndUsable = false;
 | 
			
		||||
        if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdIsFocusedOnly || (g.ActiveId == window->MoveID))
 | 
			
		||||
            if (g.FocusedWindow == window || !((g.FocusedWindow->Flags & ImGuiWindowFlags_Popup) != 0 && g.FocusedWindow->WasVisible))
 | 
			
		||||
            if (IsWindowContentHoverable(window))
 | 
			
		||||
                window->DC.LastItemHoveredAndUsable = true;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user