z8 didn't show separators correctly

This commit is contained in:
dotmg 2025-08-18 19:44:41 +02:00
parent a427b3d619
commit 2c79aa1d77
2 changed files with 14 additions and 10 deletions

View file

@ -58,7 +58,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
return return
} }
val pTemplate = T[nextTIndex] val pTemplate = T[nextTIndex]
val unitObject = TimeUnitObject(pTemplate, lastTUO) val unitObject = TimeUnitObject(pTemplate, lastTUO, N.size)
if (lastTUO == null) { if (lastTUO == null) {
unitObject.setOldKey(sharedScreenModel.songKey.value) unitObject.setOldKey(sharedScreenModel.songKey.value)
} else { } else {

View file

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyGridState import androidx.compose.foundation.lazy.grid.LazyGridState
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
@ -45,7 +44,7 @@ import androidx.compose.ui.text.withStyle
val FEUFAROO_TRIOLET_COLOR = Color.DarkGray val FEUFAROO_TRIOLET_COLOR = Color.DarkGray
val FEUFAROO_KEY_CHANGE_COLOR = Color.Blue val FEUFAROO_KEY_CHANGE_COLOR = Color.Blue
class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?) { class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?, countOfN: Int) {
var mutableNoteVersion: Int by mutableStateOf(0) var mutableNoteVersion: Int by mutableStateOf(0)
private var lyrics: MutableList<POneStanzaLyrics> = mutableListOf() private var lyrics: MutableList<POneStanzaLyrics> = mutableListOf()
var sep0: String = "" var sep0: String = ""
@ -59,10 +58,10 @@ class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?) {
companion object { companion object {
var nbBlock: Int = 0 var nbBlock: Int = 0
var sep1: String = "" var sep1: String = ""
var _hasmarker: Boolean by mutableStateOf(false) var _hasMarker: Boolean by mutableStateOf(false)
var nbStanzas: Int = 0 var nbStanzas: Int = 0
fun hasMarker(yes: Boolean) { fun hasMarker(yes: Boolean) {
_hasmarker = yes _hasMarker = yes
} }
var lastHairPinStart: Int = -1 var lastHairPinStart: Int = -1
var lastHairPinSymbol: Char? = null var lastHairPinSymbol: Char? = null
@ -93,6 +92,11 @@ class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?) {
sep1 = pTemplate.separatorAfter sep1 = pTemplate.separatorAfter
nbStanzas = 0 nbStanzas = 0
annotated = false annotated = false
if (pTemplate.template == "") {
repeat(countOfN) {
tuNotes.add(it, TUNote())
}
}
} }
fun hasHairPin(): Char? { fun hasHairPin(): Char? {
if (pTemplate.hasMarker($$"${<}")) { if (pTemplate.hasMarker($$"${<}")) {
@ -235,7 +239,7 @@ fun TimeUnitComposable(
modifier = Modifier modifier = Modifier
.background(col) .background(col)
) { ) {
if (TimeUnitObject._hasmarker) { if (TimeUnitObject._hasMarker) {
val lineHeight = 20.sp val lineHeight = 20.sp
val density = LocalDensity.current val density = LocalDensity.current
val lineHeightDp : Dp = with(density) { val lineHeightDp : Dp = with(density) {
@ -471,7 +475,7 @@ fun AutoResizingText(
// Un Text() invisible ou non affiché pour mesurer le texte sans le dessiner directement // Un Text() invisible ou non affiché pour mesurer le texte sans le dessiner directement
// Vous pouvez aussi utiliser textMeasurer.measure() directement // Vous pouvez aussi utiliser textMeasurer.measure() directement
// On rend le texte visible une fois la taille ajustée pour éviter les clignotements // On rend le texte visible une fois la taille ajustée pour éviter les clignotements.
var readyToDraw by remember { mutableStateOf(false) } var readyToDraw by remember { mutableStateOf(false) }
val textLinesCount = text.split("\n").size * maxLines val textLinesCount = text.split("\n").size * maxLines
@ -481,11 +485,11 @@ fun AutoResizingText(
style = textStyle.copy(fontSize = fontSize), style = textStyle.copy(fontSize = fontSize),
maxLines = textLinesCount, // Très important pour qu'il ne déborde pas en hauteur maxLines = textLinesCount, // Très important pour qu'il ne déborde pas en hauteur
overflow = TextOverflow.Clip, // Masque si ça déborde encore (ne devrait pas si le calcul est bon) overflow = TextOverflow.Clip, // Masque si ça déborde encore (ne devrait pas si le calcul est bon)
// onTextLayout est appelé après que le texte ait été mesuré // onTextLayout est appelé après que le texte a été mesuré
onTextLayout = { textLayoutResult: TextLayoutResult -> onTextLayout = { textLayoutResult: TextLayoutResult ->
if (textLayoutResult.hasVisualOverflow && fontSize > minFontSize) { if (textLayoutResult.hasVisualOverflow && fontSize > minFontSize) {
// Si le texte déborde en largeur, réduisez la taille de la police // Si le texte déborde en largeur, réduisez la taille de la police
// Vous pouvez utiliser un pas plus fin ou une méthode de recherche binaire pour optimiser // Vous pouvez utiliser un pas plus fin ou une méthode de recherche binaire pour optimiser.
fontSize *= 0.9f // Réduire de 10% à chaque fois fontSize *= 0.9f // Réduire de 10% à chaque fois
} else { } else {
readyToDraw = true // La taille est stable ou min atteinte, on peut dessiner readyToDraw = true // La taille est stable ou min atteinte, on peut dessiner
@ -550,7 +554,7 @@ fun LazyVerticalGridTUO(
horizontalArrangement = Arrangement.spacedBy(horizontalArrangementSpacing), horizontalArrangement = Arrangement.spacedBy(horizontalArrangementSpacing),
verticalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(8.dp), // c'est juste le padding exterieur de toute la liste contentPadding = PaddingValues(8.dp), // c'est juste le padding extérieur de toute la liste
state = lazyGridState state = lazyGridState
) { ) {
itemsIndexed(items = tuoList.drop(1), key = { _, it -> it.numBlock }) { relativeIndex, oneTUO -> itemsIndexed(items = tuoList.drop(1), key = { _, it -> it.numBlock }) { relativeIndex, oneTUO ->