summaryrefslogtreecommitdiff
path: root/metawatch/qml/com/javispedro/sowatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-12 03:49:38 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-12 03:49:38 +0200
commit3ca9235ddb93b52730099164a0dc387f7a301280 (patch)
treeaa6e74210ce6075fc9e974dd275d28adf5f5d0c5 /metawatch/qml/com/javispedro/sowatch
parentac182bd9bf076b4d03d4812e85b989edae32d756 (diff)
downloadsowatch-3ca9235ddb93b52730099164a0dc387f7a301280.tar.gz
sowatch-3ca9235ddb93b52730099164a0dc387f7a301280.zip
weather rendering in metawatchwatchlets
Diffstat (limited to 'metawatch/qml/com/javispedro/sowatch')
-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