ToiseFlikcable fully working with notes and octaves.

The binding beetween two toises has to be thinked.
This commit is contained in:
Louis-Joseph Fournier 2016-01-12 23:09:13 +01:00
parent df3a875a75
commit 73c80eb307
7 changed files with 47 additions and 17 deletions

View file

@ -113,6 +113,8 @@ Item {
note: tuner.note
octave: tuner.octave
onMultipleChanged: tuner.octave = index / 12
}
Text {
@ -139,12 +141,18 @@ Item {
theme: main.theme
marks: [1, 2, 3, 4, 5, 6, 7, 8]
min: 0
max: marks.length - 1
//nb_marks_displayed: is_portrait ? 4 : 3
width: parent.width * 0.6
height: parent.toise_h
index: tuner.octave
index: tuner.octave - 1
onIndexChanged: {
// tuner.note = (tuner.note % 12) * (index + 1)
// tuner.octave = index + 1
}
}
}
}

View file

@ -24,7 +24,7 @@ import "."
* Display notes from scale, with current note centered.
*/
Toise {
ToiseFlickable {
id: scale
// note
@ -57,4 +57,8 @@ Toise {
function isAltered(i) {
return (i < 4 && (i & 1)) || (i > 5 && !(i & 1))
}
// ToiseFlikcable parameters
min: notes_en.length * 1 // ut 1
max: notes_en.length * 9 - 1 // si 8
}

View file

@ -35,6 +35,10 @@ Item {
// function to get mark color
property var mark_color: function (id) { return "transparent" }
// min and max values
property double min: 0
property double max: 100
property int h_margin: Math.max(height / 8, main_mark.border_d)
property int nb_marks: marks.length
@ -42,16 +46,20 @@ Item {
property int nb_marks_displayed: nb_marks
property bool is_pair: nb_marks_displayed % 2 == 0
function index2pos(i) { return i - (nb_marks_displayed - 1) / 2 }
/// current mark is on the middle
property double position: index - (nb_marks_displayed - 1) / 2
property double position: index2pos(index)
property int first_mark: Math.floor(position) % nb_marks
property double delta: position - Math.floor(position)
property int idx_modulo: index % nb_marks
property alias cellWidth: toise.cellWidth
property bool animation_enabled: true
Behavior on position {
enabled: animation_enabled
NumberAnimation {
duration: 200
easing.amplitude: nb_marks
@ -76,7 +84,8 @@ Item {
width: toise.cellWidth
height: toise.height
border.width: 1
property int idx: (index + nb_marks + first_mark) % nb_marks
property int idx_ref: Math.floor(position) + index
property int idx: (index + first_mark + nb_marks) % nb_marks
color: mark_color(idx)
Text {
@ -85,6 +94,7 @@ Item {
text: marks[idx]
color: idx == idx_modulo ? theme.primaryColor : theme.secondaryColor
font.pixelSize: parent.height / 2
opacity: idx_ref >= min && idx_ref <= max ? 1 : 0.2
}
}
}

View file

@ -24,10 +24,22 @@ import QtQuick 2.0
*/
Toise {
property bool flik_enable: true
property int multiple: index % nb_marks
property double p_min: index2pos(min)
property double p_max: index2pos(max)
animation_enabled: false
MouseArea {
property int refX: 0
property double refPos: parent.position
enabled: flik_enable
anchors.fill: parent
onPressed: {
@ -38,26 +50,18 @@ Toise {
if (!pressed) return
var d = (refX - mouseX) / parent.cellWidth
var p = refPos + d
p = Math.max(Math.min(p, p_max), p_min)
var i = Math.round(p + (nb_marks_displayed - 1) / 2)
index = i % nb_marks
index = i
position = p
delta = position - Math.floor(position)
first_mark = Math.floor(position) % nb_marks
}
onReleased: {
var p = 0
var d = position - Math.floor(position)
if (d < 0.5) {
p = Math.floor(position)
}
else {
p = Math.ceil(position)
}
var i = Math.floor(p + (nb_marks_displayed - 1) / 2)
index = i % nb_marks
first_mark = p % nb_marks
var p = index2pos(index)
position = p
delta = 0
delta = position - Math.floor(position)
//console.log("index:" + index)
}
}
}

View file

@ -106,6 +106,8 @@ Item {
id: toise
theme: main.theme
flik_enable: false
anchors.top: main.is_portrait ? title_note.bottom : parent.top
anchors.topMargin: parent.margin_h

View file

@ -7,6 +7,7 @@
<file>CircleMeter.qml</file>
<file>ScaleToise.qml</file>
<file>Toise.qml</file>
<file>ToiseFlickable.qml</file>
<file>Led.qml</file>
<file>Config.qml</file>
<file>qmldir</file>

View file

@ -6,6 +6,7 @@
<file>CircleMeter.qml</file>
<file>ScaleToise.qml</file>
<file>Toise.qml</file>
<file>ToiseFlickable.qml</file>
<file>Led.qml</file>
<file>ConfigurePageSailfish.qml</file>
<file>Config.qml</file>