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

Function CreateNewWindow

tutorials/common/imgui/imgui.cpp:5667–5712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5665}
5666
5667static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
5668{
5669 ImGuiContext& g = *GImGui;
5670 //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags);
5671
5672 // Create window the first time
5673 ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name);
5674 window->Flags = flags;
5675 g.WindowsById.SetVoidPtr(window->ID, window);
5676
5677 // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
5678 const ImGuiViewport* main_viewport = ImGui::GetMainViewport();
5679 window->Pos = main_viewport->Pos + ImVec2(60, 60);
5680
5681 // User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
5682 if (!(flags & ImGuiWindowFlags_NoSavedSettings))
5683 if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
5684 {
5685 // Retrieve settings from .ini file
5686 window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings);
5687 SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
5688 ApplyWindowSettings(window, settings);
5689 }
5690 window->DC.CursorStartPos = window->DC.CursorMaxPos = window->DC.IdealMaxPos = window->Pos; // So first call to CalcWindowContentSizes() doesn't return crazy values
5691
5692 if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
5693 {
5694 window->AutoFitFramesX = window->AutoFitFramesY = 2;
5695 window->AutoFitOnlyGrows = false;
5696 }
5697 else
5698 {
5699 if (window->Size.x <= 0.0f)
5700 window->AutoFitFramesX = 2;
5701 if (window->Size.y <= 0.0f)
5702 window->AutoFitFramesY = 2;
5703 window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0);
5704 }
5705
5706 if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus)
5707 g.Windows.push_front(window); // Quite slow but rare and only once
5708 else
5709 g.Windows.push_back(window);
5710
5711 return window;
5712}
5713
5714static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& size_desired)
5715{

Callers 1

BeginMethod · 0.85

Calls 6

ImVec2Function · 0.85
ApplyWindowSettingsFunction · 0.85
SetVoidPtrMethod · 0.80
offset_from_ptrMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected