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. (#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 2080d12 commit b50b22d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
13 changes: 3 additions & 10 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@ Other changes:
Note that Linux/Mac still have inconsistent support for multi-viewports. If you want to help see https://github.com/ocornut/imgui/issues/2117.


-----------------------------------------------------------------------
VERSION 1.86 WIP (In Progress)
-----------------------------------------------------------------------

Docking+Viewports Branch:

- Docking: Revert removal of io.ConfigDockingWithShift config option (removed in 1.83). (#4643)
- Backends: Made it possible to shutdown default Platform Backends before the Renderer backends. (#4656)


-----------------------------------------------------------------------
VERSION 1.86 WIP (In Progress)
-----------------------------------------------------------------------
Expand Down Expand Up @@ -154,9 +144,12 @@ Other Changes:

Docking+Viewports Branch:

- Docking: Revert removal of io.ConfigDockingWithShift config option (removed in 1.83). (#4643)
- Viewports: Made it possible to explicitly assign ImGuiWindowClass::ParentViewportId to 0 in order
to ensure a window is not parented. Previously this would use the global default (which might be 0,
but not always as it would depend on io.ConfigViewportsNoDefaultParent). (#3152, #2871)
- Viewports: Fixed tooltip in own viewport over modal from being incorrectly dimmed. (#4729)
- Backends: Made it possible to shutdown default Platform Backends before the Renderer backends. (#4656)
- Disabled: Fixed nested BeginDisabled()/EndDisabled() bug in Docking branch due to bad merge. (#4655, #4452, #4453, #4462)


Expand Down
16 changes: 13 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4534,11 +4534,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 @@ -7303,6 +7307,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 b50b22d

Please sign in to comment.