Windows: WindowMinSize not applied on AlwaysAutoResize window. (amend e2035a5)

See "window_size_min" test. Waiting for a fuller simplification of this, probably for a future version.
This commit is contained in:
ocornut 2023-11-15 14:44:01 +01:00
parent f298491a8a
commit 623bff23ce

View File

@ -5697,6 +5697,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window) static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window)
{ {
// Popups, menus and childs bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups) // Popups, menus and childs bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups)
// FIXME: the if/else could probably be removed, "reduce artifacts" section for all windows.
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImVec2 size_min; ImVec2 size_min;
if (window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_ChildWindow)) if (window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_ChildWindow))
@ -5707,7 +5708,8 @@ static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window)
else else
{ {
ImGuiWindow* window_for_height = window; ImGuiWindow* window_for_height = window;
size_min = g.Style.WindowMinSize; size_min.x = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.x : 4.0f;
size_min.y = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.x : 4.0f;
size_min.y = ImMax(size_min.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows size_min.y = ImMax(size_min.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
} }
return size_min; return size_min;