diff --git a/qml/PlayerScreen.qml b/qml/PlayerScreen.qml
index cbdd515..d213d52 100644
--- a/qml/PlayerScreen.qml
+++ b/qml/PlayerScreen.qml
@@ -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
+ }
}
}
}
diff --git a/qml/ScaleToise.qml b/qml/ScaleToise.qml
index 7937139..1a25854 100644
--- a/qml/ScaleToise.qml
+++ b/qml/ScaleToise.qml
@@ -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
}
diff --git a/qml/Toise.qml b/qml/Toise.qml
index 58fbe6d..f5fcda9 100644
--- a/qml/Toise.qml
+++ b/qml/Toise.qml
@@ -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
}
}
}
diff --git a/qml/ToiseFlickable.qml b/qml/ToiseFlickable.qml
index 88e6e39..73ab8a3 100644
--- a/qml/ToiseFlickable.qml
+++ b/qml/ToiseFlickable.qml
@@ -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)
}
}
}
diff --git a/qml/TunerScreen.qml b/qml/TunerScreen.qml
index 32c7e3e..3089e26 100644
--- a/qml/TunerScreen.qml
+++ b/qml/TunerScreen.qml
@@ -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
diff --git a/qml/desktop.qrc b/qml/desktop.qrc
index f9113ad..79decb0 100644
--- a/qml/desktop.qrc
+++ b/qml/desktop.qrc
@@ -7,6 +7,7 @@
CircleMeter.qml
ScaleToise.qml
Toise.qml
+ToiseFlickable.qml
Led.qml
Config.qml
qmldir
diff --git a/qml/sailfish.qrc b/qml/sailfish.qrc
index 9e64aff..7cd8717 100644
--- a/qml/sailfish.qrc
+++ b/qml/sailfish.qrc
@@ -6,6 +6,7 @@
CircleMeter.qml
ScaleToise.qml
Toise.qml
+ToiseFlickable.qml
Led.qml
ConfigurePageSailfish.qml
Config.qml