summaryrefslogtreecommitdiff
path: root/src/examples/piano/qml/PianoKey.qml
blob: a69555708329dc612cda8735a2c0a5f706f52dcc (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
import QtQuick 2.0

Rectangle {
    property bool pressed: false
    property double frequency: 440
    property string note: ""

    border {
        color: "#000"
        width: 1
    }

    width: 25
    height: 100

    MouseArea {
        anchors { fill:parent; margins: 1 }
        onReleased: parent.pressed = false
        onPressed: parent.pressed = true
    }

    Text {
        anchors {
            top: parent.bottom
            horizontalCenter: parent.horizontalCenter
        }

        text: note
        visible: note
        opacity: parent.pressed ? 1 : 0.8
        font.bold: parent.pressed
    }

    Text {
        anchors {
            bottom: parent.top
            bottomMargin: 50
            horizontalCenter: parent.horizontalCenter
        }

        text: parent.frequency
        font.pixelSize: 8
        rotation: 90
    }
}