summaryrefslogtreecommitdiff
path: root/metawatch/qml
diff options
context:
space:
mode:
Diffstat (limited to 'metawatch/qml')
-rw-r--r--metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml63
-rw-r--r--metawatch/qml/com/javispedro/sowatch/metawatch/qmldir1
2 files changed, 64 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"
+ }
+ }
+}
diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir
index 10ca498..aff7045 100644
--- a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir
+++ b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir
@@ -2,3 +2,4 @@ MWPage 1.0 MWPage.qml
MWLabel 1.0 MWLabel.qml
MWTitle 1.0 MWTitle.qml
MWListView 1.0 MWListView.qml
+MWScrollable 1.0 MWScrollable.qml