mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Internals: Using ImFloor().when appropriate.
This commit is contained in:
parent
0cabd81071
commit
f610e25682
13
imgui.cpp
13
imgui.cpp
@ -4163,14 +4163,13 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
||||
{
|
||||
// Retrieve settings from .ini file
|
||||
// Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
||||
window->PosFloat = ImVec2(60, 60);
|
||||
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
|
||||
window->Pos = window->PosFloat = ImVec2(60, 60);
|
||||
|
||||
if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
|
||||
{
|
||||
SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
|
||||
window->PosFloat = settings->Pos;
|
||||
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
|
||||
window->Pos = ImFloor(window->PosFloat);
|
||||
window->Collapsed = settings->Collapsed;
|
||||
if (ImLengthSqr(settings->Size) > 0.00001f)
|
||||
size = settings->Size;
|
||||
@ -4494,7 +4493,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// Popup first latch mouse position, will position itself when it appears next frame
|
||||
window->AutoPosLastDirection = ImGuiDir_None;
|
||||
if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
|
||||
window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos;
|
||||
window->Pos = window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos;
|
||||
}
|
||||
|
||||
// Collapse window by double-clicking on title bar
|
||||
@ -4648,7 +4647,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->PosFloat = ImMin(window->PosFloat, g.IO.DisplaySize - padding);
|
||||
}
|
||||
}
|
||||
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
|
||||
window->Pos = ImFloor(window->PosFloat);
|
||||
|
||||
// Default item width. Make it proportional to window size if window manually resizes
|
||||
if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize))
|
||||
@ -4765,7 +4764,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
}
|
||||
if (pos_target.x != FLT_MAX)
|
||||
{
|
||||
window->Pos = window->PosFloat = ImVec2((float)(int)pos_target.x, (float)(int)pos_target.y);
|
||||
window->Pos = window->PosFloat = ImFloor(pos_target);
|
||||
MarkIniSettingsDirty(window);
|
||||
}
|
||||
|
||||
@ -5593,7 +5592,7 @@ static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
|
||||
// Set
|
||||
const ImVec2 old_pos = window->Pos;
|
||||
window->PosFloat = pos;
|
||||
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
|
||||
window->Pos = ImFloor(pos);
|
||||
window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
|
||||
window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user