summaryrefslogtreecommitdiff
path: root/qml/pages/Point.qml
blob: e8893369166d40e6d6b6b4af1c7741ae60d8eb85 (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
64
65
66
67
import QtQuick 2.0

Item {

    property string type: "";
    property alias piece_scale: piece.scale;

    function getImageForType() {
        if ("" === type) {
            return ""
        }
        return "../content/gfx/" + type + ".png"
    }

    function init(initType) {
        type = initType;
        piece.opacity = 1;
        piece.scale = 1;

    }

    states: [
        State {
            name: "shown"
            PropertyChanges  { target: piece; opacity:1 }
        }, State {
            name: "remove"
            onCompleted: type = "";
        }
    ]

    transitions: [
        Transition {
            to: "remove"
            NumberAnimation {
                targets: piece;
                property: "opacity";
                from: 1;
                to: 0
                duration: 500;
            }
        },
        Transition {
            to: "shown"
            PropertyAnimation {
                target: piece;
                property: "scale";
                from: 0;
                to: 1
                easing.type: Easing.OutBack
            }
        }
    ]

    MouseArea {

        id: interactiveArea
        anchors.fill: parent
        onClicked: clickHandler(index);
    }

    Image {
        id: piece
        anchors.fill: parent
        source: getImageForType();
    }
}