mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Merge branch 'viewport' into docking
# Conflicts: # imgui.cpp
This commit is contained in:
		@@ -98,10 +98,13 @@ int main(int, char**)
 | 
			
		||||
    ImGui_ImplOpenGL3_Init(glsl_version);
 | 
			
		||||
 | 
			
		||||
    // Setup Style
 | 
			
		||||
    ImGui::GetStyle().WindowRounding = 0.0f;
 | 
			
		||||
    ImGui::StyleColorsDark();
 | 
			
		||||
    //ImGui::StyleColorsClassic();
 | 
			
		||||
 | 
			
		||||
    ImGuiStyle& style = ImGui::GetStyle();
 | 
			
		||||
    style.WindowRounding = 0.0f;                                // When viewports are enabled it is preferable to disable WinodwRounding
 | 
			
		||||
    style.Colors[ImGuiCol_WindowBg].w = 1.0f;                   // When viewports are enabled it is preferable to disable WindowBg alpha
 | 
			
		||||
 | 
			
		||||
    // Load Fonts
 | 
			
		||||
    // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
 | 
			
		||||
    // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
 | 
			
		||||
 
 | 
			
		||||
@@ -92,6 +92,10 @@ int main(int, char**)
 | 
			
		||||
    ImGui::StyleColorsDark();
 | 
			
		||||
    //ImGui::StyleColorsClassic();
 | 
			
		||||
 | 
			
		||||
    ImGuiStyle& style = ImGui::GetStyle();
 | 
			
		||||
    style.WindowRounding = 0.0f;                                // When viewports are enabled it is preferable to disable WinodwRounding
 | 
			
		||||
    style.Colors[ImGuiCol_WindowBg].w = 1.0f;                   // When viewports are enabled it is preferable to disable WindowBg alpha
 | 
			
		||||
 | 
			
		||||
    // Load Fonts
 | 
			
		||||
    // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. 
 | 
			
		||||
    // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. 
 | 
			
		||||
 
 | 
			
		||||
@@ -147,10 +147,13 @@ int main(int, char**)
 | 
			
		||||
    ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
 | 
			
		||||
 | 
			
		||||
    // Setup Style
 | 
			
		||||
    ImGui::GetStyle().WindowRounding = 0.0f;
 | 
			
		||||
    ImGui::StyleColorsDark();
 | 
			
		||||
    //ImGui::StyleColorsClassic();
 | 
			
		||||
 | 
			
		||||
    ImGuiStyle& style = ImGui::GetStyle();
 | 
			
		||||
    style.WindowRounding = 0.0f;                                // When viewports are enabled it is preferable to disable WinodwRounding
 | 
			
		||||
    style.Colors[ImGuiCol_WindowBg].w = 1.0f;                   // When viewports are enabled it is preferable to disable WindowBg alpha
 | 
			
		||||
 | 
			
		||||
    // Load Fonts
 | 
			
		||||
    // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. 
 | 
			
		||||
    // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. 
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -7427,6 +7427,16 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG
 | 
			
		||||
    if (GetWindowAlwaysWantOwnViewport(window))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    for (int n = 0; n < g.Windows.Size; n++)
 | 
			
		||||
    {
 | 
			
		||||
        ImGuiWindow* window_behind = g.Windows[n];
 | 
			
		||||
        if (window_behind == window)
 | 
			
		||||
            break;
 | 
			
		||||
        if (window_behind->WasActive && window_behind->ViewportOwned && !(window_behind->Flags & ImGuiWindowFlags_ChildWindow))
 | 
			
		||||
            if (window_behind->Viewport->GetRect().Overlaps(window->Rect()))
 | 
			
		||||
                return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Move to the existing viewport, Move child/hosted windows as well (FIXME-OPT: iterate child)
 | 
			
		||||
    ImGuiViewportP* old_viewport = window->Viewport;
 | 
			
		||||
    if (window->ViewportOwned)
 | 
			
		||||
@@ -7500,7 +7510,10 @@ static void ImGui::UpdateViewports()
 | 
			
		||||
            // Clear references to this viewport in windows (window->ViewportId becomes the master data)
 | 
			
		||||
            for (int window_n = 0; window_n < g.Windows.Size; window_n++)
 | 
			
		||||
                if (g.Windows[window_n]->Viewport == viewport)
 | 
			
		||||
                {
 | 
			
		||||
                    g.Windows[window_n]->Viewport = NULL;
 | 
			
		||||
                    g.Windows[window_n]->ViewportOwned = false;
 | 
			
		||||
                }
 | 
			
		||||
            if (viewport == g.MouseLastHoveredViewport) 
 | 
			
		||||
                g.MouseLastHoveredViewport = NULL;
 | 
			
		||||
            g.Viewports.erase(g.Viewports.Data + n);
 | 
			
		||||
@@ -7687,8 +7700,9 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Merge into host viewport
 | 
			
		||||
    bool try_to_merge_into_host_viewport = false;
 | 
			
		||||
    if (window->ViewportOwned && g.ActiveId == 0)
 | 
			
		||||
        UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]);
 | 
			
		||||
        try_to_merge_into_host_viewport = true;
 | 
			
		||||
    window->ViewportOwned = false;
 | 
			
		||||
 | 
			
		||||
    // Appearing popups reset their viewport so they can inherit again
 | 
			
		||||
@@ -7719,7 +7733,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
 | 
			
		||||
        window->Viewport = FindViewportByID(g.NextWindowData.ViewportId);
 | 
			
		||||
        window->ViewportId = g.NextWindowData.ViewportId; // Store ID even if Viewport isn't resolved yet.
 | 
			
		||||
    }
 | 
			
		||||
    else if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_ChildMenu))
 | 
			
		||||
    else if ((flags & ImGuiWindowFlags_ChildWindow) || (flags & ImGuiWindowFlags_ChildMenu))
 | 
			
		||||
    {
 | 
			
		||||
        // Always inherit viewport from parent window
 | 
			
		||||
        window->Viewport = window->ParentWindow->Viewport;
 | 
			
		||||
@@ -7737,6 +7751,11 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
 | 
			
		||||
        if (window->Viewport != NULL && window->Viewport->Window == window)
 | 
			
		||||
            window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        if (try_to_merge_into_host_viewport)
 | 
			
		||||
            UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Fallback to default viewport
 | 
			
		||||
    if (window->Viewport == NULL)
 | 
			
		||||
@@ -7773,6 +7792,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
 | 
			
		||||
            window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Regular (non-child, non-popup) windows by default are also allowed to protrude
 | 
			
		||||
    // Child windows are kept contained within their parent.
 | 
			
		||||
    else if (window->ViewportAllowPlatformMonitorExtend < 0 && (flags & ImGuiWindowFlags_ChildWindow) == 0)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								imgui.h
									
									
									
									
									
								
							@@ -962,6 +962,7 @@ enum ImGuiConfigFlags_
 | 
			
		||||
    ImGuiConfigFlags_DockingNoSplit         = 1 << 7,   // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
 | 
			
		||||
 | 
			
		||||
    // [BETA] Viewports
 | 
			
		||||
    // When using viewports it is recommended that your default value for ImGuiCol_WindowBg is opaque (Alpha=1.0) so transition to a viewport won't be noticeable.
 | 
			
		||||
    ImGuiConfigFlags_ViewportsEnable        = 1 << 10,  // Viewport enable flags (require both ImGuiConfigFlags_PlatformHasViewports + ImGuiConfigFlags_RendererHasViewports set by the respective back-ends)
 | 
			
		||||
    ImGuiConfigFlags_ViewportsNoTaskBarIcon = 1 << 11,  // Disable task bars icons for all secondary viewports (will set ImGuiViewportFlags_NoTaskBarIcon on them)
 | 
			
		||||
    ImGuiConfigFlags_ViewportsNoMerge       = 1 << 12,  // All floating windows will always create their own viewport and platform window.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user