From a3cad2ff068282055760bae928706b817545cbfb Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 30 Aug 2015 18:06:54 +0100 Subject: [PATCH] BeginChild() fixed missing rounding for child sizes which leaked into layout --- imgui.cpp | 2 +- imgui_internal.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index e00b1953..728593d7 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3188,7 +3188,7 @@ bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow; const ImVec2 content_avail = ImGui::GetContentRegionAvail(); - ImVec2 size = size_arg; + ImVec2 size = ImRound(size_arg); if (size.x <= 0.0f) { if (size.x == 0.0f) diff --git a/imgui_internal.h b/imgui_internal.h index 274b0bc6..170876c7 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -129,6 +129,7 @@ static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; } static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; } static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; } +static inline ImVec2 ImRound(ImVec2 v) { return ImVec2((float)(int)v.x, (float)(int)v.y); } //----------------------------------------------------------------------------- // Types