From 3ca9235ddb93b52730099164a0dc387f7a301280 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 12 May 2013 03:49:38 +0200 Subject: weather rendering in metawatchwatchlets --- .../javispedro/sowatch/metawatch/MWScrollable.qml | 63 ++++++++++++++++++++++ .../qml/com/javispedro/sowatch/metawatch/qmldir | 1 + 2 files changed, 64 insertions(+) create mode 100644 metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml (limited to 'metawatch/qml/com/javispedro') 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 -- cgit v1.2.3