IsWindowHovered, IsItemHovered: Assert when passed any unsupported flags.

This commit is contained in:
ocornut 2023-06-19 15:34:20 +02:00
parent e7a4327eb8
commit 9214c28aad
3 changed files with 12 additions and 1 deletions

View File

@ -64,6 +64,7 @@ Other changes:
- IsItemHovered: Tweaked default value of style.HoverDelayNormal from 0.30 to 0.40, - IsItemHovered: Tweaked default value of style.HoverDelayNormal from 0.30 to 0.40,
Tweaked default value of style.HoverDelayShort from 0.10 to 0.15. (#1485) Tweaked default value of style.HoverDelayShort from 0.10 to 0.15. (#1485)
- IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary. - IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary.
- IsWindowHovered, IsItemHovered: Assert when passed any unsupported flags.
- Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either - Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either
ScrollX or ScrollY flags from being impossible to resize. (#6503) ScrollX or ScrollY flags from being impossible to resize. (#6503)
- Clipper: Rework inner logic to allow functioning with a zero-clear constructor. - Clipper: Rework inner logic to allow functioning with a zero-clear constructor.

View File

@ -3950,6 +3950,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
IM_ASSERT((flags & ~ImGuiHoveredFlags_AllowedMaskForIsItemHovered) == 0 && "Invalid flags for IsItemHovered()!");
if (g.NavDisableMouseHover && !g.NavDisableHighlight && !(flags & ImGuiHoveredFlags_NoNavOverride)) if (g.NavDisableMouseHover && !g.NavDisableHighlight && !(flags & ImGuiHoveredFlags_NoNavOverride))
{ {
@ -7253,7 +7254,8 @@ bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_b
bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
{ {
IM_ASSERT((flags & (ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled)) == 0); // Flags not supported by this function IM_ASSERT((flags & ~ImGuiHoveredFlags_AllowedMaskForIsWindowHovered) == 0 && "Invalid flags for IsWindowHovered()!");
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* ref_window = g.HoveredWindow; ImGuiWindow* ref_window = g.HoveredWindow;
ImGuiWindow* cur_window = g.CurrentWindow; ImGuiWindow* cur_window = g.CurrentWindow;

View File

@ -833,6 +833,14 @@ enum ImGuiItemStatusFlags_
#endif #endif
}; };
// Extend ImGuiHoveredFlags_
enum ImGuiHoveredFlagsPrivate_
{
ImGuiHoveredFlags_DelayMask_ = ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay,
ImGuiHoveredFlags_AllowedMaskForIsWindowHovered = ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary,
ImGuiHoveredFlags_AllowedMaskForIsItemHovered = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_NoNavOverride | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayMask_,
};
// Extend ImGuiInputTextFlags_ // Extend ImGuiInputTextFlags_
enum ImGuiInputTextFlagsPrivate_ enum ImGuiInputTextFlagsPrivate_
{ {