Skip to content

Commit

Permalink
CloseButton, CollapseButton: don't include FramePadding into size. Us…
Browse files Browse the repository at this point in the history
…e ItemInnerSpacing.x between title bar buttons. Amend for Docking. (#6749)
  • Loading branch information
ocornut committed Aug 25, 2023
1 parent 676497f commit 61d3597
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17050,23 +17050,22 @@ 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)
{
r.Min.x += button_sz + style.ItemInnerSpacing.x;
}
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; }
Expand Down

0 comments on commit 61d3597

Please sign in to comment.