Skip to content

Commit a3667f4

Browse files
committed
Fixed tooltip in own viewport over modal from being incorrectly dimmed. (ocornut#4729)
Normally we would aim to ensure that g.Windows[] gets maintained to reflect display layer but it is presently non trivial.
1 parent 3fde445 commit a3667f4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

imgui.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -4365,11 +4365,15 @@ static void AddWindowToDrawData(ImGuiWindow* window, int layer)
43654365
}
43664366
}
43674367

4368+
static inline int GetWindowDisplayLayer(ImGuiWindow* window)
4369+
{
4370+
return (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0;
4371+
}
4372+
43684373
// Layer is locked for the root window, however child windows may use a different viewport (e.g. extruding menu)
4369-
static void AddRootWindowToDrawData(ImGuiWindow* window)
4374+
static inline void AddRootWindowToDrawData(ImGuiWindow* window)
43704375
{
4371-
int layer = (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0;
4372-
AddWindowToDrawData(window, layer);
4376+
AddWindowToDrawData(window, GetWindowDisplayLayer(window));
43734377
}
43744378

43754379
void ImDrawDataBuilder::FlattenIntoSingleLayer()
@@ -6763,6 +6767,12 @@ bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent,
67636767
bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below)
67646768
{
67656769
ImGuiContext& g = *GImGui;
6770+
6771+
// It would be saner to ensure that display layer is always reflected in the g.Windows[] order, which would likely requires altering all manipulations of that array
6772+
const int display_layer_delta = GetWindowDisplayLayer(potential_above) - GetWindowDisplayLayer(potential_below);
6773+
if (display_layer_delta != 0)
6774+
return display_layer_delta > 0;
6775+
67666776
for (int i = g.Windows.Size - 1; i >= 0; i--)
67676777
{
67686778
ImGuiWindow* candidate_window = g.Windows[i];

0 commit comments

Comments
 (0)