From f3fb007471c30b8e3bff9fc518d25225aa54e0d9 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Tue, 12 Aug 2014 19:21:32 +0100 Subject: [PATCH] Fixed imgui scroll value handling on window resize. --- examples/common/imgui/imgui.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 868806ef1..df4d60701 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -771,12 +771,19 @@ struct Imgui float barHeight = (float)height / (float)sh; + // Handle m_scrollVal properly on variable scrollable area height. + const int32_t diff = height - sh; + if (diff < 0) + { + *m_scrollVal = (*m_scrollVal > diff) ? *m_scrollVal : diff; // m_scrollVal = max(diff, m_scrollVal). + } + else + { + *m_scrollVal = 0; + } + if (barHeight < 1.0f) { - // Handle m_scrollVal properly on variable scrollable area height. - const int32_t diff = height - sh; - *m_scrollVal = (*m_scrollVal < diff) ? diff : *m_scrollVal; // m_scrollVal = max(m_scrollVal, diff). - float barY = bx::fsaturate( (float)(yy - stop) / (float)sh); // Handle scroll bar logic.