Skip to content

Commit

Permalink
Fixed tooltip in own viewport over modal from being incorrectly dimme…
Browse files Browse the repository at this point in the history
…d. (ocornut#4729)

Normally we would aim to ensure that g.Windows[] gets maintained to reflect display layer but it is presently non trivial.
  • Loading branch information
ocornut committed Nov 16, 2021
1 parent 3fde445 commit a3667f4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4365,11 +4365,15 @@ static void AddWindowToDrawData(ImGuiWindow* window, int layer)
}
}

static inline int GetWindowDisplayLayer(ImGuiWindow* window)
{
return (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0;
}

// Layer is locked for the root window, however child windows may use a different viewport (e.g. extruding menu)
static void AddRootWindowToDrawData(ImGuiWindow* window)
static inline void AddRootWindowToDrawData(ImGuiWindow* window)
{
int layer = (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0;
AddWindowToDrawData(window, layer);
AddWindowToDrawData(window, GetWindowDisplayLayer(window));
}

void ImDrawDataBuilder::FlattenIntoSingleLayer()
Expand Down Expand Up @@ -6763,6 +6767,12 @@ bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent,
bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below)
{
ImGuiContext& g = *GImGui;

// 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
const int display_layer_delta = GetWindowDisplayLayer(potential_above) - GetWindowDisplayLayer(potential_below);
if (display_layer_delta != 0)
return display_layer_delta > 0;

for (int i = g.Windows.Size - 1; i >= 0; i--)
{
ImGuiWindow* candidate_window = g.Windows[i];
Expand Down

0 comments on commit a3667f4

Please sign in to comment.