MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / RenderDimmedBackgrounds

Method RenderDimmedBackgrounds

Dependencies/ImGui/src/imgui.cpp:6160–6217  ·  view source on GitHub ↗

Important: AddWindowToDrawData() has not been called yet, meaning DockNodeHost windows needs a DrawList->ChannelsMerge() before usage. We call ChannelsMerge() lazily here at it is faster that doing a full iteration of g.Windows[] prior to calling RenderDimmedBackgrounds().

Source from the content-addressed store, hash-verified

6158// Important: AddWindowToDrawData() has not been called yet, meaning DockNodeHost windows needs a DrawList->ChannelsMerge() before usage.
6159// We call ChannelsMerge() lazily here at it is faster that doing a full iteration of g.Windows[] prior to calling RenderDimmedBackgrounds().
6160static void ImGui::RenderDimmedBackgrounds()
6161{
6162 ImGuiContext& g = *GImGui;
6163 ImGuiWindow* modal_window = GetTopMostAndVisiblePopupModal();
6164 if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f)
6165 return;
6166 const bool dim_bg_for_modal = (modal_window != NULL);
6167 const bool dim_bg_for_window_list = (g.NavWindowingTargetAnim != NULL && g.NavWindowingTargetAnim->Active);
6168 if (!dim_bg_for_modal && !dim_bg_for_window_list)
6169 return;
6170
6171 ImGuiViewport* viewports_already_dimmed[2] = { NULL, NULL };
6172 if (dim_bg_for_modal)
6173 {
6174 // Draw dimming behind modal or a begin stack child, whichever comes first in draw order.
6175 ImGuiWindow* dim_behind_window = FindBottomMostVisibleWindowWithinBeginStack(modal_window);
6176 RenderDimmedBackgroundBehindWindow(dim_behind_window, GetColorU32(modal_window->DC.ModalDimBgColor, g.DimBgRatio));
6177 viewports_already_dimmed[0] = modal_window->Viewport;
6178 }
6179 else if (dim_bg_for_window_list)
6180 {
6181 // Draw dimming behind Ctrl+Tab target window and behind Ctrl+Tab UI window
6182 RenderDimmedBackgroundBehindWindow(g.NavWindowingTargetAnim, GetColorU32(ImGuiCol_NavWindowingDimBg, g.DimBgRatio));
6183 viewports_already_dimmed[0] = g.NavWindowingTargetAnim->Viewport;
6184 if (g.NavWindowingListWindow != NULL && g.NavWindowingListWindow->Active && g.NavWindowingListWindow->Viewport && g.NavWindowingListWindow->Viewport != g.NavWindowingTargetAnim->Viewport)
6185 {
6186 RenderDimmedBackgroundBehindWindow(g.NavWindowingListWindow, GetColorU32(ImGuiCol_NavWindowingDimBg, g.DimBgRatio));
6187 viewports_already_dimmed[1] = g.NavWindowingListWindow->Viewport;
6188 }
6189
6190 // Draw border around Ctrl+Tab target window
6191 ImGuiWindow* window = g.NavWindowingTargetAnim;
6192 ImGuiViewport* viewport = window->Viewport;
6193 float distance = g.FontSize;
6194 ImRect bb = window->Rect();
6195 bb.Expand(distance);
6196 if (bb.GetWidth() >= viewport->Size.x && bb.GetHeight() >= viewport->Size.y)
6197 bb.Expand(-distance - 1.0f); // If a window fits the entire viewport, adjust its highlight inward
6198 window->DrawList->ChannelsMerge();
6199 if (window->DrawList->CmdBuffer.Size == 0)
6200 window->DrawList->AddDrawCmd();
6201 window->DrawList->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size);
6202 window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), window->WindowRounding, 0, 3.0f); // FIXME-DPI
6203 window->DrawList->PopClipRect();
6204 }
6205
6206 // Draw dimming background on _other_ viewports than the ones our windows are in
6207 for (ImGuiViewportP* viewport : g.Viewports)
6208 {
6209 if (viewport == viewports_already_dimmed[0] || viewport == viewports_already_dimmed[1])
6210 continue;
6211 if (modal_window && viewport->Window && IsWindowAbove(viewport->Window, modal_window))
6212 continue;
6213 ImDrawList* draw_list = GetForegroundDrawList(viewport);
6214 const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio);
6215 draw_list->AddRectFilled(viewport->Pos, viewport->Pos + viewport->Size, dim_bg_col);
6216 }
6217}

Callers

nothing calls this directly

Calls 10

GetForegroundDrawListFunction · 0.85
GetWidthMethod · 0.80
ChannelsMergeMethod · 0.80
AddDrawCmdMethod · 0.80
AddRectMethod · 0.80
AddRectFilledMethod · 0.80
ExpandMethod · 0.45
GetHeightMethod · 0.45
PushClipRectMethod · 0.45
PopClipRectMethod · 0.45

Tested by

no test coverage detected