Viewport, DPI: Select viewport before locking style sizes and before handling double-click-on-title-bar to collapse. (#1542, #1676)

This commit is contained in:
omar 2018-03-09 15:37:16 +01:00
parent 64cbbed152
commit a4629b0b36
2 changed files with 16 additions and 15 deletions

View File

@ -6291,7 +6291,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
if (g.NextWindowData.CollapsedCond)
SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond);
if (g.NextWindowData.FocusCond)
SetWindowFocus();
FocusWindow(window);
if (window->Appearing)
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
@ -6317,6 +6317,20 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->LastFrameActive = current_frame;
window->IDStack.resize(1);
// VIEWPORT
// We need to do this before using any style/font sizes, as viewport with a different DPI will affect those sizes.
UpdateWindowViewport(window, window_pos_set_by_api);
SetCurrentViewport(window->Viewport);
window->Viewport->LastFrameActive = g.FrameCount;
flags = window->Flags;
if (p_open != NULL && window->Viewport->PlatformRequestClose && !(window->Viewport->Flags & ImGuiViewportFlags_MainViewport))
{
window->Viewport->PlatformRequestClose = false;
*p_open = false;
}
// Lock window rounding, border size and padding for the frame (so that altering them doesn't cause inconsistencies)
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
window->WindowBorderSize = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildBorderSize : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
@ -6342,19 +6356,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
}
window->CollapseToggleWanted = false;
// VIEWPORT
UpdateWindowViewport(window, window_pos_set_by_api);
SetCurrentViewport(window->Viewport);
window->Viewport->LastFrameActive = g.FrameCount;
flags = window->Flags;
if (p_open != NULL && window->Viewport->PlatformRequestClose && !(window->Viewport->Flags & ImGuiViewportFlags_MainViewport))
{
window->Viewport->PlatformRequestClose = false;
*p_open = false;
}
// SIZE
// Update contents size from last frame for auto-fitting (unless explicitly specified)

View File

@ -1076,7 +1076,7 @@ namespace ImGui
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
IMGUI_API void FocusWindow(ImGuiWindow* window);
IMGUI_API void FocusWindow(ImGuiWindow* window); // FIXME: Rename to SetWindowFocus()
IMGUI_API void BringWindowToFront(ImGuiWindow* window);
IMGUI_API void BringWindowToBack(ImGuiWindow* window);
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);