MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / RenderWindowDecorations

Method RenderWindowDecorations

plugins/Cardinal/src/DearImGui/imgui.cpp:5718–5799  ·  view source on GitHub ↗

Draw background and borders Draw and handle scrollbars

Source from the content-addressed store, hash-verified

5716// Draw background and borders
5717// Draw and handle scrollbars
5718void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size)
5719{
5720 ImGuiContext& g = *GImGui;
5721 ImGuiStyle& style = g.Style;
5722 ImGuiWindowFlags flags = window->Flags;
5723
5724 // Ensure that ScrollBar doesn't read last frame's SkipItems
5725 IM_ASSERT(window->BeginCount == 0);
5726 window->SkipItems = false;
5727
5728 // Draw window + handle manual resize
5729 // As we highlight the title bar when want_focus is set, multiple reappearing windows will have have their title bar highlighted on their reappearing frame.
5730 const float window_rounding = window->WindowRounding;
5731 const float window_border_size = window->WindowBorderSize;
5732 if (window->Collapsed)
5733 {
5734 // Title bar only
5735 float backup_border_size = style.FrameBorderSize;
5736 g.Style.FrameBorderSize = window->WindowBorderSize;
5737 ImU32 title_bar_col = GetColorU32((title_bar_is_highlight && !g.NavDisableHighlight) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBgCollapsed);
5738 RenderFrame(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, true, window_rounding);
5739 g.Style.FrameBorderSize = backup_border_size;
5740 }
5741 else
5742 {
5743 // Window background
5744 if (!(flags & ImGuiWindowFlags_NoBackground))
5745 {
5746 ImU32 bg_col = GetColorU32(GetWindowBgColorIdx(window));
5747 bool override_alpha = false;
5748 float alpha = 1.0f;
5749 if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha)
5750 {
5751 alpha = g.NextWindowData.BgAlphaVal;
5752 override_alpha = true;
5753 }
5754 if (override_alpha)
5755 bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT);
5756 window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? 0 : ImDrawFlags_RoundCornersBottom);
5757 }
5758
5759 // Title bar
5760 if (!(flags & ImGuiWindowFlags_NoTitleBar))
5761 {
5762 ImU32 title_bar_col = GetColorU32(title_bar_is_highlight ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
5763 window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, window_rounding, ImDrawFlags_RoundCornersTop);
5764 }
5765
5766 // Menu bar
5767 if (flags & ImGuiWindowFlags_MenuBar)
5768 {
5769 ImRect menu_bar_rect = window->MenuBarRect();
5770 menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them.
5771 window->DrawList->AddRectFilled(menu_bar_rect.Min + ImVec2(window_border_size, 0), menu_bar_rect.Max - ImVec2(window_border_size, 0), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawFlags_RoundCornersTop);
5772 if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y)
5773 window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
5774 }
5775

Callers

nothing calls this directly

Calls 9

GetWindowBgColorIdxFunction · 0.85
ImVec2Function · 0.85
ImLerpFunction · 0.85
AddRectFilledMethod · 0.80
RectMethod · 0.80
AddLineMethod · 0.80
PathLineToMethod · 0.80
PathArcToFastMethod · 0.80
PathFillConvexMethod · 0.80

Tested by

no test coverage detected