From 61d35972e2ee0e2ee473290fcc2e265ea5b7be38 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 25 Aug 2023 14:29:42 +0200 Subject: [PATCH] CloseButton, CollapseButton: don't include FramePadding into size. Use ItemInnerSpacing.x between title bar buttons. Amend for Docking. (#6749) --- imgui.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index af9c17eac..7bce4e4c9 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -17050,14 +17050,13 @@ static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* o r.Max.x -= style.WindowBorderSize; float button_sz = g.FontSize; - - ImVec2 window_menu_button_pos = r.Min; r.Min.x += style.FramePadding.x; r.Max.x -= style.FramePadding.x; + ImVec2 window_menu_button_pos = ImVec2(r.Min.x, r.Min.y + style.FramePadding.y); if (node->HasCloseButton) { - r.Max.x -= button_sz; - if (out_close_button_pos) *out_close_button_pos = ImVec2(r.Max.x - style.FramePadding.x, r.Min.y); + if (out_close_button_pos) *out_close_button_pos = ImVec2(r.Max.x - button_sz, r.Min.y + style.FramePadding.y); + r.Max.x -= button_sz + style.ItemInnerSpacing.x; } if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Left) { @@ -17065,8 +17064,8 @@ static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* o } else if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Right) { - r.Max.x -= button_sz + style.FramePadding.x; - window_menu_button_pos = ImVec2(r.Max.x, r.Min.y); + window_menu_button_pos = ImVec2(r.Max.x - button_sz, r.Min.y + style.FramePadding.y); + r.Max.x -= button_sz + style.ItemInnerSpacing.x; } if (out_tab_bar_rect) { *out_tab_bar_rect = r; } if (out_window_menu_button_pos) { *out_window_menu_button_pos = window_menu_button_pos; }