summaryrefslogtreecommitdiff
path: root/src/examples/piano/qml/PianoKey.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/piano/qml/PianoKey.qml')
-rw-r--r--src/examples/piano/qml/PianoKey.qml45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/examples/piano/qml/PianoKey.qml b/src/examples/piano/qml/PianoKey.qml
new file mode 100644
index 0000000..a695557
--- /dev/null
+++ b/src/examples/piano/qml/PianoKey.qml
@@ -0,0 +1,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
+ }
+}