MCPcopy Create free account
hub / github.com/RenderKit/embree / CalcWindowSizeAfterConstraint

Function CalcWindowSizeAfterConstraint

tutorials/common/imgui/imgui.cpp:5714–5747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5712}
5713
5714static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& size_desired)
5715{
5716 ImGuiContext& g = *GImGui;
5717 ImVec2 new_size = size_desired;
5718 if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint)
5719 {
5720 // Using -1,-1 on either X/Y axis to preserve the current size.
5721 ImRect cr = g.NextWindowData.SizeConstraintRect;
5722 new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x;
5723 new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y;
5724 if (g.NextWindowData.SizeCallback)
5725 {
5726 ImGuiSizeCallbackData data;
5727 data.UserData = g.NextWindowData.SizeCallbackUserData;
5728 data.Pos = window->Pos;
5729 data.CurrentSize = window->SizeFull;
5730 data.DesiredSize = new_size;
5731 g.NextWindowData.SizeCallback(&data);
5732 new_size = data.DesiredSize;
5733 }
5734 new_size.x = IM_FLOOR(new_size.x);
5735 new_size.y = IM_FLOOR(new_size.y);
5736 }
5737
5738 // Minimum size
5739 if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize)))
5740 {
5741 ImGuiWindow* window_for_height = window;
5742 const float decoration_up_height = window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight();
5743 new_size = ImMax(new_size, g.Style.WindowMinSize);
5744 new_size.y = ImMax(new_size.y, decoration_up_height + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
5745 }
5746 return new_size;
5747}
5748
5749static void CalcWindowContentSizes(ImGuiWindow* window, ImVec2* content_size_current, ImVec2* content_size_ideal)
5750{

Callers 5

CalcWindowAutoFitSizeFunction · 0.85
BeginMethod · 0.85

Calls 2

ImClampFunction · 0.85
ImMaxFunction · 0.85

Tested by

no test coverage detected