Browse Source

Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to accidental alteration of window position. We now round the provided size. (#2067)

pull/2038/head
omar 6 years ago
parent
commit
062b1f0463
  1. 2
      docs/CHANGELOG.txt
  2. 6
      imgui.cpp

2
docs/CHANGELOG.txt

@ -37,6 +37,8 @@ Other Changes:
- Fixed calling DestroyContext() always saving .ini data with the current context instead - Fixed calling DestroyContext() always saving .ini data with the current context instead
of the supplied context pointer. (#2066) of the supplied context pointer. (#2066)
- Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to
accidental alteration of window position. We now round the provided size. (#2067)
----------------------------------------------------------------------- -----------------------------------------------------------------------

6
imgui.cpp

@ -4187,7 +4187,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
if (ImLengthSqr(settings->Size) > 0.00001f) if (ImLengthSqr(settings->Size) > 0.00001f)
size = ImFloor(settings->Size); size = ImFloor(settings->Size);
} }
window->Size = window->SizeFull = window->SizeFullAtLastBegin = size; window->Size = window->SizeFull = window->SizeFullAtLastBegin = ImFloor(size);
window->DC.CursorMaxPos = window->Pos; // So first call to CalcSizeContents() doesn't return crazy values window->DC.CursorMaxPos = window->Pos; // So first call to CalcSizeContents() doesn't return crazy values
if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
@ -5659,7 +5659,7 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
if (size.x > 0.0f) if (size.x > 0.0f)
{ {
window->AutoFitFramesX = 0; window->AutoFitFramesX = 0;
window->SizeFull.x = size.x; window->SizeFull.x = ImFloor(size.x);
} }
else else
{ {
@ -5669,7 +5669,7 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
if (size.y > 0.0f) if (size.y > 0.0f)
{ {
window->AutoFitFramesY = 0; window->AutoFitFramesY = 0;
window->SizeFull.y = size.y; window->SizeFull.y = ImFloor(size.y);
} }
else else
{ {

Loading…
Cancel
Save