From 815312466ca757e23d0d6036bba21f795a223cb1 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Wed, 3 Dec 2014 22:23:00 +0100 Subject: [PATCH] Draging scroll bars with mouse now behaves more properly. --- examples/common/imgui/imgui.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index a70549cf..f10ec503 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -959,7 +959,10 @@ struct Imgui { const int32_t diff = height - sh; - const int32_t val = *area.m_scrollVal - (m_my - m_dragY); + const int32_t drag = m_my - m_dragY; + const float dragFactor = float(sh)/float(height); + + const int32_t val = *area.m_scrollVal - int32_t(drag*dragFactor); const int32_t min = (diff < 0) ? diff : *area.m_scrollVal; const int32_t max = 0; *area.m_scrollVal = IMGUI_CLAMP(val, min, max);