/usr/share/unity-2d/shell/common/AbstractScrollbar.qml is in unity-2d-shell 5.10.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | /*
* This file is part of unity-2d
*
* Copyright 2010-2011 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.0
/* Scrollbar composed of:
- a draggable slider
Usage:
Flickable {
id: flickable
}
Scrollbar {
targetFlickable: flickable
}
*/
Item {
id: scrollbar
property variant targetFlickable
property alias sliderSource: sliderImage.source
property alias sliderAnchors: sliderImage.anchors
property alias sliderSmooth: sliderImage.smooth
MouseArea {
id: scrollMouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
onPressed: {
/* Scroll one page without overshooting */
var scrollAmount = mouseY > slider.y ? targetFlickable.height : -targetFlickable.height
var destination = targetFlickable.contentY + scrollAmount
var clampedDestination = Math.max(0, Math.min(targetFlickable.contentHeight - targetFlickable.height,
destination))
scrollAnimation.to = clampedDestination
scrollAnimation.restart()
}
NumberAnimation {
id: scrollAnimation
duration: 200
easing.type: Easing.InOutQuad
target: targetFlickable
property: "contentY"
}
}
Item {
id: slider
property int minimalHeight: 40
anchors.left: parent.left
anchors.right: parent.right
Binding {
target: slider
property: "y"
value: {
var clampedYPosition = Math.max(0, Math.min(1-targetFlickable.visibleArea.heightRatio,
targetFlickable.visibleArea.yPosition))
return clampedYPosition * scrollbar.height
}
when: !dragMouseArea.drag.active
}
height: Math.min(scrollbar.height, Math.max(minimalHeight, targetFlickable.visibleArea.heightRatio * scrollbar.height))
Behavior on height {NumberAnimation {duration: 200; easing.type: Easing.InOutQuad}}
BorderImage {
id: sliderImage
anchors.fill: parent
}
MouseArea {
id: dragMouseArea
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
drag.target: slider
drag.axis: Drag.YAxis
drag.minimumY: 0
drag.maximumY: scrollbar.height - slider.height
onPositionChanged: {
if (drag.active) {
targetFlickable.contentY = slider.y * targetFlickable.contentHeight / scrollbar.height
}
}
}
}
}
|