diff --git a/qml/PlayerScreen.qml b/qml/PlayerScreen.qml index d213d52..024b277 100644 --- a/qml/PlayerScreen.qml +++ b/qml/PlayerScreen.qml @@ -111,10 +111,15 @@ Item { width: parent.width * 0.8 height: parent.toise_h - note: tuner.note - octave: tuner.octave + //note: tuner.note + //octave: tuner.octave - onMultipleChanged: tuner.octave = index / 12 + onReleased: { + octave = tuner.octave = index / 12 + note = tuner.note = index % 12 + toise_octave.index = tuner.octave - 1 + toise_octave.updateFlickable() + } } Text { @@ -132,6 +137,7 @@ Item { // octave toise ToiseFlickable { + id: toise_octave anchors.top: main.is_portrait ? title_octave.bottom : toise.bottom anchors.topMargin: parent.margin_h @@ -148,11 +154,20 @@ Item { width: parent.width * 0.6 height: parent.toise_h - index: tuner.octave - 1 - onIndexChanged: { - // tuner.note = (tuner.note % 12) * (index + 1) - // tuner.octave = index + 1 + //index: tuner.octave - 1 + onReleased: { + tuner.octave = index + 1 + toise.octave = tuner.octave } } } + + /// update toise indexes if tuner note and octave changed from exterior + function update() { + toise.note = tuner.note + toise.octave = tuner.octave + toise_octave.index = tuner.octave - 1 + } + + Component.onCompleted: update() } diff --git a/qml/ScaleToise.qml b/qml/ScaleToise.qml index 1a25854..7b81b86 100644 --- a/qml/ScaleToise.qml +++ b/qml/ScaleToise.qml @@ -61,4 +61,10 @@ ToiseFlickable { // ToiseFlikcable parameters min: notes_en.length * 1 // ut 1 max: notes_en.length * 9 - 1 // si 8 + + onOctaveChanged: { + index = note + notes_en.length * octave + updateFlickable() + } + onNoteChanged: console.log(note) } diff --git a/qml/ToiseFlickable.qml b/qml/ToiseFlickable.qml index 73ab8a3..5e6acb9 100644 --- a/qml/ToiseFlickable.qml +++ b/qml/ToiseFlickable.qml @@ -24,6 +24,7 @@ import QtQuick 2.0 */ Toise { + id: toise_flickable property bool flik_enable: true property int multiple: index % nb_marks @@ -31,8 +32,8 @@ Toise { property double p_min: index2pos(min) property double p_max: index2pos(max) - - animation_enabled: false + signal released() + //animation_enabled: false MouseArea { property int refX: 0 @@ -43,6 +44,7 @@ Toise { anchors.fill: parent onPressed: { + animation_enabled = false refX = mouseX refPos = position } @@ -58,10 +60,16 @@ Toise { first_mark = Math.floor(position) % nb_marks } onReleased: { - var p = index2pos(index) - position = p - delta = position - Math.floor(position) - //console.log("index:" + index) + updateFlickable() + animation_enabled = true + toise_flickable.released() } } + + function updateFlickable() { + var p = index2pos(index) + delta = Qt.binding(function() { return position - Math.floor(position) }) + first_mark = Qt.binding(function() { return Math.floor(position) % nb_marks }) + position = p + } }