Skip to content

Commit

Permalink
Viewports: Fixed CTRL+TAB highlight outline on docked windows not alw…
Browse files Browse the repository at this point in the history
…ays fitting in host viewport + moved EndFrameDrawDimmedBackgrounds() call + removed duplicate code in Begin() already in EndFrameDrawDimmedBackgrounds()
  • Loading branch information
ocornut committed Dec 1, 2021
1 parent 5f5ba8e commit 1ab3007
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Docking+Viewports Branch:
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)
- Viewports: Fixed CTRL+TAB highlight outline on docked windows not always fitting in host viewport.
- 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
22 changes: 4 additions & 18 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4664,7 +4664,7 @@ static void ImGui::EndFrameDrawDimmedBackgrounds()
float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding);
ImRect bb = window->Rect();
bb.Expand(g.FontSize);
if (bb.Contains(window->Viewport->GetMainRect())) // If a window fits the entire viewport, adjust its highlight inward
if (!window->Viewport->GetMainRect().Contains(bb)) // If a window fits the entire viewport, adjust its highlight inward
{
bb.Expand(-g.FontSize - 1.0f);
rounding = window->WindowRounding;
Expand Down Expand Up @@ -4704,9 +4704,6 @@ void ImGui::EndFrame()
g.CurrentWindow->Active = false;
End();

// Draw modal whitening background on _other_ viewports than the one the modal is one
EndFrameDrawDimmedBackgrounds();

// Update navigation: CTRL+Tab, wrap-around requests
NavEndFrame();

Expand Down Expand Up @@ -4736,6 +4733,9 @@ void ImGui::EndFrame()
// Initiate moving window + handle left-click and right-click focus
UpdateMouseMovingWindowEndFrame();

// Draw modal/window whitening backgrounds
EndFrameDrawDimmedBackgrounds();

// Update user-facing viewport list (g.Viewports -> g.PlatformIO.Viewports after filtering out some)
UpdateViewportsEndFrame();

Expand Down Expand Up @@ -6743,20 +6743,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->DrawList = &window->DrawListInst;
}

// Draw navigation selection/windowing rectangle border
if (g.NavWindowingTargetAnim == window)
{
float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding);
ImRect bb = window->Rect();
bb.Expand(g.FontSize);
if (bb.Contains(viewport_rect)) // If a window fits the entire viewport, adjust its highlight inward
{
bb.Expand(-g.FontSize - 1.0f);
rounding = window->WindowRounding;
}
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, 0, 3.0f);
}

// UPDATE RECTANGLES (2- THOSE AFFECTED BY SCROLLING)

// Work rectangle.
Expand Down

0 comments on commit 1ab3007

Please sign in to comment.