mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Merge branch 'viewport' into docking
# Conflicts: # docs/CHANGELOG.txt # imgui.cpp # imgui_demo.cpp
This commit is contained in:
61
imgui.cpp
61
imgui.cpp
@ -366,15 +366,13 @@ CODE
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
(Viewport Branch)
|
||||
- 2018/XX/XX (1.XX) - examples: the examples imgui_impl_xxx files have been split to separate platform (Win32, Glfw, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.)
|
||||
when adopting new bindings follow the code in examples/ to know which functions to call.
|
||||
- 2018/XX/XX (1.XX) - when multi-viewports are enabled, all positions will be in your natural OS coordinates space. It means that:
|
||||
- reference to hard-coded positions such as in SetNextWindowPos(ImVec2(0,0)) are probably not what you want anymore.
|
||||
you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos)
|
||||
- likewise io.MousePos and GetMousePos() will use OS coordinates coordinates.
|
||||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||
- 2018/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
- 2018/XX/XX (1.XX) - removed io.DisplayVisibleMin, io.DisplayVisibleMax settings (it was used to clip within the DisplayMin..DisplayMax range, I don't know of anyone using it)
|
||||
- 2018/XX/XX (1.XX) - removed io.DisplayVisibleMin, io.DisplayVisibleMax settings (they were used to clip within the (0,0)..DisplaySize range, I don't know of anyone using it)
|
||||
|
||||
|
||||
- 2018/12/10 (1.67) - renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges as we are doing a large pass on configuration flags.
|
||||
@ -1152,9 +1150,20 @@ ImGuiIO::ImGuiIO()
|
||||
FontAllowUserScaling = false;
|
||||
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
|
||||
// Miscellaneous configuration options
|
||||
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
|
||||
ConfigDockingNoSplit = false;
|
||||
ConfigDockingWithShift = false;
|
||||
ConfigDockingTabBarOnSingleWindows = false;
|
||||
ConfigDockingTransparentPayload = false;
|
||||
|
||||
// Viewport options (when ImGuiConfigFlags_ViewportsEnable is set)
|
||||
ConfigViewportsNoAutoMerge = false;
|
||||
ConfigViewportsNoTaskBarIcon = false;
|
||||
ConfigViewportsNoDecoration = true;
|
||||
ConfigViewportsNoParent = false;
|
||||
|
||||
// Miscellaneous options
|
||||
MouseDrawCursor = false;
|
||||
#ifdef __APPLE__
|
||||
ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag
|
||||
#else
|
||||
@ -5306,7 +5315,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
||||
window->Pos = FindBestWindowPosForPopup(window);
|
||||
|
||||
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned)
|
||||
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned && !window->Viewport->PlatformWindowMinimized)
|
||||
if (!window->Viewport->GetRect().Contains(window->Rect()))
|
||||
{
|
||||
// Late create viewport, based on the assumption that with our calculations, the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
|
||||
@ -5332,13 +5341,17 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
ImGuiViewportFlags viewport_flags = (window->Viewport->Flags) & ~(ImGuiViewportFlags_TopMost | ImGuiViewportFlags_NoTaskBarIcon | ImGuiViewportFlags_NoDecoration);
|
||||
if (flags & ImGuiWindowFlags_Tooltip)
|
||||
viewport_flags |= ImGuiViewportFlags_TopMost;
|
||||
if ((g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsNoTaskBarIcon) != 0 || (flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0)
|
||||
if (g.IO.ConfigViewportsNoTaskBarIcon || (flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0)
|
||||
viewport_flags |= ImGuiViewportFlags_NoTaskBarIcon;
|
||||
if ((g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsDecoration) == 0 || (flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0)
|
||||
if (g.IO.ConfigViewportsNoDecoration || (flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0)
|
||||
viewport_flags |= ImGuiViewportFlags_NoDecoration;
|
||||
|
||||
// We can overwrite viewport flags using ImGuiWindowClass (advanced users)
|
||||
window->Viewport->ParentViewportId = window->WindowClass.ParentViewportId ? window->WindowClass.ParentViewportId : IMGUI_VIEWPORT_DEFAULT_ID;
|
||||
// We don't default to the main viewport because.
|
||||
if (window->WindowClass.ParentViewportId)
|
||||
window->Viewport->ParentViewportId = window->WindowClass.ParentViewportId;
|
||||
else
|
||||
window->Viewport->ParentViewportId = g.IO.ConfigViewportsNoParent ? 0 : IMGUI_VIEWPORT_DEFAULT_ID;
|
||||
if (window->WindowClass.ViewportFlagsOverrideMask)
|
||||
viewport_flags = (viewport_flags & ~window->WindowClass.ViewportFlagsOverrideMask) | (window->WindowClass.ViewportFlagsOverrideValue & window->WindowClass.ViewportFlagsOverrideMask);
|
||||
|
||||
@ -5634,6 +5647,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
{
|
||||
window->Viewport->PlatformRequestClose = false;
|
||||
g.NavWindowingToggleLayer = false; // Assume user mapped PlatformRequestClose on ALT-F4 so we disable ALT for menu toggle. False positive not an issue.
|
||||
//IMGUI_DEBUG_LOG("Window '%s' PlatformRequestClose\n", window->Name);
|
||||
*p_open = false;
|
||||
}
|
||||
}
|
||||
@ -7561,7 +7575,7 @@ static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window)
|
||||
{
|
||||
// Tooltips and menus are not automatically forced into their own viewport when the NoMerge flag is set, however the multiplication of viewports makes them more likely to protude and create their own.
|
||||
ImGuiContext& g = *GImGui;
|
||||
if ((g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsNoMerge) && (g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
|
||||
if (g.IO.ConfigViewportsNoAutoMerge && (g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
|
||||
if (!window->DockIsActive)
|
||||
if ((window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip)) == 0)
|
||||
return true;
|
||||
@ -7638,14 +7652,25 @@ static void ImGui::UpdateViewportsNewFrame()
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.PlatformIO.Viewports.Size <= g.Viewports.Size);
|
||||
|
||||
// Update main viewport with current platform position and size
|
||||
// Update Minimized status (we need it first in order to decide if we'll apply Pos/Size of the main viewport)
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
const bool platform_funcs_available = (n == 0 || viewport->PlatformWindowCreated);
|
||||
if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
|
||||
if (g.PlatformIO.Platform_GetWindowMinimized && platform_funcs_available)
|
||||
viewport->PlatformWindowMinimized = g.PlatformIO.Platform_GetWindowMinimized(viewport);
|
||||
}
|
||||
|
||||
// Create/update main viewport with current platform position and size
|
||||
ImGuiViewportP* main_viewport = g.Viewports[0];
|
||||
IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID);
|
||||
IM_ASSERT(main_viewport->Window == NULL);
|
||||
ImVec2 main_viewport_platform_pos = ImVec2(0.0f, 0.0f);
|
||||
if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
|
||||
main_viewport_platform_pos = g.PlatformIO.Platform_GetWindowPos(main_viewport);
|
||||
AddUpdateViewport(NULL, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_platform_pos, g.IO.DisplaySize, ImGuiViewportFlags_CanHostOtherWindows);
|
||||
ImVec2 main_viewport_platform_size = g.IO.DisplaySize;
|
||||
if (g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable)
|
||||
main_viewport_platform_pos = main_viewport->PlatformWindowMinimized ? main_viewport->Pos : g.PlatformIO.Platform_GetWindowPos(main_viewport);
|
||||
AddUpdateViewport(NULL, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_platform_pos, main_viewport_platform_size, ImGuiViewportFlags_CanHostOtherWindows);
|
||||
|
||||
g.CurrentViewport = NULL;
|
||||
g.MouseViewport = NULL;
|
||||
@ -7680,9 +7705,6 @@ static void ImGui::UpdateViewportsNewFrame()
|
||||
const bool platform_funcs_available = (n == 0 || viewport->PlatformWindowCreated);
|
||||
if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
|
||||
{
|
||||
if (g.PlatformIO.Platform_GetWindowMinimized && platform_funcs_available)
|
||||
viewport->PlatformWindowMinimized = g.PlatformIO.Platform_GetWindowMinimized(viewport);
|
||||
|
||||
// Update Position and Size (from Platform Window to ImGui) if requested.
|
||||
// We do it early in the frame instead of waiting for UpdatePlatformWindows() to avoid a frame of lag when moving/resizing using OS facilities.
|
||||
if (!viewport->PlatformWindowMinimized && platform_funcs_available)
|
||||
@ -7796,7 +7818,8 @@ static void ImGui::UpdateViewportsEndFrame()
|
||||
ImGuiViewportP* viewport = g.Viewports[i];
|
||||
viewport->LastPos = viewport->Pos;
|
||||
if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f)
|
||||
continue;
|
||||
if (i > 0) // Always include main viewport in the list
|
||||
continue;
|
||||
if (viewport->Window && !IsWindowActiveAndVisible(viewport->Window))
|
||||
continue;
|
||||
if (i > 0)
|
||||
@ -13565,7 +13588,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
static void NodeViewport(ImGuiViewportP* viewport)
|
||||
{
|
||||
ImGui::SetNextTreeNodeOpen(true, ImGuiCond_Once);
|
||||
if (ImGui::TreeNode((void*)(intptr_t)viewport->ID, "Viewport #%d, ID: 0x%08X, Window: \"%s\"", viewport->Idx, viewport->ID, viewport->Window ? viewport->Window->Name : "N/A"))
|
||||
if (ImGui::TreeNode((void*)(intptr_t)viewport->ID, "Viewport #%d, ID: 0x%08X, Parent: 0x%08X, Window: \"%s\"", viewport->Idx, viewport->ID, viewport->ParentViewportId, viewport->Window ? viewport->Window->Name : "N/A"))
|
||||
{
|
||||
ImGuiWindowFlags flags = viewport->Flags;
|
||||
ImGui::BulletText("Pos: (%.0f,%.0f), Size: (%.0f,%.0f), Monitor: %d, DpiScale: %.0f%%", viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y, viewport->PlatformMonitor, viewport->DpiScale * 100.0f);
|
||||
|
Reference in New Issue
Block a user