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 unitObject = TimeUnitObject(pTemplate, lastTUO)
|
||||
if (lastTUO == null) {
|
||||
unitObject.setOldKey(sharedScreenModel.songKey.value)
|
||||
} else {
|
||||
unitObject.setOldKey(lastTUO.transposeOldKey)
|
||||
}
|
||||
val templateCharArray = pTemplate.template.toCharArray()
|
||||
var nextMarker: Char = '0'
|
||||
templateCharArray.forEach { // D.-R
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import androidx.compose.ui.draw.drawBehind
|
|||
import androidx.compose.ui.draw.drawWithContent
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
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.layout.onSizeChanged
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
|
|
@ -84,6 +86,9 @@ class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?) {
|
|||
init {
|
||||
nbBlock++
|
||||
numBlock = nbBlock
|
||||
if (sep1 == "") {
|
||||
println("Première fois : $numBlock")
|
||||
}
|
||||
sep0 = sep1
|
||||
sep1 = pTemplate.separatorAfter
|
||||
nbStanzas = 0
|
||||
|
|
@ -159,20 +164,26 @@ class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?) {
|
|||
fun getNum(): Int {
|
||||
return numBlock
|
||||
}
|
||||
fun setOldKey(theOldKey: String) {
|
||||
transposeOldKey = theOldKey
|
||||
}
|
||||
fun noteAsMultiString(): String {
|
||||
val separatorBefore = when (sep0) {
|
||||
":" -> sep0
|
||||
"!" -> "|"
|
||||
else -> ""
|
||||
}
|
||||
val markersBefore = ""//pTemplate.template.replace(Regex("[a-yA-Y\\(\\[].*"), "")
|
||||
val markersBefore = ""
|
||||
val transposeFrom = pTemplate.hasKeyChange()
|
||||
val transposeTo = if (transposeFrom != "") {
|
||||
transposeOldKey = transposeFrom
|
||||
prevTUO?.transposeOldKey ?: "Bb"
|
||||
} else {
|
||||
transposeOldKey = prevTUO?.transposeOldKey ?: "Bb"
|
||||
"" }
|
||||
if (transposeOldKey != prevTUO?.transposeOldKey) {
|
||||
transposeOldKey = prevTUO?.transposeOldKey ?: transposeOldKey
|
||||
}
|
||||
""
|
||||
}
|
||||
if (pTemplate.template == "z") {
|
||||
return "$separatorBefore\n$separatorBefore\n$separatorBefore\n$separatorBefore"
|
||||
}
|
||||
|
|
@ -527,12 +538,25 @@ fun LazyVerticalGridTUO(
|
|||
contentPadding = PaddingValues(8.dp), // c'est juste le padding exterieur de toute la liste
|
||||
state = lazyGridState
|
||||
) {
|
||||
items(items = tuoList.drop(1), key = { it.numBlock }) { oneTUO ->
|
||||
TimeUnitComposable(
|
||||
tuo = oneTUO,
|
||||
currentStanza,
|
||||
gridColumnCount
|
||||
)
|
||||
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(
|
||||
tuo = oneTUO,
|
||||
currentStanza,
|
||||
gridColumnCount
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue