2016-01-03 19:32:36 +03:00
|
|
|
/* Copyright 2016 (C) Louis-Joseph Fournier
|
|
|
|
* louisjoseph.fournier@gmail.com
|
|
|
|
*
|
|
|
|
* This file is part of SailTuner.
|
|
|
|
*
|
|
|
|
* SailTuner is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* SailTuner is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-01-01 18:39:43 +03:00
|
|
|
import QtQuick 2.0
|
2016-01-08 00:29:27 +03:00
|
|
|
import "."
|
2016-01-01 18:39:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ScaleToise
|
|
|
|
*
|
|
|
|
* Display notes from scale, with current note centered.
|
|
|
|
*/
|
|
|
|
|
2016-01-13 01:09:13 +03:00
|
|
|
ToiseFlickable {
|
2016-01-01 18:39:43 +03:00
|
|
|
id: scale
|
2016-01-01 21:20:29 +03:00
|
|
|
|
2016-01-02 18:07:12 +03:00
|
|
|
// note
|
2016-01-01 18:39:43 +03:00
|
|
|
property int note: 1
|
2016-01-02 18:07:12 +03:00
|
|
|
// octave
|
|
|
|
property int octave: 4
|
2016-01-02 17:20:19 +03:00
|
|
|
// en or fr
|
2016-01-08 00:29:27 +03:00
|
|
|
property int notes_style: Config.notes_style
|
2016-01-01 18:39:43 +03:00
|
|
|
|
2016-01-01 20:43:42 +03:00
|
|
|
property variant notes_fr: [
|
|
|
|
"do", "do#", "ré", "mib", "mi", "fa", "fa#", "sol", "sol#", "la", "sib", "si"]
|
2016-01-01 18:39:43 +03:00
|
|
|
property variant notes_en: [
|
2016-01-01 20:43:42 +03:00
|
|
|
"C", "C#", "D", "Eb", "E", "F", "F#", "G", "G#", "A", "Bb", "B"]
|
2016-01-01 18:39:43 +03:00
|
|
|
property variant notes: [notes_en, notes_fr]
|
|
|
|
|
2016-01-02 17:20:19 +03:00
|
|
|
// case colors
|
2016-01-01 20:43:42 +03:00
|
|
|
property color colorAltered: "#40888888"
|
2016-01-01 21:20:29 +03:00
|
|
|
property color colorNatural: "transparent"
|
2016-01-01 20:43:42 +03:00
|
|
|
|
2016-01-02 17:20:19 +03:00
|
|
|
// Toise parameters
|
2016-01-02 18:07:12 +03:00
|
|
|
index: note + notes_en.length * octave
|
2016-01-02 17:20:19 +03:00
|
|
|
marks: notes[notes_style]
|
2016-01-05 23:50:51 +03:00
|
|
|
nb_marks_displayed: width > 100 ? Math.min(nb_marks, width / theme.fontSizeLarge * 0.8) : 1
|
2016-01-01 18:39:43 +03:00
|
|
|
|
2016-01-02 17:20:19 +03:00
|
|
|
mark_color: function(note) {
|
|
|
|
if (isAltered(note)) return colorAltered;
|
|
|
|
else return colorNatural;
|
2016-01-01 18:39:43 +03:00
|
|
|
}
|
|
|
|
|
2016-01-01 20:43:42 +03:00
|
|
|
function isAltered(i) {
|
|
|
|
return (i < 4 && (i & 1)) || (i > 5 && !(i & 1))
|
|
|
|
}
|
2016-01-13 01:09:13 +03:00
|
|
|
|
|
|
|
// ToiseFlikcable parameters
|
2016-01-13 13:16:16 +03:00
|
|
|
min: notes_en.length * 0 // ut 0
|
2016-01-13 01:09:13 +03:00
|
|
|
max: notes_en.length * 9 - 1 // si 8
|
2016-01-13 12:15:35 +03:00
|
|
|
|
|
|
|
onOctaveChanged: {
|
2016-01-13 13:08:01 +03:00
|
|
|
if (!flik_enable) return
|
2016-01-13 12:15:35 +03:00
|
|
|
index = note + notes_en.length * octave
|
|
|
|
updateFlickable()
|
|
|
|
}
|
2016-01-01 18:39:43 +03:00
|
|
|
}
|