Player screen: note and octave toises animated together

This commit is contained in:
Louis-Joseph Fournier 2016-01-13 10:15:35 +01:00
parent 73c80eb307
commit 6850095533
3 changed files with 42 additions and 13 deletions

View file

@ -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()
}

View file

@ -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)
}

View file

@ -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: {
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
delta = position - Math.floor(position)
//console.log("index:" + index)
}
}
}