summaryrefslogtreecommitdiff
path: root/metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml
diff options
context:
space:
mode:
Diffstat (limited to 'metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml')
-rw-r--r--metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml63
1 files changed, 63 insertions, 0 deletions
diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml
new file mode 100644
index 0000000..65952c1
--- /dev/null
+++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml
@@ -0,0 +1,63 @@
+import Qt 4.7
+
+Flickable {
+ id: flickable
+
+ property bool selectable: true
+ property bool indicator: true
+
+ interactive: false
+ boundsBehavior: Flickable.StopAtBounds
+ flickableDirection: Flickable.VerticalFlick
+
+ function scrollDown() {
+ var maxY = contentHeight - height;
+ var newContentY = contentY + 96/3;
+
+ if (newContentY > maxY) {
+ contentY = maxY; // Never overscroll.
+ } else {
+ contentY = newContentY;
+ }
+ }
+
+ function scrollUp() {
+ var newContentY = contentY - 96/3;
+
+ if (newContentY < 0) {
+ contentY = 0; // Never overscroll.
+ } else {
+ contentY = newContentY;
+ }
+ }
+
+ function scrollTop() {
+ contentY = 0;
+ }
+
+ Rectangle {
+ id: indicatorCont
+ visible: flickable.indicator && (flickable.contentHeight > flickable.height)
+ anchors.top: parent.top
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ width: 4
+
+ color: "white"
+
+ Rectangle {
+ id: indicatorRect
+
+ property int minHeight: 10
+
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.leftMargin: 1
+
+ y: flickable.visibleArea.yPosition * indicatorCont.height
+ height: Math.max(minHeight, flickable.visibleArea.heightRatio * indicatorCont.height)
+
+ color: "black"
+ }
+ }
+}