summaryrefslogtreecommitdiffstats
path: root/stroke-list/StrokeList.qml
blob: edf1fed687d276040798c64bafe75e3d58c2f974 (plain)
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
import Qt 4.7
import Qt.labs.gestures 1.0

Rectangle {

    id: mainrect

    width: 380
    height: 600

    function foo(index) {
        var colors = ["blue", "green", "grey", "red", "lightgreen"];
        return colors[index % colors.length]
    }

    Rectangle {
        id: list
        anchors.left: parent.left
        anchors.right: parent.right
        height: parent.height

        Repeater {
            model: [ "apple", "orange", "pineapple", "coconut", "foo", "bar", "baz", "zealot" ]

            Button {
                x: 10
                y: 10 + (height + 2) * index
                bgColor: foo(index)
                text: modelData
            }
        }
    }
    GestureArea {
        anchors.fill: parent
        property bool panEnabled : false

        Pan {
            onUpdated: {
                if (parent.panEnabled)
                    list.y += gesture.delta.y
                else if (Math.abs(gesture.offset.y) >= 10 && Math.abs(gesture.offset.x) < 10)
                    parent.panEnabled = true
            }
            onFinished: {
                parent.panEnabled = false
            }
        }
    }
}