|
221 | 221 | - 2017/11/18 (1.53) - Style: removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency.
|
222 | 222 | - 2017/11/18 (1.53) - Style: renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg.
|
223 | 223 | - 2017/11/18 (1.53) - Style: renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding.
|
224 |
| - - 2017/11/02 (1.53) - marked IsRootWindowOrAnyChildHovered() as obsolete is favor of using IsWindowHovered(ImGuiHoveredFlags_FlattenChilds); |
| 224 | + - 2017/11/02 (1.53) - marked IsRootWindowOrAnyChildHovered() as obsolete is favor of using IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows); |
225 | 225 | - 2017/10/24 (1.52) - renamed IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency.
|
226 | 226 | - 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it.
|
227 | 227 | - 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details.
|
@@ -2032,7 +2032,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
2032 | 2032 | // Test for bounding box overlap, as updated as ItemAdd()
|
2033 | 2033 | if (!window->DC.LastItemRectHoveredRect)
|
2034 | 2034 | return false;
|
2035 |
| - IM_ASSERT((flags & ImGuiHoveredFlags_FlattenChilds) == 0); // Flags not supported by this function |
| 2035 | + IM_ASSERT((flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) == 0); // Flags not supported by this function |
2036 | 2036 |
|
2037 | 2037 | // Test if we are hovering the right window (our window could be behind another window)
|
2038 | 2038 | // [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself.
|
@@ -5440,20 +5440,43 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
5440 | 5440 | return "Unknown";
|
5441 | 5441 | }
|
5442 | 5442 |
|
| 5443 | +bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent) |
| 5444 | +{ |
| 5445 | + if (window->RootWindow == potential_parent) |
| 5446 | + return true; |
| 5447 | + while (window != NULL) |
| 5448 | + { |
| 5449 | + if (window == potential_parent) |
| 5450 | + return true; |
| 5451 | + window = window->ParentWindow; |
| 5452 | + } |
| 5453 | + return false; |
| 5454 | +} |
| 5455 | + |
5443 | 5456 | bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
|
5444 | 5457 | {
|
5445 | 5458 | IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
|
5446 | 5459 | ImGuiContext& g = *GImGui;
|
5447 |
| - if (flags & ImGuiHoveredFlags_FlattenChilds) |
| 5460 | + switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) |
5448 | 5461 | {
|
| 5462 | + case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows: |
5449 | 5463 | if (g.HoveredRootWindow != g.CurrentWindow->RootWindow)
|
5450 | 5464 | return false;
|
5451 |
| - } |
5452 |
| - else |
5453 |
| - { |
| 5465 | + break; |
| 5466 | + case ImGuiHoveredFlags_RootWindow: |
| 5467 | + if (g.HoveredWindow != g.CurrentWindow->RootWindow) |
| 5468 | + return false; |
| 5469 | + break; |
| 5470 | + case ImGuiHoveredFlags_ChildWindows: |
| 5471 | + if (g.HoveredWindow == NULL || !IsWindowChildOf(g.HoveredWindow, g.CurrentWindow)) |
| 5472 | + return false; |
| 5473 | + break; |
| 5474 | + default: |
5454 | 5475 | if (g.HoveredWindow != g.CurrentWindow)
|
5455 | 5476 | return false;
|
| 5477 | + break; |
5456 | 5478 | }
|
| 5479 | + |
5457 | 5480 | if (!IsWindowContentHoverable(g.HoveredRootWindow, flags))
|
5458 | 5481 | return false;
|
5459 | 5482 | if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
|
|
0 commit comments