Bug keyChange
This commit is contained in:
parent
df1f846f59
commit
23a628a8bb
2 changed files with 38 additions and 9 deletions
|
|
@ -51,6 +51,11 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
}
|
}
|
||||||
val pTemplate = T[nextTIndex]
|
val pTemplate = T[nextTIndex]
|
||||||
val unitObject = TimeUnitObject(pTemplate, lastTUO)
|
val unitObject = TimeUnitObject(pTemplate, lastTUO)
|
||||||
|
if (lastTUO == null) {
|
||||||
|
unitObject.setOldKey(sharedScreenModel.songKey.value)
|
||||||
|
} else {
|
||||||
|
unitObject.setOldKey(lastTUO.transposeOldKey)
|
||||||
|
}
|
||||||
val templateCharArray = pTemplate.template.toCharArray()
|
val templateCharArray = pTemplate.template.toCharArray()
|
||||||
var nextMarker: Char = '0'
|
var nextMarker: Char = '0'
|
||||||
templateCharArray.forEach { // D.-R
|
templateCharArray.forEach { // D.-R
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ import androidx.compose.ui.draw.drawBehind
|
||||||
import androidx.compose.ui.draw.drawWithContent
|
import androidx.compose.ui.draw.drawWithContent
|
||||||
import androidx.compose.ui.geometry.Offset
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.foundation.Canvas
|
import androidx.compose.foundation.Canvas
|
||||||
|
import androidx.compose.foundation.combinedClickable
|
||||||
|
import androidx.compose.foundation.lazy.grid.itemsIndexed
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.onSizeChanged
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
|
|
@ -84,6 +86,9 @@ class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?) {
|
||||||
init {
|
init {
|
||||||
nbBlock++
|
nbBlock++
|
||||||
numBlock = nbBlock
|
numBlock = nbBlock
|
||||||
|
if (sep1 == "") {
|
||||||
|
println("Première fois : $numBlock")
|
||||||
|
}
|
||||||
sep0 = sep1
|
sep0 = sep1
|
||||||
sep1 = pTemplate.separatorAfter
|
sep1 = pTemplate.separatorAfter
|
||||||
nbStanzas = 0
|
nbStanzas = 0
|
||||||
|
|
@ -159,20 +164,26 @@ class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?) {
|
||||||
fun getNum(): Int {
|
fun getNum(): Int {
|
||||||
return numBlock
|
return numBlock
|
||||||
}
|
}
|
||||||
|
fun setOldKey(theOldKey: String) {
|
||||||
|
transposeOldKey = theOldKey
|
||||||
|
}
|
||||||
fun noteAsMultiString(): String {
|
fun noteAsMultiString(): String {
|
||||||
val separatorBefore = when (sep0) {
|
val separatorBefore = when (sep0) {
|
||||||
":" -> sep0
|
":" -> sep0
|
||||||
"!" -> "|"
|
"!" -> "|"
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
val markersBefore = ""//pTemplate.template.replace(Regex("[a-yA-Y\\(\\[].*"), "")
|
val markersBefore = ""
|
||||||
val transposeFrom = pTemplate.hasKeyChange()
|
val transposeFrom = pTemplate.hasKeyChange()
|
||||||
val transposeTo = if (transposeFrom != "") {
|
val transposeTo = if (transposeFrom != "") {
|
||||||
transposeOldKey = transposeFrom
|
transposeOldKey = transposeFrom
|
||||||
prevTUO?.transposeOldKey ?: "Bb"
|
prevTUO?.transposeOldKey ?: "Bb"
|
||||||
} else {
|
} else {
|
||||||
transposeOldKey = prevTUO?.transposeOldKey ?: "Bb"
|
if (transposeOldKey != prevTUO?.transposeOldKey) {
|
||||||
"" }
|
transposeOldKey = prevTUO?.transposeOldKey ?: transposeOldKey
|
||||||
|
}
|
||||||
|
""
|
||||||
|
}
|
||||||
if (pTemplate.template == "z") {
|
if (pTemplate.template == "z") {
|
||||||
return "$separatorBefore\n$separatorBefore\n$separatorBefore\n$separatorBefore"
|
return "$separatorBefore\n$separatorBefore\n$separatorBefore\n$separatorBefore"
|
||||||
}
|
}
|
||||||
|
|
@ -527,7 +538,19 @@ fun LazyVerticalGridTUO(
|
||||||
contentPadding = PaddingValues(8.dp), // c'est juste le padding exterieur de toute la liste
|
contentPadding = PaddingValues(8.dp), // c'est juste le padding exterieur de toute la liste
|
||||||
state = lazyGridState
|
state = lazyGridState
|
||||||
) {
|
) {
|
||||||
items(items = tuoList.drop(1), key = { it.numBlock }) { oneTUO ->
|
itemsIndexed(items = tuoList.drop(1), key = { _, it -> it.numBlock }) { relativeIndex, oneTUO ->
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.combinedClickable(
|
||||||
|
onClick = {
|
||||||
|
println("Clicked: ${oneTUO.numBlock} / relative index: $relativeIndex")
|
||||||
|
} ,
|
||||||
|
onDoubleClick = {
|
||||||
|
println("Double-Clicked: ${oneTUO.numBlock} / relative index: $relativeIndex")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
) {
|
||||||
TimeUnitComposable(
|
TimeUnitComposable(
|
||||||
tuo = oneTUO,
|
tuo = oneTUO,
|
||||||
currentStanza,
|
currentStanza,
|
||||||
|
|
@ -537,5 +560,6 @@ fun LazyVerticalGridTUO(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue