summaryrefslogtreecommitdiffstats
path: root/QtDemo/qml/QtDemo/Element.qml
blob: 5150f4ffa3911ecc2fdfdcbc69e3531e845767a9 (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
import QtQuick 2.0

Rectangle {
    id: root
    color: "transparent"

    property int itemId : 1
    property int posX: 0
    property int posY: 0
    property int itemWidth: 50

    Image {
        id: elementImage
        anchors.fill: root
        z: 5
    }

    Component.onCompleted: {
        root.width = root.itemWidth
        root.height = root.itemId == 2 ? root.itemWidth*0.8 : root.itemWidth*1.3
        root.x = root.posX - root.width/2
        root.y = root.posY - root.height/2
        elementImage.source = root.itemId === 0 ? "images/tree1.png" :
                              root.itemId === 1 ? "images/tree2.png" :
                              root.itemId === 2 ? "images/stones.png" :
                              ""
    }
}