summaryrefslogtreecommitdiffstats
path: root/examples/demos/hangman/qml/Letter.qml
blob: ae9613f2aa75f541670301e3248679d9a5d82b5a (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick

Item {
    property alias text: label.text

    Text {
        anchors.top: parent.top
        anchors.horizontalCenter: parent.horizontalCenter
        id: label
        color: "white"
        font.family: "Helvetica"
        font.pixelSize: parent.height * 0.75

        opacity: applicationData.lettersOwned.indexOf(text) >= 0 ? 1.0 : 0.0
        visible: opacity > 0.0

        anchors.horizontalCenterOffset: visible ? 0 : -topLevel.width / 2

        Behavior on anchors.horizontalCenterOffset {
            NumberAnimation {
                duration: 500
                easing.type: Easing.OutQuad
            }
        }
    }

    Rectangle {
        color: "white"
        width: parent.width
        anchors.bottom: parent.bottom
        anchors.top: label.bottom
    }
}