| 6009 | } |
| 6010 | |
| 6011 | static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags) |
| 6012 | { |
| 6013 | ImGuiContext& g = *GImGui; |
| 6014 | //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); |
| 6015 | |
| 6016 | // Create window the first time |
| 6017 | ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name); |
| 6018 | window->Flags = flags; |
| 6019 | g.WindowsById.SetVoidPtr(window->ID, window); |
| 6020 | |
| 6021 | // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. |
| 6022 | const ImGuiViewport* main_viewport = ImGui::GetMainViewport(); |
| 6023 | window->Pos = main_viewport->Pos + ImVec2(60, 60); |
| 6024 | window->ViewportPos = main_viewport->Pos; |
| 6025 | |
| 6026 | // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. |
| 6027 | if (!(flags & ImGuiWindowFlags_NoSavedSettings)) |
| 6028 | if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID)) |
| 6029 | { |
| 6030 | // Retrieve settings from .ini file |
| 6031 | window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); |
| 6032 | SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false); |
| 6033 | ApplyWindowSettings(window, settings); |
| 6034 | } |
| 6035 | window->DC.CursorStartPos = window->DC.CursorMaxPos = window->DC.IdealMaxPos = window->Pos; // So first call to CalcWindowContentSizes() doesn't return crazy values |
| 6036 | |
| 6037 | if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) |
| 6038 | { |
| 6039 | window->AutoFitFramesX = window->AutoFitFramesY = 2; |
| 6040 | window->AutoFitOnlyGrows = false; |
| 6041 | } |
| 6042 | else |
| 6043 | { |
| 6044 | if (window->Size.x <= 0.0f) |
| 6045 | window->AutoFitFramesX = 2; |
| 6046 | if (window->Size.y <= 0.0f) |
| 6047 | window->AutoFitFramesY = 2; |
| 6048 | window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0); |
| 6049 | } |
| 6050 | |
| 6051 | if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus) |
| 6052 | g.Windows.push_front(window); // Quite slow but rare and only once |
| 6053 | else |
| 6054 | g.Windows.push_back(window); |
| 6055 | |
| 6056 | return window; |
| 6057 | } |
| 6058 | |
| 6059 | static ImGuiWindow* GetWindowForTitleDisplay(ImGuiWindow* window) |
| 6060 | { |
no test coverage detected