CloseButton, CollapseButton: don't include FramePadding into size. Use ItemInnerSpacing.x between title bar buttons. Amend for Docking. (#6749)

This commit is contained in:
ocornut 2023-08-25 14:29:42 +02:00
parent 676497fe05
commit 61d35972e2

View File

@ -17050,14 +17050,13 @@ static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* o
r.Max.x -= style.WindowBorderSize; r.Max.x -= style.WindowBorderSize;
float button_sz = g.FontSize; float button_sz = g.FontSize;
ImVec2 window_menu_button_pos = r.Min;
r.Min.x += style.FramePadding.x; r.Min.x += style.FramePadding.x;
r.Max.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) if (node->HasCloseButton)
{ {
r.Max.x -= button_sz; if (out_close_button_pos) *out_close_button_pos = ImVec2(r.Max.x - button_sz, r.Min.y + style.FramePadding.y);
if (out_close_button_pos) *out_close_button_pos = ImVec2(r.Max.x - style.FramePadding.x, r.Min.y); r.Max.x -= button_sz + style.ItemInnerSpacing.x;
} }
if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Left) 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) else if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Right)
{ {
r.Max.x -= button_sz + style.FramePadding.x; window_menu_button_pos = ImVec2(r.Max.x - button_sz, r.Min.y + style.FramePadding.y);
window_menu_button_pos = ImVec2(r.Max.x, r.Min.y); r.Max.x -= button_sz + style.ItemInnerSpacing.x;
} }
if (out_tab_bar_rect) { *out_tab_bar_rect = r; } 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; } if (out_window_menu_button_pos) { *out_window_menu_button_pos = window_menu_button_pos; }