| 5597 | } |
| 5598 | |
| 5599 | static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& size_desired) |
| 5600 | { |
| 5601 | ImGuiContext& g = *GImGui; |
| 5602 | ImVec2 new_size = size_desired; |
| 5603 | if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) |
| 5604 | { |
| 5605 | // Using -1,-1 on either X/Y axis to preserve the current size. |
| 5606 | ImRect cr = g.NextWindowData.SizeConstraintRect; |
| 5607 | new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x; |
| 5608 | new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y; |
| 5609 | if (g.NextWindowData.SizeCallback) |
| 5610 | { |
| 5611 | ImGuiSizeCallbackData data; |
| 5612 | data.UserData = g.NextWindowData.SizeCallbackUserData; |
| 5613 | data.Pos = window->Pos; |
| 5614 | data.CurrentSize = window->SizeFull; |
| 5615 | data.DesiredSize = new_size; |
| 5616 | g.NextWindowData.SizeCallback(&data); |
| 5617 | new_size = data.DesiredSize; |
| 5618 | } |
| 5619 | new_size.x = IM_FLOOR(new_size.x); |
| 5620 | new_size.y = IM_FLOOR(new_size.y); |
| 5621 | } |
| 5622 | |
| 5623 | // Minimum size |
| 5624 | if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize))) |
| 5625 | { |
| 5626 | ImGuiWindow* window_for_height = window; |
| 5627 | new_size = ImMax(new_size, g.Style.WindowMinSize); |
| 5628 | const float minimum_height = window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f); |
| 5629 | new_size.y = ImMax(new_size.y, minimum_height); // Reduce artifacts with very small windows |
| 5630 | } |
| 5631 | return new_size; |
| 5632 | } |
| 5633 | |
| 5634 | static void CalcWindowContentSizes(ImGuiWindow* window, ImVec2* content_size_current, ImVec2* content_size_ideal) |
| 5635 | { |
no test coverage detected