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 width: parent.width * 0.8
height: parent.toise_h height: parent.toise_h
note: tuner.note //note: tuner.note
octave: tuner.octave //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 { Text {
@ -132,6 +137,7 @@ Item {
// octave toise // octave toise
ToiseFlickable { ToiseFlickable {
id: toise_octave
anchors.top: main.is_portrait ? title_octave.bottom : toise.bottom anchors.top: main.is_portrait ? title_octave.bottom : toise.bottom
anchors.topMargin: parent.margin_h anchors.topMargin: parent.margin_h
@ -148,11 +154,20 @@ Item {
width: parent.width * 0.6 width: parent.width * 0.6
height: parent.toise_h height: parent.toise_h
index: tuner.octave - 1 //index: tuner.octave - 1
onIndexChanged: { onReleased: {
// tuner.note = (tuner.note % 12) * (index + 1) tuner.octave = index + 1
// 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 // ToiseFlikcable parameters
min: notes_en.length * 1 // ut 1 min: notes_en.length * 1 // ut 1
max: notes_en.length * 9 - 1 // si 8 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 { Toise {
id: toise_flickable
property bool flik_enable: true property bool flik_enable: true
property int multiple: index % nb_marks property int multiple: index % nb_marks
@ -31,8 +32,8 @@ Toise {
property double p_min: index2pos(min) property double p_min: index2pos(min)
property double p_max: index2pos(max) property double p_max: index2pos(max)
signal released()
animation_enabled: false //animation_enabled: false
MouseArea { MouseArea {
property int refX: 0 property int refX: 0
@ -43,6 +44,7 @@ Toise {
anchors.fill: parent anchors.fill: parent
onPressed: { onPressed: {
animation_enabled = false
refX = mouseX refX = mouseX
refPos = position refPos = position
} }
@ -58,10 +60,16 @@ Toise {
first_mark = Math.floor(position) % nb_marks first_mark = Math.floor(position) % nb_marks
} }
onReleased: { onReleased: {
updateFlickable()
animation_enabled = true
toise_flickable.released()
}
}
function updateFlickable() {
var p = index2pos(index) 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 position = p
delta = position - Math.floor(position)
//console.log("index:" + index)
}
} }
} }