summaryrefslogtreecommitdiffstats
path: root/multilayer-dashboard/MainWidget.qml
blob: bf178c3499140f749f1bc58d21fe15ef857ad76f (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
import Qt 4.7
import Qt.labs.gestures 1.0

Rectangle {

    width: 380
    height: 340
    id: dashboard

    Rectangle {
	id: rowWidgetContainer
	RowWidget {
	    id: firstRow
            reparentWidget: dashboard
            topLevel: dashboard
	}

	RowWidget {
	    id: secondRow
	    anchors.left : firstRow.right
            reparentWidget: dashboard
            topLevel: dashboard
        }

	RowWidget {
	    id: thirdRow
	    anchors.left : secondRow.right
            //reparentWidget: dashboard
            topLevel: dashboard
        }

        property int maxX : (dashboard.width < rowWidgetContainer.childrenRect.width) ?
                0 :
                (dashboard.width - rowWidgetContainer.childrenRect.width)
        property int minX : (dashboard.width < rowWidgetContainer.childrenRect.width) ?
                -(rowWidgetContainer.childrenRect.width - dashboard.width) :
                0
    }

    GestureArea {
        anchors.fill: dashboard

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

                if (rowWidgetContainer.pos.x > rowWidgetContainer.maxX) {
                    rowWidgetContainer.pos.x = rowWidgetContainer.maxX;
                }
                else if (rowWidgetContainer.pos.x < rowWidgetContainer.minX) {
                    rowWidgetContainer.pos.x = rowWidgetContainer.minX;
                }
            }
        }
    }
}