| 5121 | } |
| 5122 | |
| 5123 | static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags) |
| 5124 | { |
| 5125 | ImGuiContext& g = *GImGui; |
| 5126 | //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); |
| 5127 | |
| 5128 | // Create window the first time |
| 5129 | ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name); |
| 5130 | window->Flags = flags; |
| 5131 | g.WindowsById.SetVoidPtr(window->ID, window); |
| 5132 | |
| 5133 | // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. |
| 5134 | const ImGuiViewport* main_viewport = ImGui::GetMainViewport(); |
| 5135 | window->Pos = main_viewport->Pos + ImVec2(60, 60); |
| 5136 | |
| 5137 | // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. |
| 5138 | if (!(flags & ImGuiWindowFlags_NoSavedSettings)) |
| 5139 | if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID)) |
| 5140 | { |
| 5141 | // Retrieve settings from .ini file |
| 5142 | window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); |
| 5143 | SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false); |
| 5144 | ApplyWindowSettings(window, settings); |
| 5145 | } |
| 5146 | window->DC.CursorStartPos = window->DC.CursorMaxPos = window->Pos; // So first call to CalcContentSize() doesn't return crazy values |
| 5147 | |
| 5148 | if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) |
| 5149 | { |
| 5150 | window->AutoFitFramesX = window->AutoFitFramesY = 2; |
| 5151 | window->AutoFitOnlyGrows = false; |
| 5152 | } |
| 5153 | else |
| 5154 | { |
| 5155 | if (window->Size.x <= 0.0f) |
| 5156 | window->AutoFitFramesX = 2; |
| 5157 | if (window->Size.y <= 0.0f) |
| 5158 | window->AutoFitFramesY = 2; |
| 5159 | window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0); |
| 5160 | } |
| 5161 | |
| 5162 | if (!(flags & ImGuiWindowFlags_ChildWindow)) |
| 5163 | { |
| 5164 | g.WindowsFocusOrder.push_back(window); |
| 5165 | window->FocusOrder = (short)(g.WindowsFocusOrder.Size - 1); |
| 5166 | } |
| 5167 | |
| 5168 | if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus) |
| 5169 | g.Windows.push_front(window); // Quite slow but rare and only once |
| 5170 | else |
| 5171 | g.Windows.push_back(window); |
| 5172 | return window; |
| 5173 | } |
| 5174 | |
| 5175 | static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& size_desired) |
| 5176 | { |
no test coverage detected