mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Viewports: (breaking) removed ImGuiPlatformIO::MainViewport which is now pretty much unused and duplicate (and misleading as we will evolve the concept)
Use GetMainViewport() if stuck.
This commit is contained in:
		
							
								
								
									
										10
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -4220,7 +4220,6 @@ void ImGui::Initialize(ImGuiContext* context) | ||||
|     viewport->Idx = 0; | ||||
|     viewport->PlatformWindowCreated = true; | ||||
|     g.Viewports.push_back(viewport); | ||||
|     g.PlatformIO.MainViewport = g.Viewports[0]; // Make it accessible in public-facing GetPlatformIO() immediately (before the first call to EndFrame) | ||||
|     g.PlatformIO.Viewports.push_back(g.Viewports[0]); | ||||
|  | ||||
|     // Extensions | ||||
| @@ -6413,7 +6412,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
|                 if (window->Viewport->PlatformMonitor == -1) | ||||
|                 { | ||||
|                     // Fallback for "lost" window (e.g. a monitor disconnected): we move the window back over the main viewport | ||||
|                     SetWindowPos(window, g.Viewports[0]->Pos + style.DisplayWindowPadding, ImGuiCond_Always); | ||||
|                     ImGuiViewport* main_viewport = GetMainViewport(); | ||||
|                     SetWindowPos(window, main_viewport->Pos + style.DisplayWindowPadding, ImGuiCond_Always); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
| @@ -11260,13 +11260,14 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| // FIXME: handle 0 to N host viewports | ||||
| static bool ImGui::UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window) | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     return UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]); | ||||
| } | ||||
|  | ||||
| // Translate imgui windows when a Host Viewport has been moved | ||||
| // Translate Dear ImGui windows when a Host Viewport has been moved | ||||
| // (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!) | ||||
| void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos) | ||||
| { | ||||
| @@ -11502,7 +11503,6 @@ static void ImGui::UpdateViewportsNewFrame() | ||||
| static void ImGui::UpdateViewportsEndFrame() | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     g.PlatformIO.MainViewport = g.Viewports[0]; | ||||
|     g.PlatformIO.Viewports.resize(0); | ||||
|     for (int i = 0; i < g.Viewports.Size; i++) | ||||
|     { | ||||
| @@ -11589,7 +11589,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window) | ||||
|     window->ViewportAllowPlatformMonitorExtend = -1; | ||||
|  | ||||
|     // Restore main viewport if multi-viewport is not supported by the backend | ||||
|     ImGuiViewportP* main_viewport = g.Viewports[0]; | ||||
|     ImGuiViewportP* main_viewport = (ImGuiViewportP*)GetMainViewport(); | ||||
|     if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)) | ||||
|     { | ||||
|         SetWindowViewport(window, main_viewport); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ocornut
					ocornut