Window: fixed auto-fit calculation mismatch of whether a scrollbar will be added by maximum height clamping.

Also honor NoScrollBar in the case of height clamping, not adding extra
horizontal space.
features/sdl_renderer3_multiviewports
ocornut ago%!(EXTRA string=10 years)
parent 3115e546aa
commit 79a95256e8
  1. 7
      imgui.cpp

@ -3425,15 +3425,16 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
// Calculate auto-fit size
ImVec2 size_auto_fit;
ImVec2 window_padding = window->WindowPadding();
if ((flags & ImGuiWindowFlags_Tooltip) != 0)
{
// Tooltip always resize. We keep the spacing symmetric on both axises for aesthetic purpose.
size_auto_fit = window->SizeContents + style.WindowPadding - ImVec2(0.0f, style.ItemSpacing.y);
size_auto_fit = window->SizeContents + window_padding - ImVec2(0.0f, style.ItemSpacing.y);
}
else
{
size_auto_fit = ImClamp(window->SizeContents + style.WindowPadding, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - style.WindowPadding));
if (size_auto_fit.y < window->SizeContents.y + style.WindowPadding.y)
size_auto_fit = ImClamp(window->SizeContents + window_padding, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - window_padding));
if (size_auto_fit.y < window->SizeContents.y && !(flags & ImGuiWindowFlags_NoScrollbar))
size_auto_fit.x += style.ScrollbarWidth;
size_auto_fit.y -= style.ItemSpacing.y;
}

Loading…
Cancel
Save