~mzanetti/+junk/mastermind

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import QtQuick 2.3
import QtQuick.Layouts 1.1
import Ubuntu.Components 1.2

MaterialPane {
    id: root
    color: "#1a237e"
    width: parent.width + units.gu(2)
    height: parent.height
    anchors.centerIn: parent
    anchors.verticalCenterOffset: shown ? 0 : -height + hiddenHeight

    Behavior on anchors.verticalCenterOffset {
        UbuntuNumberAnimation {}
    }

    property bool shown: false

    readonly property int hiddenHeight: headerLayout.height + units.gu(4)
    signal play()
    signal quit()
    signal openSettings()
    signal openHelp()

    RowLayout {
        id: headerLayout
        anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: units.gu(2) }
        height: units.gu(4)
        spacing: units.gu(1)

        Label {
            Layout.fillWidth: true
            anchors.verticalCenter: parent.verticalCenter
            color: "white"
            text: "Mastermind"
            fontSize: "x-large"
        }

        AbstractButton {
            Layout.preferredHeight: units.gu(4)
            Layout.preferredWidth: height
            opacity: root.shown ? 0 : 1
            Behavior on opacity {
                UbuntuNumberAnimation {}
            }

            onClicked: root.quit();

            Icon {
                anchors.fill: parent
                name: "close"
                color: "white"
            }
        }
    }

    GridLayout {
        anchors.centerIn: parent
        rowSpacing: units.gu(4)
        columnSpacing: units.gu(4)
        columns: root.width > root.height ? 3 : 1

        AbstractButton {
            Layout.preferredHeight: units.gu(10)
            Layout.preferredWidth: units.gu(10)

            onClicked: root.play();

            Icon {
                anchors.fill: parent
                color: "white"
                name: "media-playback-start"
            }
        }

        AbstractButton {
            Layout.preferredHeight: units.gu(10)
            Layout.preferredWidth: units.gu(10)

            onClicked: root.openSettings()

            Icon {
                anchors.fill: parent
                color: "white"
                name: "settings"
            }
        }

        AbstractButton {
            Layout.preferredHeight: units.gu(10)
            Layout.preferredWidth: units.gu(10)

            onClicked: {
                root.openHelp()
            }

            Icon {
                anchors.fill: parent
                color: "white"
                name: "help"
            }
        }
    }
}