mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Tooltips: made it possible to use ImGuiHoveredFlags_ForTooltip + a ImGuiHoveredFlags_DelayXXXX override. (#1485)
This commit is contained in:
		@@ -70,6 +70,8 @@ Other changes:
 | 
				
			|||||||
- Tooltips: made using SetItemTooltip()/IsItemHovered(ImGuiHoveredFlags_ForTooltip) defaults to
 | 
					- Tooltips: made using SetItemTooltip()/IsItemHovered(ImGuiHoveredFlags_ForTooltip) defaults to
 | 
				
			||||||
  activate tooltips on disabled items. This is done by adding ImGuiHoveredFlags_AllowWhenDisabled
 | 
					  activate tooltips on disabled items. This is done by adding ImGuiHoveredFlags_AllowWhenDisabled
 | 
				
			||||||
  to the default value of style.HoverFlagsForTooltipMouse/HoverFlagsForTooltipNav. (#1485)
 | 
					  to the default value of style.HoverFlagsForTooltipMouse/HoverFlagsForTooltipNav. (#1485)
 | 
				
			||||||
 | 
					- Tooltips: made is possible to combine ImGuiHoveredFlags_ForTooltip with a ImGuiHoveredFlags_DelayXXX
 | 
				
			||||||
 | 
					  override. (#1485)
 | 
				
			||||||
- Nav: Tabbing always enable nav highlight when ImGuiConfigFlags_NavEnableKeyboard is set.
 | 
					- Nav: Tabbing always enable nav highlight when ImGuiConfigFlags_NavEnableKeyboard is set.
 | 
				
			||||||
  Previously was inconsistent and only enabled when stepping through a non-input item.
 | 
					  Previously was inconsistent and only enabled when stepping through a non-input item.
 | 
				
			||||||
  (#6802, #3092, #5759, #787)
 | 
					  (#6802, #3092, #5759, #787)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -4001,13 +4001,21 @@ bool ImGui::IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flag
 | 
				
			|||||||
static inline float CalcDelayFromHoveredFlags(ImGuiHoveredFlags flags)
 | 
					static inline float CalcDelayFromHoveredFlags(ImGuiHoveredFlags flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ImGuiContext& g = *GImGui;
 | 
					    ImGuiContext& g = *GImGui;
 | 
				
			||||||
    if (flags & ImGuiHoveredFlags_DelayShort)
 | 
					 | 
				
			||||||
        return g.Style.HoverDelayShort;
 | 
					 | 
				
			||||||
    if (flags & ImGuiHoveredFlags_DelayNormal)
 | 
					    if (flags & ImGuiHoveredFlags_DelayNormal)
 | 
				
			||||||
        return g.Style.HoverDelayNormal;
 | 
					        return g.Style.HoverDelayNormal;
 | 
				
			||||||
 | 
					    if (flags & ImGuiHoveredFlags_DelayShort)
 | 
				
			||||||
 | 
					        return g.Style.HoverDelayShort;
 | 
				
			||||||
    return 0.0f;
 | 
					    return 0.0f;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static ImGuiHoveredFlags ApplyHoverFlagsForTooltip(ImGuiHoveredFlags user_flags, ImGuiHoveredFlags shared_flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Allow instance flags to override shared flags
 | 
				
			||||||
 | 
					    if (user_flags & (ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal))
 | 
				
			||||||
 | 
					        shared_flags &= ~(ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal);
 | 
				
			||||||
 | 
					    return user_flags | shared_flags;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// This is roughly matching the behavior of internal-facing ItemHoverable()
 | 
					// This is roughly matching the behavior of internal-facing ItemHoverable()
 | 
				
			||||||
// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered()
 | 
					// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered()
 | 
				
			||||||
// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
 | 
					// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
 | 
				
			||||||
@@ -4025,7 +4033,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
 | 
				
			|||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (flags & ImGuiHoveredFlags_ForTooltip)
 | 
					        if (flags & ImGuiHoveredFlags_ForTooltip)
 | 
				
			||||||
            flags |= g.Style.HoverFlagsForTooltipNav;
 | 
					            flags = ApplyHoverFlagsForTooltip(flags, g.Style.HoverFlagsForTooltipNav);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -4035,7 +4043,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
 | 
				
			|||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (flags & ImGuiHoveredFlags_ForTooltip)
 | 
					        if (flags & ImGuiHoveredFlags_ForTooltip)
 | 
				
			||||||
            flags |= g.Style.HoverFlagsForTooltipMouse;
 | 
					            flags = ApplyHoverFlagsForTooltip(flags, g.Style.HoverFlagsForTooltipMouse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy)) == 0);   // Flags not supported by this function
 | 
					        IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy)) == 0);   // Flags not supported by this function
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -5423,7 +5431,6 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
 | 
				
			|||||||
    // Size
 | 
					    // Size
 | 
				
			||||||
    const ImVec2 content_avail = GetContentRegionAvail();
 | 
					    const ImVec2 content_avail = GetContentRegionAvail();
 | 
				
			||||||
    ImVec2 size = ImTrunc(size_arg);
 | 
					    ImVec2 size = ImTrunc(size_arg);
 | 
				
			||||||
    const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00);
 | 
					 | 
				
			||||||
    if (size.x <= 0.0f)
 | 
					    if (size.x <= 0.0f)
 | 
				
			||||||
        size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too many issues)
 | 
					        size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too many issues)
 | 
				
			||||||
    if (size.y <= 0.0f)
 | 
					    if (size.y <= 0.0f)
 | 
				
			||||||
@@ -7371,7 +7378,7 @@ bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
 | 
				
			|||||||
    // for different windows of the hierarchy. Possibly need a Hash(Current+Flags) ==> (Timer) cache.
 | 
					    // for different windows of the hierarchy. Possibly need a Hash(Current+Flags) ==> (Timer) cache.
 | 
				
			||||||
    // We can implement this for _Stationary because the data is linked to HoveredWindow rather than CurrentWindow.
 | 
					    // We can implement this for _Stationary because the data is linked to HoveredWindow rather than CurrentWindow.
 | 
				
			||||||
    if (flags & ImGuiHoveredFlags_ForTooltip)
 | 
					    if (flags & ImGuiHoveredFlags_ForTooltip)
 | 
				
			||||||
        flags |= g.Style.HoverFlagsForTooltipMouse;
 | 
					        flags = ApplyHoverFlagsForTooltip(flags, g.Style.HoverFlagsForTooltipMouse);
 | 
				
			||||||
    if ((flags & ImGuiHoveredFlags_Stationary) != 0 && g.HoverWindowUnlockedStationaryId != ref_window->ID)
 | 
					    if ((flags & ImGuiHoveredFlags_Stationary) != 0 && g.HoverWindowUnlockedStationaryId != ref_window->ID)
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user