From da34a08541c3e00ebe0751c2842a667118e11376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 21 Apr 2009 22:12:27 +0000 Subject: [PATCH] Do not scale the scroll bar thumb size between min size and max size, but between 0 and max size and restrict to min size afterwards. This leads to more consistent behavior and a more reasonable scroll bar size until the minimum size is reached. And it also fixes #3801. Probably also fixes the bug where some Pe windows could not be scrolled, or only scrolled very little. I assume this because a special trick is used for proportional scroll bars in Pe. It does not set the proportion, but only large steps and then the proportion is calculated from that. But since the minimum size was not taken into account before, it would have exactly this inconsistency. Since the size now ranges from 0 to max, this should now be in sync. But I didn't have a Pe window handy which exposed this bug to confirm my assumption... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30309 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ScrollBar.cpp | 33 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index dbb363a2d1..f88d724ed0 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -1345,21 +1345,26 @@ BScrollBar::_UpdateThumbFrame() // visual adjustments (room for darker line between thumb and buttons) maxSize--; - float thumbSize = minSize; - float proportion = fProportion; - if (fMin >= fMax || proportion > 1.0 || proportion < 0.0) - proportion = 1.0; - if (proportion == 0.0) { - // Special case a proportion of 0.0, use the large step value - // in that case (NOTE: fMin == fMax already handled above) - // This calculation is based on the assumption that "large step" - // scrolls by one "page size". - proportion = fLargeStep / (2 * (fMax - fMin)); - if (proportion > 1.0) + float thumbSize; + if (fPrivateData->fScrollBarInfo.proportional) { + float proportion = fProportion; + if (fMin >= fMax || proportion > 1.0 || proportion < 0.0) proportion = 1.0; - } - if (fPrivateData->fScrollBarInfo.proportional) - thumbSize += (maxSize - minSize) * proportion; + if (proportion == 0.0) { + // Special case a proportion of 0.0, use the large step value + // in that case (NOTE: fMin == fMax already handled above) + // This calculation is based on the assumption that "large step" + // scrolls by one "page size". + proportion = fLargeStep / (2 * (fMax - fMin)); + if (proportion > 1.0) + proportion = 1.0; + } + thumbSize = maxSize * proportion; + if (thumbSize < minSize) + thumbSize = minSize; + } else + thumbSize = minSize; + thumbSize = floorf(thumbSize + 0.5); thumbSize--;