summaryrefslogtreecommitdiffstats
path: root/multilayer-dashboard/RowWidget.qml
blob: f7f950bb82650cc3645f1ecbc283629d7239da52 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import Qt 4.7
import Qt.labs.gestures 1.0

Rectangle {
    width: 180
    height: 340
    id: myRow
    property variant reparentWidget: myRow
    property variant topLevel: myRow

    Rectangle {
	id: tapWidgetContainer

	TapWidget {
	    x: 10
	    id: firstWidget
	    color: "green"
            reparentWidget: myRow.reparentWidget
	}
	TapWidget {
	    x:10
	    anchors.top : firstWidget.bottom
	    anchors.topMargin : 2.0
	    id: secondWidget
	    color: "blue"
            reparentWidget: myRow.reparentWidget
	}
	TapWidget {
	    x:10
	    anchors.top : secondWidget.bottom
	    anchors.topMargin : 2.0
	    id: thirdWidget
            reparentWidget: myRow.reparentWidget
	}

        property int maxY : (tapWidgetContainer.childrenRect.height > topLevel.height) ?
                0 :
                (topLevel.height - tapWidgetContainer.childrenRect.height)
        property int minY : (tapWidgetContainer.childrenRect.height > topLevel.height) ?
                -(tapWidgetContainer.childrenRect.height - topLevel.height) :
                0
    }	// end Rectangle

    GestureArea {
	id: rowGestureArea
        anchors.fill: parent

        Pan {
            when: gesture.delta.x < 5 && gesture.delta.y != 0
            onUpdated: {
                tapWidgetContainer.pos.y = tapWidgetContainer.pos.y + gesture.delta.y;

                if (tapWidgetContainer.pos.y > tapWidgetContainer.maxY) { // limit pan down
                    tapWidgetContainer.pos.y = tapWidgetContainer.maxY;
                }
                else if (tapWidgetContainer.pos.y < tapWidgetContainer.minY) {// limit pan up
                    tapWidgetContainer.pos.y = tapWidgetContainer.minY;
                }
            }
        }
    } // end GestureArea

}