summaryrefslogtreecommitdiff
path: root/src/controls/Styles/Base/ScrollViewStyle.qml
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2014-05-02 09:12:49 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-02 11:19:07 +0200
commit0aefd523d2d06db514c924ebf3cc09e19ba91b29 (patch)
treeda6212086972ec99b7740049936c95dc9985b447 /src/controls/Styles/Base/ScrollViewStyle.qml
parenteff1d637159ab6fe3f4c5ca50bbb148da06cc939 (diff)
downloadqtquickcontrols-0aefd523d2d06db514c924ebf3cc09e19ba91b29.tar.gz
Calculate the position of the scrollbar handle correctly
When the width of the flickable in the ScrollArea was changing dynamically so it ended up with an originX that was not 0 then it would not calculate the leftMargin of the scrollbar correctly. The calculation here is done based on how QStyle calculates it for consistency. Change-Id: Ieb247f77ab10eba4015eed897d3babb94c752743 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls/Styles/Base/ScrollViewStyle.qml')
-rw-r--r--src/controls/Styles/Base/ScrollViewStyle.qml6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/controls/Styles/Base/ScrollViewStyle.qml b/src/controls/Styles/Base/ScrollViewStyle.qml
index 073a2e3f..d072f82e 100644
--- a/src/controls/Styles/Base/ScrollViewStyle.qml
+++ b/src/controls/Styles/Base/ScrollViewStyle.qml
@@ -372,6 +372,8 @@ Style {
property int extent: Math.max(minimumHandleLength, __styleData.horizontal ?
(flickableItem ? flickableItem.width/flickableItem.contentWidth : 0 ) * bg.width :
(flickableItem ? flickableItem.height/flickableItem.contentHeight : 0) * bg.height)
+ readonly property real range: __control.maximumValue - __control.minimumValue
+ readonly property real begin: __control.value - __control.minimumValue
Loader {
id: handleControl
@@ -379,8 +381,8 @@ Style {
width: __styleData.horizontal ? extent : implicitWidth
anchors.top: bg.top
anchors.left: bg.left
- anchors.topMargin: __styleData.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height)
- anchors.leftMargin: __styleData.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0
+ anchors.topMargin: __styleData.horizontal ? 0 : -handleOverlap + (2 * begin * (bg.height + (2 * handleOverlap) - extent) + range) / (2 * range)
+ anchors.leftMargin: __styleData.horizontal ? -handleOverlap + (2 * begin * (bg.width + (2 * handleOverlap) - extent) + range) / (2 * range) : 0
sourceComponent: handle
property QtObject styleData: QtObject {
readonly property bool hovered: activeControl === "handle"