From 9007dff5eb8bfbb19989ea238160b8a9685b6894 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 10 Jul 2018 19:16:57 +0200 Subject: [PATCH] IsItemHovered(): Added ImGuiHoveredFlags_AllowWhenDisabled flag to query hovered status on disabled items. (#1940, #211) + shallow changelog tweaks --- CHANGELOG.txt | 9 +++++---- imgui.cpp | 2 +- imgui.h | 1 + imgui_internal.h | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0eb6cc30..6bc94c7a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -51,10 +51,11 @@ Other Changes: - Drag and Drop: Fixed ImGuiDragDropFlags_SourceNoDisableHover to affect hovering state prior to calling IsItemHovered() + fixed description. (#143) - Drag and Drop: Calling BeginTooltip() between a BeginDragSource()/EndDragSource() or BeginDropTarget()/EndDropTarget() uses adjusted tooltip settings matching the one created when calling BeginDragSource() without the ImGuiDragDropFlags_SourceNoPreviewTooltip flag. (#143) + - IsItemHovered(): Added ImGuiHoveredFlags_AllowWhenDisabled flag to query hovered status on disabled items. (#1940, #211) - Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] - Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. - Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276) - - Windows: Fixed missing ImmReleaseContext() call in the default Win32 IME handler. (#1932) [@vby] + - OS/Windows: Fixed missing ImmReleaseContext() call in the default Win32 IME handler. (#1932) [@vby] - Demo: Added basic Drag and Drop demo. (#143) - Examples: Metal: Added Metal rendering backend. (#1929, #1873) [@warrenm] - Examples: OSX: Added early raw OSX platform backend. (#1873) [@pagghiu, @itamago, @ocornut] @@ -733,9 +734,9 @@ Other Changes: - Clipboard: Added a void* user_data parameter to Clipboard function handlers. (#875) (BREAKING API) - Internals: Refactor internal text alignment options to use ImVec2, removed ImGuiAlign. (#842, #222) - Internals: Renamed ImLoadFileToMemory to ImFileLoadToMemory to be consistent with ImFileOpen + fix mismatching .h name. (#917) -- Windows: Fixed Windows default clipboard handler leaving its buffer unfreed on application's exit. (#714) -- Windows: No default IME handler when compiling for Windows using GCC. (#738) -- Windows: Now using _wfopen() instead of fopen() to allow passing in paths/filenames with UTF-8 characters. (#917) +- OS/Windows: Fixed Windows default clipboard handler leaving its buffer unfreed on application's exit. (#714) +- OS/Windows: No default IME handler when compiling for Windows using GCC. (#738) +- OS/Windows: Now using _wfopen() instead of fopen() to allow passing in paths/filenames with UTF-8 characters. (#917) - Tools: binary_to_compressed_c: Avoid ?? trigraphs sequences in string outputs which break some older compilers. (#839) - Demo: Added an extra 3-way columns demo. - Demo: ShowStyleEditor: show font character map / grid in more details. diff --git a/imgui.cpp b/imgui.cpp index dd9bff9b..04aa9391 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2699,7 +2699,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) return false; // Test if the item is disabled - if (window->DC.ItemFlags & ImGuiItemFlags_Disabled) + if ((window->DC.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) return false; // Special handling for the 1st item after Begin() which represent the title bar. When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect tht case. diff --git a/imgui.h b/imgui.h index 53bf0627..6a605e69 100644 --- a/imgui.h +++ b/imgui.h @@ -719,6 +719,7 @@ enum ImGuiHoveredFlags_ //ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 4, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet. ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 5, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns. ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 6, // Return true even if the position is overlapped by another window + ImGuiHoveredFlags_AllowWhenDisabled = 1 << 7, // Return true even if the item is disabled ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped, ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows }; diff --git a/imgui_internal.h b/imgui_internal.h index 7783e3ff..a03ab0cc 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -865,7 +865,7 @@ enum ImGuiItemFlags_ { ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings. - ImGuiItemFlags_Disabled = 1 << 2, // false // FIXME-WIP: Disable interactions but doesn't affect visuals. Should be: grey out and disable interactions with widgets that affect data + view widgets (WIP) + ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211 ImGuiItemFlags_NoNav = 1 << 3, // false ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window