mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-25 09:06:35 +00:00
Merge branch 'viewport' into docking
# Conflicts: # imgui.cpp
This commit is contained in:
commit
b8d9c5c130
@ -98,10 +98,13 @@ int main(int, char**)
|
|||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
|
|
||||||
// Setup Style
|
// Setup Style
|
||||||
ImGui::GetStyle().WindowRounding = 0.0f;
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsClassic();
|
//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
|
// 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.
|
// - 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.
|
// - 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::StyleColorsDark();
|
||||||
//ImGui::StyleColorsClassic();
|
//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
|
// 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.
|
// - 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.
|
// - 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);
|
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
|
|
||||||
// Setup Style
|
// Setup Style
|
||||||
ImGui::GetStyle().WindowRounding = 0.0f;
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsClassic();
|
//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
|
// 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.
|
// - 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.
|
// - 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))
|
if (GetWindowAlwaysWantOwnViewport(window))
|
||||||
return false;
|
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)
|
// Move to the existing viewport, Move child/hosted windows as well (FIXME-OPT: iterate child)
|
||||||
ImGuiViewportP* old_viewport = window->Viewport;
|
ImGuiViewportP* old_viewport = window->Viewport;
|
||||||
if (window->ViewportOwned)
|
if (window->ViewportOwned)
|
||||||
@ -7500,7 +7510,10 @@ static void ImGui::UpdateViewports()
|
|||||||
// Clear references to this viewport in windows (window->ViewportId becomes the master data)
|
// 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++)
|
for (int window_n = 0; window_n < g.Windows.Size; window_n++)
|
||||||
if (g.Windows[window_n]->Viewport == viewport)
|
if (g.Windows[window_n]->Viewport == viewport)
|
||||||
|
{
|
||||||
g.Windows[window_n]->Viewport = NULL;
|
g.Windows[window_n]->Viewport = NULL;
|
||||||
|
g.Windows[window_n]->ViewportOwned = false;
|
||||||
|
}
|
||||||
if (viewport == g.MouseLastHoveredViewport)
|
if (viewport == g.MouseLastHoveredViewport)
|
||||||
g.MouseLastHoveredViewport = NULL;
|
g.MouseLastHoveredViewport = NULL;
|
||||||
g.Viewports.erase(g.Viewports.Data + n);
|
g.Viewports.erase(g.Viewports.Data + n);
|
||||||
@ -7687,8 +7700,9 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Merge into host viewport
|
// Merge into host viewport
|
||||||
|
bool try_to_merge_into_host_viewport = false;
|
||||||
if (window->ViewportOwned && g.ActiveId == 0)
|
if (window->ViewportOwned && g.ActiveId == 0)
|
||||||
UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]);
|
try_to_merge_into_host_viewport = true;
|
||||||
window->ViewportOwned = false;
|
window->ViewportOwned = false;
|
||||||
|
|
||||||
// Appearing popups reset their viewport so they can inherit again
|
// 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->Viewport = FindViewportByID(g.NextWindowData.ViewportId);
|
||||||
window->ViewportId = g.NextWindowData.ViewportId; // Store ID even if Viewport isn't resolved yet.
|
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
|
// Always inherit viewport from parent window
|
||||||
window->Viewport = window->ParentWindow->Viewport;
|
window->Viewport = window->ParentWindow->Viewport;
|
||||||
@ -7737,6 +7751,11 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
|
|||||||
if (window->Viewport != NULL && window->Viewport->Window == window)
|
if (window->Viewport != NULL && window->Viewport->Window == window)
|
||||||
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
|
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
|
// Fallback to default viewport
|
||||||
if (window->Viewport == NULL)
|
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);
|
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
|
// Regular (non-child, non-popup) windows by default are also allowed to protrude
|
||||||
// Child windows are kept contained within their parent.
|
// Child windows are kept contained within their parent.
|
||||||
else if (window->ViewportAllowPlatformMonitorExtend < 0 && (flags & ImGuiWindowFlags_ChildWindow) == 0)
|
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.
|
ImGuiConfigFlags_DockingNoSplit = 1 << 7, // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
|
||||||
|
|
||||||
// [BETA] Viewports
|
// [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_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_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.
|
ImGuiConfigFlags_ViewportsNoMerge = 1 << 12, // All floating windows will always create their own viewport and platform window.
|
||||||
|
Loading…
Reference in New Issue
Block a user